Windows NT Device Drivers
Windows NT is a well-architected, protected operating system. Unlike Windows 95 and previous version of Windows, it is not possible for applications or user-mode DLLs to access devices directly. To add device support for Windows NT, you need to provide a kernel-mode device driver.
Software running in kernel mode has full access to memory and I/O ports and privileged instructions, and has much greater potential for crashing the system. Device drivers are loaded as part of the Windows NT executive; they cannot call Win32 API functions, but they can use the APIs provided for kernel-mode software by the various components of the Windows NT executive. This includes services for accessing hardware and interrupts, as well as runtime library functions and memory management.
Device drivers are loaded and called by the I/O subsystem. Each request to a device driver is sent in an i/o request packet or IRP. An IRP can be routed through several device drivers in a layered manner: for example, when a file system driver is asked to read a file, it may make a request to the disk driver to read a section of the physical disk. Disk mirroring or striping can be implemented as an intermediate driver that receives all IRP requests going from the file-system to the disk driver. Device driver layering is widely used as a mechanism for sharing code and for structuring device drivers.
To develop Windows NT device drivers, you will need the Microsoft Windows NT DDK and the Win32 Platform SDK. The best place to get these is via MSDN.
The DDK includes a kernel-mode debugger (WinDbg runs on a remote machine across a serial cable) but you may want to consider using SoftICE (formerly from Numega, now part of Compuware's DriverStudio). This runs on a single machine (switching the display into character mode), is simple to set up and lets you debug nearly anything, including DirectDraw software.
A good book is the Windows NT Device Driver Book, by Art Baker (Prentice Hall, ISBN 0131844741). Microsoft maintains a useful list of resources for WDM device driver development. And for more information on the undocumented internals, look at Mark Russinovich and Bryce Cogswell's SysInternals site.
Device Driver Topics