ReactOS  0.4.15-dev-2344-g8ddbfde
FxIoQueue Class Reference

#include <fxioqueue.hpp>

Inheritance diagram for FxIoQueue:
Collaboration diagram for FxIoQueue:

Public Member Functions

 FxIoQueue (__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxPkgIo *PkgIo)
 
virtual ~FxIoQueue ()
 
_Must_inspect_result_ NTSTATUS Initialize (__in PWDF_IO_QUEUE_CONFIG pConfig, __in_opt PWDF_OBJECT_ATTRIBUTES QueueAttributes, __in_opt FxDriver *Caller, __in BOOLEAN InitialPowerStateOn)
 
 _Releases_lock_ (this->m_SpinLock.m_Lock) VOID CancelForQueue(__in FxRequest *pRequest
 
 FX_DECLARE_VF_FUNCTION_P1 (VOID, VerifyCancelForDriver, _In_ FxRequest *)
 
VOID CancelForDriver (__in FxRequest *pRequest)
 
 FX_DECLARE_VF_FUNCTION_P1 (VOID, VerifyValidateCompletedRequest, _In_ FxRequest *)
 
__inline VOID RequestCompletedCallback (__in FxRequest *Request)
 
__inline VOID PreRequestCompletedCallback (__in FxRequest *Request)
 
__inline VOID PostRequestCompletedCallback (__in FxRequest *Request)
 
__inline FxDriverGetDriver (VOID)
 
__inline CfxDeviceGetDevice (VOID)
 
__inline FxPkgIoGetPackage (VOID)
 
WDFQUEUE __inline GetHandle (VOID)
 
__inline BOOLEAN IsPowerManaged ()
 
VOID StartPowerTransitionOn (VOID)
 
VOID StartPowerTransitionOff (VOID)
 
VOID StopProcessingForPower (__in FxIoStopProcessingForPowerAction Action)
 
VOID ResumeProcessingForPower (VOID)
 
VOID SetStateForShutdown (VOID)
 
VOID ResetStateForRestart (VOID)
 
WDF_IO_QUEUE_STATE GetState (__out_opt PULONG pQueueCount, __out_opt PULONG pDriverCount)
 
VOID SetState (__in FX_IO_QUEUE_SET_STATE NewStatus)
 
__inline BOOLEAN IsState (__in WDF_IO_QUEUE_STATE State)
 
__inline BOOLEAN IsState (__in FX_IO_QUEUE_STATE State)
 
 FX_DECLARE_VF_FUNCTION_P1 (NTSTATUS, VerifyGetRequestUpdateFlags, _In_ FxRequest *)
 
 FX_DECLARE_VF_FUNCTION_P1 (VOID, VerifyGetRequestRestoreFlags, _In_ FxRequest *)
 
_Must_inspect_result_ NTSTATUS GetRequest (__in_opt MdFileObject FileObject, __in_opt FxRequest *TagRequest, __deref_out FxRequest **pOutRequest)
 
 FX_DECLARE_VF_FUNCTION_P1 (NTSTATUS, VerifyPeekRequest, _In_ FxRequest *)
 
_Must_inspect_result_ NTSTATUS PeekRequest (__in_opt FxRequest *TagRequest, __in_opt MdFileObject FileObject, __out_opt PWDF_REQUEST_PARAMETERS Parameters, __deref_out FxRequest **pOutRequest)
 
 FX_DECLARE_VF_FUNCTION_P2 (NTSTATUS, VerifyForwardRequest, _In_ FxIoQueue *, _In_ FxRequest *)
 
_Must_inspect_result_ NTSTATUS ForwardRequest (__in FxIoQueue *pDestQueue, __in FxRequest *pRequest)
 
 FX_DECLARE_VF_FUNCTION_P2 (NTSTATUS, VerifyQueueDriverCreatedRequest, _In_ FxRequest *, _Inout_ SHORT *)
 
_Must_inspect_result_ NTSTATUS QueueDriverCreatedRequest (__in FxRequest *Request, __in BOOLEAN ParentQueue)
 
 __drv_requiresIRQL (DISPATCH_LEVEL) VOID ProcessAcknowledgedRequests(__in FxRequest *Request
 
 FX_DECLARE_VF_FUNCTION_P1 (NTSTATUS, VerifyRequeue, _In_ FxRequest *)
 
_Must_inspect_result_ NTSTATUS Requeue (__in FxRequest *pRequest)
 
 FX_DECLARE_VF_FUNCTION_P2 (NTSTATUS, VerifyRequestCancelable, _In_ FxRequest *, _In_ BOOLEAN)
 
_Must_inspect_result_ NTSTATUS RequestCancelable (__in FxRequest *pRequest, __in BOOLEAN Cancelable, __in_opt PFN_WDF_REQUEST_CANCEL EvtRequestCancel, __in BOOLEAN FailIfIrpIsCancelled)
 
_Must_inspect_result_ NTSTATUS RequestCompleteEvent (__in FxRequest *Request)
 
_Must_inspect_result_ NTSTATUS QueueRequest (__in FxRequest *pRequest)
 
_Must_inspect_result_ NTSTATUS QueueRequestFromForward (__in FxRequest *pRequest)
 
_Must_inspect_result_ BOOLEAN CanThreadDispatchEventsLocked (__in KIRQL PreviousIrql)
 
 _Releases_lock_ (this->m_SpinLock.m_Lock) __drv_requiresIRQL(DISPATCH_LEVEL) BOOLEAN DispatchEvents(__in __drv_restoresIRQL KIRQL PreviousIrql
 
 _Releases_lock_ (this->m_SpinLock.m_Lock) __drv_requiresIRQL(DISPATCH_LEVEL) __inline VOID DispatchInternalEvents(__in __drv_restoresIRQL KIRQL PreviousIrql)
 
VOID DispatchRequestToDriver (__in FxRequest *pRequest)
 
virtual VOID GetConstraints (__out WDF_EXECUTION_LEVEL *ExecutionLevel, __out WDF_SYNCHRONIZATION_SCOPE *SynchronizationScope)
 
virtual FxCallbackLockGetCallbackLockPtr (__deref_out FxObject **LockObject)
 
virtual _Must_inspect_result_ NTSTATUS QueryInterface (__in FxQueryInterfaceParams *Params)
 
virtual BOOLEAN Dispose (VOID)
 
VOID QueueStart (VOID)
 
_Must_inspect_result_ NTSTATUS QueueIdle (__in BOOLEAN CancelQueueRequests, __in_opt PFN_WDF_IO_QUEUE_STATE IdleComplete, __in_opt WDFCONTEXT Context)
 
_Must_inspect_result_ NTSTATUS QueueIdleSynchronously (__in BOOLEAN CancelRequests)
 
_Must_inspect_result_ NTSTATUS QueuePurge (__in BOOLEAN CancelQueueRequests, __in BOOLEAN CancelDriverRequests, __in_opt PFN_WDF_IO_QUEUE_STATE PurgeComplete, __in_opt WDFCONTEXT Context)
 
_Must_inspect_result_ NTSTATUS QueuePurgeSynchronously (VOID)
 
_Must_inspect_result_ NTSTATUS QueueDrain (__in_opt PFN_WDF_IO_QUEUE_STATE DrainComplete, __in_opt WDFCONTEXT Context)
 
_Must_inspect_result_ NTSTATUS QueueDrainSynchronously (VOID)
 
_Must_inspect_result_ NTSTATUS ReadyNotify (__in PFN_WDF_IO_QUEUE_STATE QueueReady, __in_opt WDFCONTEXT Context)
 
VOID FlushByFileObject (__in MdFileObject FileObject)
 
VOID GetRequestCount (__out_opt PULONG pQueuedRequests, __out_opt PULONG pDriverPendingRequests)
 
_Must_inspect_result_ NTSTATUS ConfigureConstraints (__in_opt PWDF_OBJECT_ATTRIBUTES ObjectAttributes, __in_opt FxDriver *Caller)
 
VOID DeferredDispatchRequestsFromDpc (VOID)
 
VOID DeferredDispatchRequestsFromWorkerThread (VOID)
 
DECLSPEC_NORETURN VOID FatalError (__in NTSTATUS Status)
 
BOOLEAN IsIoEventHandlerRegistered (__in WDF_REQUEST_TYPE RequestType)
 
__inline VOID SetPowerState (__in FXIOQUEUE_POWER_STATE PowerState)
 
_Must_inspect_result_ NTSTATUS GetReservedRequest (__in MdIrp Irp, __deref_out_opt FxRequest **ReservedRequest)
 
__inline BOOLEAN IsForwardProgressQueue (VOID)
 
__inline NTSTATUS InvokeAllocateResourcesCallback (__in FxRequest *Request)
 
VOID ReturnReservedRequest (__in FxRequest *ReservedRequest)
 
_Must_inspect_result_ NTSTATUS AllocateReservedRequest (__deref_out FxRequest **Request)
 
_Must_inspect_result_ NTSTATUS AssignForwardProgressPolicy (__in PWDF_IO_QUEUE_FORWARD_PROGRESS_POLICY Policy)
 
 FX_DECLARE_VF_FUNCTION_P1_EX (, SHORT, 0, VerifyForwardRequestUpdateFlags, _In_ FxRequest *)
 
_Must_inspect_result_ NTSTATUS ForwardRequestWorker (__in FxRequest *Request, __in FxIoQueue *DestQueue)
 
 FX_DECLARE_VF_FUNCTION_P2 (NTSTATUS, VerifyForwardRequestToParent, _In_ FxIoQueue *, _In_ FxRequest *)
 
_Must_inspect_result_ NTSTATUS ForwardRequestToParent (__in FxIoQueue *DestQueue, __in FxRequest *Request, __in PWDF_REQUEST_FORWARD_OPTIONS ForwardOptions)
 
__inline VOID SetCxDeviceInfo (__in FxCxDeviceInfo *CxDeviceInfo)
 
__inline FxCxDeviceInfoGetCxDeviceInfo (VOID)
 
__inline VOID SetInterruptQueue (VOID)
 
VOID FlushQueuedDpcs (VOID)
 
VOID InsertQueueDpc (VOID)
 
- Public Member Functions inherited from FxNonPagedObject
 FxNonPagedObject (__in WDFTYPE Type, __in USHORT Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals)
 
 FxNonPagedObject (__in WDFTYPE Type, __in USHORT Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxObjectType ObjectType)
 
virtual ~FxNonPagedObject (VOID)
 
 _Acquires_lock_ (this->m_NPLock.m_Lock) __drv_maxIRQL(DISPATCH_LEVEL) __drv_setsIRQL(DISPATCH_LEVEL) VOID Lock(__out __drv_deref(__drv_savesIRQL) PKIRQL PreviousIrql)
 
 _Releases_lock_ (this->m_NPLock.m_Lock) __drv_requiresIRQL(DISPATCH_LEVEL) __inline VOID Unlock(__in __drv_restoresIRQL KIRQL PreviousIrql)
 
 _Acquires_lock_ (this->m_NPLock.m_Lock) __drv_requiresIRQL(DISPATCH_LEVEL) VOID LockAtDispatch(VOID)
 
 _Requires_lock_held_ (this->m_NPLock.m_Lock) _Releases_lock_(this -> m_NPLock.m_Lock) __drv_requiresIRQL(DISPATCH_LEVEL) __inline VOID UnlockFromDispatch(VOID)
 
- Public Member Functions inherited from FxObject
PVOID GetCOMWrapper ()
 
void SetCOMWrapper (__drv_aliasesMem PVOID Wrapper)
 
 FxObject (__in WDFTYPE Type, __in USHORT Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals)
 
virtual ~FxObject (VOID)
 
PVOID __inline operator new (__in size_t Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxObjectType Type)
 
PVOID __inline operator new (__in size_t Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals, __in_opt PWDF_OBJECT_ATTRIBUTES Attributes, __in USHORT ExtraSize=0)
 
VOID operator delete (__in PVOID Memory)
 
VOID SetNoContextHeader (VOID)
 
PVOID __inline GetObjectHandle (VOID)
 
__inline FxContextHeaderGetContextHeader (VOID)
 
__inline PFX_DRIVER_GLOBALS GetDriverGlobals (VOID)
 
WDFTYPE GetType (VOID)
 
USHORT GetObjectSize (VOID)
 
LONG GetRefCnt (VOID)
 
FxTagTrackerGetTagTracker (VOID)
 
CfxDeviceGetDevice (VOID)
 
CfxDeviceBaseGetDeviceBase (VOID)
 
VOID SetDeviceBase (__in CfxDeviceBase *DeviceBase)
 
__inline VOID CallCleanup (VOID)
 
ULONG __inline AddRef (__in_opt PVOID Tag=NULL, __in LONG Line=0, __in_opt PSTR File=NULL)
 
virtual ULONG Release (__in_opt PVOID Tag=NULL, __in LONG Line=0, __in_opt PSTR File=NULL)
 
virtual ULONG AddRefOverride (__in WDFOBJECT_OFFSET Offset, __in_opt PVOID Tag=NULL, __in LONG Line=0, __in_opt PSTR File=NULL)
 
virtual ULONG ReleaseOverride (__in WDFOBJECT_OFFSET Offset, __in_opt PVOID Tag=NULL, __in LONG Line=0, __in_opt PSTR File=NULL)
 
VOID MarkTraceState (VOID)
 
BOOLEAN __inline IsTraceState (VOID)
 
VOID __inline TraceDroppedEvent (__in FxObjectDroppedEvent Event)
 
VOID MarkPassiveDispose (__in FxObjectLockState State=ObjectLock)
 
VOID MarkPassiveCallbacks (__in FxObjectLockState State=ObjectLock)
 
VOID MarkForceDisposeThread (__in FxObjectLockState State=ObjectLock)
 
BOOLEAN IsPassiveCallbacks (__in BOOLEAN AcquireLock=TRUE)
 
BOOLEAN IsPassiveDispose (__in BOOLEAN AcquireLock=TRUE)
 
BOOLEAN IsForceDisposeThread (__in BOOLEAN AcquireLock=TRUE)
 
VOID MarkCommitted (VOID)
 
BOOLEAN IsCommitted (VOID)
 
VOID MarkDisposeOverride (__in FxObjectLockState State=ObjectLock)
 
VOID MarkNoDeleteDDI (__in FxObjectLockState State=ObjectLock)
 
BOOLEAN IsNoDeleteDDI (VOID)
 
_Must_inspect_result_ NTSTATUS Commit (__in_opt PWDF_OBJECT_ATTRIBUTES Attributes, __out_opt WDFOBJECT *ObjectHandle, __in_opt FxObject *Parent=NULL, __in BOOLEAN AssignDriverAsDefaultParent=TRUE)
 
VOID DeleteFromFailedCreate (VOID)
 
VOID ClearEvtCallbacks (VOID)
 
BOOLEAN EarlyDispose (VOID)
 
virtual VOID DeleteObject (VOID)
 
_Must_inspect_result_ NTSTATUS AssignParentObject (__in FxObject *ParentObject)
 
_Must_inspect_result_ NTSTATUS AddContext (__in FxContextHeader *Header, __in PVOID *Context, __in PWDF_OBJECT_ATTRIBUTES Attributes)
 
_Must_inspect_result_ NTSTATUS RemoveParentAssignment (VOID)
 
_Must_inspect_result_ FxObjectGetParentObjectReferenced (__in PVOID Tag)
 
BOOLEAN IsDisposed (VOID)
 

Static Public Member Functions

static _Must_inspect_result_ NTSTATUS _Create (__in PFX_DRIVER_GLOBALS DriverGlobals, __in_opt PWDF_OBJECT_ATTRIBUTES Attributes, __in PWDF_IO_QUEUE_CONFIG Config, __in_opt FxDriver *Caller, __in FxPkgIo *PkgIo, __in BOOLEAN InitialPowerStateOn, __deref_out FxIoQueue **Object)
 
static __inline FxIoQueue_FromIoPkgListEntry (__in PLIST_ENTRY Entry)
 
static __inline FxIoQueue_FromPowerSListEntry (__in PSINGLE_LIST_ENTRY Entry)
 
- Static Public Member Functions inherited from FxObject
static FxObject_FromDisposeEntry (__in PSINGLE_LIST_ENTRY Entry)
 
static FxObject_GetObjectFromHandle (__in WDFOBJECT Handle, __inout PWDFOBJECT_OFFSET ObjectOffset)
 
static PVOID __inline _ToHandle (__in FxObject *Object)
 
static VOID __inline _ReferenceActual (__in WDFOBJECT Object, __in_opt PVOID Tag, __in LONG Line, __in PSTR File)
 
static VOID __inline _DereferenceActual (__in WDFOBJECT Object, __in_opt PVOID Tag, __in LONG Line, __in PSTR File)
 
static PVOID _GetDebugBase (__in FxObject *Object)
 
static PFX_POOL_HEADER _CleanupPointer (__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxObject *Object)
 
static _Must_inspect_result_ NTSTATUS _GetEffectiveLock (__in FxObject *Object, __in_opt IFxHasCallbacks *Callbacks, __in BOOLEAN AutomaticLocking, __in BOOLEAN PassiveCallbacks, __out FxCallbackLock **CallbackLock, __out_opt FxObject **CallbackLockObject)
 
static _Must_inspect_result_ NTSTATUS _ObjectQuery (_In_ FxObject *Object, _In_ CONST GUID *Guid, _In_ ULONG QueryBufferLength, _Out_writes_bytes_(QueryBufferLength) PVOID QueryBuffer)
 

Public Attributes

FxIoQueueNode m_IoPkgListNode
 
SINGLE_LIST_ENTRY m_PowerSListEntry
 
__in __drv_restoresIRQL KIRQL PreviousIrql
 
__out PKIRQL PreviousIrql
 
__in_opt FxRequestNewRequest
 

Static Protected Attributes

static EVT_IRP_QUEUE_CANCEL _IrpCancelForQueue
 
static EVT_IRP_QUEUE_CANCEL _IrpCancelForDriver
 
static EVT_SYSTEMWORKITEM _DeferredDispatchThreadThunk
 
static MdDeferredRoutineType _DeferredDispatchDpcThunk
 
static EVT_WDF_IO_QUEUE_STATE _PurgeComplete
 
static EVT_WDF_IO_QUEUE_STATE _IdleComplete
 
static MdCancelRoutineType _WdmCancelRoutineForReservedIrp
 

Private Member Functions

 __drv_requiresIRQL (DISPATCH_LEVEL) VOID ProcessIdleComplete(__out PKIRQL PreviousIrql)
 
 __drv_requiresIRQL (DISPATCH_LEVEL) VOID ProcessPurgeComplete(__out PKIRQL PreviousIrql)
 
 __drv_requiresIRQL (DISPATCH_LEVEL) VOID ProcessReadyNotify(__out PKIRQL PreviousIrql)
 
 __drv_requiresIRQL (DISPATCH_LEVEL) BOOLEAN ProcessCancelledRequests(__out PKIRQL PreviousIrql)
 
 __drv_requiresIRQL (DISPATCH_LEVEL) BOOLEAN ProcessCancelledRequestsOnQueue(__out PKIRQL PreviousIrql)
 
 __drv_requiresIRQL (DISPATCH_LEVEL) BOOLEAN ProcessPowerEvents(__out PKIRQL PreviousIrql)
 
__inline BOOLEAN IsPowerStateNotifyingDriver (VOID)
 
__inline VOID InsertInDriverOwnedList (__in FxRequest *Request)
 
__inline VOID RemoveFromDriverOwnedList (__in FxRequest *Request)
 
__inline VOID PreRemoveFromDriverOwnedList (__in FxRequest *Request)
 
__inline VOID PostRemoveFromDriverOwnedList (VOID)
 
__inline VOID CheckTransitionFromEmpty (VOID)
 
__inline VOID SetTransitionFromEmpty (VOID)
 
NTSTATUS InsertNewRequestLocked (__deref_in FxRequest **Request, __in KIRQL PreviousIrql)
 
__inline NTSTATUS InsertNewRequest (__in FxRequest **Request, __in KIRQL PreviousIrql)
 
VOID FreeAllReservedRequests (__in BOOLEAN Verify)
 
_Must_inspect_result_ NTSTATUS QueueForwardProgressIrpLocked (__in MdIrp Irp)
 
_Must_inspect_result_ MdIrp GetForwardProgressIrpLocked (__in_opt PFILE_OBJECT FileObject)
 
BOOLEAN IsPagingIo (__in MdIrp Irp)
 
VOID PutBackReservedRequest (__in FxRequest *ReservedRequest)
 
VOID GetForwardProgressIrps (__in PLIST_ENTRY IrpListHead, __in_opt MdFileObject FileObject)
 
VOID CancelIrps (__in PLIST_ENTRY IrpListHead)
 
VOID PurgeForwardProgressIrps (__in_opt MdFileObject FileObject)
 
VOID VerifierVerifyFwdProgListsLocked (VOID)
 
- Private Member Functions inherited from IFxHasCallbacks
virtual _Must_inspect_result_ FxCallbackLockGetCallbackLockPtr (__out_opt FxObject **LockObject)=0
 

Private Attributes

PFXIO_FORWARD_PROGRESS_CONTEXT m_FwdProgContext
 
BOOLEAN m_SupportForwardProgress
 
BOOLEAN m_Configured
 
BOOLEAN m_PowerManaged
 
volatile BOOLEAN m_PowerReferenced
 
BOOLEAN m_AllowZeroLengthRequests
 
BOOLEAN m_PassiveLevel
 
volatile BOOLEAN m_Deleted
 
volatile BOOLEAN m_Disposing
 
MxEvent m_FinishDisposing
 
FXIOQUEUE_POWER_STATE m_PowerState
 
WDF_IO_QUEUE_DISPATCH_TYPE m_Type
 
ULONG m_MaxParallelQueuePresentedRequests
 
FX_IO_QUEUE_STATE m_QueueState
 
FxIrpQueue m_Queue
 
FxIrpQueue m_DriverCancelable
 
LIST_ENTRY m_Cancelled
 
LIST_ENTRY m_CanceledOnQueueList
 
LIST_ENTRY m_DriverOwned
 
LIST_ENTRY m_PowerNotify
 
LIST_ENTRY m_PowerDriverNotified
 
FxPkgIom_PkgIo
 
FxCxDeviceInfom_CxDeviceInfo
 
volatile ULONG m_Dispatching
 
volatile BOOLEAN m_TransitionFromEmpty
 
volatile BOOLEAN m_ForceTransitionFromEmptyWhenAddingNewRequest
 
volatile BOOLEAN m_CancelDispatchedRequests
 
BOOLEAN m_IsDevicePowerPolicyOwner
 
volatile LONG m_DriverIoCount
 
volatile LONG m_TwoPhaseCompletions
 
FxIoQueueIoDefault m_IoDefault
 
FxIoQueueIoStop m_IoStop
 
FxIoQueueIoResume m_IoResume
 
FxIoQueueIoRead m_IoRead
 
FxIoQueueIoWrite m_IoWrite
 
FxIoQueueIoDeviceControl m_IoDeviceControl
 
FxIoQueueIoInternalDeviceControl m_IoInternalDeviceControl
 
FxIoQueueIoCanceledOnQueue m_IoCanceledOnQueue
 
FxCallbackLockm_IoCancelCallbackLockPtr
 
FxIoQueueIoState m_IdleComplete
 
WDFCONTEXT m_IdleCompleteContext
 
FxIoQueueIoState m_PurgeComplete
 
WDFCONTEXT m_PurgeCompleteContext
 
FxIoQueueIoState m_ReadyNotify
 
WDFCONTEXT m_ReadyNotifyContext
 
WDF_EXECUTION_LEVEL m_ExecutionLevel
 
WDF_SYNCHRONIZATION_SCOPE m_SynchronizationScope
 
FxCallbackSpinLock m_CallbackSpinLock
 
FxCallbackMutexLock m_CallbackMutexLock
 
FxCallbackLockm_CallbackLockPtr
 
FxObjectm_CallbackLockObjectPtr
 
KDPC m_Dpc
 
FxSystemWorkItemm_SystemWorkItem
 
BOOLEAN m_DpcQueued
 
BOOLEAN m_WorkItemQueued
 
BOOLEAN m_RequeueDeferredDispatcher
 
MxEvent m_PowerIdle
 
MxEvent m_RequestWaitEventUm
 

Friends

VOID GetTriageInfo (VOID)
 

Additional Inherited Members

- Protected Member Functions inherited from FxObject
 FxObject (__in WDFTYPE Type, __in USHORT Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxObjectType ObjectType)
 
FxObjectDebugExtensionGetDebugExtension (VOID)
 
BOOLEAN IsDebug (VOID)
 
VOID AllocateTagTracker (__in WDFTYPE Type)
 
virtual VOID SelfDestruct (VOID)
 
PVOID __inline GetObjectHandleUnchecked (VOID)
 
VOID __inline DestroyChildren (VOID)
 
VOID DeleteEarlyDisposedObject (VOID)
 
- Static Protected Member Functions inherited from FxObject
static PVOID _GetBase (__in FxObject *Object)
 
- Protected Attributes inherited from FxObject
union {
   CfxDeviceBase *   m_DeviceBase
 
   CfxDevice *   m_Device
 
}; 
 

Detailed Description

Definition at line 232 of file fxioqueue.hpp.

Constructor & Destructor Documentation

◆ FxIoQueue()

FxIoQueue::FxIoQueue ( __in PFX_DRIVER_GLOBALS  FxDriverGlobals,
__in FxPkgIo PkgIo 
)

Definition at line 37 of file fxioqueue.cpp.

40  :
41  FxNonPagedObject(FX_TYPE_QUEUE, sizeof(FxIoQueue), FxDriverGlobals),
42  m_CallbackSpinLock(FxDriverGlobals),
43  m_CallbackMutexLock(FxDriverGlobals),
45  {
54 
55  // A newly created queue can not accept requests until initialized
57 
58  //
59  // Set our Cancel callbacks
60  //
62 
64 
66 
68 
70 
72 
74 
76 
77  //
78  // We do not reference count the I/O package instance
79  // since it contains us. The fact we exist, the I/O
80  // package instance exists.
81  //
82  m_PkgIo = PkgIo;
84 
85  m_Device = PkgIo->GetDevice();
86 
89 
90  m_Dispatching = 0L;
91 
94 
95  m_DriverIoCount = 0L;
97 
99 
102 
105 
108 
111 
112 #if FX_IS_KERNEL_MODE
113 
114  // Initialize the DPC used for deferrals
116  &m_Dpc,
118  this
119  );
120 #endif
121 
122  m_DpcQueued = FALSE;
123 
125 
127 
128  m_Deleted = FALSE;
131 
134 
138 
139  return;
140 }
CfxDevice * m_Device
Definition: fxobject.hpp:329
LIST_ENTRY m_Cancelled
Definition: fxioqueue.hpp:379
KDPC m_Dpc
Definition: fxioqueue.hpp:554
FxNonPagedObject(__in WDFTYPE Type, __in USHORT Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals)
LIST_ENTRY m_DriverOwned
Definition: fxioqueue.hpp:397
BOOLEAN m_RequeueDeferredDispatcher
Definition: fxioqueue.hpp:568
SINGLE_LIST_ENTRY m_PowerSListEntry
Definition: fxioqueue.hpp:591
volatile BOOLEAN m_PowerReferenced
Definition: fxioqueue.hpp:267
FxCallbackLock * m_CallbackLockPtr
Definition: fxioqueue.hpp:528
VOID MarkPassiveDispose(__in FxObjectLockState State=ObjectLock)
Definition: fxobject.hpp:944
FxObject * m_CallbackLockObjectPtr
Definition: fxioqueue.hpp:529
__inline BOOLEAN IsPnp(VOID)
Definition: fxdevice.hpp:1200
LIST_ENTRY m_PowerNotify
Definition: fxioqueue.hpp:405
FxIoQueueNode m_IoPkgListNode
Definition: fxioqueue.hpp:586
volatile LONG m_DriverIoCount
Definition: fxioqueue.hpp:475
WDFCONTEXT m_IdleCompleteContext
Definition: fxioqueue.hpp:502
volatile ULONG m_Dispatching
Definition: fxioqueue.hpp:435
PFXIO_FORWARD_PROGRESS_CONTEXT m_FwdProgContext
Definition: fxioqueue.hpp:241
FxPkgIo * m_PkgIo
Definition: fxioqueue.hpp:420
WDF_EXECUTION_LEVEL m_ExecutionLevel
Definition: fxioqueue.hpp:514
BOOLEAN m_Configured
Definition: fxioqueue.hpp:252
#define FALSE
Definition: types.h:117
BOOLEAN m_SupportForwardProgress
Definition: fxioqueue.hpp:246
WDF_SYNCHRONIZATION_SCOPE m_SynchronizationScope
Definition: fxioqueue.hpp:515
ULONG m_MaxParallelQueuePresentedRequests
Definition: fxioqueue.hpp:313
BOOLEAN m_WorkItemQueued
Definition: fxioqueue.hpp:563
BOOLEAN m_PowerManaged
Definition: fxioqueue.hpp:261
FxCallbackSpinLock m_CallbackSpinLock
Definition: fxioqueue.hpp:520
static EVT_IRP_QUEUE_CANCEL _IrpCancelForDriver
Definition: fxioqueue.hpp:1683
FxIrpQueue m_DriverCancelable
Definition: fxioqueue.hpp:372
volatile BOOLEAN m_Disposing
Definition: fxioqueue.hpp:296
BOOLEAN m_IsDevicePowerPolicyOwner
Definition: fxioqueue.hpp:463
FxIoQueueIoState m_IdleComplete
Definition: fxioqueue.hpp:501
FxSystemWorkItem * m_SystemWorkItem
Definition: fxioqueue.hpp:557
FXIOQUEUE_POWER_STATE m_PowerState
Definition: fxioqueue.hpp:302
volatile BOOLEAN m_ForceTransitionFromEmptyWhenAddingNewRequest
Definition: fxioqueue.hpp:452
FxCallbackMutexLock m_CallbackMutexLock
Definition: fxioqueue.hpp:521
PFN_WDF_IO_QUEUE_STATE Method
BOOLEAN IsPowerPolicyOwner(VOID)
Definition: fxpkgpnp.hpp:3612
struct _SINGLE_LIST_ENTRY * Next
Definition: ntbasedef.h:629
static const WCHAR L[]
Definition: oid.c:1250
static MdDeferredRoutineType _DeferredDispatchDpcThunk
Definition: fxioqueue.hpp:1691
FxIoQueueIoState m_ReadyNotify
Definition: fxioqueue.hpp:507
volatile BOOLEAN m_TransitionFromEmpty
Definition: fxioqueue.hpp:442
FxPkgPnp * m_PkgPnp
Definition: fxdevice.hpp:670
CfxDevice * GetDevice(VOID)
Definition: fxobject.hpp:781
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
BOOLEAN m_PassiveLevel
Definition: fxioqueue.hpp:280
FX_IO_QUEUE_STATE m_QueueState
Definition: fxioqueue.hpp:318
enum _FX_IO_QUEUE_STATE FX_IO_QUEUE_STATE
BOOLEAN m_AllowZeroLengthRequests
Definition: fxioqueue.hpp:273
#define NULL
Definition: types.h:112
VOID Initialize(__in FxNonPagedObject *LockObject, __in PFN_IRP_QUEUE_CANCEL Callback)
Definition: fxirpqueue.cpp:61
BOOLEAN m_DpcQueued
Definition: fxioqueue.hpp:562
LIST_ENTRY m_CanceledOnQueueList
Definition: fxioqueue.hpp:387
WDFCONTEXT m_PurgeCompleteContext
Definition: fxioqueue.hpp:505
unsigned int ULONG
Definition: retypes.h:1
volatile LONG m_TwoPhaseCompletions
Definition: fxioqueue.hpp:481
volatile BOOLEAN m_Deleted
Definition: fxioqueue.hpp:288
FxIrpQueue m_Queue
Definition: fxioqueue.hpp:366
WDF_IO_QUEUE_DISPATCH_TYPE m_Type
Definition: fxioqueue.hpp:308
VOID NTAPI KeInitializeDpc(IN PKDPC Dpc, IN PKDEFERRED_ROUTINE DeferredRoutine, IN PVOID DeferredContext)
Definition: dpc.c:711
LIST_ENTRY m_PowerDriverNotified
Definition: fxioqueue.hpp:414
WDFCONTEXT m_ReadyNotifyContext
Definition: fxioqueue.hpp:508
FxCxDeviceInfo * m_CxDeviceInfo
Definition: fxioqueue.hpp:425
FxIoQueueIoState m_PurgeComplete
Definition: fxioqueue.hpp:504
static EVT_IRP_QUEUE_CANCEL _IrpCancelForQueue
Definition: fxioqueue.hpp:1674

Referenced by _Create().

◆ ~FxIoQueue()

FxIoQueue::~FxIoQueue ( )
virtual

Definition at line 142 of file fxioqueue.cpp.

143 {
145 
146  if (m_PkgIo != NULL) {
147  m_PkgIo = NULL;
148  }
149 
160 }
LIST_ENTRY m_Cancelled
Definition: fxioqueue.hpp:379
LIST_ENTRY m_DriverOwned
Definition: fxioqueue.hpp:397
BOOLEAN m_RequeueDeferredDispatcher
Definition: fxioqueue.hpp:568
volatile BOOLEAN m_PowerReferenced
Definition: fxioqueue.hpp:267
LIST_ENTRY m_PowerNotify
Definition: fxioqueue.hpp:405
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
FxPkgIo * m_PkgIo
Definition: fxioqueue.hpp:420
BOOLEAN m_WorkItemQueued
Definition: fxioqueue.hpp:563
FxSystemWorkItem * m_SystemWorkItem
Definition: fxioqueue.hpp:557
#define NULL
Definition: types.h:112
BOOLEAN m_DpcQueued
Definition: fxioqueue.hpp:562
LIST_ENTRY m_CanceledOnQueueList
Definition: fxioqueue.hpp:387
volatile LONG m_TwoPhaseCompletions
Definition: fxioqueue.hpp:481
LIST_ENTRY m_PowerDriverNotified
Definition: fxioqueue.hpp:414
ASSERT((Request->GetVerifierFlagsLocked() &FXREQUEST_FLAG_DRIVER_OWNED) !=0)

Member Function Documentation

◆ __drv_requiresIRQL() [1/7]

FxIoQueue::__drv_requiresIRQL ( DISPATCH_LEVEL  )

◆ __drv_requiresIRQL() [2/7]

FxIoQueue::__drv_requiresIRQL ( DISPATCH_LEVEL  )
private

◆ __drv_requiresIRQL() [3/7]

FxIoQueue::__drv_requiresIRQL ( DISPATCH_LEVEL  )
private

◆ __drv_requiresIRQL() [4/7]

FxIoQueue::__drv_requiresIRQL ( DISPATCH_LEVEL  )
private

◆ __drv_requiresIRQL() [5/7]

FxIoQueue::__drv_requiresIRQL ( DISPATCH_LEVEL  )
private

◆ __drv_requiresIRQL() [6/7]

FxIoQueue::__drv_requiresIRQL ( DISPATCH_LEVEL  )
private

◆ __drv_requiresIRQL() [7/7]

FxIoQueue::__drv_requiresIRQL ( DISPATCH_LEVEL  )
private

◆ _Create()

_Must_inspect_result_ NTSTATUS FxIoQueue::_Create ( __in PFX_DRIVER_GLOBALS  DriverGlobals,
__in_opt PWDF_OBJECT_ATTRIBUTES  Attributes,
__in PWDF_IO_QUEUE_CONFIG  Config,
__in_opt FxDriver Caller,
__in FxPkgIo PkgIo,
__in BOOLEAN  InitialPowerStateOn,
__deref_out FxIoQueue **  Object 
)
static

Definition at line 164 of file fxioqueue.cpp.

173 {
175  FxIoQueue* pQueue;
176 
177  *Object = NULL;
178 
180 
181  if (pQueue == NULL) {
184  "Memory allocation failed: %!STATUS!", status);
185  return status;
186  }
187 
188  //
189  // Initialize it, creating the handle to pass the driver
190  // and configuring its callbacks and queue type
191  //
193  Attributes,
194  Caller,
195  InitialPowerStateOn);
196  if (!NT_SUCCESS(status)) {
198  "Could not configure queue: %!STATUS!", status);
199  goto Done;
200  }
201 Done:
202  if (NT_SUCCESS(status)) {
203  *Object = pQueue;
204  }
205  else {
206  //
207  // Release our newly allocated Queue object
208  //
210  }
211 
212  return status;
213 }
FxIoQueue * pQueue
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
LONG NTSTATUS
Definition: precomp.h:26
DriverGlobals
DoTraceLevelMessage(FxDriverGlobals, TRACE_LEVEL_WARNING, TRACINGIO, "WDFREQUEST 0x%p " "was cancelled in driver for WDFQUEUE 0x%p", Request->GetHandle(), GetObjectHandle())
_Must_inspect_result_ NTSTATUS Initialize(__in PWDF_IO_QUEUE_CONFIG pConfig, __in_opt PWDF_OBJECT_ATTRIBUTES QueueAttributes, __in_opt FxDriver *Caller, __in BOOLEAN InitialPowerStateOn)
Definition: fxioqueue.cpp:217
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
FxIoQueue(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxPkgIo *PkgIo)
Definition: fxioqueue.cpp:37
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_CHILD_LIST_CONFIG Config
Definition: wdfchildlist.h:474
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
NTSTATUS status
Definition: fxioqueue.cpp:887
#define NULL
Definition: types.h:112
VOID DeleteFromFailedCreate(VOID)
Definition: fxobject.cpp:391
#define TRACINGIO
Definition: dbgtrace.h:66
_Must_inspect_result_ _In_ WDFDMAENABLER _In_ _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes
Definition: ps.c:97

Referenced by FxPkgIo::CreateQueue().

◆ _FromIoPkgListEntry()

static __inline FxIoQueue* FxIoQueue::_FromIoPkgListEntry ( __in PLIST_ENTRY  Entry)
inlinestatic

Definition at line 1216 of file fxioqueue.hpp.

1219  {
1221  }
FxIoQueueNode m_IoPkgListNode
Definition: fxioqueue.hpp:586
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
LIST_ENTRY m_ListEntry
Definition: fxioqueue.hpp:56
base of all file and directory entries
Definition: entries.h:82

Referenced by FxPkgIo::AddIoQueue(), GetIoQueueList_ProcessQueueListEntry(), and FxPkgIo::GetNextIoQueueLocked().

◆ _FromPowerSListEntry()

static __inline FxIoQueue* FxIoQueue::_FromPowerSListEntry ( __in PSINGLE_LIST_ENTRY  Entry)
inlinestatic

Definition at line 1226 of file fxioqueue.hpp.

1229  {
1231  }
SINGLE_LIST_ENTRY m_PowerSListEntry
Definition: fxioqueue.hpp:591
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
base of all file and directory entries
Definition: entries.h:82

Referenced by FxPkgIo::ResetStateForRestart(), FxPkgIo::ResumeProcessingForPower(), and FxPkgIo::StopProcessingForPower().

◆ _Releases_lock_() [1/3]

FxIoQueue::_Releases_lock_ ( this->m_SpinLock.  m_Lock)

◆ _Releases_lock_() [2/3]

FxIoQueue::_Releases_lock_ ( this->m_SpinLock.  m_Lock)

◆ _Releases_lock_() [3/3]

FxIoQueue::_Releases_lock_ ( this->m_SpinLock.  m_Lock)
inline

Definition at line 1003 of file fxioqueue.hpp.

1024  {
1025  if(m_Dispatching == 0) {
1026  //
1027  // Nobody is dispatching events so we must
1028  // call the main DispatchEvents function because
1029  // the caller of this function might have affected the
1030  // state of the queue.
1031  //
1032  (VOID) DispatchEvents(PreviousIrql);
1033 
1034  } else {
1035 
1037  }
1038  }
__drv_restoresIRQL KIRQL __in BOOLEAN Unlock
Definition: fxobject.hpp:1474
__in __drv_restoresIRQL KIRQL PreviousIrql
Definition: fxioqueue.hpp:631
volatile ULONG m_Dispatching
Definition: fxioqueue.hpp:435
#define VOID
Definition: acefi.h:82

◆ AllocateReservedRequest()

_Must_inspect_result_ NTSTATUS FxIoQueue::AllocateReservedRequest ( __deref_out FxRequest **  Request)

Definition at line 6359 of file fxioqueue.cpp.

6370 {
6372  NTSTATUS status;
6374  PWDF_OBJECT_ATTRIBUTES reqAttribs;
6375 
6377  *Request = NULL;
6378  reqAttribs = NULL;
6379 
6380  //
6381  // Get the right context for this request object.
6382  //
6383  if (GetCxDeviceInfo() != NULL) {
6384  reqAttribs = &GetCxDeviceInfo()->RequestAttributes;
6385  }
6386  else {
6387  reqAttribs = m_Device->GetRequestAttributes();
6388  }
6389 
6390  //
6391  // FxRequest::_Create doesn't create a Request from the Device lookaside
6392  // hence we can't use that as the Request Context doesn't get associated
6393  // if the Request is not created from the lookaside.
6394  //
6396  if (!NT_SUCCESS(status)) {
6398  "Failure to allocate request %!STATUS!", status);
6399  return status;
6400  }
6401 
6402  pRequest->SetReserved();
6403  pRequest->SetCurrentQueue(this);
6404 
6405  //
6406  // This is used to return the request to the correct queue if it was
6407  // forwarded
6408  //
6409  pRequest->SetForwardProgressQueue(this);
6410  pRequest->SetCompleted(FALSE);
6411 
6413 
6414  pRequest->SetPresented();
6415 
6417  GetHandle(),
6418  pRequest->GetHandle());
6419  if (!NT_SUCCESS(status)) {
6421  "Failure from m_IoReservedResourcesAllocate callback %!STATUS!",
6422  status);
6423  pRequest->FreeRequest();
6424  }
6425  }
6426 
6427  if (NT_SUCCESS(status)) {
6428  *Request = pRequest;
6429  }
6430 
6431  return status;
6432 }
CfxDevice * m_Device
Definition: fxobject.hpp:329
LONG NTSTATUS
Definition: precomp.h:26
static _Must_inspect_result_ NTSTATUS _CreateForPackage(__in CfxDevice *Device, __in PWDF_OBJECT_ATTRIBUTES RequestAttributes, __in MdIrp Irp, __deref_out FxRequest **Request)
Definition: fxrequest.cpp:75
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
PFN_WDF_IO_ALLOCATE_RESOURCES_FOR_RESERVED_REQUEST Method
PFXIO_FORWARD_PROGRESS_CONTEXT m_FwdProgContext
Definition: fxioqueue.hpp:241
DoTraceLevelMessage(FxDriverGlobals, TRACE_LEVEL_WARNING, TRACINGIO, "WDFREQUEST 0x%p " "was cancelled in driver for WDFQUEUE 0x%p", Request->GetHandle(), GetObjectHandle())
#define FALSE
Definition: types.h:117
FxIoQueueForwardProgressAllocateResourcesReserved m_IoReservedResourcesAllocate
Definition: fxioqueue.hpp:156
VOID _In_ FxRequest * pRequest
Definition: fxioqueue.cpp:947
_Must_inspect_result_ NTSTATUS Invoke(__in WDFQUEUE Queue, __in WDFREQUEST Request)
PFX_DRIVER_GLOBALS pFxDriverGlobals
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
WDFQUEUE __inline GetHandle(VOID)
Definition: fxioqueue.hpp:786
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
WDF_OBJECT_ATTRIBUTES RequestAttributes
__inline FxCxDeviceInfo * GetCxDeviceInfo(VOID)
Definition: fxioqueue.hpp:1360
NTSTATUS status
Definition: fxioqueue.cpp:887
#define NULL
Definition: types.h:112
__inline PWDF_OBJECT_ATTRIBUTES GetRequestAttributes(VOID)
Definition: fxdevice.hpp:1315
#define TRACINGIO
Definition: dbgtrace.h:66
Definition: ps.c:97

◆ AssignForwardProgressPolicy()

_Must_inspect_result_ NTSTATUS FxIoQueue::AssignForwardProgressPolicy ( __in PWDF_IO_QUEUE_FORWARD_PROGRESS_POLICY  Policy)

Definition at line 214 of file fxioqueueum.hpp.

223 {
225 
227  return STATUS_NOT_IMPLEMENTED;
228 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
VOID UfxVerifierTrapNotImpl()
return STATUS_NOT_IMPLEMENTED
_In_ WDFINTERRUPT _In_ WDF_INTERRUPT_POLICY Policy
Definition: wdfinterrupt.h:651

◆ CancelForDriver()

VOID FxIoQueue::CancelForDriver ( __in FxRequest pRequest)

Definition at line 4535 of file fxioqueue.cpp.

4555 {
4556  PFX_DRIVER_GLOBALS FxDriverGlobals = GetDriverGlobals();
4557  KIRQL irql;
4558 
4559  // This is not an error, but want to make sure cancel testing works
4560  VerifyCancelForDriver(FxDriverGlobals, pRequest);
4561 
4562  //
4563  // We are called with no locks held, but
4564  // can be in arbitrary thread context from
4565  // a cancel occuring from another driver within
4566  // a driver stack.
4567  //
4568 
4569  //
4570  // The Csq has removed this request from the driver pending
4571  // queue, and it no longer has a cancel function if the
4572  // driver does not accept the cancel right now.
4573  //
4574  // When callside eventually goes to remove it from the queue
4575  // by CsqContext, the Csq's will return NULL.
4576  //
4577  // Irp and FxRequest is still valid until the driver calls
4578  // WdfRequestComplete either as a result of this cancel
4579  // callback, or at its leasure if it chooses to ignore it.
4580  //
4581  // The insert of FxRequest onto the FxIrpQueue took out a
4582  // reference, and when an IRP gets cancelled, we are responsible
4583  // for this final dereference after calling into the driver.
4584  //
4585 
4586  //
4587  // Cancellations are dispatched as events to the device driver
4588  // using the standard DispatchEvents processing loop. In order
4589  // to support this, we must defer it by linking this request
4590  // into a list of cancelled requests.
4591  //
4592  // The requests will be removed from this list and cancel notified
4593  // to the device driver by the processing loop.
4594  //
4595 
4596  pRequest->MarkRemovedFromIrpQueue();
4597 
4598  //
4599  // Queue it on the cancelled list
4600  //
4601  Lock(&irql);
4602 
4604 
4605  //
4606  // Visit the event dispatcher
4607  //
4608  DispatchInternalEvents(irql);
4609 
4610  return;
4611 }
LIST_ENTRY m_Cancelled
Definition: fxioqueue.hpp:379
Lock & irql
Definition: fxioqueue.cpp:924
#define InsertTailList(ListHead, Entry)
UCHAR KIRQL
Definition: env_spec_w32.h:591
VOID _In_ FxRequest * pRequest
Definition: fxioqueue.cpp:947
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
Definition: wdfsync.h:124

Referenced by QueueIdle(), QueuePurge(), and RequestCancelable().

◆ CancelIrps()

VOID FxIoQueue::CancelIrps ( __in PLIST_ENTRY  IrpListHead)
private

Definition at line 6436 of file fxioqueue.cpp.

6447 {
6448  MdIrp irp;
6449  FxIrp fxIrp;
6451 
6452  while(!IsListEmpty(IrpListHead)) {
6453 
6454  entry = RemoveHeadList(IrpListHead);
6455 
6457 
6458  fxIrp.SetIrp(irp);
6459 
6460  fxIrp.SetInformation(0);
6463  }
6464 }
static MdIrp GetIrpFromListEntry(__in PLIST_ENTRY Ple)
Definition: fxirpum.cpp:1190
VOID SetStatus(__in NTSTATUS Status)
Definition: fxirpum.cpp:457
Definition: fxirp.hpp:28
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
FORCEINLINE PLIST_ENTRY RemoveHeadList(_Inout_ PLIST_ENTRY ListHead)
Definition: rtlfuncs.h:128
IWudfIrp * MdIrp
Definition: mxum.h:103
VOID CompleteRequest(__in_opt CCHAR PriorityBoost=IO_NO_INCREMENT)
Definition: fxirpum.cpp:24
#define STATUS_CANCELLED
Definition: udferr_usr.h:170
VOID SetInformation(__in ULONG_PTR Information)
Definition: fxirpum.cpp:504
uint32_t entry
Definition: isohybrid.c:63
Definition: typedefs.h:119
FxIrp fxIrp(Irp)
#define IO_NO_INCREMENT
Definition: iotypes.h:598
MdIrp SetIrp(MdIrp irp)
Definition: fxirpkm.hpp:71
FxIrp * irp

Referenced by PurgeForwardProgressIrps(), and QueueIdle().

◆ CanThreadDispatchEventsLocked()

_Must_inspect_result_ BOOLEAN FxIoQueue::CanThreadDispatchEventsLocked ( __in KIRQL  PreviousIrql)

Definition at line 2633 of file fxioqueue.cpp.

2653 {
2654  //
2655  // If the current irql is not at passive-level and the queue is configured
2656  // to receive events only at passive-level then we should queue a
2657  // workitem to defer the processing.
2658  //
2662  "Current thread 0x%p is not at the passive-level"
2663  " %!irql!, posting to worker thread for WDFQUEUE"
2664  " 0x%p",
2666  PreviousIrql,
2667  GetObjectHandle());
2668  //
2669  // We only need to post this once
2670  //
2671  if (m_WorkItemQueued == FALSE) {
2672 
2674 
2676  ASSERT(FALSE);
2678  }
2679  }
2680 
2681  return FALSE;
2682  }
2683 
2684  //
2685  // If the current thread is holding the presentation lock, we
2686  // must defer to a DPC or work item.
2687  // This is the result of the device driver calling
2688  // WdfRequestForwardToIoQueue, or WdfIoQueueStart/Stop from
2689  // within I/O dispatch handler. This can also occur if a driver
2690  // attempts to forward a request among a circular series of Queues
2691  // that are configured to have locking constraints.
2692  //
2694 
2696  "Presentation lock for WDFQUEUE 0x%p is "
2697  "already held, deferring to dpc or workitem",
2698  GetObjectHandle());
2699 
2700  if (m_PassiveLevel) {
2701 
2702  if(m_WorkItemQueued == FALSE) {
2703 
2705 
2707  ASSERT(FALSE);
2709  }
2710  }
2711  }
2712  else {
2713  //
2714  // We only need to post this once
2715  //
2716  if (m_DpcQueued == FALSE) {
2717 
2718  m_DpcQueued = TRUE;
2719 
2720  InsertQueueDpc();
2721  }
2722  }
2723 
2724  return FALSE;
2725  }
2726 
2727  return TRUE;
2728 }
static EVT_SYSTEMWORKITEM _DeferredDispatchThreadThunk
Definition: fxioqueue.hpp:1687
#define TRUE
Definition: types.h:120
FxCallbackLock * m_CallbackLockPtr
Definition: fxioqueue.hpp:528
__in __drv_restoresIRQL KIRQL PreviousIrql
Definition: fxioqueue.hpp:631
virtual _Must_inspect_result_ BOOLEAN IsOwner(VOID)=0
__inline BOOLEAN Enqueue(__in PFN_WDF_SYSTEMWORKITEM CallbackFunc, __in PVOID Parameter)
DoTraceLevelMessage(FxDriverGlobals, TRACE_LEVEL_WARNING, TRACINGIO, "WDFREQUEST 0x%p " "was cancelled in driver for WDFQUEUE 0x%p", Request->GetHandle(), GetObjectHandle())
#define FALSE
Definition: types.h:117
PVOID __inline GetObjectHandle(VOID)
Definition: fxobject.hpp:603
VOID InsertQueueDpc(VOID)
BOOLEAN m_WorkItemQueued
Definition: fxioqueue.hpp:563
FxSystemWorkItem * m_SystemWorkItem
Definition: fxioqueue.hpp:557
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
#define TRACE_LEVEL_WARNING
Definition: storswtr.h:28
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
static __inline MxThread MxGetCurrentThread()
Definition: mxgeneralkm.h:61
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
BOOLEAN m_PassiveLevel
Definition: fxioqueue.hpp:280
BOOLEAN m_DpcQueued
Definition: fxioqueue.hpp:562
#define TRACINGIO
Definition: dbgtrace.h:66
ASSERT((Request->GetVerifierFlagsLocked() &FXREQUEST_FLAG_DRIVER_OWNED) !=0)

◆ CheckTransitionFromEmpty()

__inline VOID FxIoQueue::CheckTransitionFromEmpty ( VOID  )
inlineprivate

Definition at line 1541 of file fxioqueue.hpp.

1544  {
1545  if (m_Queue.GetRequestCount() == 1L ||
1547 
1549  }
1550  }
LONG GetRequestCount()
Definition: fxirpqueue.hpp:193
__inline VOID SetTransitionFromEmpty(VOID)
Definition: fxioqueue.hpp:1559
volatile BOOLEAN m_ForceTransitionFromEmptyWhenAddingNewRequest
Definition: fxioqueue.hpp:452
static const WCHAR L[]
Definition: oid.c:1250
FxIrpQueue m_Queue
Definition: fxioqueue.hpp:366

Referenced by InsertNewRequestLocked(), QueueRequestFromForward(), and Requeue().

◆ ConfigureConstraints()

_Must_inspect_result_ NTSTATUS FxIoQueue::ConfigureConstraints ( __in_opt PWDF_OBJECT_ATTRIBUTES  ObjectAttributes,
__in_opt FxDriver Caller 
)

Definition at line 571 of file fxioqueue.cpp.

592 {
593  WDF_EXECUTION_LEVEL ParentLevel;
594  WDF_SYNCHRONIZATION_SCOPE ParentScope;
595  BOOLEAN AutomaticLockingRequired;
596 
597  AutomaticLockingRequired = FALSE;
598  ASSERT(m_Device != NULL);
599 
600  //
601  // Initialize both spin and mutex locks
602  //
605 
606  //
607  // If WDF_OBJECT_ATTRIBUTES is specified, these override any
608  // default settings.
609  //
610  if (ObjectAttributes != NULL) {
611  m_ExecutionLevel = ObjectAttributes->ExecutionLevel;
612  m_SynchronizationScope = ObjectAttributes->SynchronizationScope;
613  }
614 
615  //
616  // If no WDFQUEUE specific attributes are specified, we
617  // get them from WDFDEVICE, which allows WDFDEVICE to
618  // provide a default for all WDFQUEUE's created.
619  //
620  m_Device->GetConstraints(&ParentLevel, &ParentScope);
623 
625  m_ExecutionLevel = ParentLevel;
626  }
627 
629  m_SynchronizationScope = ParentScope;
630  }
631 
632  //
633  // For backward compatibility purposes always have a lock associated with the
634  // object even for WdfSynchronizationScopeNone. This is so that we return a non-null
635  // presentation lock for the WDFQUEUE object.
636  //
638  //
639  // Mark FxObject as passive level to ensure that Dispose and Destroy
640  // callbacks are passive to the driver
641  //
644 
645  //
646  // Passive Callbacks constraint has been set, we use a mutex for the
647  // callback lock.
648  //
651  }
652  else {
653  //
654  // If no passive level constraint is specified, then spinlocks
655  // are used for callbacks since they are lightweight and work with
656  // DPC's and Timer's
657  //
660  }
661 
662  //
663  // Configure synchronization scope
664  //
667 
668  //
669  // WDF extensions are not allowed to use this type of synchronization.
670  //
671  if (Caller != NULL && Caller != GetDriverGlobals()->Driver) {
674  "WDFQUEUE 0x%p Synchronization scope is set to "
675  "device; WDF extension drivers are not allowed "
676  "to use this type of synchronization, %!STATUS!",
678  return status;
679  }
680 
681  //
682  // If we inherit the Sync. scope from parent or device
683  // and if the parent/device has Exec. Level different from Queue
684  // then disallow that case.
685  // FUTURE PROOF NOTE: Adding a new Execution Level will need reevaluation
686  // of the check below.
687  //
688  if (ParentLevel != m_ExecutionLevel) {
691  "WDFQUEUE 0x%p Synchronization scope is set to device"
692  " but the Device ExecutionLevel: 0x%x"
693  " doesn't match Queue ExecutionLevel: 0x%x, %!STATUS!",
694  GetObjectHandle(), ParentLevel,
696  return status;
697  }
698  //
699  // Per device automatic callback synchronization, so we update our
700  // callback lock ptr to point to the devices lock
701  //
702  AutomaticLockingRequired = TRUE;
703 
704  //
705  // Get the callback lock and object from the device
706  //
708  }
710  //
711  // Per object automatic serialization
712  //
713  AutomaticLockingRequired = TRUE;
714 
715  // m_CallbackLockPtr has been set above in execution level constraint
716  }
717 
718 
719  if (AutomaticLockingRequired) {
720  //
721  // If automatic locking has been configured, set the lock
722  // on the FxCallback object delegates
723  //
734 
736  }
737  else {
738  //
739  // No automatic locking specified
740  //
751 
753 
754  }
755 
756  return STATUS_SUCCESS;
757 }
CfxDevice * m_Device
Definition: fxobject.hpp:329
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
FxCallbackLock * m_CallbackLockPtr
Definition: fxioqueue.hpp:528
LONG NTSTATUS
Definition: precomp.h:26
FxObject * m_CallbackLockObjectPtr
Definition: fxioqueue.hpp:529
FxIoQueueIoCanceledOnQueue m_IoCanceledOnQueue
Definition: fxioqueue.hpp:494
DoTraceLevelMessage(FxDriverGlobals, TRACE_LEVEL_WARNING, TRACINGIO, "WDFREQUEST 0x%p " "was cancelled in driver for WDFQUEUE 0x%p", Request->GetHandle(), GetObjectHandle())
FxIoQueueIoDefault m_IoDefault
Definition: fxioqueue.hpp:487
WDF_EXECUTION_LEVEL m_ExecutionLevel
Definition: fxioqueue.hpp:514
#define FALSE
Definition: types.h:117
FxIoQueueIoResume m_IoResume
Definition: fxioqueue.hpp:489
PVOID __inline GetObjectHandle(VOID)
Definition: fxobject.hpp:603
WDF_SYNCHRONIZATION_SCOPE m_SynchronizationScope
Definition: fxioqueue.hpp:515
unsigned char BOOLEAN
virtual void Initialize(FxObject *ParentObject)
VOID MarkPassiveCallbacks(__in FxObjectLockState State=ObjectLock)
Definition: fxobject.hpp:972
enum _WDF_SYNCHRONIZATION_SCOPE WDF_SYNCHRONIZATION_SCOPE
FxCallbackSpinLock m_CallbackSpinLock
Definition: fxioqueue.hpp:520
FxCallbackMutexLock m_CallbackMutexLock
Definition: fxioqueue.hpp:521
FxIoQueueIoInternalDeviceControl m_IoInternalDeviceControl
Definition: fxioqueue.hpp:493
FxIoQueueIoRead m_IoRead
Definition: fxioqueue.hpp:490
void SetCallbackLockPtr(FxCallbackLock *Lock)
Definition: fxcallback.hpp:105
FxCallbackLock * m_IoCancelCallbackLockPtr
Definition: fxioqueue.hpp:496
virtual void Initialize(FxObject *ParentObject)
return STATUS_SUCCESS
Definition: fxioqueue.cpp:939
FxIoQueueIoState m_ReadyNotify
Definition: fxioqueue.hpp:507
FxIoQueueIoWrite m_IoWrite
Definition: fxioqueue.hpp:491
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
FxCallbackLock * GetCallbackLockPtr(__out_opt FxObject **LockObject)
BOOLEAN m_PassiveLevel
Definition: fxioqueue.hpp:280
NTSTATUS status
Definition: fxioqueue.cpp:887
#define NULL
Definition: types.h:112
VOID GetConstraints(__out_opt WDF_EXECUTION_LEVEL *ExecutionLevel, __out_opt WDF_SYNCHRONIZATION_SCOPE *SynchronizationScope)
WDF_EXTERN_C_START enum _WDF_EXECUTION_LEVEL WDF_EXECUTION_LEVEL
FxIoQueueIoDeviceControl m_IoDeviceControl
Definition: fxioqueue.hpp:492
#define TRACINGIO
Definition: dbgtrace.h:66
FxIoQueueIoStop m_IoStop
Definition: fxioqueue.hpp:488
_Must_inspect_result_ _In_ WDFDRIVER Driver
Definition: wdfcontrol.h:83
ASSERT((Request->GetVerifierFlagsLocked() &FXREQUEST_FLAG_DRIVER_OWNED) !=0)
FxIoQueueIoState m_PurgeComplete
Definition: fxioqueue.hpp:504
Definition: ps.c:97

Referenced by Initialize().

◆ DeferredDispatchRequestsFromDpc()

VOID FxIoQueue::DeferredDispatchRequestsFromDpc ( VOID  )

Definition at line 2475 of file fxioqueue.cpp.

2491 {
2492  KIRQL irql;
2493 
2494  Lock(&irql);
2495 
2496  ASSERT(m_DpcQueued != FALSE);
2497 
2499 
2500  DispatchEvents(irql);
2501 
2502  //
2503  // DispatchEvents drops the lock before returning. So reacquire the lock.
2504  //
2505  Lock(&irql);
2506 
2508  InsertQueueDpc();
2509  } else {
2511  m_DpcQueued = FALSE;
2512  }
2513 
2514  Unlock(irql);
2515 
2516  return;
2517 }
__drv_restoresIRQL KIRQL __in BOOLEAN Unlock
Definition: fxobject.hpp:1474
BOOLEAN m_RequeueDeferredDispatcher
Definition: fxioqueue.hpp:568
Lock & irql
Definition: fxioqueue.cpp:924
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define FALSE
Definition: types.h:117
VOID InsertQueueDpc(VOID)
BOOLEAN m_DpcQueued
Definition: fxioqueue.hpp:562
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
Definition: wdfsync.h:124
volatile BOOLEAN m_Deleted
Definition: fxioqueue.hpp:288
ASSERT((Request->GetVerifierFlagsLocked() &FXREQUEST_FLAG_DRIVER_OWNED) !=0)

◆ DeferredDispatchRequestsFromWorkerThread()

VOID FxIoQueue::DeferredDispatchRequestsFromWorkerThread ( VOID  )

Definition at line 2520 of file fxioqueue.cpp.

2536 {
2537  KIRQL irql;
2538 
2539  Lock(&irql);
2540 
2542 
2544 
2545  DispatchEvents(irql);
2546 
2547  //
2548  // DispatchEvents drops the lock before returning. So reacquire
2549  // the lock.
2550  //
2551  Lock(&irql);
2552 
2553  if (m_Deleted == FALSE &&
2556  //
2557  // Workitem is queued.
2558  //
2559  DO_NOTHING();
2560  } else {
2563  }
2564 
2565  Unlock(irql);
2566 
2567  return;
2568 }
__drv_restoresIRQL KIRQL __in BOOLEAN Unlock
Definition: fxobject.hpp:1474
static EVT_SYSTEMWORKITEM _DeferredDispatchThreadThunk
Definition: fxioqueue.hpp:1687
BOOLEAN m_RequeueDeferredDispatcher
Definition: fxioqueue.hpp:568
Lock & irql
Definition: fxioqueue.cpp:924
__inline BOOLEAN Enqueue(__in PFN_WDF_SYSTEMWORKITEM CallbackFunc, __in PVOID Parameter)
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define FALSE
Definition: types.h:117
BOOLEAN m_WorkItemQueued
Definition: fxioqueue.hpp:563
FxSystemWorkItem * m_SystemWorkItem
Definition: fxioqueue.hpp:557
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
Definition: wdfsync.h:124
volatile BOOLEAN m_Deleted
Definition: fxioqueue.hpp:288
ASSERT((Request->GetVerifierFlagsLocked() &FXREQUEST_FLAG_DRIVER_OWNED) !=0)
#define DO_NOTHING()
Definition: mxgeneral.h:32

◆ DispatchRequestToDriver()

VOID FxIoQueue::DispatchRequestToDriver ( __in FxRequest pRequest)

Definition at line 3110 of file fxioqueue.cpp.

3133 {
3134  PFX_DRIVER_GLOBALS FxDriverGlobals;
3135  NTSTATUS Status;
3136  FxRequestCompletionState oldState;
3137  WDFREQUEST hRequest;
3138  FxIrp* pIrp;
3139 
3140  FxDriverGlobals = GetDriverGlobals();
3141 
3142 
3143 
3144 
3145 
3146  (VOID)pRequest->GetCurrentIrpStackLocation();
3147 
3148  pIrp = pRequest->GetFxIrp();
3149 
3150  // The Irp does not have a cancel function right now
3151 #if (FX_CORE_MODE == FX_CORE_KERNEL_MODE)
3153 #endif
3154 
3155  //
3156  // Set our completion callback on the request now before
3157  // calling the driver since the driver can complete the
3158  // request in the callback handler, and to avoid races with
3159  // the drivers completion thread.
3160  //
3161  // This takes a reference on the request object.
3162  //
3163  oldState = pRequest->SetCompletionState(FxRequestCompletionStateQueue);
3164  ASSERT(oldState == FxRequestCompletionStateNone);
3165  UNREFERENCED_PARAMETER(oldState);
3166 
3167  if (FxDriverGlobals->FxVerifierOn) {
3168  //
3169  // If the verifier is on, we do not release the extra
3170  // reference so we can mark the request as no longer
3171  // being dispatched to the driver on return from the
3172  // event callback to the driver
3173  //
3174 
3175  ASSERT((pRequest->GetVerifierFlags() & FXREQUEST_FLAG_DRIVER_OWNED) == 0);
3176 
3177  // Mark the request as being "owned" by the driver
3178  pRequest->SetVerifierFlags(FXREQUEST_FLAG_DRIVER_OWNED |
3180  }
3181  else {
3182 
3183  //
3184  // Release our original reference. The FxRequest::Complete
3185  // will release the final one since we have registered a completion
3186  // callback handler
3187  //
3188  // We now have one reference count on the FxRequest object until
3189  // its completion routine runs since the completion event made
3190  // an extra reference, and will dereference it when it fires, or
3191  // its canceled.
3192  //
3193 
3194  pRequest->RELEASE(FXREQUEST_STATE_TAG);
3195  }
3196 
3197  //
3198  // Attempt to dispatch it to the driver
3199  //
3200 
3201  //
3202  // Note: A driver that changes its callback pointers at runtime
3203  // could run into a race here since we released the queue
3204  // lock. Currently, changing parameters on a processing
3205  // queue is undefined.
3206  //
3207  // The C DDI's force the callbacks to be registered at
3208  // queue creation time and avoid this race.
3209  //
3210 
3211  hRequest = pRequest->GetHandle();
3212 
3214 
3215  if ((majorFunction == IRP_MJ_READ) && m_IoRead.Method) {
3216  ULONG readLength = pIrp->GetParameterReadLength();
3217 
3218  //
3219  // Complete zero length reads with STATUS_SUCCESS unless the
3220  // driver specified it wants them delivered.
3221  //
3222  if ((readLength == 0) &&
3224 
3226  FxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGIO,
3227  "Zero length WDFREQUEST 0x%p completed automatically "
3228  "by WDFQUEUE 0x%p", hRequest, GetObjectHandle());
3229 
3230  pRequest->Complete(STATUS_SUCCESS);
3231  if (FxDriverGlobals->FxVerifierOn) {
3232  //
3233  // Release the reference taken in the call to SetCompletionState
3234  // at the top of the function.
3235  //
3236  pRequest->RELEASE(FXREQUEST_STATE_TAG);
3237  }
3238  return;
3239  }
3240 
3241  pRequest->SetPresented();
3242 
3244  "Calling driver EvtIoRead for WDFREQUEST 0x%p",
3245  hRequest);
3246 
3247  m_IoRead.Invoke(
3248  GetHandle(),
3249  hRequest,
3250  readLength
3251  );
3252  }
3253  else if ((majorFunction == IRP_MJ_WRITE) && m_IoWrite.Method) {
3254  ULONG writeLength = pIrp->GetParameterWriteLength();
3255 
3256  //
3257  // Complete zero length writes with STATUS_SUCCESS unless the
3258  // driver specified it wants them delivered.
3259  //
3260  if ((writeLength == 0) &&
3262 
3264  FxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGIO,
3265  "Zero length WDFREQUEST 0x%p completed automatically "
3266  "by WDFQUEUE 0x%p", hRequest, GetObjectHandle());
3267 
3268  pRequest->Complete(STATUS_SUCCESS);
3269 
3270  if (FxDriverGlobals->FxVerifierOn) {
3271  //
3272  // Release the reference taken in the call to SetCompletionState
3273  // at the top of the function.
3274  //
3275  pRequest->RELEASE(FXREQUEST_STATE_TAG);
3276  }
3277  return;
3278  }
3279 
3280  pRequest->SetPresented();
3281 
3283  "Calling driver EvtIoWrite for WDFREQUEST 0x%p",
3284  pRequest->GetObjectHandle());
3285 
3286  m_IoWrite.Invoke(
3287  GetHandle(),
3288  hRequest,
3289  writeLength
3290  );
3291  }
3293 
3294  pRequest->SetPresented();
3295 
3297  "Calling driver EvtIoDeviceControl for "
3298  "WDFREQUEST 0x%p", hRequest);
3299 
3301  GetHandle(),
3302  hRequest,
3306  );
3307  }
3308 
3310 
3311  pRequest->SetPresented();
3312 
3314  FxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGIO,
3315  "Calling driver EvtIoInternalDeviceControl for WDFREQUEST 0x%p",
3316  hRequest);
3317 
3319  GetHandle(),
3320  hRequest,
3324  );
3325  }
3326  else {
3327 
3328  //
3329  // If we have an IoStart registered, call it
3330  //
3331  if (m_IoDefault.Method) {
3332 
3334  FxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGIO,
3335  "Calling driver EvtIoDefault for WDFREQUEST 0x%p", hRequest);
3336 
3337 
3338  //
3339  // If we don't allow zero length requests, we must dig in whether
3340  // its a read or a write
3341  //
3343 
3344  if (majorFunction == IRP_MJ_READ) {
3345 
3346  if (pIrp->GetParameterReadLength() == 0) {
3347 
3349  FxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGIO,
3350  "Zero length WDFREQUEST 0x%p completed automatically "
3351  "by WDFQUEUE 0x%p", hRequest, GetObjectHandle());
3352 
3353  pRequest->Complete(STATUS_SUCCESS);
3354  if (FxDriverGlobals->FxVerifierOn) {
3355  //
3356  // Release the reference taken in the call to SetCompletionState
3357  // at the top of the function.
3358  //
3359  pRequest->RELEASE(FXREQUEST_STATE_TAG);
3360  }
3361  return;
3362  }
3363  }
3364  else if (majorFunction == IRP_MJ_WRITE) {
3365 
3366  if (pIrp->GetParameterWriteLength() == 0) {
3367 
3368  pRequest->Complete(STATUS_SUCCESS);
3369 
3371  FxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGIO,
3372  "Zero length WDFREQUEST 0x%p completed automatically "
3373  "by WDFQUEUE 0x%p", hRequest, GetObjectHandle());
3374 
3375  if (FxDriverGlobals->FxVerifierOn) {
3376  //
3377  // Release the reference taken in the call to SetCompletionState
3378  // at the top of the function.
3379  //
3380  pRequest->RELEASE(FXREQUEST_STATE_TAG);
3381  }
3382  return;
3383  }
3384  }
3385  }
3386 
3387  pRequest->SetPresented();
3388 
3389  m_IoDefault.Invoke(GetHandle(), hRequest);
3390  }
3391  else {
3393 
3395  "Driver has no event callback "
3396  "for %!WDF_REQUEST_TYPE!, completing WDFREQUEST 0x%p with "
3397  "%!STATUS!",
3398  majorFunction,
3399  pRequest,
3400  Status);
3401 
3402  pRequest->Complete(Status);
3403 
3404  if (FxDriverGlobals->FxVerifierOn) {
3405  //
3406  // Release our extra verifier reference now
3407  //
3408  // Release the reference taken in the call to SetCompletionState
3409  // at the top of the function.
3410  //
3411  pRequest->RELEASE(FXREQUEST_STATE_TAG);
3412  }
3413 
3414  return;
3415  }
3416  }
3417 
3418  // ******************************
3419  // Request may now be a freed object unless verifier is on. Only touch
3420  // request if verifier is on.
3421  // ******************************
3422 
3423  if (FxDriverGlobals->FxVerifierOn) {
3424 
3425  //
3426  // If the request has been forwarded, don't clear this
3427  // since the new queue may already be dispatching in a new thread or DPC
3428  //
3429  if ((pRequest->GetVerifierFlags() & FXREQUEST_FLAG_FORWARDED) == 0x0) {
3430  pRequest->ClearVerifierFlags(FXREQUEST_FLAG_DRIVER_DISPATCH);
3431  }
3432 
3433  //
3434  // Release our extra verifier reference now
3435  //
3436  // Release the reference taken in the call to SetCompletionState
3437 
3438  // at the top of the function.
3439  //
3440  pRequest->RELEASE(FXREQUEST_STATE_TAG);
3441  }
3442 
3443  // Driver accepted a request
3444  return;
3445 }
ULONG GetParameterReadLength(VOID)
Definition: fxirpum.cpp:1589
BOOLEAN FxVerifierOn
Definition: fxglobals.h:420
PFN_WDF_IO_QUEUE_IO_WRITE Method
PFN_WDF_IO_QUEUE_IO_INTERNAL_DEVICE_CONTROL Method
GLint x0
Definition: linetemp.h:95
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
LONG NTSTATUS
Definition: precomp.h:26
PIO_STACK_LOCATION GetCurrentIrpStackLocation(VOID)
Definition: fxirpum.cpp:370
Definition: fxirp.hpp:28
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
FxIrp * pIrp
DoTraceLevelMessage(FxDriverGlobals, TRACE_LEVEL_WARNING, TRACINGIO, "WDFREQUEST 0x%p " "was cancelled in driver for WDFQUEUE 0x%p", Request->GetHandle(), GetObjectHandle())
FxIoQueueIoDefault m_IoDefault
Definition: fxioqueue.hpp:487
#define TRACE_LEVEL_VERBOSE
Definition: storswtr.h:30
ULONG GetParameterIoctlInputBufferLength(VOID)
Definition: fxirpum.cpp:1518
PFN_WDF_IO_QUEUE_IO_DEVICE_CONTROL Method
PFN_WDF_IO_QUEUE_IO_READ Method
PVOID __inline GetObjectHandle(VOID)
Definition: fxobject.hpp:603
PFN_WDF_IO_QUEUE_IO_DEFAULT Method
#define FXREQUEST_STATE_TAG
Definition: fxrequest.hpp:42
VOID _In_ FxRequest * pRequest
Definition: fxioqueue.cpp:947
Status
Definition: gdiplustypes.h:24
WDFQUEUE __inline GetHandle(VOID)
Definition: fxioqueue.hpp:786
FxIoQueueIoInternalDeviceControl m_IoInternalDeviceControl
Definition: fxioqueue.hpp:493
FxRequestCompletionState
#define IRP_MJ_INTERNAL_DEVICE_CONTROL
FxIoQueueIoRead m_IoRead
Definition: fxioqueue.hpp:490
void Invoke(__in WDFQUEUE Queue, __in WDFREQUEST Request)
unsigned char UCHAR
Definition: xmlstorage.h:181
#define VOID
Definition: acefi.h:82
return STATUS_SUCCESS
Definition: fxioqueue.cpp:939
ULONG GetParameterWriteLength(VOID)
Definition: fxirpum.cpp:1601
FxIoQueueIoWrite m_IoWrite
Definition: fxioqueue.hpp:491
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
ULONG GetParameterIoctlOutputBufferLength(VOID)
Definition: fxirpum.cpp:1504
BOOLEAN m_AllowZeroLengthRequests
Definition: fxioqueue.hpp:273
#define NULL
Definition: types.h:112
UCHAR majorFunction
#define IRP_MJ_READ
Definition: rdpdr.c:46
void Invoke(__in WDFQUEUE Queue, __in WDFREQUEST Request, __in ULONG Length)
unsigned int ULONG
Definition: retypes.h:1
void Invoke(__in WDFQUEUE Queue, __in WDFREQUEST Request, __in ULONG OutputBufferLength, __in ULONG InputBufferLength, __in ULONG IoControlCode)
FxIoQueueIoDeviceControl m_IoDeviceControl
Definition: fxioqueue.hpp:492
#define IRP_MJ_WRITE
Definition: rdpdr.c:47
#define TRACINGIO
Definition: dbgtrace.h:66
ULONG GetParameterIoctlCode(VOID)
Definition: fxirpum.cpp:1474
UCHAR GetMajorFunction(VOID)
Definition: fxirpum.cpp:217
ASSERT((Request->GetVerifierFlagsLocked() &FXREQUEST_FLAG_DRIVER_OWNED) !=0)
void Invoke(__in WDFQUEUE Queue, __in WDFREQUEST Request, __in ULONG OutputBufferLength, __in ULONG InputBufferLength, __in ULONG IoInternalControlCode)
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52
void Invoke(__in WDFQUEUE Queue, __in WDFREQUEST Request, __in ULONG Length)

◆ Dispose()

BOOLEAN FxIoQueue::Dispose ( VOID  )
virtual

Reimplemented from FxObject.

Definition at line 448 of file fxioqueue.cpp.

464 {
465  KIRQL irql;
466 
467  if (IsCommitted() == FALSE) {
468  //
469  // We called DeleteFromFailedCreate because we couldn't commit the
470  // object.
471  //
472  goto End;
473  }
474 
475  //
476  // If object is commited means we are added to the FxPkgIo queue list.
477  //
478  //
479  // Purge the queue asynchrnously without providing any callback. That way,
480  // we allow the driver to have an outstanding purge request while the delete
481  // is in progress.
482  //
484 
485  Lock(&irql);
486 
487  //
488  // Mark that this queue is disposing
489  //
490 
492 
493  m_Disposing = TRUE;
494 
495  //
496  // Just make sure the state hasn't changed after the purge.
497  //
499 
500  //
501  // Call the FxPkgIo to remove its references to this queue
502  //
503  // Note: We are holding the queue lock to prevent races, and
504  // FxPkgIo never calls FxIoQueue methods while holding
505  // its lock.
506  //
508 
509  DispatchEvents(irql);
510 
511  //
512  // Wait for the finished event to be signalled. This event will
513  // be signalled when the queue is in a disposed state and there
514  // are no more pending events.
515  //
517  "waiting for the queue to be deleted, WDFQUEUE", GetHandle(),
520 
521 
522  ASSERT(m_Deleted == TRUE);
523 
525  ASSERT(m_DriverIoCount == 0);
526 
527  if (IsForwardProgressQueue()) {
531  }
532 
533  if (m_FwdProgContext != NULL) {
537  }
538 
539  //
540  // Rundown the workitem.
541  //
542  if (m_SystemWorkItem != NULL) {
545  }
546 
547  //
548  // Rundown the DPCs
549  //
550  if (m_DpcQueued) {
551  FlushQueuedDpcs();
552  }
553 
554  //
555  // All callbacks into the device driver acquire and release a
556  // reference on the queue. This ensures that the queue will
557  // not actually complete deleting until return from any
558  // outstanding event callbacks into the device driver.
559  //
560  // See DispatchRequestToDriver()
561  //
562 End:
563 
564  FxNonPagedObject::Dispose(); // __super call
565 
566  return TRUE;
567 }
virtual VOID DeleteObject(VOID)
VOID RemoveQueueReferences(__inout FxIoQueue *pQueue)
Definition: fxpkgio.cpp:1091
#define TRUE
Definition: types.h:120
Lock & irql
Definition: fxioqueue.cpp:924
VOID WaitForSignal(__in MxEvent *Event, __in PCSTR ReasonForWaiting, __in PVOID Handle, __in ULONG WarningTimeoutInSec, __in ULONG WaitSignalFlags)
Definition: globals.cpp:1705
volatile LONG m_DriverIoCount
Definition: fxioqueue.hpp:475
PFXIO_FORWARD_PROGRESS_CONTEXT m_FwdProgContext
Definition: fxioqueue.hpp:241
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
MxEvent * GetSelfPointer(VOID)
Definition: mxevent.h:110
FxPkgIo * m_PkgIo
Definition: fxioqueue.hpp:420
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define FALSE
Definition: types.h:117
LONG GetRequestCount()
Definition: fxirpqueue.hpp:193
volatile BOOLEAN m_Disposing
Definition: fxioqueue.hpp:296
FxSystemWorkItem * m_SystemWorkItem
Definition: fxioqueue.hpp:557
VOID FlushQueuedDpcs(VOID)
BOOLEAN IsCommitted(VOID)
Definition: fxobject.hpp:1087
WDFQUEUE __inline GetHandle(VOID)
Definition: fxioqueue.hpp:786
__inline VOID Uninitialize()
Definition: mxlockkm.h:104
__inline BOOLEAN IsForwardProgressQueue(VOID)
Definition: fxioqueue.hpp:1264
#define VOID
Definition: acefi.h:82
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
VOID FreeAllReservedRequests(__in BOOLEAN Verify)
Definition: fxioqueueum.hpp:81
ULONG FxVerifierDbgWaitForSignalTimeoutInSec
Definition: fxglobals.h:527
#define NULL
Definition: types.h:112
BOOLEAN m_DpcQueued
Definition: fxioqueue.hpp:562
__inline BOOLEAN IsState(__in WDF_IO_QUEUE_STATE State)
Definition: fxioqueue.hpp:843
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
Definition: wdfsync.h:124
_Must_inspect_result_ NTSTATUS QueuePurge(__in BOOLEAN CancelQueueRequests, __in BOOLEAN CancelDriverRequests, __in_opt PFN_WDF_IO_QUEUE_STATE PurgeComplete, __in_opt WDFCONTEXT Context)
Definition: fxioqueue.cpp:3894
MxEvent m_FinishDisposing
Definition: fxioqueue.hpp:297
volatile BOOLEAN m_Deleted
Definition: fxioqueue.hpp:288
FxIrpQueue m_Queue
Definition: fxioqueue.hpp:366
virtual BOOLEAN Dispose(VOID)
void FxPoolFree(__in_xcount(ptr is at an offset from AllocationStart) PVOID ptr)
Definition: wdfpool.cpp:361
ASSERT((Request->GetVerifierFlagsLocked() &FXREQUEST_FLAG_DRIVER_OWNED) !=0)

◆ FatalError()

DECLSPEC_NORETURN VOID FxIoQueue::FatalError ( __in NTSTATUS  Status)

Definition at line 6339 of file fxioqueue.cpp.

6342 {
6344 
6345  RtlZeroMemory(&data, sizeof(data));
6346 
6347  data.Queue = GetHandle();
6348  data.Request = NULL;
6349  data.Status = Status;
6350 
6353  (ULONG_PTR) &data);
6354 }
#define FxVerifierBugCheck(FxDriverGlobals, Error,...)
Definition: fxverifier.h:58
uint32_t ULONG_PTR
Definition: typedefs.h:65
Status
Definition: gdiplustypes.h:24
WDFQUEUE __inline GetHandle(VOID)
Definition: fxioqueue.hpp:786
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
#define NULL
Definition: types.h:112
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262

◆ FlushByFileObject()

VOID FxIoQueue::FlushByFileObject ( __in MdFileObject  FileObject)

Definition at line 4256 of file fxioqueue.cpp.

4275 {
4276  FxRequest* pRequest = NULL;
4277  NTSTATUS status;
4278  KIRQL irql;
4279 
4280  if (IsForwardProgressQueue()) {
4282  }
4283 
4284  Lock(&irql);
4285 
4286  #pragma warning(disable:4127)
4287  while (TRUE) {
4288  #pragma warning(default:4127)
4289 
4290  //
4291  // Get the next FxRequest from the cancel safe queue
4292  //
4295  break;
4296  }
4297  if(!NT_SUCCESS(status)) {
4298  ASSERTMSG("GetNextRequest failed\n", FALSE);
4299  break;
4300  }
4301 
4302  //
4303  // We must add a reference since the CancelForQueue path
4304  // assumes we were on the FxIrpQueue with the extra reference
4305  //
4306  pRequest->ADDREF(FXREQUEST_QUEUE_TAG);
4307 
4308  //
4309  // Mark the request as cancelled, place it on the cancel list,
4310  // and schedule the cancel event to the driver
4311  //
4312  CancelForQueue(pRequest, irql);
4313 
4314  //
4315  // Reacquire the lock because CancelForQueue visits the dispatch-loop
4316  // and releases the lock.
4317  //
4318  Lock(&irql);
4319  }
4320 
4321  DispatchEvents(irql);
4322 
4323  return;
4324 
4325 }
static _Must_inspect_result_ FxRequest * GetNextRequest(__in FxIrpQueue *IrpQueue)
Definition: fxrequest.cpp:2025
#define FXREQUEST_QUEUE_TAG
Definition: fxrequest.hpp:47
#define STATUS_NO_MORE_ENTRIES
Definition: ntstatus.h:205
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
Lock & irql
Definition: fxioqueue.cpp:924
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define FALSE
Definition: types.h:117
#define ASSERTMSG(msg, exp)
Definition: nt_native.h:431
VOID _In_ FxRequest * pRequest
Definition: fxioqueue.cpp:947
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
__inline BOOLEAN IsForwardProgressQueue(VOID)
Definition: fxioqueue.hpp:1264
VOID PurgeForwardProgressIrps(__in_opt MdFileObject FileObject)
Definition: fxioqueue.cpp:6467
NTSTATUS status
Definition: fxioqueue.cpp:887
#define NULL
Definition: types.h:112
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
Definition: wdfsync.h:124
FxIrpQueue m_Queue
Definition: fxioqueue.hpp:366
Definition: ps.c:97

◆ FlushQueuedDpcs()

VOID FxIoQueue::FlushQueuedDpcs ( VOID  )

Definition at line 150 of file fxioqueueum.hpp.

164 {
166 }
VOID UfxVerifierTrapNotImpl()

Referenced by Dispose().

◆ ForwardRequest()

_Must_inspect_result_ NTSTATUS FxIoQueue::ForwardRequest ( __in FxIoQueue pDestQueue,
__in FxRequest pRequest 
)

Definition at line 1712 of file fxioqueue.cpp.

1746 {
1747  NTSTATUS status;
1748 
1749  PFX_DRIVER_GLOBALS FxDriverGlobals = GetDriverGlobals();
1750 
1751  status = VerifyForwardRequest(FxDriverGlobals, pDestQueue, pRequest);
1752  if (!NT_SUCCESS(status)) {
1753  return status;
1754  }
1755 
1757  return status;
1758 }
LONG NTSTATUS
Definition: precomp.h:26
_Must_inspect_result_ NTSTATUS ForwardRequestWorker(__in FxRequest *Request, __in FxIoQueue *DestQueue)
Definition: fxioqueue.cpp:1354
VOID _In_ FxRequest * pRequest
Definition: fxioqueue.cpp:947
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_Must_inspect_result_ NTSTATUS _In_ FxIoQueue * pDestQueue
Definition: fxioqueue.cpp:1667
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
NTSTATUS status
Definition: fxioqueue.cpp:887
Definition: ps.c:97

Referenced by FxPkgGeneral::OnCreate().

◆ ForwardRequestToParent()

_Must_inspect_result_ NTSTATUS FxIoQueue::ForwardRequestToParent ( __in FxIoQueue DestQueue,
__in FxRequest Request,
__in PWDF_REQUEST_FORWARD_OPTIONS  ForwardOptions 
)

Definition at line 1569 of file fxioqueue.cpp.

1605 {
1606  NTSTATUS status;
1608  BOOLEAN forwardRequestToParent;
1609  FxIrp* pIrp;
1610 
1612 
1614 
1615  forwardRequestToParent = Request->m_ForwardRequestToParent;
1616 
1617  status = VerifyForwardRequestToParent(pFxDriverGlobals,
1618  DestQueue,
1619  Request);
1620  if(!NT_SUCCESS(status)){
1621  return status;
1622  }
1623 
1624  pIrp = Request->GetFxIrp();
1625 
1628 
1629  //
1630  // Save a pointer to the device object for this request so that it can
1631  // be used later in completion.
1632  //
1634 
1635  Request->SetDeviceBase((CfxDeviceBase *)m_Device->m_ParentDevice);
1636  Request->m_ForwardRequestToParent = TRUE;
1637 
1639 
1640  //
1641  // Undo the actions of changing the FxDevice and
1642  // changing the deviceObject and stack location in the IRP
1643  //
1644  if (!NT_SUCCESS(status)) {
1645  Request->SetDeviceBase((CfxDeviceBase *)m_Device);
1646  pIrp = Request->GetFxIrp();
1649 
1650  //
1651  // Set the value of m_ForwardRequestToParent to the previous
1652  // value so that if the Request has been forwarded to Parent
1653  // successfully but fails to be forwarded to the grandparent
1654  // from the parent then we free it back using ExFreePool
1655  // instead of the Lookaside buffer .
1656  //
1657  Request->m_ForwardRequestToParent = forwardRequestToParent;
1658  }
1659 
1660  return status;
1661 }
CfxDevice * m_Device
Definition: fxobject.hpp:329
CfxDevice * m_ParentDevice
Definition: fxdevice.hpp:569
VOID SetCurrentDeviceObject(__in MdDeviceObject DeviceObject)
Definition: fxirpum.cpp:1362
MdDeviceObject __inline GetDeviceObject(VOID)
Definition: fxdevice.hpp:174
MdDeviceObject GetDeviceObject(VOID)
Definition: fxirpum.cpp:1352
_Must_inspect_result_ _In_ WDFREQUEST _In_ WDFQUEUE _In_ PWDF_REQUEST_FORWARD_OPTIONS ForwardOptions
Definition: wdfrequest.h:1731
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
LONG NTSTATUS
Definition: precomp.h:26
Definition: fxirp.hpp:28
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
FxIrp * pIrp
_Must_inspect_result_ NTSTATUS ForwardRequestWorker(__in FxRequest *Request, __in FxIoQueue *DestQueue)
Definition: fxioqueue.cpp:1354
VOID SetNextIrpStackLocation(VOID)
Definition: fxirpum.cpp:1235
VOID SkipCurrentIrpStackLocation(VOID)
Definition: fxirpum.cpp:400
unsigned char BOOLEAN
PFX_DRIVER_GLOBALS pFxDriverGlobals
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
NTSTATUS status
Definition: fxioqueue.cpp:887
_Must_inspect_result_ NTSTATUS _In_ FxIoQueue * DestQueue
Definition: fxioqueue.cpp:1476
VOID CopyCurrentIrpStackLocationToNext(VOID)
Definition: fxirpum.cpp:209
ASSERT((Request->GetVerifierFlagsLocked() &FXREQUEST_FLAG_DRIVER_OWNED) !=0)
Definition: ps.c:97

◆ ForwardRequestWorker()

_Must_inspect_result_ NTSTATUS FxIoQueue::ForwardRequestWorker ( __in FxRequest Request,
__in FxIoQueue DestQueue 
)

Definition at line 1354 of file fxioqueue.cpp.

1358 {
1359  NTSTATUS status;
1360  FxRequestCompletionState oldState;
1361  PLIST_ENTRY ple;
1362  SHORT OldFlags;
1363  KIRQL irql;
1364 
1365  PFX_DRIVER_GLOBALS FxDriverGlobals = GetDriverGlobals();
1366 
1367  OldFlags = 0;
1368 
1369  //
1370  // The request has only one reference, held by the completion
1371  // callback function. We need to take another one before cancelling
1372  // this function, otherwise we will lose the request object
1373  //
1374  Request->ADDREF(FXREQUEST_STATE_TAG);
1375 
1376  //
1377  // Cancel its current completion event for this queue
1378  //
1379  oldState = Request->SetCompletionState(FxRequestCompletionStateNone);
1381 
1382  OldFlags = VerifyForwardRequestUpdateFlags(FxDriverGlobals, Request);
1383 
1384  //
1385  // Remove it from this queues driver owned list.
1386  //
1387  // This must be done before forward since new queue will
1388  // use the list entry in the FxRequest
1389  //
1390  // We can't use RemoveFromDriverOwnedList since we want the
1391  // m_DriverIoCount to be left alone in case the forward fails.
1392  // If we don't, another thread can run when we drop the lock, notice
1393  // that there are no more requests, and raise the purged and empty
1394  // events. But if the forward fails, the request will wind up back
1395  // on the queue! So m_DriverIoCount is used as a gate to prevent
1396  // these events from firing until we are really sure this queue
1397  // is done with the request.
1398  //
1399 
1400 
1401 
1402 
1403 
1404 
1405 
1406 
1407 
1408 
1409 
1410  Lock(&irql);
1411  ple = Request->GetListEntry(FxListEntryDriverOwned);
1414  Unlock(irql);
1415 
1416  //
1417  // Attempt to pass the request onto the target queue
1418  //
1420  if (!NT_SUCCESS(status)) {
1421 
1422  //
1423  // Target queue did not accept the request, so we
1424  // restore the original completion callback function
1425  // and flags
1426  //
1427  oldState = Request->SetCompletionState(oldState);
1428  ASSERT(oldState == FxRequestCompletionStateNone);
1429  UNREFERENCED_PARAMETER(oldState);
1430 
1431  if (FxDriverGlobals->FxVerifierOn) {
1432  Request->SetVerifierFlags(OldFlags);
1433  }
1434 
1435  // Release the extra reference we took
1436  Request->RELEASE(FXREQUEST_STATE_TAG);
1437 
1438  Lock(&irql);
1439  // Place it back on the driver owned list
1441  Unlock(irql);
1442  }
1443  else {
1444 
1445  Lock(&irql);
1446 
1447  // Request is no longer part of the I/O count for this queue
1448  m_DriverIoCount--;
1449 
1450  ASSERT(m_DriverIoCount >= 0);
1451 
1452  //
1453  // Don't run the event dispatcher if we are called from a
1454  // dispath routine in order to prevent stack recursion.
1455  // Since some other thread (possibly this thread higher on
1456  // the stack) is running the dispatcher, no events will get lost.
1457  //
1458  //
1459  // This returns with the IoQueue lock released
1460  //
1461  DispatchInternalEvents(irql);
1462 
1463  //
1464  // We don't dereference the request object since the new IoQueue
1465  // will release it when it is done.
1466  //
1467  }
1468 
1469  return status;
1470 }
__drv_restoresIRQL KIRQL __in BOOLEAN Unlock
Definition: fxobject.hpp:1474
BOOLEAN FxVerifierOn
Definition: fxglobals.h:420
LIST_ENTRY m_DriverOwned
Definition: fxioqueue.hpp:397
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
LONG NTSTATUS
Definition: precomp.h:26
Lock & irql
Definition: fxioqueue.cpp:924
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
volatile LONG m_DriverIoCount
Definition: fxioqueue.hpp:475
#define InsertTailList(ListHead, Entry)
PSINGLE_LIST_ENTRY ple
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
UCHAR KIRQL
Definition: env_spec_w32.h:591
short SHORT
Definition: pedump.c:59
#define FXREQUEST_STATE_TAG
Definition: fxrequest.hpp:42
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
FxRequestCompletionState
_Must_inspect_result_ NTSTATUS QueueRequestFromForward(__in FxRequest *pRequest)
Definition: fxioqueue.cpp:2351
Definition: typedefs.h:119
SHORT OldFlags
Definition: fxioqueue.cpp:1325
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
NTSTATUS status
Definition: fxioqueue.cpp:887
_Must_inspect_result_ NTSTATUS _In_ FxIoQueue * DestQueue
Definition: fxioqueue.cpp:1476
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
Definition: wdfsync.h:124
ASSERT((Request->GetVerifierFlagsLocked() &FXREQUEST_FLAG_DRIVER_OWNED) !=0)
Definition: ps.c:97

Referenced by ForwardRequest(), and ForwardRequestToParent().

◆ FreeAllReservedRequests()

VOID FxIoQueue::FreeAllReservedRequests ( __in BOOLEAN  Verify)
private

Definition at line 81 of file fxioqueueum.hpp.

96 {
98 
100  return;
101 
102 }
Definition: msg.c:1065
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
VOID UfxVerifierTrapNotImpl()

Referenced by Dispose().

◆ FX_DECLARE_VF_FUNCTION_P1() [1/6]

FxIoQueue::FX_DECLARE_VF_FUNCTION_P1 ( VOID  ,
VerifyCancelForDriver  ,
_In_ FxRequest  
)

◆ FX_DECLARE_VF_FUNCTION_P1() [2/6]

FxIoQueue::FX_DECLARE_VF_FUNCTION_P1 ( VOID  ,
VerifyValidateCompletedRequest  ,
_In_ FxRequest  
)

◆ FX_DECLARE_VF_FUNCTION_P1() [3/6]

FxIoQueue::FX_DECLARE_VF_FUNCTION_P1 ( NTSTATUS  ,
VerifyGetRequestUpdateFlags  ,
_In_ FxRequest  
)

◆ FX_DECLARE_VF_FUNCTION_P1() [4/6]

FxIoQueue::FX_DECLARE_VF_FUNCTION_P1 ( VOID  ,
VerifyGetRequestRestoreFlags  ,
_In_ FxRequest  
)

◆ FX_DECLARE_VF_FUNCTION_P1() [5/6]

FxIoQueue::FX_DECLARE_VF_FUNCTION_P1 ( NTSTATUS  ,
VerifyPeekRequest  ,
_In_ FxRequest  
)

◆ FX_DECLARE_VF_FUNCTION_P1() [6/6]

FxIoQueue::FX_DECLARE_VF_FUNCTION_P1 ( NTSTATUS  ,
VerifyRequeue  ,
_In_ FxRequest  
)

◆ FX_DECLARE_VF_FUNCTION_P1_EX()

FxIoQueue::FX_DECLARE_VF_FUNCTION_P1_EX ( SHORT  ,
,
VerifyForwardRequestUpdateFlags  ,
_In_ FxRequest  
)

◆ FX_DECLARE_VF_FUNCTION_P2() [1/4]

FxIoQueue::FX_DECLARE_VF_FUNCTION_P2 ( NTSTATUS  ,
VerifyForwardRequest  ,
_In_ FxIoQueue ,
_In_ FxRequest  
)

◆ FX_DECLARE_VF_FUNCTION_P2() [2/4]

FxIoQueue::FX_DECLARE_VF_FUNCTION_P2 ( NTSTATUS  ,
VerifyQueueDriverCreatedRequest  ,
_In_ FxRequest ,
_Inout_ SHORT  
)

◆ FX_DECLARE_VF_FUNCTION_P2() [3/4]

FxIoQueue::FX_DECLARE_VF_FUNCTION_P2 ( NTSTATUS  ,
VerifyRequestCancelable  ,
_In_ FxRequest ,
_In_  BOOLEAN 
)

◆ FX_DECLARE_VF_FUNCTION_P2() [4/4]

FxIoQueue::FX_DECLARE_VF_FUNCTION_P2 ( NTSTATUS  ,
VerifyForwardRequestToParent  ,
_In_ FxIoQueue ,
_In_ FxRequest  
)

◆ GetCallbackLockPtr()

virtual FxCallbackLock* FxIoQueue::GetCallbackLockPtr ( __deref_out FxObject **  LockObject)
inlinevirtual

Definition at line 1064 of file fxioqueue.hpp.

1067  {
1068  if (LockObject != NULL) {
1070  }
1071 
1072  return m_CallbackLockPtr;
1073  }
FxCallbackLock * m_CallbackLockPtr
Definition: fxioqueue.hpp:528
FxObject * m_CallbackLockObjectPtr
Definition: fxioqueue.hpp:529
#define LockObject(Object, Irql)
Definition: titypes.h:34
#define NULL
Definition: types.h:112

◆ GetConstraints()

virtual VOID FxIoQueue::GetConstraints ( __out WDF_EXECUTION_LEVEL ExecutionLevel,
__out WDF_SYNCHRONIZATION_SCOPE SynchronizationScope 
)
inlinevirtual

Implements IFxHasCallbacks.

Definition at line 1048 of file fxioqueue.hpp.

1051  {
1052 
1053  if (ExecutionLevel != NULL) {
1054  *ExecutionLevel = m_ExecutionLevel;
1055  }
1056 
1057  if (SynchronizationScope != NULL) {
1058  *SynchronizationScope = m_SynchronizationScope;
1059  }
1060  }
WDF_EXECUTION_LEVEL m_ExecutionLevel
Definition: fxioqueue.hpp:514
WDF_SYNCHRONIZATION_SCOPE m_SynchronizationScope
Definition: fxioqueue.hpp:515
#define NULL
Definition: types.h:112

◆ GetCxDeviceInfo()

__inline FxCxDeviceInfo* FxIoQueue::GetCxDeviceInfo ( VOID  )
inline

Definition at line 1360 of file fxioqueue.hpp.

1363  {
1364  return m_CxDeviceInfo;
1365  }
FxCxDeviceInfo * m_CxDeviceInfo
Definition: fxioqueue.hpp:425

Referenced by AllocateReservedRequest().

◆ GetDevice()

__inline CfxDevice* FxIoQueue::GetDevice ( VOID  )
inline

Definition at line 773 of file fxioqueue.hpp.

774  {
775  return m_Device;
776  }
CfxDevice * m_Device
Definition: fxobject.hpp:329

Referenced by __drv_strictTypeMatch(), if(), PerfEvtIoStopStart(), PerfEvtIoStopStop(), PerfIoComplete(), and PerfIoStart().

◆ GetDriver()

__inline FxDriver* FxIoQueue::GetDriver ( VOID  )
inline

Definition at line 767 of file fxioqueue.hpp.

767  {
768  return m_PkgIo->GetDriver();
769  }
FxPkgIo * m_PkgIo
Definition: fxioqueue.hpp:420
FxDriver * GetDriver(VOID)
Definition: fxpkgio.cpp:543

◆ GetForwardProgressIrpLocked()

_Must_inspect_result_ PIRP FxIoQueue::GetForwardProgressIrpLocked ( __in_opt PFILE_OBJECT  FileObject)
private

Definition at line 60 of file fxioqueueum.hpp.

71 {
73 
75  return NULL;
76 
77 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
VOID UfxVerifierTrapNotImpl()
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547
#define NULL
Definition: types.h:112

◆ GetForwardProgressIrps()

VOID FxIoQueue::GetForwardProgressIrps ( __in PLIST_ENTRY  IrpListHead,
__in_opt MdFileObject  FileObject 
)
private

Definition at line 127 of file fxioqueueum.hpp.

139 {
140  UNREFERENCED_PARAMETER(IrpListHead);
142 
144  return;
145 
146 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
VOID UfxVerifierTrapNotImpl()
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547

Referenced by PurgeForwardProgressIrps(), and QueueIdle().

◆ GetHandle()

◆ GetPackage()

__inline FxPkgIo* FxIoQueue::GetPackage ( VOID  )
inline

Definition at line 780 of file fxioqueue.hpp.

780  {
781  return m_PkgIo;
782  }
FxPkgIo * m_PkgIo
Definition: fxioqueue.hpp:420

◆ GetRequest()

_Must_inspect_result_ NTSTATUS FxIoQueue::GetRequest ( __in_opt MdFileObject  FileObject,
__in_opt FxRequest TagRequest,
__deref_out FxRequest **  pOutRequest 
)

Definition at line 962 of file fxioqueue.cpp.

986 {
989  FxRequestCompletionState oldState;
991  KIRQL irql;
992 
993  status = VerifyGetRequestUpdateFlags(pFxDriverGlobals, TagRequest);
994  if(!NT_SUCCESS(status)){
995  return status;
996  }
997 
998  //
999  // Don't allow on parallel queues
1000  //
1001  if ((m_Type != WdfIoQueueDispatchManual) &&
1005  "Cannot be called on a parallel WDFQUEUE 0x%p, %!STATUS!",
1006  GetObjectHandle(), status);
1007  return status;
1008  }
1009 
1010  Lock(&irql);
1011 
1012  //
1013  // Only if the queue state allows requests to be retrieved.
1014  // It's okay to retrieve requests while the queue is in a transitioning state.
1015  //
1019  "WDFQUEUE 0x%p is powered off, %!STATUS!",
1020  GetObjectHandle(), status);
1021  Unlock(irql);
1022  return status;
1023  }
1024 
1025  //
1026  // See if the queue is (still) processing requests
1027  //
1031  "WDFQUEUE 0x%p is stopped, %!STATUS!",
1032  GetObjectHandle(), status);
1033  Unlock(irql);
1034  return status;
1035  }
1036 
1037  #pragma warning(disable:4127)
1038  while (TRUE) {
1039 
1040  #pragma warning(default:4127)
1041  //
1042  // Get the next FxRequest from the cancel safe queue
1043  //
1045  if (!NT_SUCCESS(status)) {
1046  //
1047  // This code address the following race condition:
1048  // 1) Queue has only one request (count 1).
1049  // 2) Request in queue is cancelled.
1050  // 3) Request's cancellation logic starts to run on thread 1.
1051  // 4) But before cancellation logic gets the queue's lock
1052  // thread 2 calls WdfIoQueueRetrieveNextRequest.
1053  // 5) WdfIoQueueRetrieveNextRequest returns no more requests.
1054  // Driver waits for the ReadyNotify callback. (count 1)
1055  // 6) Thread 3 adds a new request in queue. (count 1->2)
1056  // 7) Thread 1 finally runs. (count 2->1).
1057  // 8) At this point driver stops responding b/c it never receives ReadyNotify.
1058  //
1059  // This code below forces the queue logic to send a ReadyNotify
1060  // callback the next time a new request is added (in step 6 above).
1061  //
1062  if (STATUS_NO_MORE_ENTRIES == status &&
1063  NULL == FileObject && // WdfIoQueueRetrieveNextRequest
1064  NULL == TagRequest && // WdfIoQueueRetrieveNextRequest
1065  m_Queue.GetRequestCount() > 0L) {
1066 
1068  }
1069 
1070  Unlock(irql);
1071  return status;
1072  }
1073 
1074  //
1075  // If we don't allow zero length read/write's to the driver,
1076  // complete it now with success and attempt to get another
1077  // request from the queue.
1078  //
1080 
1081 
1082 
1083 
1084 
1085  (VOID)pRequest->GetCurrentIrpStackLocation();
1086 
1087  FxIrp* pIrp = pRequest->GetFxIrp();
1089 
1090  if ((majorFunction == IRP_MJ_READ) &&
1091  (pIrp->GetParameterReadLength() == 0)) {
1092 
1093  Unlock(irql);
1095  "Zero length WDFREQUEST 0x%p completed automatically by WDFQUEUE 0x%p",
1096  pRequest->GetHandle(),GetObjectHandle());
1097  pRequest->CompleteWithInformation(STATUS_SUCCESS, 0);
1098  pRequest->RELEASE(FXREQUEST_COMPLETE_TAG);
1099 
1100  Lock(&irql);
1101 
1102  // Get another request from the queue
1103  continue;
1104  }
1105  else if ((majorFunction == IRP_MJ_WRITE) &&
1106  (pIrp->GetParameterWriteLength() == 0)) {
1107 
1108  Unlock(irql);
1110  "Zero length WDFREQUEST 0x%p completed automatically by WDFQUEUE 0x%p",
1111  pRequest->GetHandle(), GetObjectHandle());
1112 
1113  pRequest->CompleteWithInformation(STATUS_SUCCESS, 0);
1114  pRequest->RELEASE(FXREQUEST_COMPLETE_TAG);
1115 
1116  Lock(&irql);
1117 
1118  // Get another request from the queue
1119  continue;
1120  }
1121  }
1122 
1123  break;
1124  }
1125 
1126  // Increase the driver owned request count
1128 
1129  Unlock(irql);
1130 
1131  //
1132  // We don't need to check for PurgeComplete since
1133  // we are giving the request to the driver
1134  //
1135 
1136  // pRequest is not cancellable now
1137 
1138  //
1139  // We are now going to return the request
1140  // to the driver, and it must complete it.
1141  //
1142 
1143  //
1144  // Set a completion event, this takes a reference
1145  //
1146  oldState = pRequest->SetCompletionState(FxRequestCompletionStateQueue);
1147  ASSERT(oldState == FxRequestCompletionStateNone);
1148  UNREFERENCED_PARAMETER(oldState);
1149 
1150  //
1151  // Track that we have given the request to the driver
1152  //
1153  VerifyGetRequestRestoreFlags(pFxDriverGlobals, pRequest);
1154 
1155  pRequest->SetPresented();
1156 
1157  //
1158  // Release our original reference. The FxRequest::Complete
1159  // will release the final one since we have registered a completion
1160  // callback handler
1161  //
1162  // We now have one reference count on the FxRequest object until
1163  // its completion routine runs since the completion event made
1164  // an extra reference, and will dereference it when it fires, or
1165  // its canceled.
1166  //
1167 
1168  pRequest->RELEASE(FXREQUEST_STATE_TAG);
1169 
1170  // Return it to the driver
1171  *pOutRequest = pRequest;
1172 
1173  return STATUS_SUCCESS;
1174 }
static _Must_inspect_result_ FxRequest * GetNextRequest(__in FxIrpQueue *IrpQueue)
Definition: fxrequest.cpp:2025
__drv_restoresIRQL KIRQL __in BOOLEAN Unlock
Definition: fxobject.hpp:1474
ULONG GetParameterReadLength(VOID)
Definition: fxirpum.cpp:1589
#define STATUS_NO_MORE_ENTRIES
Definition: ntstatus.h:205
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
LONG NTSTATUS
Definition: precomp.h:26
Lock & irql
Definition: fxioqueue.cpp:924
Definition: fxirp.hpp:28
FxIrp * pIrp
#define STATUS_INVALID_DEVICE_STATE
Definition: udferr_usr.h:178
DoTraceLevelMessage(FxDriverGlobals, TRACE_LEVEL_WARNING, TRACINGIO, "WDFREQUEST 0x%p " "was cancelled in driver for WDFQUEUE 0x%p", Request->GetHandle(), GetObjectHandle())
__inline VOID InsertInDriverOwnedList(__in FxRequest *Request)
Definition: fxioqueue.hpp:1451
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define TRACE_LEVEL_VERBOSE
Definition: storswtr.h:30
PVOID __inline GetObjectHandle(VOID)
Definition: fxobject.hpp:603
LONG GetRequestCount()
Definition: fxirpqueue.hpp:193
_Must_inspect_result_ NTSTATUS _In_ FxRequest * TagRequest
Definition: fxioqueue.cpp:885
#define FXREQUEST_STATE_TAG
Definition: fxrequest.hpp:42
#define STATUS_WDF_PAUSED
Definition: wdfstatus.h:117
VOID _In_ FxRequest * pRequest
Definition: fxioqueue.cpp:947
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547
PFX_DRIVER_GLOBALS pFxDriverGlobals
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
FXIOQUEUE_POWER_STATE m_PowerState
Definition: fxioqueue.hpp:302
volatile BOOLEAN m_ForceTransitionFromEmptyWhenAddingNewRequest
Definition: fxioqueue.hpp:452
FxRequestCompletionState
unsigned char UCHAR
Definition: xmlstorage.h:181
static const WCHAR L[]
Definition: oid.c:1250
#define VOID
Definition: acefi.h:82
return STATUS_SUCCESS
Definition: fxioqueue.cpp:939
ULONG GetParameterWriteLength(VOID)
Definition: fxirpum.cpp:1601
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
NTSTATUS status
Definition: fxioqueue.cpp:887
BOOLEAN m_AllowZeroLengthRequests
Definition: fxioqueue.hpp:273
#define NULL
Definition: types.h:112
UCHAR majorFunction
#define FXREQUEST_COMPLETE_TAG
Definition: fxrequest.hpp:52
#define IRP_MJ_READ
Definition: rdpdr.c:46
__inline BOOLEAN IsState(__in WDF_IO_QUEUE_STATE State)
Definition: fxioqueue.hpp:843
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
Definition: wdfsync.h:124
#define IRP_MJ_WRITE
Definition: rdpdr.c:47
#define TRACINGIO
Definition: dbgtrace.h:66
FxIrpQueue m_Queue
Definition: fxioqueue.hpp:366
WDF_IO_QUEUE_DISPATCH_TYPE m_Type
Definition: fxioqueue.hpp:308
UCHAR GetMajorFunction(VOID)
Definition: fxirpum.cpp:217
ASSERT((Request->GetVerifierFlagsLocked() &FXREQUEST_FLAG_DRIVER_OWNED) !=0)
Definition: ps.c:97

Referenced by FxPkgGeneral::OnCreate().

◆ GetRequestCount()

VOID FxIoQueue::GetRequestCount ( __out_opt PULONG  pQueuedRequests,
__out_opt PULONG  pDriverPendingRequests 
)

Definition at line 4227 of file fxioqueue.cpp.

4243 {
4244  if (pQueuedRequests != NULL) {
4245  *pQueuedRequests = m_Queue.GetRequestCount();
4246  }
4247 
4248  if (pDriverPendingRequests != NULL) {
4249  *pDriverPendingRequests = m_DriverIoCount;
4250  }
4251 
4252  return;
4253 }
volatile LONG m_DriverIoCount
Definition: fxioqueue.hpp:475
LONG GetRequestCount()
Definition: fxirpqueue.hpp:193
#define NULL
Definition: types.h:112
FxIrpQueue m_Queue
Definition: fxioqueue.hpp:366

Referenced by GetState().

◆ GetReservedRequest()

_Must_inspect_result_ NTSTATUS FxIoQueue::GetReservedRequest ( __in MdIrp  Irp,
__deref_out_opt FxRequest **  ReservedRequest 
)

Definition at line 192 of file fxioqueueum.hpp.

203 {
205  UNREFERENCED_PARAMETER(ReservedRequest);
206 
208  return STATUS_NOT_IMPLEMENTED;
209 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
VOID UfxVerifierTrapNotImpl()
return STATUS_NOT_IMPLEMENTED
_In_ PIRP Irp
Definition: csq.h:116

◆ GetState()

WDF_IO_QUEUE_STATE FxIoQueue::GetState ( __out_opt PULONG  pQueueCount,
__out_opt PULONG  pDriverCount 
)

Definition at line 760 of file fxioqueue.cpp.

764 {
765  int stat;
767 
768  // Get request counts
770 
771  if (pQueueCount ) *pQueueCount = QueueCount;
772 
773  if (pDriverCount ) *pDriverCount = DriverCount;
774 
775  //
776  // First fill in the values that are kept up to date at runtime
777  //
779 
780  //
781  // Set additional information bits from information retrieved
782  // from other sources. It's cheaper to get this info at the infrequent
783  // GetStatus time, rather than keep the bits up to date at each
784  // request and queue transition.
785  //
786  if (QueueCount == 0) {
788  }
789 
790  if (DriverCount == 0) {
792  }
793 
794  if(m_PowerManaged) {
795 
798  }
799  }
800 
801  return (WDF_IO_QUEUE_STATE)stat;
802 }
__in WDFQUEUE __out_opt PULONG QueueCount
VOID GetRequestCount(__out_opt PULONG pQueuedRequests, __out_opt PULONG pDriverPendingRequests)
Definition: fxioqueue.cpp:4227
BOOLEAN m_PowerManaged
Definition: fxioqueue.hpp:261
enum _WDF_IO_QUEUE_STATE WDF_IO_QUEUE_STATE
FXIOQUEUE_POWER_STATE m_PowerState
Definition: fxioqueue.hpp:302
Definition: stat.h:55
_CRTIMP int __cdecl stat(const char *_Filename, struct stat *_Stat)
Definition: stat.h:345
FX_IO_QUEUE_STATE m_QueueState
Definition: fxioqueue.hpp:318
unsigned int ULONG
Definition: retypes.h:1
__in WDFQUEUE __out_opt PULONG __out_opt PULONG DriverCount
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

◆ Initialize()

_Must_inspect_result_ NTSTATUS FxIoQueue::Initialize ( __in PWDF_IO_QUEUE_CONFIG  pConfig,
__in_opt PWDF_OBJECT_ATTRIBUTES  QueueAttributes,
__in_opt FxDriver Caller,
__in BOOLEAN  InitialPowerStateOn 
)

Definition at line 217 of file fxioqueue.cpp.

240 {
242  PFX_DRIVER_GLOBALS FxDriverGlobals = GetDriverGlobals();
243 
245  if (!NT_SUCCESS(Status)) {
246  return Status;
247  }
248 
250  if (!NT_SUCCESS(Status)) {
251  return Status;
252  }
253 
254 #if (FX_CORE_MODE==FX_CORE_USER_MODE)
256  if (!NT_SUCCESS(Status)) {
257  return Status;
258  }
259 #endif
260 
262 
263  //
264  // Set the execution level and callback synchronization based on
265  // configuration
266  //
268  if (!NT_SUCCESS(Status)) {
269  return Status;
270  }
271 
272  //
273  // Validate dispatch type.
274  //
275  if (pConfig->DispatchType <= WdfIoQueueDispatchInvalid ||
276  pConfig->DispatchType >= WdfIoQueueDispatchMax) {
278  "Invalid dispatch type "
279  "specified %d, Queue 0x%p %!STATUS!",
280  pConfig->DispatchType,
281  GetObjectHandle(),
284  }
285 
286  //
287  // If not a manual queue, must set at least IoStart, or one of
288  // read|write|devicecontrol
289  //
290  if ((pConfig->DispatchType != WdfIoQueueDispatchManual) &&
291  (pConfig->EvtIoDefault == NULL)) {
292 
293  if ((pConfig->EvtIoDefault == NULL) &&
294  (pConfig->EvtIoRead == NULL) &&
295  (pConfig->EvtIoWrite == NULL) &&
296  (pConfig->EvtIoDeviceControl == NULL) &&
297  (pConfig->EvtIoInternalDeviceControl == NULL)) {
298 
300  "At least one of EvtIoDefault|EvtIoRead|EvtIoWrite|"
301  "EvtIoDeviceControl|EvtIoInternalDeviceControl "
302  "must be set %!STATUS!", STATUS_WDF_NO_CALLBACK);
303  return STATUS_WDF_NO_CALLBACK;
304  }
305  }
306 
307  //
308  // A manual queue should not set any callback function
309  // pointers since they will not get invoked.
310  //
311  if (pConfig->DispatchType == WdfIoQueueDispatchManual) {
312 
313  if ((pConfig->EvtIoDefault != NULL) ||
314  (pConfig->EvtIoRead != NULL) ||
315  (pConfig->EvtIoWrite != NULL) ||
316  (pConfig->EvtIoDeviceControl != NULL) ||
317  (pConfig->EvtIoInternalDeviceControl != NULL)) {
318 
320  "Cannot set io callback events "
321  "on a manual WDFQUEUE 0x%p %!STATUS!",
322  GetObjectHandle(),
325  }
326  }
327 
328  //
329  // For version less than v1.9 m_MaxParallelQueuePresentedRequests is set to
330  // -1 by the FxIoQueue Constructor.
331  // By checking > below we mean v1.9 and above (public API already did the official
332  // validation).
333  //
334  if (pConfig->Size > sizeof(WDF_IO_QUEUE_CONFIG_V1_7)) {
335  if (pConfig->Settings.Parallel.NumberOfPresentedRequests != 0 &&
336  (pConfig->DispatchType == WdfIoQueueDispatchSequential ||
337  pConfig->DispatchType == WdfIoQueueDispatchManual)) {
340  "Cannot have NumberOfPresentedRequests other "
341  "than 0 on a Sequential or manual WDFQUEUE 0x%p."
342  "Make Sure you set NumberOfPresentedRequests"
343  " to 0, %!STATUS!",
344  GetObjectHandle(),
345  Status
346  );
347  return Status;
348 
349  }
350  else{
352  pConfig->Settings.Parallel.NumberOfPresentedRequests;
353  }
354  }
355 
356  //
357  // Initialize our workitem if we have to support passive callbacks
358  //
359  if (m_PassiveLevel) {
360 
361  Status = FxSystemWorkItem::_Create(FxDriverGlobals,
364  );
365 
366  if (!NT_SUCCESS(Status)) {
368  "Could not allocate workitem: %!STATUS!", Status);
369  return Status;
370  }
371  }
372 
373  m_Type = pConfig->DispatchType;
374 
375  switch(pConfig->PowerManaged) {
376 
377  case WdfUseDefault:
378  if(m_Device->IsFilter()){
380  } else {
382  }
383  break;
384 
385  case WdfTrue:
387  break;
388 
389  case WdfFalse:
391  break;
392  default:
393  ASSERTMSG("Invalid value in WDF_IO_QUEUE_CONFIG PowerManaged field\n", FALSE);
394  break;
395  }
396 
397  //
398  // Queues for NonPnp devices can't be power managed.
399  //
400  if(m_Device->IsLegacy()) {
402  }
403 
404  //
405  // If power managed queue, ensure its initial power state
406  // is same as the device.
407  //
408  if (m_PowerManaged) {
409  if (InitialPowerStateOn) {
411  }
412  else {
414  }
415  } else {
417  }
418 
419  m_AllowZeroLengthRequests = pConfig->AllowZeroLengthRequests;
420 
422  "EvtIoDefault 0x%p, EvtIoRead 0x%p, EvtIoWrite 0x%p, "
423  "EvtIoDeviceControl 0x%p for WDFQUEUE 0x%p",
424  pConfig->EvtIoDefault,
425  pConfig->EvtIoRead,
426  pConfig->EvtIoWrite,
427  pConfig->EvtIoDeviceControl, GetObjectHandle());
428 
429  m_IoDefault.Method = pConfig->EvtIoDefault;
430  m_IoStop.Method = pConfig->EvtIoStop;
431  m_IoResume.Method = pConfig->EvtIoResume;
432  m_IoRead.Method = pConfig->EvtIoRead;
433  m_IoWrite.Method = pConfig->EvtIoWrite;
434  m_IoDeviceControl.Method = pConfig->EvtIoDeviceControl;
435  m_IoInternalDeviceControl.Method = pConfig->EvtIoInternalDeviceControl;
436  m_IoCanceledOnQueue.Method = pConfig->EvtIoCanceledOnQueue;
437 
438 
439  // A newly created queue can accept and dispatch requests once initialized
441 
442  m_Configured = TRUE;
443 
444  return STATUS_SUCCESS;
445 }
CfxDevice * m_Device
Definition: fxobject.hpp:329
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_IO_QUEUE_CONFIG _In_opt_ PWDF_OBJECT_ATTRIBUTES QueueAttributes
Definition: wdfio.h:613
static _Must_inspect_result_ NTSTATUS _Create(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PVOID WdmObject, __out FxSystemWorkItem **pObject)
PFN_WDF_IO_QUEUE_IO_WRITE Method
PFN_WDF_IO_QUEUE_IO_INTERNAL_DEVICE_CONTROL Method
MdDeviceObject __inline GetDeviceObject(VOID)
Definition: fxdevice.hpp:174
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
PFN_WDF_IO_QUEUE_IO_RESUME Method
__inline BOOLEAN IsLegacy(VOID)
Definition: fxdevice.hpp:1209
FxIoQueueIoCanceledOnQueue m_IoCanceledOnQueue
Definition: fxioqueue.hpp:494
DoTraceLevelMessage(FxDriverGlobals, TRACE_LEVEL_WARNING, TRACINGIO, "WDFREQUEST 0x%p " "was cancelled in driver for WDFQUEUE 0x%p", Request->GetHandle(), GetObjectHandle())
FxIoQueueIoDefault m_IoDefault
Definition: fxioqueue.hpp:487
CHECK_RETURN_IF_USER_MODE __inline NTSTATUS Initialize(__in EVENT_TYPE Type, __in BOOLEAN InitialState)
Definition: mxeventkm.h:55
BOOLEAN m_Configured
Definition: fxioqueue.hpp:252
#define FALSE
Definition: types.h:117
#define TRACE_LEVEL_VERBOSE
Definition: storswtr.h:30
PFN_WDF_IO_QUEUE_IO_DEVICE_CONTROL Method
PFN_WDF_IO_QUEUE_IO_READ Method
#define ASSERTMSG(msg, exp)
Definition: nt_native.h:431
VOID MarkDisposeOverride(__in FxObjectLockState State=ObjectLock)
Definition: fxobject.hpp:1101
FxIoQueueIoResume m_IoResume
Definition: fxioqueue.hpp:489
enum _FX_IO_QUEUE_SET_STATE FX_IO_QUEUE_SET_STATE
PVOID __inline GetObjectHandle(VOID)
Definition: fxobject.hpp:603
ULONG m_MaxParallelQueuePresentedRequests
Definition: fxioqueue.hpp:313
PFN_WDF_IO_QUEUE_IO_DEFAULT Method
BOOLEAN m_PowerManaged
Definition: fxioqueue.hpp:261
_Must_inspect_result_ NTSTATUS ConfigureConstraints(__in_opt PWDF_OBJECT_ATTRIBUTES ObjectAttributes, __in_opt FxDriver *Caller)
Definition: fxioqueue.cpp:571
Status
Definition: gdiplustypes.h:24
MxEvent m_PowerIdle
Definition: fxioqueue.hpp:571
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
__inline BOOLEAN IsFilter()
Definition: fxdevice.hpp:1408
FxSystemWorkItem * m_SystemWorkItem
Definition: fxioqueue.hpp:557
FXIOQUEUE_POWER_STATE m_PowerState
Definition: fxioqueue.hpp:302
VOID SetState(__in FX_IO_QUEUE_SET_STATE NewStatus)
Definition: fxioqueue.cpp:805
FxIoQueueIoInternalDeviceControl m_IoInternalDeviceControl
Definition: fxioqueue.hpp:493
FxIoQueueIoRead m_IoRead
Definition: fxioqueue.hpp:490
return STATUS_SUCCESS
Definition: fxioqueue.cpp:939
#define STATUS_WDF_NO_CALLBACK
Definition: wdfstatus.h:189
FxIoQueueIoWrite m_IoWrite
Definition: fxioqueue.hpp:491
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
BOOLEAN m_PassiveLevel
Definition: fxioqueue.hpp:280
BOOLEAN m_AllowZeroLengthRequests
Definition: fxioqueue.hpp:273
#define NULL
Definition: types.h:112
PFN_WDF_IO_QUEUE_IO_STOP Method
FxIoQueueIoDeviceControl m_IoDeviceControl
Definition: fxioqueue.hpp:492
MxEvent m_FinishDisposing
Definition: fxioqueue.hpp:297
#define TRACINGIO
Definition: dbgtrace.h:66
WDF_IO_QUEUE_DISPATCH_TYPE m_Type
Definition: fxioqueue.hpp:308
FxIoQueueIoStop m_IoStop
Definition: fxioqueue.hpp:488
PFN_WDF_IO_QUEUE_IO_CANCELED_ON_QUEUE Method
MxEvent m_RequestWaitEventUm
Definition: fxioqueue.hpp:578

Referenced by _Create().

◆ InsertInDriverOwnedList()

__inline VOID FxIoQueue::InsertInDriverOwnedList ( __in FxRequest Request)
inlineprivate

Definition at line 1451 of file fxioqueue.hpp.

1454  {
1455  m_DriverIoCount++;
1456 
1458  return;
1459  }
LIST_ENTRY m_DriverOwned
Definition: fxioqueue.hpp:397
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
volatile LONG m_DriverIoCount
Definition: fxioqueue.hpp:475
#define InsertTailList(ListHead, Entry)

Referenced by GetRequest().

◆ InsertNewRequest()

__inline NTSTATUS FxIoQueue::InsertNewRequest ( __in FxRequest **  Request,
__in KIRQL  PreviousIrql 
)
inlineprivate

Definition at line 1584 of file fxioqueue.hpp.

1588  {
1589  NTSTATUS status;
1590 
1591  if (*Request != NULL) {
1593  }
1594  else {
1595  status = STATUS_SUCCESS; // nothing to do.
1596  }
1597 
1598  return status;
1599  }
__in __drv_restoresIRQL KIRQL PreviousIrql
Definition: fxioqueue.hpp:631
LONG NTSTATUS
Definition: precomp.h:26
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
NTSTATUS InsertNewRequestLocked(__deref_in FxRequest **Request, __in KIRQL PreviousIrql)
Definition: fxioqueue.cpp:2571
#define NULL
Definition: types.h:112
#define STATUS_SUCCESS
Definition: shellext.h:65
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

◆ InsertNewRequestLocked()

NTSTATUS FxIoQueue::InsertNewRequestLocked ( __deref_in FxRequest **  Request,
__in KIRQL  PreviousIrql 
)
private

Definition at line 2571 of file fxioqueue.cpp.

2594 {
2595  NTSTATUS status;
2596 
2597  status = (*Request)->InsertTailIrpQueue(&m_Queue, NULL);
2598 
2599  if (!NT_SUCCESS(status)) {
2600  //
2601  // Request was never presented to the driver
2602  // so there is no need to call CancelForQueue
2603  // in this case.
2604  //
2606 
2608 
2609  (*Request)->CompleteWithInformation(status, 0);
2610 
2611  (*Request)->RELEASE(FXREQUEST_COMPLETE_TAG);
2612 
2613  Lock(&PreviousIrql);
2614  }
2615  else {
2616  (*Request)->SetCurrentQueue(this);
2617 
2618  // Check if went from no requests to have requests
2620  }
2621 
2622  //
2623  // Request is either inserted into the queue or completed. Clear
2624  // the field to prevent touching the request.
2625  //
2626  *Request = NULL;
2627 
2628  return status;
2629 }
__drv_restoresIRQL KIRQL __in BOOLEAN Unlock
Definition: fxobject.hpp:1474
__in __drv_restoresIRQL KIRQL PreviousIrql
Definition: fxioqueue.hpp:631
LONG NTSTATUS
Definition: precomp.h:26
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_CANCELLED
Definition: udferr_usr.h:170
NTSTATUS status
Definition: fxioqueue.cpp:887
#define NULL
Definition: types.h:112
#define FXREQUEST_COMPLETE_TAG
Definition: fxrequest.hpp:52
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
Definition: wdfsync.h:124
FxIrpQueue m_Queue
Definition: fxioqueue.hpp:366
ASSERT((Request->GetVerifierFlagsLocked() &FXREQUEST_FLAG_DRIVER_OWNED) !=0)
Definition: ps.c:97
__inline VOID CheckTransitionFromEmpty(VOID)
Definition: fxioqueue.hpp:1541

Referenced by InsertNewRequest(), and QueueRequest().

◆ InsertQueueDpc()

VOID FxIoQueue::InsertQueueDpc ( VOID  )

Definition at line 171 of file fxioqueueum.hpp.

185 {
187 }
VOID UfxVerifierTrapNotImpl()

Referenced by CanThreadDispatchEventsLocked(), and DeferredDispatchRequestsFromDpc().

◆ InvokeAllocateResourcesCallback()

__inline NTSTATUS FxIoQueue::InvokeAllocateResourcesCallback ( __in FxRequest Request)
inline

Definition at line 1273 of file fxioqueue.hpp.

1283  {
1284  NTSTATUS status;
1285 
1286  ASSERT(Request->IsReserved() == FALSE);
1287 
1290  Request->SetPresented();
1292  GetHandle(), Request->GetHandle());
1293  }
1294 
1295  return status;
1296  }
_Must_inspect_result_ NTSTATUS Invoke(__in WDFQUEUE Queue, __in WDFREQUEST Request)
FxIoQueueForwardProgressAllocateResources m_IoResourcesAllocate
Definition: fxioqueue.hpp:160
LONG NTSTATUS
Definition: precomp.h:26
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
PFN_WDF_IO_ALLOCATE_REQUEST_RESOURCES Method
PFXIO_FORWARD_PROGRESS_CONTEXT m_FwdProgContext
Definition: fxioqueue.hpp:241
#define FALSE
Definition: types.h:117
#define ASSERT(a)
Definition: mode.c:45
WDFQUEUE __inline GetHandle(VOID)
Definition: fxioqueue.hpp:786
#define NULL
Definition: types.h:112
#define STATUS_SUCCESS
Definition: shellext.h:65
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

◆ IsForwardProgressQueue()

__inline BOOLEAN FxIoQueue::IsForwardProgressQueue ( VOID  )
inline

Definition at line 1264 of file fxioqueue.hpp.

1267  {
1268  return m_SupportForwardProgress;
1269  }
BOOLEAN m_SupportForwardProgress
Definition: fxioqueue.hpp:246

Referenced by Dispose(), FlushByFileObject(), QueueIdle(), and QueuePurge().

◆ IsIoEventHandlerRegistered()

BOOLEAN FxIoQueue::IsIoEventHandlerRegistered ( __in WDF_REQUEST_TYPE  RequestType)

Definition at line 6178 of file fxioqueue.cpp.

6193 {
6195  //
6196  // Manual queues wouldn't have any IoEvent callbacks registered.
6197  //
6198  return TRUE;
6199  }
6200 
6201  //
6202  // Default handler is a catch all handler.
6203  //
6204  if(m_IoDefault.Method != NULL) {
6205  return TRUE;
6206  }
6207 
6208  //
6209  // Default handle is not registered. So check to see if request specific
6210  // handler is registered.
6211  //
6212  switch(RequestType) {
6213  case WdfRequestTypeRead:
6214  if(m_IoRead.Method == NULL) {
6215  return FALSE;
6216  }
6217  break;
6218  case WdfRequestTypeWrite:
6219  if(m_IoWrite.Method == NULL) {
6220  return FALSE;
6221  }
6222  break;
6224  if(m_IoDeviceControl.Method == NULL) {
6225  return FALSE;
6226  }
6227  break;
6230  return FALSE;
6231  }
6232  break;
6233  case WdfRequestTypeCreate: // Fall through. Must have default handler.
6234  default:
6235  return FALSE;
6236  }
6237 
6238  return TRUE;
6239 }
PFN_WDF_IO_QUEUE_IO_WRITE Method
PFN_WDF_IO_QUEUE_IO_INTERNAL_DEVICE_CONTROL Method
#define TRUE
Definition: types.h:120
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFQUEUE _In_ _Strict_type_match_ WDF_REQUEST_TYPE RequestType
Definition: wdfdevice.h:4227
FxIoQueueIoDefault m_IoDefault
Definition: fxioqueue.hpp:487
#define FALSE
Definition: types.h:117
PFN_WDF_IO_QUEUE_IO_DEVICE_CONTROL Method
PFN_WDF_IO_QUEUE_IO_READ Method
PFN_WDF_IO_QUEUE_IO_DEFAULT Method
FxIoQueueIoInternalDeviceControl m_IoInternalDeviceControl
Definition: fxioqueue.hpp:493
FxIoQueueIoRead m_IoRead
Definition: fxioqueue.hpp:490
FxIoQueueIoWrite m_IoWrite
Definition: fxioqueue.hpp:491
#define NULL
Definition: types.h:112
FxIoQueueIoDeviceControl m_IoDeviceControl
Definition: fxioqueue.hpp:492
WDF_IO_QUEUE_DISPATCH_TYPE m_Type
Definition: fxioqueue.hpp:308

Referenced by FxPkgIo::EnqueueRequest().

◆ IsPagingIo()

__inline BOOLEAN FxIoQueue::IsPagingIo ( __in MdIrp  Irp)
private

Definition at line 30 of file fxioqueuekm.hpp.

39 {
40  //
41  // NOTE: IRP_INPUT_OPERATION has the same value as IRP_SYNCHRONOUS_PAGING_IO
42  // and IRP_MOUNT_COMPLETION the same as IRP_PAGING_IO so how does one know if
43  // the IO is a paging IO ?
44  //
45 
46  // One can assume that if IRP_PAGING_IO is set and the MJ code is not
47  // FILE_SYSTEM_CONTROL then it is a paging I/O.
48  //
49  if (Irp->Flags & IRP_PAGING_IO) {
52  return TRUE;
53  }
54  }
55 
56  return FALSE;
57 }
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
_In_ PIRP Irp
Definition: csq.h:116
#define IRP_MJ_FILE_SYSTEM_CONTROL
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
_In_ UCHAR MajorFunction
Definition: wdfdevice.h:1697
#define IRP_PAGING_IO

◆ IsPowerManaged()

__inline BOOLEAN FxIoQueue::IsPowerManaged ( )
inline

Definition at line 795 of file fxioqueue.hpp.

795  {
796  return m_PowerManaged;
797  }
BOOLEAN m_PowerManaged
Definition: fxioqueue.hpp:261

◆ IsPowerStateNotifyingDriver()

__inline BOOLEAN FxIoQueue::IsPowerStateNotifyingDriver ( VOID  )
inlineprivate

Definition at line 1429 of file fxioqueue.hpp.

1432  {
1436  return TRUE;
1437  }
1438  else {
1439  return FALSE;
1440  }
1441  }
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
FXIOQUEUE_POWER_STATE m_PowerState
Definition: fxioqueue.hpp:302

◆ IsState() [1/2]

__inline BOOLEAN FxIoQueue::IsState ( __in WDF_IO_QUEUE_STATE  State)
inline

Definition at line 843 of file fxioqueue.hpp.

846  {
847  ASSERT(!(State & 0x80000000)); // Don't allow FX_IO_QUEUE_SET states
848  return (((int)m_QueueState & (int) (State)) != 0);
849  }
#define ASSERT(a)
Definition: mode.c:45
FX_IO_QUEUE_STATE m_QueueState
Definition: fxioqueue.hpp:318

Referenced by Dispose(), GetRequest(), QueueRequest(), QueueRequestFromForward(), ReadyNotify(), and SetState().

◆ IsState() [2/2]

__inline BOOLEAN FxIoQueue::IsState ( __in FX_IO_QUEUE_STATE  State)
inline

Definition at line 853 of file fxioqueue.hpp.

856  {
857  ASSERT(!(State & 0x80000000)); // Don't allow FX_IO_QUEUE_SET states
858  return (((int)m_QueueState & (int) (State)) != 0);
859  }
#define ASSERT(a)
Definition: mode.c:45
FX_IO_QUEUE_STATE m_QueueState
Definition: fxioqueue.hpp:318

◆ PeekRequest()

_Must_inspect_result_ NTSTATUS FxIoQueue::PeekRequest ( __in_opt FxRequest TagRequest,
__in_opt MdFileObject  FileObject,
__out_opt PWDF_REQUEST_PARAMETERS  Parameters,
__deref_out FxRequest **  pOutRequest 
)

Definition at line 1197 of file fxioqueue.cpp.

1233 {
1234  NTSTATUS status;
1235  FxRequest* pRequest = NULL;
1237  KIRQL irql;
1238 
1239  //
1240  // FindRequest is allowed only on a manual queue.
1241  //
1245  "FindRequest is allowed only on a manaul queue 0x%p, %!STATUS!",
1246  GetHandle(), status);
1248  return status;
1249  }
1250 
1251  if (TagRequest != NULL) {
1252  status = VerifyPeekRequest(pFxDriverGlobals, TagRequest);
1253  if (!NT_SUCCESS(status)) {
1254  return status;
1255  }
1256  }
1257 
1258  //
1259  // Get the next FxRequest from the cancel safe queue
1260  //
1261  // If success, it will return a referenced FxRequest in
1262  // which the caller must release the reference.
1263  //
1264  Lock(&irql);
1265 
1267  &m_Queue,
1268  TagRequest,
1269  FileObject,
1270  Parameters,
1271  &pRequest
1272  );
1273 
1274  //
1275  // This code address the following potential race condition:
1276  // 1) Queue has only one request (count 1).
1277  // 2) Request in queue is cancelled.
1278  // 3) Request's cancellation logic starts to run on thread 1.
1279  // 4) But before cancellation logic gets the queue's lock
1280  // thread 2 calls WdfIoQueueFindRequest to find any request.
1281  // 5) WdfIoQueueFindRequest returns no more requests.
1282  // Driver waits for the ReadyNotify callback. (count 1)
1283  // 6) Thread 3 adds a new request in queue. (count 1->2)
1284  // 7) Thread 1 finally runs. (count 2->1).
1285  // 8) At this point driver stops responding b/c it never receives ReadyNotify.
1286  //
1287  // This code below forces the queue logic to send a ReadyNotify
1288  // callback the next time a new request is added (in step 6 above).
1289  //
1290  if (STATUS_NO_MORE_ENTRIES == status &&
1291  NULL == FileObject && // WdfIoQueueFindRequest(any request)
1292  NULL == TagRequest && // WdfIoQueueFindRequest(any request)
1293  m_Queue.GetRequestCount() > 0L) {
1294 
1296  }
1297 
1298  Unlock(irql);
1299 
1300  if (!NT_SUCCESS(status)) {
1301  return status;
1302  }
1303 
1304  //
1305  // Mark it as a tag request to detect abuse since its not
1306  // driver owned.
1307  //
1309  pRequest->SetVerifierFlags(FXREQUEST_FLAG_TAG_REQUEST);
1310  }
1311 
1312  // Return it to the driver
1313  *pOutRequest = pRequest;
1314 
1315  return status;
1316 }
__drv_restoresIRQL KIRQL __in BOOLEAN Unlock
Definition: fxobject.hpp:1474
BOOLEAN FxVerifierOn
Definition: fxglobals.h:420
#define STATUS_NO_MORE_ENTRIES
Definition: ntstatus.h:205
_Must_inspect_result_ _In_ WDFQUEUE _In_opt_ WDFREQUEST _In_opt_ WDFFILEOBJECT _Inout_opt_ PWDF_REQUEST_PARAMETERS Parameters
Definition: wdfio.h:863
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
Lock & irql
Definition: fxioqueue.cpp:924
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
DoTraceLevelMessage(FxDriverGlobals, TRACE_LEVEL_WARNING, TRACINGIO, "WDFREQUEST 0x%p " "was cancelled in driver for WDFQUEUE 0x%p", Request->GetHandle(), GetObjectHandle())
UCHAR KIRQL
Definition: env_spec_w32.h:591
LONG GetRequestCount()
Definition: fxirpqueue.hpp:193
_Must_inspect_result_ NTSTATUS _In_ FxRequest * TagRequest
Definition: fxioqueue.cpp:885
VOID _In_ FxRequest * pRequest
Definition: fxioqueue.cpp:947
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547
PFX_DRIVER_GLOBALS pFxDriverGlobals
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
volatile BOOLEAN m_ForceTransitionFromEmptyWhenAddingNewRequest
Definition: fxioqueue.hpp:452
WDFQUEUE __inline GetHandle(VOID)
Definition: fxioqueue.hpp:786
static const WCHAR L[]
Definition: oid.c:1250
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
NTSTATUS status
Definition: fxioqueue.cpp:887
#define NULL
Definition: types.h:112
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
Definition: wdfsync.h:124
#define TRACINGIO
Definition: dbgtrace.h:66
FxIrpQueue m_Queue
Definition: fxioqueue.hpp:366
WDF_IO_QUEUE_DISPATCH_TYPE m_Type
Definition: fxioqueue.hpp:308
static _Must_inspect_result_ NTSTATUS PeekRequest(__in FxIrpQueue *IrpQueue, __in_opt FxRequest *TagRequest, __in_opt MdFileObject FileObject, __out_opt PWDF_REQUEST_PARAMETERS Parameters, __deref_out FxRequest **ppOutRequest)
Definition: fxrequest.cpp:2098
FxVerifierDbgBreakPoint(pFxDriverGlobals)
Definition: ps.c:97

◆ PostRemoveFromDriverOwnedList()

__inline VOID FxIoQueue::PostRemoveFromDriverOwnedList ( VOID  )
inlineprivate

Definition at line 1522 of file fxioqueue.hpp.

1525  {
1528 
1529  m_DriverIoCount--;
1530  ASSERT(m_DriverIoCount >= 0);
1531  return;
1532  }
volatile LONG m_DriverIoCount
Definition: fxioqueue.hpp:475
#define ASSERT(a)
Definition: mode.c:45
volatile LONG m_TwoPhaseCompletions
Definition: fxioqueue.hpp:481

Referenced by PostRequestCompletedCallback().

◆ PostRequestCompletedCallback()

__inline VOID FxIoQueue::PostRequestCompletedCallback ( __in FxRequest Request)
inline

Definition at line 725 of file fxioqueue.hpp.

728  {
729  // Do not acccess Request, at this point the object may have already been
730  // deleted or reused.
731 
732  //
733  // This is called when a queued-by-driver request (driver created) is
734  // completed or sent to a lower driver with 'send-and-forget' option.
735  // This callback allows the queue to schedule another request for delivery.
736  //
737 
738  KIRQL irql;
739 
740 #if FX_VERBOSE_TRACE
742  "Enter: WDFQUEUE 0x%p, WDFREQUEST 0x%p",
744 #else
746 #endif
747 
748  Lock(&irql);
749 
750  //
751  // I/O has been completed by the driver
752  //
754 
755  //
756  // Don't run the event dispatcher if we come from a Request
757  // complete callback in order to prevent stack recursion.
758  //
759  // Since some other thread (possibly this thread higher on
760  // the stack) is running the dispatcher, no events will get lost.
761  //
762  DispatchInternalEvents(irql);
763  }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
KIRQL irql
Definition: wave.h:1
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define TRACE_LEVEL_VERBOSE
Definition: storswtr.h:30
PVOID __inline GetObjectHandle(VOID)
Definition: fxobject.hpp:603
__inline VOID PostRemoveFromDriverOwnedList(VOID)
Definition: fxioqueue.hpp:1522
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
static PVOID __inline _ToHandle(__in FxObject *Object)
Definition: fxobject.hpp:659
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
Definition: wdfsync.h:124
#define TRACINGIO
Definition: dbgtrace.h:66

◆ PreRemoveFromDriverOwnedList()

__inline VOID FxIoQueue::PreRemoveFromDriverOwnedList ( __in FxRequest Request)
inlineprivate

Definition at line 1497 of file fxioqueue.hpp.

1500  {
1501  PLIST_ENTRY listEntry;
1502 
1503  listEntry = Request->GetListEntry(FxListEntryDriverOwned);
1504 
1505  RemoveEntryList(listEntry);
1506  InitializeListHead(listEntry);
1507 
1510 
1511  return;
1512  }
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
#define ASSERT(a)
Definition: mode.c:45
Definition: typedefs.h:119
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
volatile LONG m_TwoPhaseCompletions
Definition: fxioqueue.hpp:481

Referenced by PreRequestCompletedCallback().

◆ PreRequestCompletedCallback()

__inline VOID FxIoQueue::PreRequestCompletedCallback ( __in FxRequest Request)
inline

Definition at line 692 of file fxioqueue.hpp.

695  {
696  //
697  // This is called when a driver created request is about to be completed.
698  // This callback removes the FxRequest object from the internal queue linked
699  // lists. A call to PostRequestCompletedCallback must be made after irp is
700  // completed.
701  //
702 
703  KIRQL irql;
704 
705 #if FX_VERBOSE_TRACE