Processing any IRP begins in the Dispatch routine that the DriverEntry routine set up to handle the given major function code (IRP_MJ_XXX), which is set in the driver�s I/O stack location of each incoming IRP.
Most NT drivers� Dispatch routines are called in an arbitrary thread context at IRQL PASSIVE_LEVEL, with the following exceptions:
In other words, the Dispatch routines of NT file system drivers and other highest-level NT drivers are called in a nonarbitrary thread context at IRQL PASSIVE_LEVEL.
The DispatchRead and/or DispatchWrite and any other routine that also processes read and/or write requests in such a device or intermediate driver must be resident at all times. These NT driver routines can neither be pageable nor be part of a driver�s pageable-image section.
For more information about pageable and pageable-image driver routines, see the Programmer�s Guide.
The driver writer determines how many Dispatch routines any NT driver has. An NT driver can have as many Dispatch routines as the IRP_MJ_XXX function codes the driver handles, as already mentioned in Chapter 4.