IO_CSQ_PEEK_NEXT_IRP callback function

The CsqPeekNextIrp routine is used by the system to find the next matching IRP in a driver-implemented, cancel-safe IRP queue.

Syntax

IO_CSQ_PEEK_NEXT_IRP IoCsqPeekNextIrp;

PIRP IoCsqPeekNextIrp(
  PIO_CSQ Csq,
  PIRP Irp,
  PVOID PeekContext
)
{...}

Parameters

Csq

Pointer to the IO_CSQ structure for the cancel-safe IRP queue.

Irp

Pointer to an IRP in the driver's IRP queue, or NULL to specify the beginning of the queue.

PeekContext

Pointer to driver-defined context information. The CsqPeekNextIrp routine returns the first IRP that follows Irp and matches PeekContext.

Return Value

CsqPeekNextIrp returns the first IRP that follows Irp in the queue and matches PeekContext, or NULL if there is no matching IRP. If Irp is NULL, CsqPeekNextIrp returns the first matching IRP in the queue, or NULL if there is no matching IRP.

Remarks

The driver specifies the CsqPeekNextIrp routine for a cancel-safe IRP queue when it initializes the queue's IO_CSQ structure. The driver specifies the routine as the CsqPeekNextIrp parameter of IoCsqInitialize or IoCsqInitializeEx when it initializes IO_CSQ. For more information, see Cancel-Safe IRP Queues.

The system uses CsqPeekNextIrp to iterate through the IRPs in the driver's IRP queue. For example, the IoCsqRemoveNextIrp routine uses this routine to find the IRP to be removed.

Examples

To define a CsqPeekNextIrp callback routine, you must first provide a function declaration that identifies the type of callback routine you're defining. Windows provides a set of callback function types for drivers. Declaring a function using the callback function types helps Code Analysis for Drivers, Static Driver Verifier (SDV), and other verification tools find errors, and it's a requirement for writing drivers for the Windows operating system.

For example, to define a CsqPeekNextIrp callback routine that is named MyCsqPeekNextIrp, use the IO_CSQ_PEEK_NEXT_IRP type as shown in this code example:

IO_CSQ_PEEK_NEXT_IRP MyCsqPeekNextIrp;
Then, implement your callback routine as follows:
_Use_decl_annotations_
PIRP 
 MyCsqPeekNextIrp(
    PIO_CSQ  Csq,
    PIRP  Irp,
    PVOID  PeekContext
    )
  {
      // Function body
  }
The IO_CSQ_PEEK_NEXT_IRP function type is defined in the Wdm.h header file. To more accurately identify errors when you run the code analysis tools, be sure to add the Use_decl_annotations annotation to your function definition. The Use_decl_annotations annotation ensures that the annotations that are applied to the IO_CSQ_PEEK_NEXT_IRP function type in the header file are used. For more information about the requirements for function declarations, see Declaring Functions by Using Function Role Types for WDM Drivers. For information about Use_decl_annotations, see Annotating Function Behavior.

Requirements

   
Target Platform Desktop
Header wdm.h (include Wdm.h, Ntddk.h, Ntifs.h)

See Also

CsqAcquireLock

CsqCompleteCanceledIrp

CsqInsertIrp

CsqInsertIrpEx

CsqReleaseLock

CsqRemoveIrp

IO_CSQ

IoCsqInitialize

IoCsqInitializeEx

IoCsqInsertIrp

IoCsqInsertIrpEx

IoCsqRemoveIrp

IoCsqRemoveNextIrp