2.3.4 Points to Consider about NT Standard Driver Routines
Keep the following points in mind when designing an NT driver:
·An NT driver must have at least one Dispatch routine and must define the Dispatch entry point in its driver object for each IRP_MJ_XXX the driver handles. An NT driver can have up to as many Dispatch routines as the IRP_MJ_XXX function codes the driver handles.
·An NT driver must have an Unload routine and define one Unload entry point in its driver object if the driver can be replaced while the system is running. An Unload routine is responsible for releasing any system resources, such as NT objects or driver-allocated memory, that the driver is using before the driver itself is unloaded from the system.
·An NT driver can have a StartIo routine and define one StartIo entry point in its driver object. Any lowest-level driver that does not have a StartIo routine must set up and manage internal queues of IRPs sent to its Dispatch routine(s) unless it can complete every IRP it gets within its Dispatch routine(s). Higher-level drivers can have a StartIo routine, but seldom do because higher-level NT drivers usually pass IRPs on to lower-level drivers directly from their Dispatch routines.
·The only exceptions to the preceding requirements are NT SCSI and video miniport drivers. For general information about how SCSI miniport drivers fit into the system, see Sections 2.4.4.3 and 2.5.7 later in this chapter. See Appendix A for more information about requirements for SCSI miniport drivers. For general information about how video miniport drivers fit into the system, see Sections 2.4.1.1 and 2.5.1 later in this chapter. See the Graphics Driver Design Guide for more information about requirements for video miniport drivers.
·Whether an NT driver has any other kind of standard routine depends on its functionality and on how that driver fits into the system (for example, whether it interoperates with system-supplied drivers). The remaining sections in this chapter show how various kinds of system-supplied NT drivers are configured in Windows NT machines, how they are layered, and how certain NT objects represent physical, logical, and virtual devices, system DMA controllers, and device controllers. Use these sections as a guide to developing new NT device and intermediate drivers or as a guide to replacing system-supplied drivers with new device drivers.
See also the following documentation:
·Section 2.5 for how various kinds of NT device drivers use device objects to represent physical, logical, and virtual devices and for more information about NT objects that represent system DMA controllers or device controllers
·Chapter 3 for detailed information about NT objects that drivers can use
·Chapter 4 for an overview of the standard NT driver routines and Chapters 5-15 for routine-specific requirements
·Chapter 16 for more information about how NT drivers manage the system-defined hardware priorities at which standard NT driver routines execute
·Chapter 16 for more information about how NT drivers use the registry during driver initialization
·The Glossary for a summary of terminology and acronyms relevant to NT driver writers