Each kernel-mode driver is constructed around a set of system-defined, standard driver routines. Kernel-mode drivers process I/O request packets (IRPs) within these standard routines by calling system-supplied driver support routines.
All drivers, regardless of their level in a chain of attached drivers, must have a basic set of standard routines in order to process IRPs. Whether a driver must implement additional standard routines depends on whether the driver controls a physical device or is layered over a physical device driver, as well as on the nature of the underlying physical device. Lowest-level drivers that control physical devices have more required routines than higher-level drivers, which typically pass IRPs to a lower driver for processing.
Standard driver routines can be divided into two groups: those that each kernel-mode driver must have, and those that are optional, depending on the driver type and location in the device stack.
This section describes required standard routines. Other sections describe the optional routines.
Following are two tables. The first table lists required standard routines. The second lists most of the optional routines.
| Required Standard Driver Routines | |
|---|---|
| DriverEntry | |
| Purpose: Initializes the driver and its driver object.
Where Described: Writing a DriverEntry Routine |
|
| AddDevice | |
| Purpose: Initializes devices and creates device objects.
Where Described: Writing an AddDevice Routine |
|
| Dispatch Routines | |
| Purpose: Receive and process IRPs.
Where Described: Writing Dispatch Routines |
|
| Unload | |
| Purpose: Release system resources acquired by the driver.
Where Described: Writing an Unload Routine |
|
| Optional Standard Driver Routines | |
|---|---|
| Reinitialize | |
| Purpose: Completes driver initialization if DriverEntry cannot.
Where Described: Writing a Reinitialize Routine |
|
| StartIo | |
| Purpose: Starts an I/O operation on a physical device.
Where Described: Writing a StartIo Routine |
|
| Interrupt Service Routine | |
| Purpose: Saves the state of a device when it interrupts.
Where Described: Writing an ISR |
|
| Deferred Procedure Calls | |
| Purpose: Completes the processing of a device interrupt after an ISR saves the device state.
Where Described: DPC Objects and DPCs |
|
| SynchCritSection | |
| Purpose: Synchronizes access to driver data.
Where Described: Using Critical Sections |
|
| AdapterControl | |
| Purpose: Initiates DMA operations.
Where Described: Adapter Objects and DMA |
|
| IoCompletion | |
| Purpose: Completes a driver's processing of an IRP.
Where Described: Completing IRPs |
|
| Cancel | |
| Purpose: Cancels a driver's processing of an IRP.
Where Described: Canceling IRPs |
|
| CustomTimerDpc, IoTimer | |
| Purpose: Timing and synchronizing events
Where Described: Synchronization Techniques |
|
The current IRP and target device object are input parameters to many standard routines. Every driver processes each IRP in stages through its set of standard routines.
By convention, the system-supplied drivers prepend an identifying, driver-specific or device-specific prefix to the name of every standard routine except DriverEntry. As an example, this documentation uses "DD", as shown in the figure of a Driver Object. Following this convention makes it easier to debug and maintain drivers.