Writing Dispatch Routines

Processing any I/O request packet (IRP) begins in a dispatch routine that the driver registers to handle an IRP major function code (IRP_MJ_*XXX). The driver's [DriverEntry](https://msdn.microsoft.com/library/windows/hardware/ff544113) routine exports entry points for dispatch routines in a dispatch table within the driver's [DRIVER_OBJECT*](https://msdn.microsoft.com/library/windows/hardware/ff544174) structure.

A driver can provide a separate dispatch routine for each major I/O function code that it handles. Alternatively, dispatch routines can be written to handle multiple I/O function codes.

This section contains the following topics:

Dispatch Routine Functionality

Required Dispatch Routines

Optional Dispatch Routines

Dispatch Routines and IRQLs

When to Check the Driver's I/O Stack Location

DispatchCreate, DispatchClose, and DispatchCreateClose Routines

DispatchCleanup Routines

DispatchRead, DispatchWrite, and DispatchReadWrite Routines

DispatchDeviceControl and DispatchInternalDeviceControl Routines

DispatchPnP Routines

DispatchPower Routines

DispatchQueryInformation Routines

DispatchSetInformation Routines

DispatchFlushBuffers Routines

DispatchShutdown Routines

DispatchSystemControl Routines

Send comments about this topic to Microsoft