Creating Framework Request Objects
Most framework request objects are created by the framework, but your driver can also create request objects.
When a framework-based driver receives an I/O request packet (IRP) from the I/O manager, the framework intercepts the IRP and creates a framework request object. The framework places the request object into an I/O queue and, if the driver has registered request handlers for the queue, calls the appropriate handler.
The following diagram illustrates the steps that occur when the framework creates a request object for a read operation.
The following steps correspond to the numbers in the preceding diagram:
A user-mode application reads a file by calling the Microsoft Win32 ReadFile function.
The ReadFile function calls the I/O manager, which runs in kernel mode.
The I/O manager allocates an IRP structure and stores an IRP_MJ_READ function code in the structure.
The I/O manager calls the DispatchRead standard driver routine for driver x, passing a pointer to the IRP structure. Because driver x is a framework-based driver, the framework provides the driver's DispatchRead routine.
The framework creates a request object that represents the IRP structure. The framework adds the request object to one of the driver's queue objects.
The framework calls the driver's EvtIoRead request handler, passing a queue object handle and a request object handle.
Framework-based drivers can also create request objects. For example, a driver might create request objects if it receives a read or write request for an amount of data that is larger than the driver's I/O targets can handle at one time. In such a situation, the driver can divide the data into several smaller requests and use additional request objects to send these smaller requests to one or more I/O targets.
If a driver receives WDM IRPs in a WDM dispatch routine and then services or forwards them by using the framework, the driver can call WdfRequestCreateFromIrp.