[Microsoft Home][Products][Search][Support][Shop][Write Us][Image][Microsoft Home] [Microsoft Technical Support][Microsoft Technical Support][Image][Current Features] [Image] [Search Support Online] [Submit a Question] [Return to...] Getting Started With Device Drivers ------------------------------------------------------------------------ Software required for driver development * Platform SDK * Visual C++ compiler (V 4.0 and above )of the platform for which the driver is targeted * Windows NT 4.0 DDK Suggested Readings * "Inside Windows NT", by Helen Custer - To learn about design philosophy and architecture of NT * "MSDN Kernel-Mode Drivers Design Guide" - To learn design & implementation details of kernel-mode drivers * The Windows NT Device Drive Book, by Art Baker * Inside the Windows NT File System, by Helen Custer * Windows NT File System Internals , by Rajeev Nagar * Advanced Windows, by Jeffrey M. Richter * DDK and SDK related Knowledge base articles from MSDN Library. Following are some of the articles that cover general issues concerning device drivers o Q115486 Two Methods to Control Device Driver Load Order o Q126416 Cautions on Using METHOD_NEITHER IOCTL o Q115758 Meanings of Address Fields in an IRP Structure o Q117308 How Drivers Notify User-Mode Pgms of Asynchronous Events o Q120170 Creation and Destruction of File Objects o Q126368 Creating Device Objects in Dispatch Routines o Q126415 SAMPLE: Async Notification from Kernel Mode Driver o Q121965 How to Change Max Memory Allowed with MmProbeAndLockPages o Q126286 SAMPLE: Using ZwCreateFile() to Open File from Kernel o Q128372 How to Remove Symbols from Device Drivers o Q90082 Debug Printing Implementation in the Device Drivers o Q113996 Mapping NT Status Error Codes to Win32 Error Codes o Q120171 I/O Request Packet (IRP) Cancellation o Q101501 Differences Between a Service and a Device Driver o Q126547 Floating Point Math Is Not Supported in a Kernel-Mode Driver o Q152044 How To Create a PCI Device Driver for WindowsNT * Newsgroup: comp.os.ms-windows.programmer.nt.kernel-mode o Search at http://www.dejanews.com for archived articles posted in Usenet * Mailing Lists NTDEV & NTIFS NTDEV - Windows NT Device Drivers To subscribe, send "SUBSCRIBE NTDEV" in the body of a message to Majordomo@atria.com. NTIFS - Windows NT Installable File Systems To subscribe, send "SUBSCRIBE NTFSD" in the body of a message to Majordomo@atria.com. Following are the list of samples available as part of NT DDK, which cover all aspects of device driver development. * Generic Device Driver Samples * Serial & Parallel drivers * Keyboard and Mouse drivers * Network drivers * Storage drivers * Multimedia drivers * Printer drivers * Virtual DOS Drivers (VDD) * Video drivers * Kernel debugger extensions Generic Device Driver Samples: Generic Samples Purpose ddk\src\general SIMPLE This is a simple "Hello World" driver. Demonstrates how to implement basic routines such as DriverEntry, Unload, Create and Close in a driver. Check the INSTDRV sample for another simple driver. IOCTL Purpose of this driver to demonstrate how various types of IOCTL can be used and how the I/O manager handles the user I/O buffer in each case. This sample also helps to understand the usage of some of the memory manager functions. PORTIO This is a minimal driver that tells you how to reserve ports and read and write to it. INT This sample tells you how to connect to an interrupt, implement DpcForIsr and StartIo routines. MAPMEM Demonstrates how to map physical memory into a user-mode process space. EVENT Demonstrates one way that a Windows NT kernel-mode device driver can share and explicitly signal an Event Object with a Win32 application. An alternative method would be to create a named event in the driver via IoCreateNotificationEvent and then open the event in user mode. This API however is new to Windows NT 4.0 so you can not use this method in your NT 3.5x drivers. Check ASYNC sample for more details. ASYNC Demonstrates how to notify a user mode application or a service of an asynchronous event from kernel mode. This sample is an updated version of NT3.51 ASYNC, to take advantage of new system services (IoCreateXXXEvent) available in kernel mode for NT 4.0. ZWCREATE Demonstrates how to open a file and read the contents of it from a kernel-mode driver. This sample uses ZwCreateFile & ZwReadFile functions. ERRORLOG Demonstrates event-logging techniques in kernel-mode. CANCEL & CLEANUP Demonstrates the use of new IRP cancellation technique that minimizes the use of global cancellation spinlock thereby reducing contention and improving overall system performance. This sample also demonstrates how to cleanup the pending IRP in the Cleanup (IRP_MJ_CLEANUP) dispatch function. JOYFILTER A sample on filter driver. This driver filters the output of joystick driver for button input; converts them into keyboard data packets and inserts them into the keyboard stream. This is a good example of 2 in 1-filter driver. TAGPOOL The purpose of this sample is to demonstrate how using ExallocatePoolWithTag can assist developers in tracking down memory leaks in their code. This sample consists of a kernel-mode device driver and a Win32 application that communicates with the device driver. MONO The MONO sample is composed of a simple monolithic export driver and a Win32 test application. NAMED PIPE Demonstrates how to open a named pipe created in the user-mode and read/write to the pipe. This sample also shows how to create system thread. REPARSE Demonstrates how to create a new device object in a dispatch routine and how a Win32 program gets a handle to this new device object. This sample is a boilerplate that can easily be converted to allow multiple device objects to be created with just one attempt at opening the device. GEXPORT – Export This sample tell you how to write a export DLL in driver kernel-mode for NT 4.0 graphics drivers PCIDUMP This sample helps to scan PCI slots to find out resource information. The user-mode application also tells you how to dynamically load/unload a driver using the Service Control Manager APIs. These APIs allow a driver to be loaded without having to modify the registry and rebooting the system. INSTRDRV Demonstrates how to use the Win32 Service Control Manager APIs to install, start, stop, and delete a kernel-mode device driver. It consists of a Win32 console application ("INSTSRV") and a simple NT kernel-mode device driver ("SIMPLDRV"). DELAY This sample is designed to show the usage of KeDelayExecutionThread. It will also demonstrate that KeDelayExecutionThread works as designed by getting and returning tick count information. DOSDEV A user mode test app that lists the entire DOS device names, or connects to a device and sends it an IOCTL. Back to top Serial & Parallel Device Drivers DDK\SRC\COMM PARCLASS Source code of the system supplied parallel class driver. PARPORT There are many different protocols, such as Centronics, EPP, ECP, LapLink, Dongles, and so forth, for reading from and writing to devices on the parallel port. The Windows NT parallel drivers implement the Centronics protocol for writing to printers. The system-supplied parallel port driver supports any number of parallel class drivers in sharing its hardware ports. Refer KB article Q117894 for further info. PARSIMP Contains code for a simple parallel class driver. PARSTAT This is a simple parallel class driver, which supports just getting the parallel port status for a specific parallel port. INTPAR Simple parallel port driver that uses interrupt mechanism. POLLPAR Simple parallel port driver that uses polling technique. SERIAL Source code of the serial port driver. This driver handles interrupts and controls its hardware directly. Back to top Keyboard and Mouse Drivers DDK\SRC\INPUT Purpose I8042PRT Source code of the system supplied Intel i8042 port driver common to both the keyboard and the auxiliary (PS/2 mouse) device. INPORT Microsoft InPort mouse port driver. KBDCLASS Source code of the system supplied Keyboard class driver. KBDGR Keyboard layout DLL for German. KBDUS Keyboard layout DLL for United States MOUCLASS Source code of the system supplied Mouse class driver. SERMOUSE Source code of the system supplied Microsoft serial (i8250) mouse port driver. This driver supports Microsoft 2 button serial devices, Logitech 3 button serial devices (Microsoft compatible) and Microsoft Ballpoint devices. Back to top Network Device Driver Samples \DDK\SRC\NETWORK Samples Purpose MACADDR This sample is a simple User mode program that will return the hardware address being used by the network adapter. Currently, it is set up for ethernet, but can easily be modified for any media type. This sample demonstrates how to send an IOCTL to a Ndis Miniport. NE2000 This sample is the NE2000 ethernet card source code. This driver should compile and run over any NE2000 compatible adapter. This sample is written for an ISA NE2000 adapter, but can easily be modified to work with PCMCIA, PCI, or proprietary busses. This sample communicates with the card via PortIO. NE3000 This sample is the driver for the Novell NE3200 EISA Ethernet adapter. This driver conforms to the NDIS 3.0 miniport interface. This sample communicates with the card via PortIO. PACKET The packet driver demonstrates the use of the upper edge NDIS 3.0 services to communicate with NDIS 3.0 MAC drivers. The driver creates a device object, which may be opened by Win32 apps via a symbolic link. A Packet may be sent by writing data to the driver. Receives may be pended to the driver by reading from the driver. The driver expects that it will be bound an Ethernet card as it makes assumptions about frame size. The testapp that accompanies the driver is there only to illustrate that the kernel mode driver functions as advertised. It is not intended as a full-featured reliable test application. RASWAN This driver provides a sample of how to develop a WAN/TAPI Miniport driver, and shows how to install the driver to work with Windows NT Remote Access Service (RAS). TDI If you are writing a protocol driver for Windows NT this is the preferred method to do so. This sample has a TDI server interface on top and a NDIS interface on the bottom. Also see the wshsmpl as it may be required as well. WSHSMPL This is a sample Winsock helper DLL. Winsock helper DLL's are supplied for the protocols that ship with Windows NT. If you are writing a protocol that replaces a shipped protocol (i.e. TCP/IP) you can likely use the helper DLL that ships with Windows NT. Winsock helper DLLs are required for Winsock Support. STREAMS This sample is no longer supported by Microsoft. The sample was to help in the porting of protocols to Windows NT. The TDI sample ships with the DDK and is the preferred method of writing a Windows NT protocol. Also see the wshsmpl as it may be required as well. SONIC This is a Full MAC driver for a National Semiconductor adapter. It can be adapted to other adapters. Note: Full MAC drivers will not be supported under Windows NT 5.0. DETAPP Sample NIC detection tester application. This drives your NIC detection DLL. There is a detailed readme.txt describing it's use. DETECT Sample NIC detection DLL for NIC driver installation, configuration querying, verification, and validation. See the documentation under Network Drivers \ Design Guide \ Part 2: Miniport NIC drivers \ CH.8 and CH.9 NIC Detection. IBMTOK NDIS 3.0 miniport driver for IBM Token Ring 16/4 Adapter. Uses programmed I/O. IBMTOK2 NDIS 3.0 miniport driver for IBM Token Ring 16/4 Adapter II. Uses programmed I/O. LANCE NDIS 3.0 miniport driver for Lance (AMD 7990) Ethernet chip. Uses programmed I/O. Back to top Storage Device Driver Samples DDK\SRC\Storage Device Samples Purpose CLASS CLASS Generic SCSI class routines. Creates CLASS.LIB. OLDCLASS Generic SCSI class routines created before WinNT 4.0. Creates OLDCLASS.LIB. SCSICDRM SCSI CDROM class driver. Requires CLASS.LIB. SCSICDWO CDWO_API is a sample Win32 application that interfaces with the SCSICDWO class driver. SCSI CD Writer (Write Once) is class driver. Requires CLASS.LIB. SCSIDISK SCSI disk class driver. Requires CLASS.LIB. SCSITAPE SCSI tape class driver. Requires OLDCLASS.LIB. SPTI Sample Win32 application that demonstrates how to send SCSI commands to SCSI devices. Features IOCTL_SCSI_PASS_THROUGH, IOCTL_SCSI_PASS_THROUGH_DIRECT, IOCTL_SCSI_GET_INQUIRY_DATA, and IOCTL_SCSI_GET_CAPABILITIES. DISK ATDISK IDE disk driver. This driver is used when there are no ATAPI devices on the system. FLOPPY Floppy diskette driver. RAMDISK Sample RAM disk driver. FILTER CDAUDIO SCSI filter driver that layers on top of the SCSI CDROM class driver. This driver filters SCSI-2 CDROM audio commands for CDROM drives that Cannot handle the SCSI-2 CDROM audio commands. DISKPERF SCSI filter driver that layers on top of the SCSI disk class driver. This driver is used to capture performance data on a disk drive by intercepting all I/O and maintaining counters on various operations. MINIPORT AHA154X SCSI miniport driver for the Adaptec AHA154x adapter. Busmaster DMA. ISA and MCA bus. Uses interrupts. AHA174X SCSI miniport driver for the Adaptec AHA174x adapter. Busmaster DMA. EISA bus. Uses interrupts. ATAPI SCSI miniport driver for the ATAPI IDE controller. PIO device. PCI, ISA, and MCA bus. Uses interrupts FD8XX SCSI miniport driver for the Future Domain TMC-8xx adapter. PIO device. ISA bus. Uses interrupts. NCR53C9X SCSI miniport driver for the adapters based on the NCR 53c9x. System DMA. MCA, Internal (NEC), and EISA bus. Uses interrupts. SMPI Sample that demonstrates how to implement IOCTL_SCSI_MINIPORT within a SCSI miniport and how to call into the driver from a Win32 application. TAPE QIC117 Tape driver for the QIC117 device. SCSI 4MMDAT Tape miniclass driver for 4mm DAT devices. ARCHQIC Tape miniclass driver for Archive QIC devices. DLTTAPE Tape miniclass driver for DLT devices. EXABYTE1 Tape miniclass driver for the Exabyte EXB-8200 and the EXB-8200sx handled as an EXB-8200. EXABYTE2 Tape miniclass driver for the Exabyte EXB-8500 device. MINIQIC Tape miniclass driver for the minicartridge QIC devices. TANDQIC Tape miniclass driver for the Tandberg QIC devices. WANGQIC Tape miniclass driver for the WangTek QIC devices. Back to top Multi-Media Driver Samples \DDK\SRC\MMEDIA Samples Purpose IMAADPCM The IMA ADPCM Audio Codec, imaadp32.dll, converts between PCM and the IMA ADPCM format. This codec is optimized for speed, and illustrates how to design conversion routines to reduce computation time. It also provides a configuration dialog box. The first time the codec is opened, it tries to automatically configure itself by calculating its maximum sample rate. GSM610 The Microsoft GSM 6.10 Audio Codec, msgsm32.dll, implements the GSM 6.10 voice encoding standard, originally developed for digital cellular telephone encoding. The codec converts between GSM 6.10 and PCM formats. Like imaadp32.dll, this codec provides a configuration dialog box, and also attempts to automatically configure itself the first time it is opened. MSFILTER The Microsoft Audio Filter, msfltr32.dll, is a single driver that provides both a volume filter and an echo filter. This driver supports a custom About box and a custom icon. MCIPIONR Pioneer 4200 Videodisc MVAUDIO Media Vision ProAudio Spectrum 16 driver SNDLST Creative Labs Sound Blaster driver SNDSYS Windows sound system driver SYNTH Ad Lib and OPL3 MIDI synthesizer driver BRAVADO Truevision Bravado SPIGOT Video Spigot MSYUV Microsoft YUV Codec Back to top Printer Device Samples: \DDK\SRC\PRINT Samples Purpose CPSUI Shows how driver property page callbacks work with mini and mono drivers. LOCALMON Shows how to create your own port monitor (localmon.dll) to replace the system-supplied driver. Can be installed with AddPrinter() in conjunction with AddPort(). MINI Several samples of mini-drivers. These simple drivers a the fastest way to get a non-postscript/non-plotter driver running. You create a data file with the printer specific features, control strings and escapes using UNITOOL and this is built as a resource. This resource coupled with RASDD.DLL and its user-mode counterpart RASDDUI.DLL together constitute your driver. This driver can be installed with the AddPrinter wizard and an appropriate OEMSETUP.INF. PJLMON Shows a custom language monitor (for HP PJL). PSPRINT Shows monolithic POSTSCRIPT (tm) kernel-mode driver. This sample can be used as a skeleton to do any raster driver as it has all necessary entry points for a whole driver. UMPD Shows example of user-mode printer driver (can't do much with NT4 hardware). WINPRINT Shows example of custom print processor. **** There are no samples for localspl.dll or spoolss.dll as these are not IHV replaceable printing components. There is no sample for win32spl.dll (network print provider) which is an IHV replaceable printing component. Back to top VDD DDK\SRC\VDD Samples Purpose APPINTS This directory contains a rudimentary structure for application based-intercept approach for writing a VDD. The details for this approach are given in the Virtual Device Driver chapter. "fax16" is a sub-directory, which has a minimal FAX stub device driver. FAX32 directory has the sources for a FAX VDD. {fax16.sys,fax32.dll} COM_VDD This VDD sample implements serial port support for the Virtual DOS Machine (VDM) under Windows NT. The Windows NT VDM has a built-in Virtual Device Driver for serial communications, so this sample driver is completely redundant. It illustrates how serial support might have been implemented using Win32 and the Windows NT DDK. This sample is based in part on the built-in serial driver, but it has been significantly modified and works differently. You should not rely on any feature of this driver when writing serial I/O code that might be used under Windows NT. DOSIOCTL This sample demonstrates the simulation of DOS function calls under NT. Specifically, it shows how a DOS driver and VDD can translate DOS OPEN's, CLOSE's and IOCTL's to the Win32 calls CreateFile(), CloseHandle() and DeviceIoControl(). The 4 modules that make up this sample are listed below: DOSAPP - DOS Application DOSDRVR - DOS Device Driver VDD - NT Virtual Device Driver KRLNDRVR - NT Kernel Device Driver VDMINTS This directory contains a rudimentary structure for NTVDM based-intercept approach for writing a VDD. The details for this approach are given in the Virtual Device Driver chapter. "16bits" is a sub-directory, which has a test device driver. VDD directory has the sources for VDD. {16bits.exe,vdd.dll) Back to top Video Driver Samples DDK\SRC\VIDEO Purpose Cirrus Display Miniport Driver for Cirrus Labs Chips Sets. Shows GDI Frame buffer and Linear drawing surfaces. Dell_DGX Display Miniport Driver for Dell Computer Corporation DGX Video chip. ET4000 Display Miniport Driver for Tseng Labs ET4000 Chipset. Driver uses both frame buffer and linear surfaces management. S3 Display Miniport Driver for S3 Corporations Chipsets. This miniport driver is the most complete and diverse miniport sample. FRAMEBUF Sample Display Driver showing the general technique with driver managed I386 and MIPS support MGA Matrox Millennium Display Driver. S3 S3 Display Driver for most I386, ALPHA, MIPS, PPC support. VGA Generic 640x480 and 800x600 16 Color sample. VGA256 Generic 640x480 and 800x600 256 Color Sample. VGA64K Generic 640x480 and 800x600 65K Color sample. Back to top Kernel Debugger Extensions DDK\SRC\KRNLDG Samples Purpose KDAPIS This module defines the 32-Bit Windows Kernel Debugger interface. KDEXTS This module contains some example KD debugger extensions. Back to top ------------------------------------------------------------------------ Last reviewed: September 29, 1997 © 1997 Microsoft Corporation. All rights reserved. Terms of Use.