For Reasons™, I needed to be able to compile and debug drivers for Windows 98. This meant setting up the DDK (Driver Development Kit) and Visual C++. So that this knowledge isn't lost, here's a quick guide.1
Prerequisites
- A Windows 98 ISO.
- For instance, from WinWorld. Be sure to get "OEM Full" version.
- The DDK.
- For instance, this page has a bunch of useful downloads.
- Specifically, get the complete DDK with patches (that's what worked for me): https://www.mdgx.com/spx/98DDK.RAR.
- Visual C++ 5.0.
- Again, WinWorld to the rescue.
Installation
- Install Windows on a VM.
- Install Visual C++.
- To be on the safe side, install everything.
- Install the DDK.
- Again, install everything.
- Important: increase the environment space by adding the following
line to
config.sys
:shell=c:\command.com /p /e:4096
- Check the installation by building the samples.
- Open a "Checked Build Environment" command prompt from the start menu, go to
C:\98DDK\src
, and runbuild -cZ
- There will be a few errors, but most of the samples will compile. The binaries
will be at
C:\98DDK\lib\i386\checked
.
- Open a "Checked Build Environment" command prompt from the start menu, go to
- Check that debugging works.
- Reboot into DOS mode and run
\98ddk\bin\wdeb386 /c:1 /r:19200 \windows\win.com
- This starts the debugger on COM port 1 (on the guest), with a baud rate of 19200,
and instructs it to run the kernel at
\windows\win.com
.
- This starts the debugger on COM port 1 (on the guest), with a baud rate of 19200,
and instructs it to run the kernel at
- On the host, connect to the VM's serial port with the correct baud rate
and press
Ctrl-C
.- The debugger should break in (see screenshot below).
- Enter
g
to resume execution.
- Reboot into DOS mode and run
- Make sure the debugger starts on boot.
- Add the following line to
config.sys
:DEVICE=C:\98ddk\bin\wdeb386.exe /c:1 /r:19200
- Note: I'm not sure about the importance of the line order in this file. In my setup this line comes before the one that increases environment space (see screenshot below).
- Reboot and check that this works. On boot, the debugger should print a version string (see screenshot below).
- Add the following line to
Note: the debugger we're using here is WDEB386
. There's a better debugger installed
with the DDK — WDEB98
— but it requires the use of a special client
— RTerm98
— which complicates matters.
So that we can use PuTTY, we're sticking with the old debugger.
Building drivers
Now that the environment is all set up, you may want to actually write your own driver in it. Here's a gist of a minimal WDM driver project. To build it:
- Put all files in the same directory.
- Inside said directory, create the path
bin\i386\checked
- Open a "Checked Build Environment" command prompt.
- From within the directory, run
build -cZ
To make the driver load on boot, place the binary in C:\WINDOWS\SYSTEM32\DRIVERS
and run the supplied .reg
file.
Fun fact: the built binary also runs on Windows 10 😎.
Screenshots
Final config.sys
Debugger break-in
Boot with debugger
Driver output
-
This may or may not be related to some previous shenanigans. ↩︎