Bewerken

Delen via


IoAllocateIrp function (wdm.h)

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. See also IoAllocateIrpEx.

Syntax

PIRP IoAllocateIrp(
  [in] CCHAR   StackSize,
  [in] BOOLEAN ChargeQuota
);

Parameters

[in] StackSize

Specifies the number of I/O stack locations to be allocated for the IRP. This value 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 need not allocate a stack location in the IRP for itself.

[in] ChargeQuota

Setting this to TRUE causes the memory allocated for the IRP to be charged against the quota for the current process. Should be set to FALSE by intermediate drivers. This can be set to TRUE only by 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.

Return value

IoAllocateIrp returns a pointer to an IRP, which was allocated from nonpaged system space, or NULL if an IRP could not be allocated.

Remarks

The IoAllocateIrp routine 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 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.

Requirements

Requirement Value
Minimum supported client Available starting with Windows 2000.
Target Platform Universal
Header wdm.h (include Wdm.h, Ntddk.h, Ntifs.h)
Library NtosKrnl.lib
DLL NtosKrnl.exe
IRQL <= DISPATCH_LEVEL
DDI compliance rules ForwardedAtBadIrqlAllocate(wdm), HwStorPortProhibitedDDIs(storport), IoAllocateComplete(wdm), IoAllocateForward(wdm), IoAllocateFree(wdm), IoAllocateIrpSignalEventInCompletion(wdm), IoAllocateIrpSignalEventInCompletion2(wdm), IoAllocateIrpSignalEventInCompletion3(wdm), IoAllocateIrpSignalEventInCompletionTimeout(wdm), IoFreeIrp(storport), IoReuseIrp(wdm), MarkPower(wdm), MarkPowerDown(wdm), MarkQueryRelations(wdm), MarkStartDevice(wdm), SpNoWait(storport), StorPortStartIo(storport)

See also

IO_STACK_LOCATION

IRP

IoAllocateIrpEx

IoBuildAsynchronousFsdRequest

IoBuildDeviceIoControlRequest

IoBuildSynchronousFsdRequest

IoFreeIrp

IoMakeAssociatedIrp

IoReuseIrp

IoSetCompletionRoutine