1.2.2 Driver-Allocated IRPs

IoBuildAsynchronousFsdRequest

Allocates and sets up an IRP specifying a major function code (IRP_MJ_READ, IRP_MJ_WRITE, IRP_MJ_SHUTDOWN, or IRP_MJ_FLUSH_BUFFERS) with a pointer to the lower driver's device object on which the I/O should occur, a pointer to a buffer which will contain the data to be read or which contains the data to be written, the length of the buffer in bytes, a pointer to the starting offset on the media, and a pointer to the I/O status block where the called driver can return status information and the caller's IoCompletion routine can access it. Returns a pointer to the IRP so the caller can set any necessary minor function code and set up its IoCompletion routine before sending the IRP to the target driver.

IoBuildSynchronousFsdRequest

Allocates and sets up an IRP specifying a major function code (IRP_MJ_READ, IRP_MJ_WRITE, IRP_MJ_SHUTDOWN, or IRP_MJ_FLUSH_BUFFERS) with a pointer to the lower driver's device object on which the I/O should occur, a pointer to a buffer which will contain the data to be read or which contains the data to be written, the length of the buffer in bytes, a pointer to the starting offset on the media, a pointer to an event object to be set to the Signaled state when the requested operation completes, and a pointer to the I/O status block where the called driver can return status information and the caller's IoCompletion routine can access it. Returns a pointer to the IRP so the caller can set any necessary minor function code and set up its IoCompletion routine before sending the IRP to the target driver.

IoBuildDeviceIoControlRequest

Allocates and sets up an IRP specifying a major function code (either IRP_MJ_INTERNAL_DEVICE_CONTROL or IRP_MJ_DEVICE_CONTROL) with an optional input or output buffer, a pointer to the lower driver's device object, an event to be set to the Signaled state when the requested operation completes, and an I/O status block to be set by the to-be-called driver. Returns a pointer the the IRP so the caller can set the appropriate IOCTL_XXX before sending the IRP to the next-lower-level driver.

IoSizeOfIrp

Returns the size in bytes required for an IRP with a given count of I/O stack locations.

IoAllocateIrp

Allocates an IRP, given the number of I/O stack locations (optionally, for the caller, but at least one for each driver layered under the caller) and whether to charge quota against the caller. Returns a pointer to an IRP in nonpaged system space if successful; otherwise, returns NULL.

IoInitializeIrp

Initializes an IRP, given a pointer to an already allocated IRP, its length in bytes, and the number of I/O stack locations it has.

IoSetNextIrpStackLocation

Sets the current IRP stack location to the caller's in an IRP, which must have been allocated by a preceding call to IoAllocateIrp that specified a stack-size argument large enough to give the caller its own stack location.

IoAllocateMdl

Allocates a MDL large enough to map the starting address and length supplied by the caller; optionally associates the MDL with a given IRP.

IoBuildPartialMdl

Builds an MDL for the specified starting virtual address and length in bytes from a given source MDL. Drivers that split large transfer requests into a number of smaller transfers can call this routine.

IoFreeMdl

Releases a given MDL allocated by the caller.

IoMakeAssociatedIrp

Allocates and initializes an IRP to be associated with a master IRP sent to the highest-level driver, allowing the driver to "split" the original request and send associated IRPs on to lower-level drivers or to the device.

IoSetCompletionRoutine

Registers a driver-supplied IoCompletion routine with a given IRP, so the IoCompletion routine is called when lower-level drivers have completed the request, so the caller can release the IRP it allocated with IoAllocateIrp or IoBuildAsynchronousFsdRequest and any other resources it allocated to set up an IRP for lower drivers and/or perform any I/O completion processing necessary.

IoCallDriver

Sends an IRP to a lower-level driver.

IoFreeIrp

Releases an IRP that was allocated by the caller.