IoCsqInsertIrpEx function (wdm.h)

The IoCsqInsertIrpEx routine inserts an IRP into the driver's cancel-safe IRP queue.

Syntax

NTSTATUS IoCsqInsertIrpEx(
  [in, out]       PIO_CSQ             Csq,
  [in, out]       PIRP                Irp,
  [out, optional] PIO_CSQ_IRP_CONTEXT Context,
  [in, optional]  PVOID               InsertContext
);

Parameters

[in, out] Csq

Pointer to the IO_CSQ structure for the driver's cancel-safe IRP queue. This structure must have been initialized by IoCsqInitialize or IoCsqInitializeEx.

[in, out] Irp

Pointer to the IRP to be queued.

[out, optional] Context

Pointer to an IO_CSQ_IRP_CONTEXT structure. IoCsqInsertIrpEx initializes this structure with context information for the inserted IRP. The driver passes this value to IoCsqRemoveIrp to delete the IRP from the queue. Context can be NULL if the driver will not use IoCsqRemoveIrp to remove this IRP from the queue.

[in, optional] InsertContext

Pointer to a driver-defined context value. This parameter is passed to the driver's CsqInsertIrpEx routine, if it has one. Otherwise, this parameter is ignored.

Return value

If the Csq parameter was initialized with IoCsqInitialize, IoCsqInsertIrpEx always returns STATUS_SUCCESS. If Csq was initialized with IoCsqInitializeEx, IoCsqInsertIrpEx returns the value that was returned by the driver's CsqInsertIrpEx routine.

Remarks

IoCsqInsertIrpEx uses the queue's dispatch routines to insert the IRP. The IoCsqInsertIrpEx routine:

  1. Calls the queue's CsqAcquireLock routine to lock the queue.
  2. If the queue's IO_CSQ structure was initialized by IoCsqInitialize, IoCsqInsertIrpEx calls the queue's CsqInsertIrp routine to insert the IRP. If the queue's IO_CSQ structure was initialized by IoCsqInitializeEx, IoCsqInsertIrpEx calls the queue's CsqInsertIrpEx routine to insert the IRP, and passes the InsertContext parameter as the InsertContext parameter of CsqInsertIrpEx.
  3. Calls the queue's CsqReleaseLock routine to unlock the queue.
If the IRP to be inserted has already been canceled, IoCsqInsertIrpEx does not attempt to insert the IRP into the queue.

For more information, see Cancel-Safe IRP Queues.

Note that IoCsqXxx routines use the DriverContext[3] member of the IRP to hold IRP context information. Drivers that use these routines to queue IRPs must leave that member unused.

Callers of IoCsqInsertIrpEx must be running at an IRQL <= DISPATCH_LEVEL. The driver's callback routines must work correctly at this IRQL.

Requirements

Requirement Value
Minimum supported client Available in Windows Server 2003 and later versions of the Windows operating system. The routine is also available in the Csq.lib library that ships with the Windows Driver Kit (WDK) and the Driver Development Kit (DDK) for Windows Server 2003. Drivers that must also work for on Windows XP, Windows 2000, and Windows 98/Me can instead link to Csq.lib to use the routine.
Target Platform Universal
Header wdm.h (include Wdm.h, Ntddk.h, Ntifs.h)
Library NtosKrnl.lib
DLL NtosKrnl.exe
IRQL <= DISPATCH_LEVEL (see Remarks section)
DDI compliance rules IoAllocateFree(wdm), IoReuseIrp(wdm), IrpCancelField(wdm), RemoveLockCheck(wdm), RemoveLockForward(wdm), RemoveLockForward2(wdm), RemoveLockForwardDeviceControl(wdm), RemoveLockForwardDeviceControl2(wdm), RemoveLockForwardDeviceControlInternal(wdm), RemoveLockForwardDeviceControlInternal2(wdm), RemoveLockForwardRead(wdm), RemoveLockForwardRead2(wdm), RemoveLockForwardWrite(wdm), RemoveLockForwardWrite2(wdm), RemoveLockReleaseCleanup(wdm), RemoveLockReleaseClose(wdm), RemoveLockReleaseCreate(wdm), RemoveLockReleaseDeviceControl(wdm), RemoveLockReleaseInternalDeviceControl(wdm), RemoveLockReleasePower(wdm), RemoveLockReleaseRead(wdm), RemoveLockReleaseShutdown(wdm), RemoveLockReleaseSystemControl(wdm), RemoveLockReleaseWrite(wdm)

See also

CsqAcquireLock

CsqCompleteCanceledIrp

CsqInsertIrp

CsqInsertIrpEx

CsqPeekNextIrp

CsqReleaseLock

CsqRemoveIrp

IO_CSQ

IO_CSQ_IRP_CONTEXT

IoCsqInitialize

IoCsqInitializeEx

IoCsqInsertIrp

IoCsqRemoveIrp

IoCsqRemoveNextIrp