IoAllocateIrpEx function (wdm.h)

IoAllocateIrpEx allocates an IRP from the system nonpaged pool, possibly with an IRP extension.

Syntax

PIRP IoAllocateIrpEx(
  PDEVICE_OBJECT DeviceObject,
  CCHAR          StackSize,
  BOOLEAN        ChargeQuota
);

Parameters

DeviceObject

Pointer to the device object to check to determine whether to add space for an IRP extension. When DeviceObject is set to DEVICE_WITH_IRP_EXTENSION, space for the IRP extension is also allocated.

StackSize

Maximum number of stack locations to be allocated for the IRP. StackSize must be at least equal to the StackSize of the next-lower driver's device object, but can be one greater than this value. The calling driver does not need to allocate a stack location in the IRP for itself.

ChargeQuota

Setting ChargeQuota to TRUE causes the memory allocated for the IRP to be charged against the quota for the current process. This parameter can be set TRUE only by the highest-level drivers that are called in the context of the thread that originates the I/O request for which the driver is allocating another IRP. Intermediate drivers should set this parameter to FALSE.

Return value

IoAllocateIrpEx returns a pointer to the allocated and initialized IRP, or NULL if an IRP could not be allocated.

Remarks

IoAllocateIrpEx allocates StackSize stack locations and initializes the IRP. It does not associate the IRP with a thread. The allocating driver must free the IRP instead of completing it back to the I/O manager.

An intermediate or highest-level driver can call IoAllocateIrpEx to create IRPs for requests it sends to lower-level drivers. Such a driver must initialize the IRP and must set its IoCompletion callback routine in the IRP it creates so the caller can dispose of the IRP when lower-level drivers have completed processing of the request. IoAllocateIrp automatically initializes the IRP's members. Do not use IoInitializeIrp to initialize the IRP before its first use. (You can use IoInitializeIrp to reuse an IRP that you have already used under certain special circumstances. See Reusing IRPs for details.) An intermediate or highest-level driver also can call IoBuildDeviceIoControlRequest, IoBuildAsynchronousFsdRequest or IoBuildSynchronousFsdRequest to set up requests it sends to lower-level drivers. Only a highest-level driver can call IoMakeAssociatedIrp.

Requirements

   
Minimum supported client Available starting Windows 10 (version 1507)
Target Platform Universal
Header wdm.h (include wdm.h, ntddk.h, ntifs.h)
Library ntoskrnl.lib
DLL ntoskrnl.exe
IRQL <= DISPATCH_LEVEL

See also

IO_STACK_LOCATION

IRP

IoAllocateIrp

IoBuildAsynchronousFsdRequest

IoBuildDeviceIoControlRequest

IoCompletion

IoBuildSynchronousFsdRequest

IoFreeIrp

IoMakeAssociatedIrp

IoReuseIrp

IoSetCompletionRoutine