IoSizeOfIrpEx

This function computes what size, in bytes, is required for an I/O Request Packet (IRP).

Declaration

USHORT 
IoSizeOfIrpEx (
    DEVICE_OBJECT *DeviceObject, 
    CHAR StackSize);

Parameters

The DeviceObject argument is the address of a DEVICE_OBJECT that represents the device the request will be sent to. This argument can be NULL.

The StackSize argument tells how many I/O stack locations are wanted for the IRP.

Return Value

This function returns the size, in bytes.

Availability

The IoSizeOfIrpEx function is exported by name from the kernel in version 10.0 and higher.

Documentation Status

The IoSizeOfIrpEx function is not documented. It is, however, declared in WDM.H.

Behaviour

The IoSizeOfIrpEx function is the ancient, documented IoSizeOfIrp function—long replaced by a macro in ordinary practice—except for having the DeviceObject argument as an elaboration. The only known purpose to the elaboration is to help device objects that anticipate receiving requests that carry additional parameters in an IRP extension. Such a DEVICE_OBJECT has a set DO_DEVICE_IRP_REQUIRES_EXTENSION bit (0x08000000) in its Flags. Requests for such device objects are prepared and managed more efficiently if the IRP extension is in the same memory block as the IRP and its I/O stack locations.

The IoSizeOfIrpEx function computes the least size that suffices for the one memory block to hold the following items in the following order:

Whatever the details, this size will be what’s used for an IRP that is obtained through IoAllocateIrpEx or what’s needed for an IRP that is prepared through IoInitializeIrpEx, if given the same DeviceObject and StackSize.