The IoAllocateIrp routine allocates an IRP, given the number of I/O stack locations for each driver layered under the caller, and, optionally, for the caller.
PIRP
IoAllocateIrp(
IN CCHAR StackSize,
IN BOOLEAN ChargeQuota
);
IoAllocateIrp returns a pointer to an IRP, which was allocated from nonpaged system space, or NULL if an IRP could not be allocated.
Declared in wdm.h and ntddk.h. Include wdm.h or ntddk.h.
An intermediate or highest-level driver can call IoAllocateIrp to create IRPs for requests it sends to lower-level drivers. Such a driver must initialize the IRP and must set its IoCompletion 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.
Callers of IoAllocateIrp must be running at IRQL <= DISPATCH_LEVEL.
IO_STACK_LOCATION, IoBuildAsynchronousFsdRequest, IoBuildDeviceIoControlRequest, IoBuildSynchronousFsdRequest, IoFreeIrp, IoMakeAssociatedIrp, IoReuseIrp, IoSetCompletionRoutine, IRP