Introduction to Standard Driver Routines

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 Purpose Where described


Initializes the driver and its driver object.

Writing a DriverEntry Routine


Initializes devices and creates device objects.

Writing an AddDevice Routine

Dispatch Routines

Receive and process IRPs.

Writing Dispatch Routines


Release system resources acquired by the driver.

Writing an Unload Routine

Optional standard driver routines Purpose Where described


Completes driver initialization if DriverEntry cannot.

Writing a Reinitialize Routine


Starts an I/O operation on a physical device.

Writing a StartIo Routine

Interrupt Service Routine

Saves the state of a device when it interrupts.

Writing an ISR

Deferred Procedure Calls

Completes the processing of a device interrupt after an ISR saves the device state.

DPC Objects and DPCs


Synchronizes access to driver data.

Using Critical Sections


Initiates DMA operations.

Adapter Objects and DMA


Completes a driver's processing of an IRP.

Completing IRPs


Cancels a driver's processing of an IRP.

Canceling IRPs

CustomTimerDpc, IoTimer

Timing and synchronizing events.

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 driver object illustration. Following this convention makes it easier to debug and maintain drivers.