ReactOS  0.4.15-dev-2344-g8ddbfde
FxPkgIo Class Reference

#include <fxpkgio.hpp>

Inheritance diagram for FxPkgIo:
Collaboration diagram for FxPkgIo:

Public Member Functions

 FxPkgIo (__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in CfxDevice *Device)
 
 ~FxPkgIo ()
 
virtual _Must_inspect_result_ NTSTATUS Dispatch (__inout MdIrp Irp)
 
FxIoQueueGetDispatchQueue (_In_ UCHAR MajorFunction)
 
 FX_DECLARE_VF_FUNCTION_P1 (NTSTATUS, VerifyDispatchContext, _In_ WDFCONTEXT)
 
_Must_inspect_result_ NTSTATUS __fastcall DispatchStep1 (__inout MdIrp Irp, __in WDFCONTEXT DispatchContext)
 
_Must_inspect_result_ NTSTATUS __fastcall DispatchStep2 (__inout MdIrp Irp, __in_opt FxIoInCallerContext *IoInCallerCtx, __in_opt FxIoQueue *Queue)
 
_Must_inspect_result_ NTSTATUS InitializeDefaultQueue (__in CfxDevice *Device, __inout FxIoQueue *Queue)
 
__inline VOID SetIoInCallerContextCallback (__inout PFN_WDF_IO_IN_CALLER_CONTEXT EvtIoInCallerContext)
 
 FX_DECLARE_VF_FUNCTION_P2 (NTSTATUS, VerifyEnqueueRequestUpdateFlags, _In_ FxRequest *, _Inout_ SHORT *)
 
 FX_DECLARE_VF_FUNCTION_P2 (VOID, VerifyEnqueueRequestRestoreFlags, _In_ FxRequest *, _In_ SHORT)
 
_Must_inspect_result_ NTSTATUS EnqueueRequest (__in CfxDevice *Device, __inout FxRequest *pRequest)
 
FxDriverGetDriver (VOID)
 
__inline CfxDeviceGetDevice (VOID)
 
__inline FxIoQueueGetDefaultQueue (VOID)
 
__inline BOOLEAN IsFilter (VOID)
 
_Must_inspect_result_ NTSTATUS StopProcessingForPower (__in FxIoStopProcessingForPowerAction Action)
 
_Must_inspect_result_ NTSTATUS ResumeProcessingForPower ()
 
VOID ResetStateForRestart (VOID)
 
_Must_inspect_result_ NTSTATUS SetFilter (__in BOOLEAN Value)
 
_Must_inspect_result_ NTSTATUS CreateQueue (__in PWDF_IO_QUEUE_CONFIG Config, __in PWDF_OBJECT_ATTRIBUTES QueueAttributes, __in_opt FxDriver *Caller, __deref_out FxIoQueue **ppQueue)
 
VOID RemoveQueueReferences (__inout FxIoQueue *pQueue)
 
_Must_inspect_result_ NTSTATUS ConfigureDynamicDispatching (__in UCHAR MajorFunction, __in_opt FxCxDeviceInfo *CxDeviceInfo, __in PFN_WDFDEVICE_WDM_IRP_DISPATCH EvtDeviceWdmIrpDispatch, __in_opt WDFCONTEXT DriverContext)
 
_Must_inspect_result_ NTSTATUS ConfigureForwarding (__inout FxIoQueue *TargetQueue, __in WDF_REQUEST_TYPE RequestType)
 
_Must_inspect_result_ NTSTATUS FlushAllQueuesByFileObject (__in MdFileObject FileObject)
 
__inline VOID RequestCompletedCallback (__in FxRequest *Request)
 
__inline BOOLEAN IsTopLevelQueue (__in FxIoQueue *Queue)
 
NTSTATUS DispathToInCallerContextCallback (__in FxIoInCallerContext *InCallerContextInfo, __in FxRequest *Request, __inout MdIrp Irp)
 
__inline FxIoInCallerContextGetIoInCallerContextCallback (__in_opt FxCxDeviceInfo *CxDeviceInfo)
 
- Public Member Functions inherited from FxPackage
 FxPackage (__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in CfxDevice *Device, __in WDFTYPE Type)
 
virtual NTSTATUS Dispatch (__in MdIrp Irp)=0
 
__inline CfxDeviceGetDevice (VOID)
 
 DECLARE_INTERNAL_NEW_OPERATOR ()
 
- 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)
 
virtual _Must_inspect_result_ NTSTATUS QueryInterface (__in FxQueryInterfaceParams *Params)
 
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)
 
virtual BOOLEAN Dispose (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)
 

Private Member Functions

VOID AddIoQueue (__inout FxIoQueue *IoQueue)
 
VOID RemoveIoQueue (__inout FxIoQueue *IoQueue)
 
FxIoQueueGetFirstIoQueueLocked (__in FxIoQueueNode *QueueBookmark, __in PVOID Tag)
 
FxIoQueueGetNextIoQueueLocked (__in FxIoQueueNode *QueueBookmark, __in PVOID Tag)
 
VOID GetIoQueueListLocked (__in PSINGLE_LIST_ENTRY SListHead, __inout FxIoIteratorList ListType)
 
_Must_inspect_result_ NTSTATUS VerifierFreeRequestToTestForwardProgess (__in FxRequest *Request)
 

Private Attributes

FxIoQueuem_DefaultQueue
 
LIST_ENTRY m_IoQueueListHead
 
FxIoQueuem_DispatchTable [IRP_MJ_MAXIMUM_FUNCTION+1]
 
ULONG m_RandomSeed
 
BOOLEAN m_Filter
 
BOOLEAN m_PowerStateOn
 
BOOLEAN m_QueuesAreShuttingDown
 
LIST_ENTRY m_DynamicDispatchInfoListHead
 
FxIoInCallerContext m_InCallerContextCallback
 

Additional Inherited Members

- 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)
 
- 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 57 of file fxpkgio.hpp.

Constructor & Destructor Documentation

◆ FxPkgIo()

FxPkgIo::FxPkgIo ( __in PFX_DRIVER_GLOBALS  FxDriverGlobals,
__in CfxDevice Device 
)

Definition at line 47 of file fxpkgio.cpp.

50  :
51  FxPackage(FxDriverGlobals, Device, FX_TYPE_PACKAGE_IO),
52  m_InCallerContextCallback(FxDriverGlobals)
53 {
54  LARGE_INTEGER tickCount;
55 
56  m_Device = Device;
57 
59 
61 
62  m_Filter = FALSE;
63 
65 
67 
69 
71 
72  Mx::MxQueryTickCount(&tickCount);
73 
74  m_RandomSeed = tickCount.LowPart;
75 
77  "Constructed FxPkgIo 0x%p",this);
78 }
CfxDevice * m_Device
Definition: fxobject.hpp:329
ULONG m_RandomSeed
Definition: fxpkgio.hpp:81
LIST_ENTRY m_DynamicDispatchInfoListHead
Definition: fxpkgio.hpp:98
FxIoInCallerContext m_InCallerContextCallback
Definition: fxpkgio.hpp:103
static __inline VOID MxQueryTickCount(__out PLARGE_INTEGER TickCount)
Definition: mxgeneralkm.h:116
BOOLEAN m_PowerStateOn
Definition: fxpkgio.hpp:86
FxIoQueue * m_DispatchTable[IRP_MJ_MAXIMUM_FUNCTION+1]
Definition: fxpkgio.hpp:75
BOOLEAN m_Filter
Definition: fxpkgio.hpp:84
#define FALSE
Definition: types.h:117
#define TRACE_LEVEL_VERBOSE
Definition: storswtr.h:30
BOOLEAN m_QueuesAreShuttingDown
Definition: fxpkgio.hpp:91
FxIoQueue * m_DefaultQueue
Definition: fxpkgio.hpp:62
FxPackage(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in CfxDevice *Device, __in WDFTYPE Type)
Definition: fxpackage.cpp:31
ULONG LowPart
Definition: typedefs.h:106
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
#define NULL
Definition: types.h:112
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
LIST_ENTRY m_IoQueueListHead
Definition: fxpkgio.hpp:70
#define TRACINGIO
Definition: dbgtrace.h:66

◆ ~FxPkgIo()

FxPkgIo::~FxPkgIo ( )

Definition at line 80 of file fxpkgio.cpp.

81 {
83 
85 
86  m_Device = NULL;
87 
93  delete info;
94  }
95 
97 
99  "Destroyed FxPkgIo 0x%p",this);
100 }
CfxDevice * m_Device
Definition: fxobject.hpp:329
LIST_ENTRY m_DynamicDispatchInfoListHead
Definition: fxpkgio.hpp:98
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
#define TRACE_LEVEL_VERBOSE
Definition: storswtr.h:30
FORCEINLINE PLIST_ENTRY RemoveHeadList(_Inout_ PLIST_ENTRY ListHead)
Definition: rtlfuncs.h:128
PLIST_ENTRY next
Definition: fxpkgio.cpp:130
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
FxIoQueue * m_DefaultQueue
Definition: fxpkgio.hpp:62
#define ASSERT(a)
Definition: mode.c:45
struct _test_info info[]
Definition: SetCursorPos.c:19
Definition: typedefs.h:119
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
#define NULL
Definition: types.h:112
LIST_ENTRY m_IoQueueListHead
Definition: fxpkgio.hpp:70
#define TRACINGIO
Definition: dbgtrace.h:66

Member Function Documentation

◆ AddIoQueue()

VOID FxPkgIo::AddIoQueue ( __inout FxIoQueue IoQueue)
private

Definition at line 1533 of file fxpkgio.cpp.

1536 {
1537  PLIST_ENTRY listHead, le;
1538  FxIoQueue* queue;
1539  KIRQL irql;
1540  FxIoQueueNode* listNode;
1541  CCHAR queueIndex, curIndex;
1542 
1543  listHead = &m_IoQueueListHead;
1544  queueIndex = FxDevice::GetCxDriverIndex(IoQueue->GetCxDeviceInfo());
1545  Lock(&irql);
1546 
1547  ASSERT(IoQueue->m_IoPkgListNode.IsNodeType(FxIoQueueNodeTypeQueue));
1548 
1549  //
1550  // Insert new queue in sorted list; search from last to first.
1551  //
1552  for (le = listHead->Blink; le != listHead; le = le->Blink) {
1553  //
1554  // Skip any nodes that are not queues. They can be bookmarks for
1555  // in-progress flush operations.
1556  //
1557  listNode = FxIoQueueNode::_FromListEntry(le);
1558  if (listNode->IsNodeType(FxIoQueueNodeTypeQueue) == FALSE) {
1559  continue;
1560  }
1561 
1562  //
1563  // Get current queue's driver index.
1564  //
1566  curIndex = FxDevice::GetCxDriverIndex(queue->GetCxDeviceInfo());
1567  //
1568  // Queues are inserted in order at the end of its allowed range.
1569  //
1570  if (curIndex < queueIndex || curIndex == queueIndex) {
1571  break;
1572  }
1573  }
1574 
1575  InsertHeadList(le, &IoQueue->m_IoPkgListNode.m_ListEntry);
1576 
1577  if (m_PowerStateOn) {
1578  IoQueue->SetPowerState(FxIoQueuePowerOn);
1579  } else {
1580  IoQueue->SetPowerState(FxIoQueuePowerOff);
1582  // Clear accept requests
1583  IoQueue->SetStateForShutdown();
1584  }
1585  }
1586 
1587  Unlock(irql);
1588 
1589  return;
1590 }
__drv_restoresIRQL KIRQL __in BOOLEAN Unlock
Definition: fxobject.hpp:1474
FxIoQueue * queue
struct _LIST_ENTRY * Blink
Definition: typedefs.h:122
FORCEINLINE VOID InsertHeadList(_Inout_ PLIST_ENTRY ListHead, _Inout_ __drv_aliasesMem PLIST_ENTRY Entry)
Definition: rtlfuncs.h:201
__inline BOOLEAN IsNodeType(__in FxIoQueueNodeType NodeType)
Definition: fxioqueue.hpp:117
static __inline FxIoQueue * _FromIoPkgListEntry(__in PLIST_ENTRY Entry)
Definition: fxioqueue.hpp:1216
static FxIoQueueNode * _FromListEntry(__in PLIST_ENTRY Entry)
Definition: fxioqueue.hpp:98
BOOLEAN m_PowerStateOn
Definition: fxpkgio.hpp:86
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define FALSE
Definition: types.h:117
static __inline CCHAR GetCxDriverIndex(__in FxCxDeviceInfo *CxDeviceInfo)
Definition: fxdevice.hpp:1640
BOOLEAN m_QueuesAreShuttingDown
Definition: fxpkgio.hpp:91
Definition: _queue.h:59
#define ASSERT(a)
Definition: mode.c:45
char CCHAR
Definition: typedefs.h:51
Definition: typedefs.h:119
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
Definition: wdfsync.h:124
LIST_ENTRY m_IoQueueListHead
Definition: fxpkgio.hpp:70
KIRQL irql
Definition: fxpkgio.cpp:562

Referenced by CreateQueue().

◆ ConfigureDynamicDispatching()

_Must_inspect_result_ NTSTATUS FxPkgIo::ConfigureDynamicDispatching ( __in UCHAR  MajorFunction,
__in_opt FxCxDeviceInfo CxDeviceInfo,
__in PFN_WDFDEVICE_WDM_IRP_DISPATCH  EvtDeviceWdmIrpDispatch,
__in_opt WDFCONTEXT  DriverContext 
)

Definition at line 786 of file fxpkgio.cpp.

792 {
796  FxIrpDynamicDispatchInfo* dispatchInfo;
797  LONG mjIndex;
798  CCHAR driverIndex;
799  BOOLEAN addNew;
800 
802  addNew = TRUE;
803 
805 
806  //
807  // Indirect MajorFunction validation.
808  //
812  "Invalid MajorFunction %!IRPMJ!, %!STATUS!",
814  goto Done;
815  }
816 
817  //
818  // Get driver I/O device path index.
819  //
820  driverIndex = FxDevice::GetCxDriverIndex(CxDeviceInfo);
821 
822  //
823  // Insert new info into correct slot in the I/O path.
824  // Index goes from higher to lower (..., 2, 1, 0) b/c cx's callback is called before
825  // client's one.
826  //
829  next = next->Flink) {
830 
831  CCHAR curIndex = 0;
832 
833  dispatchInfo = CONTAINING_RECORD(next,
835  ListEntry);
836  //
837  // Get current I/O device path index.
838  //
839  curIndex = FxDevice::GetCxDriverIndex(dispatchInfo->CxDeviceInfo);
840  if (driverIndex == curIndex) {
841  //
842  // Found it.
843  //
844  if (dispatchInfo->Dispatch[mjIndex].EvtDeviceDynamicDispatch != NULL) {
848  "Driver %p has already set a dispatch callback for "
849  "%!IRPMJ!, %!STATUS!",
850  CxDeviceInfo == NULL ?
851  GetDriver()->GetHandle() :
852  CxDeviceInfo->Driver->GetHandle(),
854  goto Done;
855  }
856 
857  dispatchInfo->Dispatch[mjIndex].DriverContext = DriverContext;
858  dispatchInfo->Dispatch[mjIndex].EvtDeviceDynamicDispatch =
860 
861  ASSERT(dispatchInfo->CxDeviceInfo == CxDeviceInfo);
862 
863  addNew = FALSE;
864  break;
865  }
866  else if (driverIndex > curIndex) {
867  //
868  // Not found (past valid range), add one before current.
869  //
870  break;
871  }
872  else if (driverIndex < curIndex) {
873  //
874  // Keep looking, too high.
875  //
876  continue;
877  }
878  }
879 
880  if (addNew) {
881  dispatchInfo = new(fxDriverGlobals) FxIrpDynamicDispatchInfo();
882  if (dispatchInfo == NULL) {
886  "Couldn't create object DynamicDispatchInfo, %!STATUS!",
887  status);
888  goto Done;
889  }
890 
891  dispatchInfo->CxDeviceInfo = CxDeviceInfo;
892  dispatchInfo->Dispatch[mjIndex].DriverContext = DriverContext;
893  dispatchInfo->Dispatch[mjIndex].EvtDeviceDynamicDispatch =
895 
896  //
897  // We must insert it before 'next' element.
898  //
899  InsertTailList(next, &dispatchInfo->ListEntry);
900  }
901 
903 
904 Done:
905  return status;
906 }
#define GetHandle(h)
Definition: treelist.c:116
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
LIST_ENTRY m_DynamicDispatchInfoListHead
Definition: fxpkgio.hpp:98
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
#define InsertTailList(ListHead, Entry)
static __inline int Mj2Index(UCHAR MajorFunction)
#define FALSE
Definition: types.h:117
long LONG
Definition: pedump.c:60
static __inline CCHAR GetCxDriverIndex(__in FxCxDeviceInfo *CxDeviceInfo)
Definition: fxdevice.hpp:1640
unsigned char BOOLEAN
PLIST_ENTRY next
Definition: fxpkgio.cpp:130
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
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define TRACINGDEVICE
Definition: dbgtrace.h:58
#define ASSERT(a)
Definition: mode.c:45
_Must_inspect_result_ _In_ WDFDEVICE _In_opt_ WDFDRIVER _In_ UCHAR _In_ PFN_WDFDEVICE_WDM_IRP_DISPATCH EvtDeviceWdmIrpDispatch
char CCHAR
Definition: typedefs.h:51
Definition: typedefs.h:119
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
_In_ UCHAR MajorFunction
Definition: wdfdevice.h:1697
Info Dispatch[DynamicDispatchMax]
PFX_DRIVER_GLOBALS fxDriverGlobals
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
#define NULL
Definition: types.h:112
return status
Definition: fxpkgio.cpp:159
#define STATUS_SUCCESS
Definition: shellext.h:65
#define TRACINGIO
Definition: dbgtrace.h:66
_In_ UCHAR _In_ UCHAR _In_ ULONG _In_ WDFCONTEXT DriverContext
Definition: wdfdevice.h:1697
PFN_WDFDEVICE_WDM_IRP_DISPATCH EvtDeviceDynamicDispatch
FxDriver * GetDriver(VOID)
Definition: fxpkgio.cpp:543
Definition: ps.c:97

◆ ConfigureForwarding()

_Must_inspect_result_ NTSTATUS FxPkgIo::ConfigureForwarding ( __inout FxIoQueue TargetQueue,
__in WDF_REQUEST_TYPE  RequestType 
)

Definition at line 910 of file fxpkgio.cpp.

914 {
915  PFX_DRIVER_GLOBALS FxDriverGlobals = GetDriverGlobals();
916  KIRQL irql;
918 
920 
921  if(TargetQueue->IsIoEventHandlerRegistered(RequestType) == FALSE){
924  "Must have EvtIoDefault or %!WDF_REQUEST_TYPE! "
925  "specific dispatch event registered for "
926  "WDFQUEUE 0x%p, %!STATUS!", RequestType,
927  TargetQueue->GetObjectHandle(),
928  status);
929  FxVerifierDbgBreakPoint(FxDriverGlobals);
930  return status;
931  }
932 
933  // Lock IoPackage data structure
934 
935  Lock(&irql);
936 
937  if (TargetQueue == m_DefaultQueue) {
940  "Default WDFQUEUE 0x%p cannot be configured to "
941  "dispatch specific type of request, %!STATUS!",
942  TargetQueue->GetObjectHandle(),
943  status);
944  FxVerifierDbgBreakPoint(FxDriverGlobals);
945  Unlock(irql);
946  return status;
947  }
948 
949  // Error if already has an entry
950  if (m_DispatchTable[RequestType] != NULL &&
954  "%!WDF_REQUEST_TYPE! is already configured for"
955  "WDFQUEUE 0x%p, %!STATUS!", RequestType,
956  TargetQueue->GetObjectHandle(),
957  status);
958  FxVerifierDbgBreakPoint(FxDriverGlobals);
959  Unlock(irql);
960  return status;
961  }
962 
963  //
964  // We don't take an extra reference count since we already
965  // have one from our associated list (DriverQueues)
966  //
967  m_DispatchTable[RequestType] = TargetQueue;
968 
969  //
970  // Queues configured to auto-dispatch requests cannot be deleted
971  //
972  TargetQueue->MarkNoDeleteDDI();
973 
974  Unlock(irql);
975 
976  return STATUS_SUCCESS;
977 }
__drv_restoresIRQL KIRQL __in BOOLEAN Unlock
Definition: fxobject.hpp:1474
#define STATUS_WDF_BUSY
Definition: wdfstatus.h:126
#define IRP_MJ_MAXIMUM_FUNCTION
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
FxIoQueue * m_DispatchTable[IRP_MJ_MAXIMUM_FUNCTION+1]
Definition: fxpkgio.hpp:75
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFQUEUE _In_ _Strict_type_match_ WDF_REQUEST_TYPE RequestType
Definition: wdfdevice.h:4227
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define FALSE
Definition: types.h:117
FxIoQueue * m_DefaultQueue
Definition: fxpkgio.hpp:62
#define ASSERT(a)
Definition: mode.c:45
VOID MarkNoDeleteDDI(__in FxObjectLockState State=ObjectLock)
Definition: fxobject.hpp:1118
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
#define NULL
Definition: types.h:112
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
Definition: wdfsync.h:124
return status
Definition: fxpkgio.cpp:159
#define STATUS_SUCCESS
Definition: shellext.h:65
#define TRACINGIO
Definition: dbgtrace.h:66
FxVerifierDbgBreakPoint(pFxDriverGlobals)
KIRQL irql
Definition: fxpkgio.cpp:562
Definition: ps.c:97

Referenced by __drv_strictTypeMatch().

◆ CreateQueue()

_Must_inspect_result_ NTSTATUS FxPkgIo::CreateQueue ( __in PWDF_IO_QUEUE_CONFIG  Config,
__in PWDF_OBJECT_ATTRIBUTES  QueueAttributes,
__in_opt FxDriver Caller,
__deref_out FxIoQueue **  ppQueue 
)

Definition at line 981 of file fxpkgio.cpp.

987 {
989  FxObject* pParent;
990  FxIoQueue* pQueue;
992  FxDriver* pDriver;
993 
994  pParent = NULL;
995  pQueue = NULL;
996  pDriver = NULL;
998 
999  if (QueueAttributes != NULL && QueueAttributes->ParentObject != NULL) {
1000  CfxDeviceBase* pSearchDevice;
1001 
1003  QueueAttributes->ParentObject,
1005  (PVOID*)&pParent);
1006 
1007  pSearchDevice = FxDeviceBase::_SearchForDevice(pParent, NULL);
1008 
1009  if (pSearchDevice == NULL) {
1011 
1014  "QueueAttributes->ParentObject 0x%p must have WDFDEVICE as an "
1015  "eventual ancestor, %!STATUS!",
1016  QueueAttributes->ParentObject, status);
1017 
1018  return status;
1019  }
1020  else if (pSearchDevice != m_DeviceBase) {
1022 
1025  "Attributes->ParentObject 0x%p ancestor is WDFDEVICE %p, but "
1026  "not the same WDFDEVICE 0x%p passed to WdfIoQueueCreate, "
1027  "%!STATUS!",
1028  QueueAttributes->ParentObject, pSearchDevice->GetHandle(),
1029  m_Device->GetHandle(), status);
1030 
1031  return status;
1032  }
1033  }
1034  else {
1035  //
1036  // By default, use the package as the parent
1037  //
1038  pParent = this;
1039  }
1040 
1041  //
1042  // v1.11 and up: get driver object if driver handle is specified.
1043  // Client driver can also specify a driver handle, the end result in this case is
1044  // a PkgIoContext that is NULL (see below), i.e., the same as if driver handle
1045  // was NULL.
1046  //
1047  if (Config->Size > sizeof(WDF_IO_QUEUE_CONFIG_V1_9) &&
1048  Config->Driver != NULL) {
1049 
1051  Config->Driver,
1053  (PVOID*)&pDriver);
1054  }
1055 
1058  Config,
1059  Caller,
1060  this,
1062  &pQueue
1063  );
1064 
1065  if (!NT_SUCCESS(status)) {
1066  ASSERT(pQueue == NULL);
1067  return status;
1068  }
1069 
1070  //
1071  // Class extension support: associate queue with a specific cx layer.
1072  //
1073  if (pDriver != NULL) {
1075  }
1076 
1078  if (!NT_SUCCESS(status)) {
1080  return status;
1081  }
1082 
1083  AddIoQueue(pQueue);
1084  *ppQueue = pQueue;
1085 
1086  return status;
1087 }
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
FxIoQueue * pQueue
_Must_inspect_result_ NTSTATUS Commit(__in_opt PWDF_OBJECT_ATTRIBUTES Attributes, __out_opt WDFOBJECT *ObjectHandle, __in_opt FxObject *Parent=NULL, __in BOOLEAN AssignDriverAsDefaultParent=TRUE)
Definition: fxobject.cpp:904
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)
Definition: fxioqueue.cpp:164
WDFDEVICE __inline GetHandle(VOID)
Definition: fxdevice.hpp:237
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN m_PowerStateOn
Definition: fxpkgio.hpp:86
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
FxObjectHandleGetPtr(GetFxDriverGlobals(DriverGlobals), Fdo, FX_TYPE_DEVICE,(PVOID *)&pFdo)
static FxDeviceBase * _SearchForDevice(__in FxObject *Object, __out_opt IFxHasCallbacks **Callbacks)
FxDriver * Driver
Definition: fxglobals.h:374
__inline VOID SetCxDeviceInfo(__in FxCxDeviceInfo *CxDeviceInfo)
Definition: fxioqueue.hpp:1351
FxDriver * pDriver
PFX_DRIVER_GLOBALS pFxDriverGlobals
#define ASSERT(a)
Definition: mode.c:45
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
VOID AddIoQueue(__inout FxIoQueue *IoQueue)
Definition: fxpkgio.cpp:1533
CfxDeviceBase * m_DeviceBase
Definition: fxobject.hpp:328
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_CHILD_LIST_CONFIG Config
Definition: wdfchildlist.h:474
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
FxCxDeviceInfo * GetCxDeviceInfo(__in FxDriver *CxDriver)
Definition: fxdevice.hpp:1560
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
#define NULL
Definition: types.h:112
VOID DeleteFromFailedCreate(VOID)
Definition: fxobject.cpp:391
FxObject * pParent
Definition: fxdpcapi.cpp:86
return status
Definition: fxpkgio.cpp:159
#define TRACINGIO
Definition: dbgtrace.h:66
Definition: ps.c:97

Referenced by FxPkgGeneral::PostCreateDeviceInitialize().

◆ Dispatch()

_Must_inspect_result_ NTSTATUS FxPkgIo::Dispatch ( __inout MdIrp  Irp)
virtual

Definition at line 104 of file fxpkgio.cpp.

107 {
108  FxIrp fxIrp(Irp);
110 
113  "WDFDEVICE 0x%p !devobj 0x%p %!IRPMJ!, IRP_MN %x, IRP 0x%p",
117 
119 }
CfxDevice * m_Device
Definition: fxobject.hpp:329
LIST_ENTRY m_DynamicDispatchInfoListHead
Definition: fxpkgio.hpp:98
MdDeviceObject __inline GetDeviceObject(VOID)
Definition: fxdevice.hpp:174
WDFDEVICE __inline GetHandle(VOID)
Definition: fxdevice.hpp:237
Definition: fxirp.hpp:28
_In_ PIRP Irp
Definition: csq.h:116
#define TRACE_LEVEL_VERBOSE
Definition: storswtr.h:30
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
_Must_inspect_result_ NTSTATUS __fastcall DispatchStep1(__inout MdIrp Irp, __in WDFCONTEXT DispatchContext)
Definition: fxpkgio.cpp:165
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
FxIrp fxIrp(Irp)
FX_TRACK_DRIVER(fxDriverGlobals)
UCHAR GetMinorFunction(VOID)
Definition: fxirpum.cpp:297
#define TRACINGIO
Definition: dbgtrace.h:66
UCHAR GetMajorFunction(VOID)
Definition: fxirpum.cpp:217

◆ DispatchStep1()

_Must_inspect_result_ NTSTATUS __fastcall FxPkgIo::DispatchStep1 ( __inout MdIrp  Irp,
__in WDFCONTEXT  DispatchContext 
)

Definition at line 165 of file fxpkgio.cpp.

188 {
190  FxIrp fxIrp(Irp);
191 
193 
195 
196  //
197  // Look for I/O dynamic dispatch callbacks.
198  //
200  int index;
202 
203  //
204  // Only read/writes/ctrls/internal_ctrls IRPs are allowed, i.e., request cannot
205  // IRP type in its callback.
206  //
211  "Driver cannot change the IRP type in its dispatch "
212  "callback Irp 0x%p, %!IRPMJ!, IRP_MN %x, Device 0x%p, "
213  "%!STATUS!",
217  goto CompleteIrp;
218  }
219 
220  //
221  // Verifier checks.
222  //
223  status = VerifyDispatchContext(GetDriverGlobals(), DispatchContext);
224  if( !NT_SUCCESS(status)){
225  goto CompleteIrp;
226  }
227 
228  do {
230 
233  ListEntry);
234  //
235  // Advance to next node.
236  //
239 
244 
245  //
246  // If registered, invoke dispatch callback for this major function.
247  //
249  if (NULL != info->Dispatch[index].EvtDeviceDynamicDispatch){
250  return info->Dispatch[index].EvtDeviceDynamicDispatch(
251  m_Device->GetHandle(),
255  info->Dispatch[index].DriverContext,
256  reinterpret_cast<PIRP> (fxIrp.GetIrp()),
259  );
260  }
261  } while ((PLIST_ENTRY)DispatchContext !=
263  }
264 
265  //
266  // Only now push these local variables on the stack, this is to keep the
267  // stack from growing unnecessarily in the dynamic dispatch path above.
268  //
269  FxIoQueue* queue;
271 
272  //
273  // Get the queue from the dispatch-table
274  //
276  if (queue == NULL) {
278  if (ioInCallerCtx->m_Method == NULL) {
279  //
280  // No queue configured yet, fail request unless the driver is a filter.
281  //
282  if (m_Filter) {
283  goto Forward;
284  }
285 
289  "No queue configured for WDFDEVICE 0x%p, failing IRP 0x%p,"
290  " %!STATUS!",
292 
293  goto CompleteIrp;
294  }
295  }
296  else {
297  ioInCallerCtx = GetIoInCallerContextCallback(queue->GetCxDeviceInfo());
298  }
299 
300  //
301  // If the driver is filter and queue is a default-queue then before
302  // calling the queue, we should make sure the queue can dispatch
303  // requests to the driver. If the queue cannot dispatch request,
304  // we should forward it down to the lower driver ourself.
305  // This is to cover the scenario where the driver has registered only
306  // type specific handler and expect the framework to auto-forward other
307  // requests.
308  //
309  if (m_Filter &&
311  queue == m_DefaultQueue &&
312  queue->IsIoEventHandlerRegistered((WDF_REQUEST_TYPE)fxIrp.GetMajorFunction()) == FALSE) {
313  //
314  // Default queue doesn't have callback events registered to
315  // handle this request. So forward it down.
316  //
317  goto Forward;
318  }
319 
320  //
321  // Finally queue request.
322  //
324 
325 Forward:
326 
329 
331 
335 
336  return status;
337 }
CfxDevice * m_Device
Definition: fxobject.hpp:329
_In_ UCHAR _In_ UCHAR _In_ ULONG _In_ WDFCONTEXT _Inout_ PIRP _In_ WDFCONTEXT DispatchContext
Definition: wdfdevice.h:1697
FxIoQueue * queue
LIST_ENTRY m_DynamicDispatchInfoListHead
Definition: fxpkgio.hpp:98
VOID SetStatus(__in NTSTATUS Status)
Definition: fxirpum.cpp:457
WDFDEVICE __inline GetHandle(VOID)
Definition: fxdevice.hpp:237
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define IRP_MJ_MAXIMUM_FUNCTION
LONG NTSTATUS
Definition: precomp.h:26
Definition: fxirp.hpp:28
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
FxIoQueue * m_DispatchTable[IRP_MJ_MAXIMUM_FUNCTION+1]
Definition: fxpkgio.hpp:75
static __inline int Mj2Index(UCHAR MajorFunction)
_Must_inspect_result_ NTSTATUS __fastcall DispatchStep2(__inout MdIrp Irp, __in_opt FxIoInCallerContext *IoInCallerCtx, __in_opt FxIoQueue *Queue)
Definition: fxpkgio.cpp:342
VOID CompleteIrp(IN PIRP Irp, IN NTSTATUS Status, IN ULONG_PTR Information)
Definition: pnp.c:12
uint32_t ULONG_PTR
Definition: typedefs.h:65
BOOLEAN m_Filter
Definition: fxpkgio.hpp:84
#define FALSE
Definition: types.h:117
_In_ PIRP Irp
Definition: csq.h:116
VOID SkipCurrentIrpStackLocation(VOID)
Definition: fxirpum.cpp:400
Definition: _queue.h:59
NTSTATUS CallDriver(__in MdDeviceObject DeviceObject)
Definition: fxirpum.cpp:36
MdDeviceObject __inline GetAttachedDevice(VOID)
Definition: fxdevice.hpp:210
FxIoInCallerContext * ioInCallerCtx
GLuint index
Definition: glext.h:6031
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
FxIoQueue * m_DefaultQueue
Definition: fxpkgio.hpp:62
PVOID WDFCONTEXT
Definition: wdftypes.h:94
enum _WDF_REQUEST_TYPE WDF_REQUEST_TYPE
#define ASSERT(a)
Definition: mode.c:45
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
VOID CompleteRequest(__in_opt CCHAR PriorityBoost=IO_NO_INCREMENT)
Definition: fxirpum.cpp:24
PFN_WDF_IO_IN_CALLER_CONTEXT m_Method
VOID SetInformation(__in ULONG_PTR Information)
Definition: fxirpum.cpp:504
#define IRP_MJ_INTERNAL_DEVICE_CONTROL
struct _test_info info[]
Definition: SetCursorPos.c:19
unsigned char UCHAR
Definition: xmlstorage.h:181
#define index(s, c)
Definition: various.h:29
Definition: typedefs.h:119
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
MdIrp GetIrp(VOID)
Definition: fxirpum.cpp:15
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
FxIrp fxIrp(Irp)
#define NULL
Definition: types.h:112
#define IRP_MJ_READ
Definition: rdpdr.c:46
UCHAR GetMinorFunction(VOID)
Definition: fxirpum.cpp:297
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define ULONG_PTR
Definition: config.h:101
#define IRP_MJ_WRITE
Definition: rdpdr.c:47
return status
Definition: fxpkgio.cpp:159
#define TRACINGIO
Definition: dbgtrace.h:66
ULONG GetParameterIoctlCode(VOID)
Definition: fxirpum.cpp:1474
UCHAR GetMajorFunction(VOID)
Definition: fxirpum.cpp:217
#define FX_IN_DISPATCH_CALLBACK
Definition: fxpkgio.hpp:39
__inline FxIoInCallerContext * GetIoInCallerContextCallback(__in_opt FxCxDeviceInfo *CxDeviceInfo)
Definition: fxpkgio.hpp:396
FxVerifierDbgBreakPoint(pFxDriverGlobals)
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52
Definition: ps.c:97

Referenced by Dispatch().

◆ DispatchStep2()

_Must_inspect_result_ NTSTATUS __fastcall FxPkgIo::DispatchStep2 ( __inout MdIrp  Irp,
__in_opt FxIoInCallerContext IoInCallerCtx,
__in_opt FxIoQueue Queue 
)

Definition at line 342 of file fxpkgio.cpp.

347 {
350  BOOLEAN isForwardProgressQueue;
351  BOOLEAN inCriticalRegion;
352  PWDF_OBJECT_ATTRIBUTES reqAttribs;
353  FxIrp fxIrp(Irp);
354 
355  request = NULL;
356  inCriticalRegion = FALSE;
357  isForwardProgressQueue = Queue != NULL && Queue->IsForwardProgressQueue();
358 
360  ASSERT((IoInCallerCtx != NULL && IoInCallerCtx->m_Method != NULL) ||
361  Queue != NULL);
362  //
363  // The request inserted into the queue can be retrieved and processed
364  // by an arbitrary thread. So we need to make sure that such a thread doesn't
365  // get suspended and deadlock the driver and potentially the system by
366  // entering critical region.The KeEnterCriticalRegion temporarily disables
367  // the delivery of normal kernel APCs used to suspend a thread.
368  // Kernel APCs queued to this thread will get executed when we leave the
369  // critical region.
370  //
371  if (Mx::MxGetCurrentIrql() <= APC_LEVEL) {
372  Mx::MxEnterCriticalRegion();
373  inCriticalRegion = TRUE;
374  }
375 
376  if (Queue != NULL && Queue->GetCxDeviceInfo() != NULL) {
377  reqAttribs = &Queue->GetCxDeviceInfo()->RequestAttributes;
378  }
379  else {
380  reqAttribs = m_Device->GetRequestAttributes();
381  }
382 
384 
385  //
386  // Check if it is forward progress queue and the EnhancedVerifierOption for
387  // testing forward progress are set.
388  //
389  if (isForwardProgressQueue &&
390  NT_SUCCESS(status) &&
392  //
393  // This function returns STATUS_INSUFFICIENT_RESOURCES
394  // if testing forward progress is enabled and free's the passed in request.
395  //
397  }
398 
399  if (!NT_SUCCESS(status)) {
400  if (m_Filter && Queue == NULL) {
401  goto CompleteIrp;
402  }
403 
404  if (isForwardProgressQueue) {
405  status = Queue->GetReservedRequest(Irp, &request);
406  if (status == STATUS_PENDING) {
407  goto IrpIsGone;
408  }
409  else if (!NT_SUCCESS(status)) {
410  goto CompleteIrp;
411  }
412  }
413  else {
414  //
415  // Fail the request
416  //
419  "Could not create WDFREQUEST, %!STATUS!", status);
420 
421  goto CompleteIrp;
422  }
423  }
424  else {
425  if (isForwardProgressQueue) {
426  status = Queue->InvokeAllocateResourcesCallback(request);
427  if (!NT_SUCCESS(status)) {
428  //
429  // Failure of the callback means the driver wasn't able to
430  // allocate resources for the request. In that case free the
431  // request allocated earlier and use the reserved one.
432  //
433  request->FreeRequest();
434  request = NULL;
435 
436  status = Queue->GetReservedRequest(Irp, &request);
437  if (status == STATUS_PENDING) {
438  goto IrpIsGone;
439  }
440  else if (!NT_SUCCESS(status)) {
441  goto CompleteIrp;
442  }
443  }
444  }
445  }
446 
447  //
448  // Since we can't guarantee the callback to be called in the context of the
449  // caller for reserved requests, we will skip calling InCallerContextCallback
450  // for reserverd request.
451  //
452  if (IoInCallerCtx != NULL &&
453  IoInCallerCtx->m_Method != NULL &&
454  request->IsReserved() == FALSE) {
455 
456  request->SetInternalContext(Queue);
458 
459  //
460  // The driver is responsible for calling WdfDeviceEnqueueRequest to
461  // insert it back into the I/O processing pipeline, or completing it.
462  //
463  goto IrpIsGone;
464  }
465 
466  ASSERT(Queue != NULL);
467  status = Queue->QueueRequest(request);
468  goto IrpIsGone;
469 
471 
475  //
476  // fallthrough
477  //
478 IrpIsGone:
479 
480  if (inCriticalRegion) {
481  Mx::MxLeaveCriticalRegion();
482  }
483 
484  return status;
485 }
NTSTATUS DispathToInCallerContextCallback(__in FxIoInCallerContext *InCallerContextInfo, __in FxRequest *Request, __inout MdIrp Irp)
Definition: fxpkgio.cpp:1699
CfxDevice * m_Device
Definition: fxobject.hpp:329
VOID SetStatus(__in NTSTATUS Status)
Definition: fxirpum.cpp:457
#define TRUE
Definition: types.h:120
_Must_inspect_result_ _In_ WDFDEVICE _In_ PIRP _In_ WDFQUEUE Queue
Definition: wdfdevice.h:2221
#define IRP_MJ_MAXIMUM_FUNCTION
LONG NTSTATUS
Definition: precomp.h:26
Definition: fxirp.hpp:28
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
VOID CompleteIrp(IN PIRP Irp, IN NTSTATUS Status, IN ULONG_PTR Information)
Definition: pnp.c:12
FxRequest * request
BOOLEAN m_Filter
Definition: fxpkgio.hpp:84
#define FALSE
Definition: types.h:117
_In_ PIRP Irp
Definition: csq.h:116
unsigned char BOOLEAN
#define ASSERT(a)
Definition: mode.c:45
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
VOID CompleteRequest(__in_opt CCHAR PriorityBoost=IO_NO_INCREMENT)
Definition: fxirpum.cpp:24
VOID SetInformation(__in ULONG_PTR Information)
Definition: fxirpum.cpp:504
static __inline KIRQL MxGetCurrentIrql()
Definition: mxgeneralkm.h:86
_Must_inspect_result_ NTSTATUS VerifierFreeRequestToTestForwardProgess(__in FxRequest *Request)
Definition: fxpkgio.cpp:1758
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
__inline BOOLEAN IsFxVerifierTestForwardProgress(__in PFX_DRIVER_GLOBALS FxDriverGlobals)
Definition: fxverifier.h:235
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
FxIrp fxIrp(Irp)
#define NULL
Definition: types.h:112
Definition: tftpd.h:85
__inline PWDF_OBJECT_ATTRIBUTES GetRequestAttributes(VOID)
Definition: fxdevice.hpp:1315
#define IO_NO_INCREMENT
Definition: iotypes.h:598
return status
Definition: fxpkgio.cpp:159
#define TRACINGIO
Definition: dbgtrace.h:66
UCHAR GetMajorFunction(VOID)
Definition: fxirpum.cpp:217
#define APC_LEVEL
Definition: env_spec_w32.h:695
Definition: ps.c:97

Referenced by DispatchStep1(), and FxIoTargetSelf::Send().

◆ DispathToInCallerContextCallback()

NTSTATUS FxPkgIo::DispathToInCallerContextCallback ( __in FxIoInCallerContext InCallerContextInfo,
__in FxRequest Request,
__inout MdIrp  Irp 
)

Definition at line 1699 of file fxpkgio.cpp.

1704 {
1706  FxRequestCompletionState oldState;
1707  FxIrp fxIrp(Irp);
1708 
1710 
1711  //
1712  // Mark the IRP pending since we are going
1713  // to return STATUS_PENDING regardless of whether
1714  // the driver completes the request right away
1715  // or not
1716  //
1718 
1722  }
1723 
1724  //
1725  // Set a completion callback to manage the reference
1726  // count on the request
1727  //
1728  oldState = Request->SetCompletionState(FxRequestCompletionStateIoPkg);
1729 
1730  ASSERT(oldState == FxRequestCompletionStateNone);
1731  UNREFERENCED_PARAMETER(oldState);
1732 
1733  //
1734  // Release the reference count on the request since
1735  // the callback will hold the only one that gets
1736  // decremented when the request is completed
1737  //
1738  Request->RELEASE(FXREQUEST_STATE_TAG);
1739 
1740  Request->SetPresented();
1741 
1742  //
1743  // Drivers that use this API are responsible for handling
1744  // all locking, threading, and IRQL level issues...
1745  //
1746  InCallerContextInfo->Invoke(m_Device->GetHandle(),
1747  Request->GetHandle());
1748  //
1749  // The driver is responsible for calling WdfDeviceEnqueueRequest to insert
1750  // it back into the I/O processing pipeline, or completing it.
1751  //
1752 
1753  return STATUS_PENDING;
1754 }
CfxDevice * m_Device
Definition: fxobject.hpp:329
BOOLEAN FxVerifierOn
Definition: fxglobals.h:420
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
WDFDEVICE __inline GetHandle(VOID)
Definition: fxdevice.hpp:237
Definition: fxirp.hpp:28
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
_In_ PIRP Irp
Definition: csq.h:116
#define FXREQUEST_STATE_TAG
Definition: fxrequest.hpp:42
PFX_DRIVER_GLOBALS pFxDriverGlobals
#define ASSERT(a)
Definition: mode.c:45
#define STATUS_PENDING
Definition: ntstatus.h:82
FxRequestCompletionState
VOID MarkIrpPending()
Definition: fxirpum.cpp:415
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
FxIrp fxIrp(Irp)

Referenced by DispatchStep2().

◆ EnqueueRequest()

_Must_inspect_result_ NTSTATUS FxPkgIo::EnqueueRequest ( __in CfxDevice Device,
__inout FxRequest pRequest 
)

Definition at line 607 of file fxpkgio.cpp.

611 {
613  FxIoQueue* pQueue;
614  FxIrp* Irp = NULL;
615  FxRequestCompletionState oldState;
616  PFX_DRIVER_GLOBALS FxDriverGlobals = GetDriverGlobals();
617  SHORT origVerifierFlags = 0;
618 
619  //
620  // Request is owned by the driver, and has a reference count of == 1
621  // (or > 1 if EvtIoInCallerContext callback took an additional reference),
622  // with a FxPkgIoInProcessRequestComplete callback registered.
623  //
624  ASSERT(pRequest->GetRefCnt() >= 1);
625 
626  Irp = pRequest->GetFxIrp();
627 
629  "WDFREQUEST 0x%p", pRequest->GetObjectHandle());
630 
631  status = VerifyEnqueueRequestUpdateFlags(FxDriverGlobals,
632  pRequest,
633  &origVerifierFlags);
634  if (!NT_SUCCESS(status)) {
635  return status;
636  }
637 
638  //
639  // Get the associated queue
640  //
642  if (NULL == pQueue) {
643  pQueue = m_DispatchTable[Irp->GetMajorFunction()];
644  if (pQueue == NULL) {
645  //
646  // No queue configured yet, fail request unless the driver is a filter.
647  //
648  if (m_Filter) {
649  goto Forward;
650  }
651 
653 
655  "No queue configured for WDFDEVICE 0x%p, "
656  "failing WDFREQUEST 0x%p %!STATUS!",
657  Device->GetHandle(),
659  status);
660 
661  FxVerifierDbgBreakPoint(FxDriverGlobals);
662 
663  //
664  // Return it back to the driver to decide the outcome
665  //
666  goto Error;
667  }
668  }
669 
670  //
671  // If the queue is a default-queue and driver is a filter then before
672  // calling the queue we should make sure the queue can dispatch
673  // requests to the driver. If the queue cannot dispatch request,
674  // we should forward it down to the lower driver ourself.
675  if (m_Filter &&
676  pQueue == m_DefaultQueue &&
677  pQueue->IsIoEventHandlerRegistered((WDF_REQUEST_TYPE)Irp->GetMajorFunction()) == FALSE) {
678  //
679  // Default queue doesn't have callback events registered to
680  // handle this request. So forward it down.
681  //
682  goto Forward;
683  }
684 
685  pQueue->AddRef();
686 
687  // Must add a reference before releasing the callback and its reference
688  pRequest->ADDREF(FXREQUEST_STATE_TAG);
689 
690  // Release the callback
693  UNREFERENCED_PARAMETER(oldState);
694 
696 
697  pQueue->Release();
698 
699  //
700  // If not successfull, must place the request back
701  // to the state it was in on entry so that the driver
702  // can decide what to do next with it
703  //
704  if (!NT_SUCCESS(status)) {
705 
706  //
707  // If the request comes back to us, it should still
708  // have a reference count of 1
709  //
711 
713  UNREFERENCED_PARAMETER(oldState);
714 
715  //
716  // Release the reference count on the request since
717  // the callback will hold the only one that gets
718  // decremented when the request is completed
719  //
720  pRequest->RELEASE(FXREQUEST_STATE_TAG);
721  goto Error;
722  }
723  else {
724  //
725  // On success, can not touch the request since it
726  // may have already been completed
727  //
728  }
729 
730  return status;
731 
732 Forward:
733 
734  //
735  // Cannot send-and-forget a request with a formatted IO context.
736  //
737  if (pRequest->HasContext()) {
739 
741  FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGIO,
742  "Cannot send-and-forget WDFREQUEST 0x%p with formatted IO"
743  " context for filter WDFDEVICE 0x%p, %!STATUS!",
745  Device->GetHandle(),
746  status );
747 
748  FxVerifierDbgBreakPoint(FxDriverGlobals);
749  goto Error;
750  }
751 
752  //
753  // This will skip the current stack location and perform
754  // early dispose on the request.
755  //
757 
758  (VOID)Irp->CallDriver(Device->GetAttachedDevice());
759 
760  //
761  // This will delete the request and free the memory back
762  // to the device lookaside list.
763  //
765 
766  //
767  // Return a success status in this code path even if the previous call
768  // to send the request to the lower driver failed. The status code returned
769  // by this function should reflect the status of enqueuing the request and
770  // not the status returned by the lower driver.
771  //
772  return STATUS_SUCCESS;
773 
774 Error:
775 
776  //
777  // If not successful, we must set the original verifier flags.
778  //
779  VerifyEnqueueRequestRestoreFlags(FxDriverGlobals, pRequest, origVerifierFlags);
780 
781  return status;
782 }
FxRequestCompletionState SetCompletionState(__in FxRequestCompletionState NewState)
Definition: fxrequest.cpp:1760
virtual ULONG Release(__in_opt PVOID Tag=NULL, __in LONG Line=0, __in_opt PSTR File=NULL)
Definition: fxobject.hpp:853
FxIoQueue * pQueue
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
LONG NTSTATUS
Definition: precomp.h:26
FxRequest * pRequest
Definition: fxirp.hpp:28
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
FxIoQueue * m_DispatchTable[IRP_MJ_MAXIMUM_FUNCTION+1]
Definition: fxpkgio.hpp:75
VOID PostProcessSendAndForget(VOID)
Definition: fxrequest.cpp:1149
BOOLEAN m_Filter
Definition: fxpkgio.hpp:84
#define FALSE
Definition: types.h:117
_In_ PIRP Irp
Definition: csq.h:116
#define TRACE_LEVEL_VERBOSE
Definition: storswtr.h:30
short SHORT
Definition: pedump.c:59
PVOID __inline GetObjectHandle(VOID)
Definition: fxobject.hpp:603
VOID PreProcessSendAndForget(VOID)
Definition: fxrequest.cpp:1101
#define FXREQUEST_STATE_TAG
Definition: fxrequest.hpp:42
FxIoQueue * m_DefaultQueue
Definition: fxpkgio.hpp:62
enum _WDF_REQUEST_TYPE WDF_REQUEST_TYPE
#define ASSERT(a)
Definition: mode.c:45
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
__inline PVOID GetInternalContext(VOID)
Definition: fxrequest.hpp:1492
BOOL Error
Definition: chkdsk.c:66
FxRequestCompletionState
_Must_inspect_result_ NTSTATUS QueueRequestFromForward(__in FxRequest *pRequest)
Definition: fxioqueue.cpp:2351
FxIrp * GetFxIrp(VOID)
Definition: fxrequest.hpp:957
#define VOID
Definition: acefi.h:82
BOOLEAN IsIoEventHandlerRegistered(__in WDF_REQUEST_TYPE RequestType)
Definition: fxioqueue.cpp:6178
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
LONG GetRefCnt(VOID)
Definition: fxobject.hpp:758
__inline BOOLEAN HasContext(VOID)
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
#define NULL
Definition: types.h:112
ULONG __inline AddRef(__in_opt PVOID Tag=NULL, __in LONG Line=0, __in_opt PSTR File=NULL)
Definition: fxobject.hpp:826
return status
Definition: fxpkgio.cpp:159
#define STATUS_SUCCESS
Definition: shellext.h:65
#define TRACINGIO
Definition: dbgtrace.h:66
FxVerifierDbgBreakPoint(pFxDriverGlobals)
Definition: ps.c:97

◆ FlushAllQueuesByFileObject()

_Must_inspect_result_ NTSTATUS FxPkgIo::FlushAllQueuesByFileObject ( __in MdFileObject  FileObject)

Definition at line 1393 of file fxpkgio.cpp.

1412 {
1413  FxIoQueue* queue = NULL;
1416  KIRQL irql;
1417 
1419 
1421  "Currently framework allow flushing of queues "
1422  "by fileobject on cleanup only at PASSIVE_LEVEL");
1423 
1425  return STATUS_SUCCESS;
1426  }
1427 
1428  //
1429  // Iterate through the queue list and flush each one.
1430  //
1431  Lock(&irql);
1433  Unlock(irql);
1434 
1435  while(queue != NULL) {
1436 
1437  queue->FlushByFileObject(FileObject);
1438 
1439  queue->RELEASE(IO_ITERATOR_FLUSH_TAG);
1440 
1441  Lock(&irql);
1443  Unlock(irql);
1444  }
1445 
1446  return STATUS_SUCCESS;
1447 }
__drv_restoresIRQL KIRQL __in BOOLEAN Unlock
Definition: fxobject.hpp:1474
FxIoQueue * GetFirstIoQueueLocked(__in FxIoQueueNode *QueueBookmark, __in PVOID Tag)
Definition: fxpkgio.cpp:1610
FxIoQueue * GetNextIoQueueLocked(__in FxIoQueueNode *QueueBookmark, __in PVOID Tag)
Definition: fxpkgio.cpp:1640
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define IO_ITERATOR_FLUSH_TAG
Definition: fxpkgio.hpp:47
Definition: _queue.h:59
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547
PFX_DRIVER_GLOBALS pFxDriverGlobals
static __inline KIRQL MxGetCurrentIrql()
Definition: mxgeneralkm.h:86
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
#define NULL
Definition: types.h:112
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
Definition: wdfsync.h:124
#define STATUS_SUCCESS
Definition: shellext.h:65
#define TRACINGIO
Definition: dbgtrace.h:66
FxVerifierDbgBreakPoint(pFxDriverGlobals)
KIRQL irql
Definition: fxpkgio.cpp:562

Referenced by FxPkgGeneral::OnCleanup().

◆ FX_DECLARE_VF_FUNCTION_P1()

FxPkgIo::FX_DECLARE_VF_FUNCTION_P1 ( NTSTATUS  ,
VerifyDispatchContext  ,
_In_  WDFCONTEXT 
)

◆ FX_DECLARE_VF_FUNCTION_P2() [1/2]

FxPkgIo::FX_DECLARE_VF_FUNCTION_P2 ( NTSTATUS  ,
VerifyEnqueueRequestUpdateFlags  ,
_In_ FxRequest ,
_Inout_ SHORT  
)

◆ FX_DECLARE_VF_FUNCTION_P2() [2/2]

FxPkgIo::FX_DECLARE_VF_FUNCTION_P2 ( VOID  ,
VerifyEnqueueRequestRestoreFlags  ,
_In_ FxRequest ,
_In_  SHORT 
)

◆ GetDefaultQueue()

__inline FxIoQueue* FxPkgIo::GetDefaultQueue ( VOID  )
inline

Definition at line 243 of file fxpkgio.hpp.

246  {
247  return m_DefaultQueue;
248  }
FxIoQueue * m_DefaultQueue
Definition: fxpkgio.hpp:62

◆ GetDevice()

__inline CfxDevice* FxPkgIo::GetDevice ( VOID  )
inline

Definition at line 234 of file fxpkgio.hpp.

237  {
238  return m_Device;
239  }
CfxDevice * m_Device
Definition: fxobject.hpp:329

◆ GetDispatchQueue()

FxIoQueue* FxPkgIo::GetDispatchQueue ( _In_ UCHAR  MajorFunction)
inline

Definition at line 128 of file fxpkgio.hpp.

131  {
133  }
FxIoQueue * m_DispatchTable[IRP_MJ_MAXIMUM_FUNCTION+1]
Definition: fxpkgio.hpp:75
_In_ UCHAR MajorFunction
Definition: wdfdevice.h:1697

Referenced by FxIoTargetSelf::GetDispatchQueue().

◆ GetDriver()

__inline FxDriver * FxPkgIo::GetDriver ( VOID  )

Definition at line 543 of file fxpkgio.cpp.

546 {
547  return m_Device->GetDriver();
548 }
CfxDevice * m_Device
Definition: fxobject.hpp:329
__inline FxDriver * GetDriver(VOID)
Definition: fxdevice.hpp:164

Referenced by ConfigureDynamicDispatching(), and FxIoQueue::GetDriver().

◆ GetFirstIoQueueLocked()

FxIoQueue * FxPkgIo::GetFirstIoQueueLocked ( __in FxIoQueueNode QueueBookmark,
__in PVOID  Tag 
)
private

Definition at line 1610 of file fxpkgio.cpp.

1630 {
1631  ASSERT(QueueBookmark->IsNodeType(FxIoQueueNodeTypeBookmark));
1632  ASSERT(IsListEmpty(&QueueBookmark->m_ListEntry));
1633 
1634  InsertHeadList(&m_IoQueueListHead, &QueueBookmark->m_ListEntry);
1635 
1636  return GetNextIoQueueLocked(QueueBookmark, Tag);
1637 }
FORCEINLINE VOID InsertHeadList(_Inout_ PLIST_ENTRY ListHead, _Inout_ __drv_aliasesMem PLIST_ENTRY Entry)
Definition: rtlfuncs.h:201
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
FxIoQueue * GetNextIoQueueLocked(__in FxIoQueueNode *QueueBookmark, __in PVOID Tag)
Definition: fxpkgio.cpp:1640
#define ASSERT(a)
Definition: mode.c:45
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
Definition: wdfdevice.h:4061
LIST_ENTRY m_IoQueueListHead
Definition: fxpkgio.hpp:70

Referenced by FlushAllQueuesByFileObject().

◆ GetIoInCallerContextCallback()

__inline FxIoInCallerContext* FxPkgIo::GetIoInCallerContextCallback ( __in_opt FxCxDeviceInfo CxDeviceInfo)
inline

Definition at line 396 of file fxpkgio.hpp.

399  {
400  if (CxDeviceInfo != NULL) {
401  return &CxDeviceInfo->IoInCallerContextCallback;
402  }
403  else {
405  }
406  }
FxIoInCallerContext m_InCallerContextCallback
Definition: fxpkgio.hpp:103
#define NULL
Definition: types.h:112

Referenced by DispatchStep1(), and FxIoTargetSelf::Send().

◆ GetIoQueueListLocked()

VOID FxPkgIo::GetIoQueueListLocked ( __in PSINGLE_LIST_ENTRY  SListHead,
__inout FxIoIteratorList  ListType 
)
private

Definition at line 1480 of file fxpkgio.cpp.

1492 {
1493  PLIST_ENTRY listHead, le;
1494 
1495  listHead = &m_IoQueueListHead;
1496 
1497  if (FxIoQueueIteratorListPowerOn == ListType ||
1498  (FxIoQueueIteratorListPowerOff == ListType && // backwards compatibility order.
1499  m_Device->IsCxInIoPath() == FALSE)) {
1500  //
1501  // Power up: first client driver's queues then cx's queues.
1502  // List is already sorted with client driver's queue first.
1503  // Since we are inserting into the head of the single list head, if we walked
1504  // over the list from first to last, we would reverse the entries. By walking
1505  // the list backwards, we build the single list head in the order of m_IoQueueListHead.
1506  //
1507  for (le = listHead->Blink; le != listHead; le = le->Blink) {
1509  SListHead,
1511  }
1512  }
1513  else if (FxIoQueueIteratorListPowerOff == ListType) {
1514  //
1515  // Power down: first cx's queues then client driver's queues.
1516  // List is already sorted with client driver's queue first.
1517  // Since we are inserting into the head of the single list head, if we walked
1518  // over the list from last to first, we would reverse the entries. By walking
1519  // the list forwards, we build the single list head in the desired order
1520  //
1521  for (le = listHead->Flink; le != listHead; le = le->Flink) {
1523  SListHead,
1525  }
1526  }
1527  else {
1528  ASSERT(FALSE);
1529  }
1530 }
CfxDevice * m_Device
Definition: fxobject.hpp:329
struct _LIST_ENTRY * Blink
Definition: typedefs.h:122
#define FALSE
Definition: types.h:117
#define IO_ITERATOR_POWER_TAG
Definition: fxpkgio.hpp:48
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define ASSERT(a)
Definition: mode.c:45
Definition: typedefs.h:119
__inline BOOLEAN IsCxInIoPath(VOID)
Definition: fxdevice.hpp:1594
static VOID GetIoQueueList_ProcessQueueListEntry(PLIST_ENTRY QueueLE, PSINGLE_LIST_ENTRY SListHead, PVOID Tag)
Definition: fxpkgio.cpp:1451
LIST_ENTRY m_IoQueueListHead
Definition: fxpkgio.hpp:70

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

◆ GetNextIoQueueLocked()

FxIoQueue * FxPkgIo::GetNextIoQueueLocked ( __in FxIoQueueNode QueueBookmark,
__in PVOID  Tag 
)
private

Definition at line 1640 of file fxpkgio.cpp.

1657 {
1658  PLIST_ENTRY ple = NULL;
1659  FxIoQueue* queue = NULL;
1660  FxIoQueueNode* listNode = NULL;
1661 
1662  ASSERT(QueueBookmark->IsNodeType(FxIoQueueNodeTypeBookmark));
1663  ASSERT(IsListEmpty(&QueueBookmark->m_ListEntry) == FALSE);
1664 
1665  //
1666  // Try to advance bookmark to next location.
1667  //
1668  ple = QueueBookmark->m_ListEntry.Flink;
1669  RemoveEntryList(&QueueBookmark->m_ListEntry);
1670  InitializeListHead(&QueueBookmark->m_ListEntry);
1671 
1672  for (; ple != &m_IoQueueListHead; ple = ple->Flink) {
1673  //
1674  // Skip any nodes that are not queues. These nodes can be
1675  // bookmarks for in-progress flush operations.
1676  //
1677  listNode = FxIoQueueNode::_FromListEntry(ple);
1678  if (listNode->IsNodeType(FxIoQueueNodeTypeQueue)) {
1679 
1680  //
1681  // This entry is a real queue.
1682  //
1684  queue->ADDREF(Tag);
1685 
1686  //
1687  // Insert bookmark after this entry.
1688  //
1689  InsertHeadList(ple, &QueueBookmark->m_ListEntry);
1690 
1691  break;
1692  }
1693  }
1694 
1695  return queue;
1696 }
FxIoQueue * queue
FORCEINLINE VOID InsertHeadList(_Inout_ PLIST_ENTRY ListHead, _Inout_ __drv_aliasesMem PLIST_ENTRY Entry)
Definition: rtlfuncs.h:201
__inline BOOLEAN IsNodeType(__in FxIoQueueNodeType NodeType)
Definition: fxioqueue.hpp:117
static __inline FxIoQueue * _FromIoPkgListEntry(__in PLIST_ENTRY Entry)
Definition: fxioqueue.hpp:1216
static FxIoQueueNode * _FromListEntry(__in PLIST_ENTRY Entry)
Definition: fxioqueue.hpp:98
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
PSINGLE_LIST_ENTRY ple
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
#define FALSE
Definition: types.h:117
Definition: _queue.h:59
#define ASSERT(a)
Definition: mode.c:45
Definition: typedefs.h:119
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
Definition: wdfdevice.h:4061
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define NULL
Definition: types.h:112
LIST_ENTRY m_IoQueueListHead
Definition: fxpkgio.hpp:70

Referenced by FlushAllQueuesByFileObject(), and GetFirstIoQueueLocked().

◆ InitializeDefaultQueue()

_Must_inspect_result_ NTSTATUS FxPkgIo::InitializeDefaultQueue ( __in CfxDevice Device,
__inout FxIoQueue Queue 
)

Definition at line 489 of file fxpkgio.cpp.

513 {
514  PFX_DRIVER_GLOBALS FxDriverGlobals = GetDriverGlobals();
515  ULONG index;
516 
517  if (m_DefaultQueue != NULL) {
519  "Default Queue Already Configured for "
520  "FxPkgIo 0x%p, WDFDEVICE 0x%p %!STATUS!",this,
521  Device->GetHandle(), STATUS_UNSUCCESSFUL);
522  return STATUS_UNSUCCESSFUL;
523  }
524 
525  for (index=0; index <= IRP_MJ_MAXIMUM_FUNCTION; index++) {
526  if (m_DispatchTable[index] == NULL) {
528  }
529  }
530 
532 
533  //
534  // Default queue can't be deleted. So mark the object to fail WdfObjectDelete on
535  // the default queue.
536  //
537  Queue->MarkNoDeleteDDI();
538  return STATUS_SUCCESS;
539 }
_Must_inspect_result_ _In_ WDFDEVICE _In_ PIRP _In_ WDFQUEUE Queue
Definition: wdfdevice.h:2221
#define IRP_MJ_MAXIMUM_FUNCTION
FxIoQueue * m_DispatchTable[IRP_MJ_MAXIMUM_FUNCTION+1]
Definition: fxpkgio.hpp:75
GLuint index
Definition: glext.h:6031
FxIoQueue * m_DefaultQueue
Definition: fxpkgio.hpp:62
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define index(s, c)
Definition: various.h:29
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
#define NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1
#define STATUS_SUCCESS
Definition: shellext.h:65
#define TRACINGIO
Definition: dbgtrace.h:66

◆ IsFilter()

__inline BOOLEAN FxPkgIo::IsFilter ( VOID  )
inline

Definition at line 252 of file fxpkgio.hpp.

255  {
256  return m_Filter;
257  }
BOOLEAN m_Filter
Definition: fxpkgio.hpp:84

◆ IsTopLevelQueue()

__inline BOOLEAN FxPkgIo::IsTopLevelQueue ( __in FxIoQueue Queue)
inline

Definition at line 373 of file fxpkgio.hpp.

376  {
377  UCHAR index;
378 
379  for (index = 0; index <= IRP_MJ_MAXIMUM_FUNCTION; index++) {
380  if (m_DispatchTable[index] == Queue) {
381  return TRUE;
382  }
383  }
384  return FALSE;
385  }
#define TRUE
Definition: types.h:120
_Must_inspect_result_ _In_ WDFDEVICE _In_ PIRP _In_ WDFQUEUE Queue
Definition: wdfdevice.h:2221
#define IRP_MJ_MAXIMUM_FUNCTION
FxIoQueue * m_DispatchTable[IRP_MJ_MAXIMUM_FUNCTION+1]
Definition: fxpkgio.hpp:75
#define FALSE
Definition: types.h:117
GLuint index
Definition: glext.h:6031
unsigned char UCHAR
Definition: xmlstorage.h:181
#define index(s, c)
Definition: various.h:29

◆ RemoveIoQueue()

VOID FxPkgIo::RemoveIoQueue ( __inout FxIoQueue IoQueue)
private

Definition at line 1593 of file fxpkgio.cpp.

1596 {
1597  KIRQL irql;
1598 
1599  Lock(&irql);
1600 
1601  RemoveEntryList(&IoQueue->m_IoPkgListNode.m_ListEntry);
1602  ASSERT(IoQueue->m_IoPkgListNode.IsNodeType(FxIoQueueNodeTypeQueue));
1603 
1604  InitializeListHead(&IoQueue->m_IoPkgListNode.m_ListEntry);
1605 
1606  Unlock(irql);
1607 }
__drv_restoresIRQL KIRQL __in BOOLEAN Unlock
Definition: fxobject.hpp:1474
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define ASSERT(a)
Definition: mode.c:45
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
Definition: wdfsync.h:124
KIRQL irql
Definition: fxpkgio.cpp:562

Referenced by RemoveQueueReferences().

◆ RemoveQueueReferences()

VOID FxPkgIo::RemoveQueueReferences ( __inout FxIoQueue pQueue)

Definition at line 1091 of file fxpkgio.cpp.

1112 {
1113  // Remove it from transacation list
1115  return;
1116 }
FxIoQueue * pQueue
VOID RemoveIoQueue(__inout FxIoQueue *IoQueue)
Definition: fxpkgio.cpp:1593

Referenced by FxIoQueue::Dispose().

◆ RequestCompletedCallback()

__inline VOID FxPkgIo::RequestCompletedCallback ( __in FxRequest Request)
inline

Definition at line 355 of file fxpkgio.hpp.

358  {
360 
361  //
362  // If this is called, the driver called WDFREQUEST.Complete
363  // from the PreProcess callback handler.
364  //
365  // Since we have a handler, the FXREQUEST object will
366  // dereference itself upon return from this callback, which
367  // will destroy the final reference count.
368  //
369  }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547

Referenced by FxRequest::PostProcessCompletion(), and FxRequest::PostProcessCompletionForReserved().

◆ ResetStateForRestart()

VOID FxPkgIo::ResetStateForRestart ( VOID  )

Definition at line 1332 of file fxpkgio.cpp.

1349 {
1350  KIRQL irql;
1351  FxIoQueue* queue;
1352  SINGLE_LIST_ENTRY queueList, *ple;
1353 
1355  "Restart queues from purged state for WDFDEVICE 0x%p due to "
1356  "device restart", m_Device->GetHandle());
1357 
1358  queueList.Next = NULL;
1359 
1360  Lock(&irql);
1361 
1363 
1364  Unlock(irql);
1365 
1366  for (ple = PopEntryList(&queueList);
1367  ple != NULL;
1368  ple = PopEntryList(&queueList)) {
1369 
1371 
1372  queue->ResetStateForRestart();
1373 
1374  ple->Next = NULL;
1375 
1376  queue->RELEASE(IO_ITERATOR_POWER_TAG);
1377  }
1378 
1379  Lock(&irql);
1380 
1381  m_PowerStateOn = TRUE;
1382 
1384 
1385  Unlock(irql);
1386 
1387  return;
1388 
1389 }
__drv_restoresIRQL KIRQL __in BOOLEAN Unlock
Definition: fxobject.hpp:1474
CfxDevice * m_Device
Definition: fxobject.hpp:329
FxIoQueue * queue
Definition: ntbasedef.h:628
#define TRUE
Definition: types.h:120
WDFDEVICE __inline GetHandle(VOID)
Definition: fxdevice.hpp:237
BOOLEAN m_PowerStateOn
Definition: fxpkgio.hpp:86
#define TRACE_LEVEL_INFORMATION
Definition: storswtr.h:29
PSINGLE_LIST_ENTRY ple
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define FALSE
Definition: types.h:117
VOID GetIoQueueListLocked(__in PSINGLE_LIST_ENTRY SListHead, __inout FxIoIteratorList ListType)
Definition: fxpkgio.cpp:1480
#define IO_ITERATOR_POWER_TAG
Definition: fxpkgio.hpp:48
BOOLEAN m_QueuesAreShuttingDown
Definition: fxpkgio.hpp:91
Definition: _queue.h:59
static __inline FxIoQueue * _FromPowerSListEntry(__in PSINGLE_LIST_ENTRY Entry)
Definition: fxioqueue.hpp:1226
FORCEINLINE PSINGLE_LIST_ENTRY PopEntryList(_Inout_ PSINGLE_LIST_ENTRY ListHead)
Definition: rtlfuncs.h:240
struct _SINGLE_LIST_ENTRY * Next
Definition: ntbasedef.h:629
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
#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
KIRQL irql
Definition: fxpkgio.cpp:562

◆ ResumeProcessingForPower()

_Must_inspect_result_ NTSTATUS FxPkgIo::ResumeProcessingForPower ( )

Definition at line 1254 of file fxpkgio.cpp.

1273 {
1274  KIRQL irql;
1275  FxIoQueue* queue;
1276  SINGLE_LIST_ENTRY queueList, *ple;
1277 
1279  "Power resume all queues of WDFDEVICE 0x%p",
1280  m_Device->GetHandle());
1281 
1282  queueList.Next = NULL;
1283 
1284  Lock(&irql);
1285 
1287  //
1288  // Change the state so that new queues created while we
1289  // are resuming the existing queues can be in a powered-on state.
1290  //
1291  m_PowerStateOn = TRUE;
1292 
1293  //
1294  // Change the accepting state so that new queues created while we
1295  // are resuming the existing queues can be accept request.
1296  //
1298 
1299  Unlock(irql);
1300 
1301  //
1302  // We will power-up the queues in two steps. First we will resume
1303  // the power of all the queues and then we will start dispatching I/Os.
1304  // This is to avoid a queue being powered up at the begining of the list
1305  // trying to forward a request to another queue lower in the list that's
1306  // not powered up yet.
1307  //
1308  for(ple = queueList.Next; ple != NULL; ple = ple->Next) {
1309 
1311 
1312  queue->ResumeProcessingForPower();
1313  }
1314 
1315  for (ple = PopEntryList(&queueList);
1316  ple != NULL;
1317  ple = PopEntryList(&queueList)) {
1318 
1320 
1321  queue->StartPowerTransitionOn();
1322 
1323  ple->Next = NULL;
1324 
1325  queue->RELEASE(IO_ITERATOR_POWER_TAG);
1326  }
1327 
1328  return STATUS_SUCCESS;
1329 }
__drv_restoresIRQL KIRQL __in BOOLEAN Unlock
Definition: fxobject.hpp:1474
CfxDevice * m_Device
Definition: fxobject.hpp:329
FxIoQueue * queue
Definition: ntbasedef.h:628
#define TRUE
Definition: types.h:120
WDFDEVICE __inline GetHandle(VOID)
Definition: fxdevice.hpp:237
BOOLEAN m_PowerStateOn
Definition: fxpkgio.hpp:86
#define TRACE_LEVEL_INFORMATION
Definition: storswtr.h:29
PSINGLE_LIST_ENTRY ple
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define FALSE
Definition: types.h:117
VOID GetIoQueueListLocked(__in PSINGLE_LIST_ENTRY SListHead, __inout FxIoIteratorList ListType)
Definition: fxpkgio.cpp:1480
#define IO_ITERATOR_POWER_TAG
Definition: fxpkgio.hpp:48
BOOLEAN m_QueuesAreShuttingDown
Definition: fxpkgio.hpp:91
Definition: _queue.h:59
static __inline FxIoQueue * _FromPowerSListEntry(__in PSINGLE_LIST_ENTRY Entry)
Definition: fxioqueue.hpp:1226
FORCEINLINE PSINGLE_LIST_ENTRY PopEntryList(_Inout_ PSINGLE_LIST_ENTRY ListHead)
Definition: rtlfuncs.h:240
struct _SINGLE_LIST_ENTRY * Next
Definition: ntbasedef.h:629
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
#define NULL
Definition: types.h:112
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
Definition: wdfsync.h:124
#define STATUS_SUCCESS
Definition: shellext.h:65
#define TRACINGIO
Definition: dbgtrace.h:66
KIRQL irql
Definition: fxpkgio.cpp:562

◆ SetFilter()

_Must_inspect_result_ NTSTATUS FxPkgIo::SetFilter ( __in BOOLEAN  Value)

Definition at line 1120 of file fxpkgio.cpp.

1123 {
1124  PFX_DRIVER_GLOBALS FxDriverGlobals = GetDriverGlobals();
1125 
1126  if (m_DefaultQueue != NULL) {
1128  "I/O Package already has a default queue. "
1129  "SetFilter must be called before creating "
1130  "a default queue %!STATUS!",
1132  FxVerifierDbgBreakPoint(FxDriverGlobals);
1134  }
1135 
1136  m_Filter = Value;
1137 
1138  return STATUS_SUCCESS;
1139 }
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
BOOLEAN m_Filter
Definition: fxpkgio.hpp:84
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:406
FxIoQueue * m_DefaultQueue
Definition: fxpkgio.hpp:62
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
#define NULL
Definition: types.h:112
#define STATUS_SUCCESS
Definition: shellext.h:65
#define TRACINGIO
Definition: dbgtrace.h:66
FxVerifierDbgBreakPoint(pFxDriverGlobals)

Referenced by FxDevice::SetFilter().

◆ SetIoInCallerContextCallback()

__inline VOID FxPkgIo::SetIoInCallerContextCallback ( __inout PFN_WDF_IO_IN_CALLER_CONTEXT  EvtIoInCallerContext)
inline

Definition at line 193 of file fxpkgio.hpp.

196  {
198  }
FxIoInCallerContext m_InCallerContextCallback
Definition: fxpkgio.hpp:103
PFN_WDF_IO_IN_CALLER_CONTEXT m_Method
_In_ PWDFDEVICE_INIT _In_ PFN_WDF_IO_IN_CALLER_CONTEXT EvtIoInCallerContext
Definition: wdfdevice.h:3502

Referenced by FxDevice::Initialize().

◆ StopProcessingForPower()

_Must_inspect_result_ NTSTATUS FxPkgIo::StopProcessingForPower ( __in FxIoStopProcessingForPowerAction  Action)

Definition at line 1143 of file fxpkgio.cpp.

1181 {
1182  KIRQL irql;
1183  FxIoQueue* queue;
1184  SINGLE_LIST_ENTRY queueList, *ple;
1185 
1187  "Perform %!FxIoStopProcessingForPowerAction! for all queues of "
1188  "WDFDEVICE 0x%p", Action, m_Device->GetHandle());
1189 
1190  queueList.Next = NULL;
1191 
1192  Lock(&irql);
1193  //
1194  // Device is moving into low power state. So any new queues
1195  // created after this point would start off as powered off.
1196  //
1198 
1199  //
1200  // If queues are shutting down, any new queue created after
1201  // this point would not accept any requests.
1202  //
1203  switch(Action) {
1207  break;
1208  }
1209 
1211 
1212  Unlock(irql);
1213 
1214  //
1215  // If the power action is hold then first change the state of all the queues
1216  // to PowerStartTransition. This will prevent the queues from dispatching
1217  // new requests before we start asking each queue to stop processing
1218  // inflight requests.
1219  //
1221 
1222  //
1223  // Walk the list without popping entries because we need to scan
1224  // the list again.
1225  //
1226  for(ple = queueList.Next; ple != NULL; ple = ple->Next) {
1227 
1229 
1230  queue->StartPowerTransitionOff();
1231  }
1232  }
1233 
1234  //
1235  // Ask the queues to stop processing inflight requests.
1236  //
1237  for (ple = PopEntryList(&queueList); ple != NULL;
1238  ple = PopEntryList(&queueList)) {
1239 
1241 
1242  queue->StopProcessingForPower(Action);
1243 
1244  ple->Next = NULL;
1245 
1246  queue->RELEASE(IO_ITERATOR_POWER_TAG);
1247  }
1248 
1249  return STATUS_SUCCESS;
1250 }
__drv_restoresIRQL KIRQL __in BOOLEAN Unlock
Definition: fxobject.hpp:1474
CfxDevice * m_Device
Definition: fxobject.hpp:329
FxIoQueue * queue
Definition: ntbasedef.h:628
#define TRUE
Definition: types.h:120
WDFDEVICE __inline GetHandle(VOID)
Definition: fxdevice.hpp:237
BOOLEAN m_PowerStateOn
Definition: fxpkgio.hpp:86
#define TRACE_LEVEL_INFORMATION
Definition: storswtr.h:29
PSINGLE_LIST_ENTRY ple
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define FALSE
Definition: types.h:117
VOID GetIoQueueListLocked(__in PSINGLE_LIST_ENTRY SListHead, __inout FxIoIteratorList ListType)
Definition: fxpkgio.cpp:1480
#define IO_ITERATOR_POWER_TAG
Definition: fxpkgio.hpp:48
BOOLEAN m_QueuesAreShuttingDown
Definition: fxpkgio.hpp:91
Definition: _queue.h:59
static __inline FxIoQueue * _FromPowerSListEntry(__in PSINGLE_LIST_ENTRY Entry)
Definition: fxioqueue.hpp:1226
FORCEINLINE PSINGLE_LIST_ENTRY PopEntryList(_Inout_ PSINGLE_LIST_ENTRY ListHead)
Definition: rtlfuncs.h:240
struct _SINGLE_LIST_ENTRY * Next
Definition: ntbasedef.h:629
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
_In_ WDFIOTARGET _In_ _Strict_type_match_ WDF_IO_TARGET_SENT_IO_ACTION Action
Definition: wdfiotarget.h:506
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
#define NULL
Definition: types.h:112
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
Definition: wdfsync.h:124
#define STATUS_SUCCESS
Definition: shellext.h:65
#define TRACINGIO
Definition: dbgtrace.h:66
KIRQL irql
Definition: fxpkgio.cpp:562

Referenced by FxPkgPnp::PnpCleanupForRemove(), FxPkgPnp::PnpEventRemovedCommonCode(), and FxPkgPnp::PowerGotoDx().

◆ VerifierFreeRequestToTestForwardProgess()

_Must_inspect_result_ NTSTATUS FxPkgIo::VerifierFreeRequestToTestForwardProgess ( __in FxRequest Request)
private

Definition at line 1758 of file fxpkgio.cpp.

1761 {
1762  BOOLEAN failAllocation;
1764 
1766  failAllocation = FALSE;
1767  //
1768  // forwardProgressTestFailAll takes precedence over forwardProgressTestFailRandom
1769  //
1771  failAllocation = TRUE;
1772  }
1774  //
1775  // Modulo 17 makes the probability of failure ~6% just like verifier.exe
1776  //
1777  failAllocation = (FxRandom(&m_RandomSeed) % 17 == 0);
1778  }
1779 
1780  if (failAllocation) {
1781  //
1782  // Don't use DeleteObject() here as the Request wasn't presented to the
1783  // driver and the cleanup /dispose callback can be invoked unless
1784  // we use FreeRequest() which clears the cleanup /dispose callbacks
1785  //
1786  Request->FreeRequest();
1787 
1789  }
1790  else {
1791  return STATUS_SUCCESS;
1792  }
1793 }
ULONG m_RandomSeed
Definition: fxpkgio.hpp:81
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define TRUE
Definition: types.h:120
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
__inline BOOLEAN IsFxVerifierTestForwardProgressFailAll(__in PFX_DRIVER_GLOBALS FxDriverGlobals)
Definition: fxverifier.h:205
#define FALSE
Definition: types.h:117
unsigned char BOOLEAN
PFX_DRIVER_GLOBALS pFxDriverGlobals
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
#define STATUS_SUCCESS
Definition: shellext.h:65
__inline BOOLEAN IsFxVerifierTestForwardProgressFailRandom(__in PFX_DRIVER_GLOBALS FxDriverGlobals)
Definition: fxverifier.h:220
__inline ULONG FxRandom(__inout PULONG RandomSeed)
Definition: fxglobals.h:1054

Referenced by DispatchStep2().

Member Data Documentation

◆ m_DefaultQueue

FxIoQueue* FxPkgIo::m_DefaultQueue
private

◆ m_DispatchTable

◆ m_DynamicDispatchInfoListHead

LIST_ENTRY FxPkgIo::m_DynamicDispatchInfoListHead
private

Definition at line 98 of file fxpkgio.hpp.

Referenced by ConfigureDynamicDispatching(), Dispatch(), DispatchStep1(), FxPkgIo(), and ~FxPkgIo().

◆ m_Filter

BOOLEAN FxPkgIo::m_Filter
private

Definition at line 84 of file fxpkgio.hpp.

Referenced by DispatchStep1(), DispatchStep2(), EnqueueRequest(), FxPkgIo(), IsFilter(), and SetFilter().

◆ m_InCallerContextCallback

FxIoInCallerContext FxPkgIo::m_InCallerContextCallback
private

Definition at line 103 of file fxpkgio.hpp.

Referenced by GetIoInCallerContextCallback(), and SetIoInCallerContextCallback().

◆ m_IoQueueListHead

LIST_ENTRY FxPkgIo::m_IoQueueListHead
private

◆ m_PowerStateOn

BOOLEAN FxPkgIo::m_PowerStateOn
private

◆ m_QueuesAreShuttingDown

BOOLEAN FxPkgIo::m_QueuesAreShuttingDown
private

◆ m_RandomSeed

ULONG FxPkgIo::m_RandomSeed
private

Definition at line 81 of file fxpkgio.hpp.

Referenced by FxPkgIo(), and VerifierFreeRequestToTestForwardProgess().


The documentation for this class was generated from the following files: