#include <ntdef.h>
#include <ntifs.h>
Go to the source code of this file.
|
| _Function_class_ (DRIVER_CANCEL) |
| Cancel routine that is installed on any IRP that this library manages. More...
|
|
NTSTATUS NTAPI | IoCsqInitialize (_Out_ PIO_CSQ Csq, _In_ PIO_CSQ_INSERT_IRP CsqInsertIrp, _In_ PIO_CSQ_REMOVE_IRP CsqRemoveIrp, _In_ PIO_CSQ_PEEK_NEXT_IRP CsqPeekNextIrp, _In_ PIO_CSQ_ACQUIRE_LOCK CsqAcquireLock, _In_ PIO_CSQ_RELEASE_LOCK CsqReleaseLock, _In_ PIO_CSQ_COMPLETE_CANCELED_IRP CsqCompleteCanceledIrp) |
| Set up a CSQ struct to initialize the queue. More...
|
|
NTSTATUS NTAPI | IoCsqInitializeEx (_Out_ PIO_CSQ Csq, _In_ PIO_CSQ_INSERT_IRP_EX CsqInsertIrpEx, _In_ PIO_CSQ_REMOVE_IRP CsqRemoveIrp, _In_ PIO_CSQ_PEEK_NEXT_IRP CsqPeekNextIrp, _In_ PIO_CSQ_ACQUIRE_LOCK CsqAcquireLock, _In_ PIO_CSQ_RELEASE_LOCK CsqReleaseLock, _In_ PIO_CSQ_COMPLETE_CANCELED_IRP CsqCompleteCanceledIrp) |
| Set up a CSQ struct to initialize the queue (extended version) More...
|
|
VOID NTAPI | IoCsqInsertIrp (_Inout_ PIO_CSQ Csq, _Inout_ PIRP Irp, _Out_opt_ PIO_CSQ_IRP_CONTEXT Context) |
| Insert an IRP into the CSQ. More...
|
|
NTSTATUS NTAPI | IoCsqInsertIrpEx (_Inout_ PIO_CSQ Csq, _Inout_ PIRP Irp, _Out_opt_ PIO_CSQ_IRP_CONTEXT Context, _In_opt_ PVOID InsertContext) |
| Insert an IRP into the CSQ, with additional tracking context. More...
|
|
PIRP NTAPI | IoCsqRemoveIrp (_Inout_ PIO_CSQ Csq, _Inout_ PIO_CSQ_IRP_CONTEXT Context) |
| Remove anb IRP from the queue. More...
|
|
PIRP NTAPI | IoCsqRemoveNextIrp (_Inout_ PIO_CSQ Csq, _In_opt_ PVOID PeekContext) |
| IoCsqRemoveNextIrp - Removes the next IRP from the queue. More...
|
|
◆ DECLSPEC_IMPORT
Definition at line 29 of file csq.c.
◆ _Function_class_()
_Function_class_ |
( |
DRIVER_CANCEL |
| ) |
|
Cancel routine that is installed on any IRP that this library manages.
- Parameters
-
- Note
- We assume that Irp->Tail.Overlay.DriverContext[3] has either a IO_CSQ or an IO_CSQ_IRP_CONTEXT in it, but we have to figure out which it is
- By the time this routine executes, the I/O Manager has already cleared the cancel routine pointer in the IRP, so it will only be canceled once
- Because of this, we're guaranteed that Irp is valid the whole time
- Don't forget to release the cancel spinlock ASAP --> #1 hot lock in the system
- May be called at high IRQL
Definition at line 49 of file csq.c.
PIO_CSQ_ACQUIRE_LOCK CsqAcquireLock
#define IO_TYPE_CSQ_IRP_CONTEXT
PIO_CSQ_REMOVE_IRP CsqRemoveIrp
PIO_CSQ_RELEASE_LOCK CsqReleaseLock
PIO_CSQ_COMPLETE_CANCELED_IRP CsqCompleteCanceledIrp
VOID NTAPI IoReleaseCancelSpinLock(IN KIRQL Irql)
struct _IO_CSQ_IRP_CONTEXT * PIO_CSQ_IRP_CONTEXT
◆ IoCsqInitialize()
Set up a CSQ struct to initialize the queue.
- Parameters
-
Csq | - Caller-allocated non-paged space for our IO_CSQ to be initialized |
CsqInsertIrp | - Insert routine |
CsqRemoveIrp | - Remove routine |
CsqPeekNextIrp | - Routine to paeek at the next IRP in queue |
CsqAcquireLock | - Acquire the queue's lock |
CsqReleaseLock | - Release the queue's lock |
CsqCompleteCanceledIrp | - Routine to complete IRPs when they are canceled |
- Returns
- STATUS_SUCCESS in all cases
- Note
- Csq must be non-paged, as the queue is manipulated with a held spinlock
Definition at line 103 of file csq.c.
_In_ PIO_CSQ_INSERT_IRP CsqInsertIrp
PIO_CSQ_ACQUIRE_LOCK CsqAcquireLock
_In_ PIO_CSQ_INSERT_IRP _In_ PIO_CSQ_REMOVE_IRP _In_ PIO_CSQ_PEEK_NEXT_IRP _In_ PIO_CSQ_ACQUIRE_LOCK _In_ PIO_CSQ_RELEASE_LOCK CsqReleaseLock
PIO_CSQ_PEEK_NEXT_IRP CsqPeekNextIrp
_In_ PIO_CSQ_INSERT_IRP _In_ PIO_CSQ_REMOVE_IRP _In_ PIO_CSQ_PEEK_NEXT_IRP CsqPeekNextIrp
_In_ PIO_CSQ_INSERT_IRP _In_ PIO_CSQ_REMOVE_IRP CsqRemoveIrp
PIO_CSQ_REMOVE_IRP CsqRemoveIrp
_In_ PIO_CSQ_INSERT_IRP _In_ PIO_CSQ_REMOVE_IRP _In_ PIO_CSQ_PEEK_NEXT_IRP _In_ PIO_CSQ_ACQUIRE_LOCK _In_ PIO_CSQ_RELEASE_LOCK _In_ PIO_CSQ_COMPLETE_CANCELED_IRP CsqCompleteCanceledIrp
PIO_CSQ_INSERT_IRP CsqInsertIrp
PIO_CSQ_RELEASE_LOCK CsqReleaseLock
PIO_CSQ_COMPLETE_CANCELED_IRP CsqCompleteCanceledIrp
_In_ PIO_CSQ_INSERT_IRP _In_ PIO_CSQ_REMOVE_IRP _In_ PIO_CSQ_PEEK_NEXT_IRP _In_ PIO_CSQ_ACQUIRE_LOCK CsqAcquireLock
Referenced by DriverEntry(), MsfsCreateMailslot(), and USBPORT_StartDevice().
◆ IoCsqInitializeEx()
Set up a CSQ struct to initialize the queue (extended version)
- Parameters
-
Csq | - Caller-allocated non-paged space for our IO_CSQ to be initialized |
CsqInsertIrpEx | - Extended insert routine |
CsqRemoveIrp | - Remove routine |
CsqPeekNextIrp | - Routine to paeek at the next IRP in queue |
CsqAcquireLock | - Acquire the queue's lock |
CsqReleaseLock | - Release the queue's lock |
CsqCompleteCanceledIrp | - Routine to complete IRPs when they are canceled |
- Returns
- STATUS_SUCCESS in all cases
- Note
- Csq must be non-paged, as the queue is manipulated with a held spinlock
Definition at line 143 of file csq.c.
PIO_CSQ_ACQUIRE_LOCK CsqAcquireLock
_In_ PIO_CSQ_INSERT_IRP _In_ PIO_CSQ_REMOVE_IRP _In_ PIO_CSQ_PEEK_NEXT_IRP _In_ PIO_CSQ_ACQUIRE_LOCK _In_ PIO_CSQ_RELEASE_LOCK CsqReleaseLock
PIO_CSQ_PEEK_NEXT_IRP CsqPeekNextIrp
NTSTATUS NTAPI CsqInsertIrpEx(PIO_CSQ Csq, PIRP Irp, PVOID InsertContext)
_In_ PIO_CSQ_INSERT_IRP _In_ PIO_CSQ_REMOVE_IRP _In_ PIO_CSQ_PEEK_NEXT_IRP CsqPeekNextIrp
_In_ PIO_CSQ_INSERT_IRP _In_ PIO_CSQ_REMOVE_IRP CsqRemoveIrp
PIO_CSQ_REMOVE_IRP CsqRemoveIrp
_In_ PIO_CSQ_INSERT_IRP _In_ PIO_CSQ_REMOVE_IRP _In_ PIO_CSQ_PEEK_NEXT_IRP _In_ PIO_CSQ_ACQUIRE_LOCK _In_ PIO_CSQ_RELEASE_LOCK _In_ PIO_CSQ_COMPLETE_CANCELED_IRP CsqCompleteCanceledIrp
PIO_CSQ_INSERT_IRP CsqInsertIrp
PIO_CSQ_RELEASE_LOCK CsqReleaseLock
IO_CSQ_INSERT_IRP * PIO_CSQ_INSERT_IRP
PIO_CSQ_COMPLETE_CANCELED_IRP CsqCompleteCanceledIrp
_In_ PIO_CSQ_INSERT_IRP _In_ PIO_CSQ_REMOVE_IRP _In_ PIO_CSQ_PEEK_NEXT_IRP _In_ PIO_CSQ_ACQUIRE_LOCK CsqAcquireLock
Referenced by FsRtlPrivateLock(), and InitializeMessageWaiterQueue().
◆ IoCsqInsertIrp()
Insert an IRP into the CSQ.
- Parameters
-
Csq | - Pointer to the initialized CSQ |
Irp | - Pointer to the IRP to queue |
Context | - Context record to track the IRP while queued |
- Returns
- Just passes through to IoCsqInsertIrpEx, with no InsertContext
Definition at line 177 of file csq.c.
NTSTATUS NTAPI IoCsqInsertIrpEx(_Inout_ PIO_CSQ Csq, _Inout_ PIRP Irp, _Out_opt_ PIO_CSQ_IRP_CONTEXT Context, _In_opt_ PVOID InsertContext)
Insert an IRP into the CSQ, with additional tracking context.
Referenced by DeviceIoctl(), DispatchReadWrite(), MsfsRead(), ReadWrite(), USBPORT_DoIdleNotificationCallback(), USBPORT_HandleSubmitURB(), and USBPORT_IdleNotification().
◆ IoCsqInsertIrpEx()
Insert an IRP into the CSQ, with additional tracking context.
- Parameters
-
Csq | - Pointer to the initialized CSQ |
Irp | - Pointer to the IRP to queue |
Context | - Context record to track the IRP while queued |
InsertContext | - additional data that is passed through to CsqInsertIrpEx |
- Note
- Passes the additional context through to the driver-supplied callback, which can be used with more sophistocated queues
- Marks the IRP pending in all cases
- Guaranteed to not queue a canceled IRP
- This is complicated logic, and is patterend after the Microsoft library. I'm sure I have gotten the details wrong on a fine point or two, but basically this works with the MS-supplied samples.
Definition at line 205 of file csq.c.
230 Irp->Tail.Overlay.DriverContext[3] =
Csq;
294 Irp->Tail.Overlay.DriverContext[3] = 0;
PIO_CSQ_ACQUIRE_LOCK CsqAcquireLock
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
IoSetCancelRoutine(Irp, CancelRoutine)
_In_ PIRP _In_ PVOID InsertContext
#define IO_TYPE_CSQ_IRP_CONTEXT
PIO_CSQ_REMOVE_IRP CsqRemoveIrp
PIO_CSQ_INSERT_IRP CsqInsertIrp
PIO_CSQ_RELEASE_LOCK CsqReleaseLock
PIO_CSQ_COMPLETE_CANCELED_IRP CsqCompleteCanceledIrp
struct tagContext Context
IO_CSQ_INSERT_IRP_EX * PIO_CSQ_INSERT_IRP_EX
Referenced by FsRtlFastUnlockSingle(), FsRtlPrivateLock(), and IoCsqInsertIrp().
◆ IoCsqRemoveIrp()
Remove anb IRP from the queue.
- Parameters
-
Csq | - Queue to remove the IRP from |
Context | - Context record containing the IRP to be dequeued |
- Returns
- Pointer to an IRP if we found it
- Note
- Don't forget that we can be canceled any time up to the point where we unset our cancel routine
Definition at line 326 of file csq.c.
370 Irp->Tail.Overlay.DriverContext[3] = 0;
PIO_CSQ_ACQUIRE_LOCK CsqAcquireLock
IoSetCancelRoutine(Irp, CancelRoutine)
#define InterlockedExchangePointer(Target, Value)
#define IO_TYPE_CSQ_IRP_CONTEXT
PIO_CSQ_REMOVE_IRP CsqRemoveIrp
PIO_CSQ_RELEASE_LOCK CsqReleaseLock
struct _IO_CSQ_IRP_CONTEXT * PIO_CSQ_IRP_CONTEXT
Referenced by MsfsTimeout().
◆ IoCsqRemoveNextIrp()
IoCsqRemoveNextIrp - Removes the next IRP from the queue.
- Parameters
-
Csq | - Queue to remove the IRP from |
PeekContext | - Identifier of the IRP to be removed |
- Returns
- Pointer to the IRP that was removed, or NULL if one could not be found
- Note
- This function is sensitive to yet another race condition. The basic idea is that we have to return the first IRP that we get that matches the PeekContext >that is not already canceled<. Therefore, we have to do a trick similar to the one done in Insert above.
Definition at line 398 of file csq.c.
431 Irp->Tail.Overlay.DriverContext[3] = 0;
PIO_CSQ_ACQUIRE_LOCK CsqAcquireLock
IoSetCancelRoutine(Irp, CancelRoutine)
PIO_CSQ_PEEK_NEXT_IRP CsqPeekNextIrp
#define InterlockedExchangePointer(Target, Value)
#define IO_TYPE_CSQ_IRP_CONTEXT
PIO_CSQ_REMOVE_IRP CsqRemoveIrp
PIO_CSQ_RELEASE_LOCK CsqReleaseLock
struct _IO_CSQ_IRP_CONTEXT * PIO_CSQ_IRP_CONTEXT
_In_opt_ PIRP _In_opt_ PVOID PeekContext
struct tagContext Context
Referenced by DispatchCreateCloseCleanup(), DispatchIoctl(), FsRtlFastUnlockSingle(), FsRtlUninitializeFileLock(), MsfsWrite(), QueueThread(), USBPORT_BadRequestFlush(), USBPORT_CompletePendingIdleIrp(), and USBPORT_DoIdleNotificationCallback().