News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

How do I debug a DOS Driver?

Started by Shintaro, February 20, 2022, 06:26:02 PM

Previous topic - Next topic

Shintaro

I copied the code from Expanding DOS for EMSDISK, and obviously made an error somewhere.
Tried it on MS-DOS 5 and 6.0,6.11.

Also I needed to turn MASM 5.1 compatibility on when compiling under MASM 6Something with the way the STRUC is layed out?
In the config.sys after emm386
device=c:\emsdisk.sys 512k

Error:
"Expanded memory allocation failed"

How do I debug a DOS Driver?
The problem is, it doesn't have a stack and starting location.
Do I leave it as an exe?

Code is attached.
"Wyrd bið ful āræd. Fate is inexorable."

_japheth

Quote
How do I debug a DOS Driver?

There exist debuggers that are loaded as device drivers, thus they can debug other drivers. For example, see https://github.com/Baron-von-Riedesel/DOS-debug. Please read the docs carefully, the device driver version is DebugXG.com

Quote
The problem is, it doesn't have a stack and starting location.
Do I leave it as an exe?

DOS device drivers need not define a stack, they use the stack of the caller.
As it is described in the source, the .EXE is supposed to be converted to a .SYS by tool EXE2BIN.
Dummheit, gepaart mit Dreistigkeit - eine furchtbare Macht.

_japheth

Quote from: Shintaro on February 20, 2022, 06:26:02 PM
Code is attached.

I tried it. There are problems, though:

1. wrong register used to call EMM


;init74: mov     al,43h    ;original line
init74: mov     ah,43h    ;adjusted. register AH must be used to allocate EMS memory!!!!
mov     bx,ownedp
int     emm_int


2. After this modification, the driver loads, but very soon an "overflow" error occurs. Looks like this driver works with MS-DOS v3.3 (only)?
Dummheit, gepaart mit Dreistigkeit - eine furchtbare Macht.

Shintaro

Thanks mate for your help. I do appreciate it.
Strange that it only runs in MS-DOS 3.3 (1987), the book was out in 1992. So I would have thought MS-DOS 5.0 at least.
I'll run up a VM and see what happens.
"Wyrd bið ful āræd. Fate is inexorable."

Shintaro

Quote from: _japheth on February 20, 2022, 09:13:02 PM


There exist debuggers that are loaded as device drivers, thus they can debug other drivers. For example, see https://github.com/Baron-von-Riedesel/DOS-debug. Please read the docs carefully, the device driver version is DebugXG.com

Mate, I have compiled DebugXG.exe and loaded it in the config.sys. But that is as far as I am able to work it out. DebugXG.exe doesn't seem to catch a crashing program, unlike SoftICE.I looked at the instructions for some way to communicate with the loaded DebugXG, but couldn't find anything.
Am I doing something wrong? Missing something? Or maybe this is just beyond my understanding at the moment?

"Wyrd bið ful āræd. Fate is inexorable."

_japheth

Quote
Mate, I have compiled DebugXG.exe and loaded it in the config.sys. But that is as far as I am able to work it out. DebugXG.exe doesn't seem to catch a crashing program, unlike SoftICE.I looked at the instructions for some way to communicate with the loaded DebugXG, but couldn't find anything.
Am I doing something wrong? Missing something? Or maybe this is just beyond my understanding at the moment?

I guess so - better don't use tools that you haven't fully understood yet or that you cannot handle "left-handedly".

Debug is a simple debugger, it has no ( or little ) "post-mortem analysing" capabilities, compared to SoftIce. What do you expect from a 20 kB program? In the case of DebugXG, to debug a device driver, it is supposed that you insert a breakpoint ( "int 3" ) into your driver that has to be debugged, the debugger will then "pop up" when that breakpoint is reached. That's it.

Generally, in real-mode, "post-mortem" capabilities are far less useful than in protected-mode - simple because IT IS NOT protected-mode. Or, in other words, when the crash occurs, it's usually far too late in real-mode to get any idea about what may have caused the crash.
Dummheit, gepaart mit Dreistigkeit - eine furchtbare Macht.

Shintaro

Quote from: _japheth on March 01, 2022, 05:27:50 PM


I guess so - better don't use tools that you haven't fully understood yet or that you cannot handle "left-handedly".

Debug is a simple debugger, it has no ( or little ) "post-mortem analysing" capabilities, compared to SoftIce. What do you expect from a 20 kB program? In the case of DebugXG, to debug a device driver, it is supposed that you insert a breakpoint ( "int 3" ) into your driver that has to be debugged, the debugger will then "pop up" when that breakpoint is reached. That's it.
What is "left-handedly"?
Mate, all you needed to say was insert "int 3" in your program and go from there. I must have missed it in the docs.
I may have known that, but the last serious attempt at ASM in MS-DOS was 1990.

I was looking for something that I would set in DebugXG, but it is the other way around, all good.
That obviously saves time as the recommendations that I have read (Advanced MS-DOS Programming Ray Duncan), direct people to debug in parts.

Most likely there will be plenty of "obvious" things that I will miss, that people with a lot more experience will roll their eyes at.
But, I am fine with that. I just want to learn.

I do appreciate your responce and patience.

"Wyrd bið ful āræd. Fate is inexorable."

_japheth

Quote from: Shintaro on March 01, 2022, 08:05:55 PM
What is "left-handedly"?

It's the German expression "etwas mit links erledigen" translated to English, perhaps a bit too literally - I couldn't remember the appropriate English analogy.
Dummheit, gepaart mit Dreistigkeit - eine furchtbare Macht.

Shintaro

Quote from: _japheth on March 01, 2022, 09:35:10 PM
Quote from: Shintaro on March 01, 2022, 08:05:55 PM
What is "left-handedly"?

It's the German expression "etwas mit links erledigen" translated to English, perhaps a bit too literally - I couldn't remember the appropriate English analogy.

Ah, I understand.
But in order to be able to do it so easily as with the "Left hand", it requires practise first.
"Wyrd bið ful āræd. Fate is inexorable."

Gunther

Andreas,

Quote from: _japheth on March 01, 2022, 09:35:10 PM
It's the German expression "etwas mit links erledigen" translated to English, perhaps a bit too literally - I couldn't remember the appropriate English analogy.

that's hard to translate. But what about doing it blindfold?

But no offense intended. Your answer was, of course, absolutely correct.

Quote from: Shintaro on March 01, 2022, 09:40:32 PM
But in order to be able to do it so easily as with the "Left hand", it requires practise first.
That's as sure as the amen in a church. But you're on a good path. :thumbsup:
You have to know the facts before you can distort them.