32#ifndef _FXVERIFIERLOCK_HPP_
33#define _FXVERIFIERLOCK_HPP_
36#if defined(EVENT_TRACING)
37#include "FxVerifierLock.hpp.tmh"
81#define FX_LOCK_ORDER_NONE 0x0000
82#define FX_LOCK_ORDER_UNKNOWN 0xFFFF
84#define FX_LOCK_ORDER_PACKAGE_PDO 0x1000
85#define FX_LOCK_ORDER_PACKAGE_FDO 0x1000
86#define FX_LOCK_ORDER_WMI_IRP_HANDLER 0x1000
87#define FX_LOCK_ORDER_PACKAGE_GENERAL 0x1000
89#define FX_LOCK_ORDER_IO_TARGET 0x1000
91#define FX_LOCK_ORDER_WMI_PROVIDER 0x1001
92#define FX_LOCK_ORDER_WMI_INSTANCE 0x1002
94#define FX_LOCK_ORDER_DMA_ENABLER 0x1000
95#define FX_LOCK_ORDER_DMA_TRANSACTION 0x1001
96#define FX_LOCK_ORDER_COMMON_BUFFER 0x1001
102#define FX_LOCK_ORDER_USB_DEVICE_IO_TARGET 0x1000
103#define FX_LOCK_ORDER_USB_PIPE_IO_TARGET 0x1001
106#define FX_LOCK_ORDER_DRIVER 0x1010
107#define FX_LOCK_ORDER_DEVICE 0x1020
108#define FX_LOCK_ORDER_MP_DEVICE 0x1020
109#define FX_LOCK_ORDER_DEFAULT_IRP_HANDLER 0x1030
110#define FX_LOCK_ORDER_QUEUE 0x1030
111#define FX_LOCK_ORDER_PACKAGE_IO 0x1031
112#define FX_LOCK_ORDER_REQUEST 0x1040
113#define FX_LOCK_ORDER_IRPQUEUE 0x1051
114#define FX_LOCK_ORDER_TIMER 0x1059
115#define FX_LOCK_ORDER_DPC 0x1060
116#define FX_LOCK_ORDER_WORKITEM 0x1060
117#define FX_LOCK_ORDER_CLEANUPLIST 0x1060
118#define FX_LOCK_ORDER_INTERRUPT 0x1060
119#define FX_LOCK_ORDER_FILEOBJECT 0x1060
120#define FX_LOCK_ORDER_DEVICE_LIST 0x1061
121#define FX_LOCK_ORDER_COLLECTION 0x1070
123#define FX_LOCK_ORDER_USEROBJECT 0x2000
127#define FX_LOCK_ORDER_DISPOSELIST 0x8000
129#define FX_LOCK_ORDER_SYSTEMWORKITEM FX_LOCK_ORDER_UNKNOWN
130#define FX_LOCK_ORDER_SYSTEMTHREAD FX_LOCK_ORDER_UNKNOWN
155#define FX_CALLBACKLOCK_ORDER_DRIVER 0x10
156#define FX_CALLBACKLOCK_ORDER_DEVICE 0x20
157#define FX_CALLBACKLOCK_ORDER_PACKAGE 0x30
158#define FX_CALLBACKLOCK_ORDER_QUEUE 0x31
160#define FX_VERIFIER_LOCK_ENTRY(FX_OBJECT_TYPE, FX_LOCK_ORDER) { FX_OBJECT_TYPE, FX_LOCK_ORDER }
163#define FX_VERIFIER_LOCK_ENTRIES() \
164 FX_VERIFIER_LOCK_ENTRY(FX_TYPE_DRIVER, FX_LOCK_ORDER_DRIVER), \
165 FX_VERIFIER_LOCK_ENTRY(FX_TYPE_DEVICE, FX_LOCK_ORDER_DEVICE), \
166 FX_VERIFIER_LOCK_ENTRY(FX_TYPE_MP_DEVICE, FX_LOCK_ORDER_MP_DEVICE), \
167 FX_VERIFIER_LOCK_ENTRY(FX_TYPE_PACKAGE_IO, FX_LOCK_ORDER_PACKAGE_IO), \
168 FX_VERIFIER_LOCK_ENTRY(FX_TYPE_WMI_INSTANCE, FX_LOCK_ORDER_WMI_INSTANCE), \
169 FX_VERIFIER_LOCK_ENTRY(FX_TYPE_WMI_PROVIDER, FX_LOCK_ORDER_WMI_PROVIDER), \
170 FX_VERIFIER_LOCK_ENTRY(FX_TYPE_QUEUE, FX_LOCK_ORDER_QUEUE), \
171 FX_VERIFIER_LOCK_ENTRY(FX_TYPE_REQUEST, FX_LOCK_ORDER_REQUEST), \
172 FX_VERIFIER_LOCK_ENTRY(FX_TYPE_IRPQUEUE, FX_LOCK_ORDER_IRPQUEUE), \
173 FX_VERIFIER_LOCK_ENTRY(FX_TYPE_PACKAGE_PDO, FX_LOCK_ORDER_PACKAGE_PDO), \
174 FX_VERIFIER_LOCK_ENTRY(FX_TYPE_PACKAGE_FDO, FX_LOCK_ORDER_PACKAGE_FDO), \
175 FX_VERIFIER_LOCK_ENTRY(FX_TYPE_WMI_IRP_HANDLER, FX_LOCK_ORDER_WMI_IRP_HANDLER), \
176 FX_VERIFIER_LOCK_ENTRY(FX_TYPE_PACKAGE_GENERAL, FX_LOCK_ORDER_PACKAGE_GENERAL), \
177 FX_VERIFIER_LOCK_ENTRY(FX_TYPE_DMA_ENABLER, FX_LOCK_ORDER_DMA_ENABLER), \
178 FX_VERIFIER_LOCK_ENTRY(FX_TYPE_DMA_TRANSACTION, FX_LOCK_ORDER_DMA_TRANSACTION), \
179 FX_VERIFIER_LOCK_ENTRY(FX_TYPE_COMMON_BUFFER, FX_LOCK_ORDER_COMMON_BUFFER), \
180 FX_VERIFIER_LOCK_ENTRY(FX_TYPE_IO_TARGET, FX_LOCK_ORDER_IO_TARGET), \
181 FX_VERIFIER_LOCK_ENTRY(FX_TYPE_IO_TARGET_SELF, FX_LOCK_ORDER_IO_TARGET), \
182 FX_VERIFIER_LOCK_ENTRY(FX_TYPE_IO_TARGET_USB_DEVICE,FX_LOCK_ORDER_USB_DEVICE_IO_TARGET),\
183 FX_VERIFIER_LOCK_ENTRY(FX_TYPE_IO_TARGET_USB_PIPE, FX_LOCK_ORDER_USB_PIPE_IO_TARGET), \
184 FX_VERIFIER_LOCK_ENTRY(FX_TYPE_DPC, FX_LOCK_ORDER_DPC), \
185 FX_VERIFIER_LOCK_ENTRY(FX_TYPE_WORKITEM, FX_LOCK_ORDER_WORKITEM), \
186 FX_VERIFIER_LOCK_ENTRY(FX_TYPE_SYSTEMTHREAD, FX_LOCK_ORDER_SYSTEMTHREAD), \
187 FX_VERIFIER_LOCK_ENTRY(FX_TYPE_CLEANUPLIST, FX_LOCK_ORDER_CLEANUPLIST), \
188 FX_VERIFIER_LOCK_ENTRY(FX_TYPE_INTERRUPT, FX_LOCK_ORDER_INTERRUPT), \
189 FX_VERIFIER_LOCK_ENTRY(FX_TYPE_TIMER, FX_LOCK_ORDER_TIMER), \
190 FX_VERIFIER_LOCK_ENTRY(FX_TYPE_FILEOBJECT, FX_LOCK_ORDER_FILEOBJECT), \
191 FX_VERIFIER_LOCK_ENTRY(FX_TYPE_CHILD_LIST, FX_LOCK_ORDER_DEVICE_LIST), \
192 FX_VERIFIER_LOCK_ENTRY(FX_TYPE_SYSTEMWORKITEM, FX_LOCK_ORDER_SYSTEMWORKITEM), \
193 FX_VERIFIER_LOCK_ENTRY(FX_TYPE_DEFAULT_IRP_HANDLER, FX_LOCK_ORDER_DEFAULT_IRP_HANDLER), \
194 FX_VERIFIER_LOCK_ENTRY(FX_TYPE_COLLECTION, FX_LOCK_ORDER_COLLECTION), \
195 FX_VERIFIER_LOCK_ENTRY(FX_TYPE_DISPOSELIST, FX_LOCK_ORDER_DISPOSELIST), \
196 FX_VERIFIER_LOCK_ENTRY(FX_TYPE_USEROBJECT, FX_LOCK_ORDER_USEROBJECT), \
197 FX_VERIFIER_LOCK_ENTRY(0, 0)
200#define FX_VERIFIER_CALLBACKLOCK_ENTRIES() \
201 FX_VERIFIER_LOCK_ENTRY(FX_TYPE_DRIVER, FX_CALLBACKLOCK_ORDER_DRIVER), \
202 FX_VERIFIER_LOCK_ENTRY(FX_TYPE_DEVICE, FX_CALLBACKLOCK_ORDER_DEVICE), \
203 FX_VERIFIER_LOCK_ENTRY(FX_TYPE_PACKAGE_IO, FX_CALLBACKLOCK_ORDER_PACKAGE), \
204 FX_VERIFIER_LOCK_ENTRY(FX_TYPE_QUEUE, FX_CALLBACKLOCK_ORDER_QUEUE), \
205 FX_VERIFIER_LOCK_ENTRY(0, 0)
226#define VERIFIER_THREAD_HASHTABLE_SIZE 64
355 "Unable to initialize paged lock for VerifierLock 0x%p "
422 verifierLock =
new (FxDriverGlobals)
FxVerifierLock(FxDriverGlobals,
425 if (
NULL == verifierLock) {
428 "Failed to allocate verifier lock, returning %!STATUS!",
439 *VerifierLock = verifierLock;
458 verifierLock =
new (FxDriverGlobals)
FxVerifierLock(FxDriverGlobals,
460 if (
NULL == verifierLock) {
463 "Failed to allocate verifier lock, returning %!STATUS!",
474 *VerifierLock = verifierLock;
486 "Lock 0x%p is being destroyed while owned by "
487 "thread 0x%p, Owning Object 0x%p",
FxVerifierLock(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxObject *ParentObject)
static ULONG ThreadTableSize
FxVerifierThreadTableEntry m_ThreadTableEntry
_Must_inspect_result_ __inline NTSTATUS Initialize()
FxVerifierLock(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxObject *ParentObject, __in BOOLEAN UseMutex)
void FxVerifierLockDumpDetails(__in FxVerifierLock *Lock, __in PVOID curThread, __in FxVerifierLock *PerThreadList)
FxVerifierLock(PFX_DRIVER_GLOBALS FxDriverGlobals)
static void FreeThreadTable(__in PFX_DRIVER_GLOBALS FxDriverGlobals)
KIRQL GetLockPreviousIrql(VOID)
FxVerifierLock * m_OwnedLink
static void ReleaseOrReplaceThreadTableEntry(__in MxThread curThread, __in FxVerifierLock *pLock)
static void AllocateThreadTable(__in PFX_DRIVER_GLOBALS FxDriverGlobals)
static void DumpDetails(__in FxVerifierLock *Lock, __in MxThread curThread, __in FxVerifierLock *PerThreadList)
static pFxVerifierThreadTableEntry GetThreadTableEntry(__in MxThread curThread, __in FxVerifierLock *pLock, __in BOOLEAN LookupOnly)
_Must_inspect_result_ static __inline NTSTATUS CreateAndInitialize(__out FxVerifierLock **VerifierLock, __in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxObject *ParentObject)
FxObject * m_ParentObject
static KSPIN_LOCK ThreadTableLock
static PLIST_ENTRY ThreadTable
void InitializeLockOrder(VOID)
_Must_inspect_result_ static __inline NTSTATUS CreateAndInitialize(__out FxVerifierLock **VerifierLock, __in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxObject *ParentObject, __in BOOLEAN UseMutex)
_Must_inspect_result_ __inline NTSTATUS Initialize()
#define NT_SUCCESS(StatCode)
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
FxVerifierDbgBreakPoint(pFxDriverGlobals)
#define FX_LOCK_ORDER_UNKNOWN
struct FxVerifierOrderMapping * pFxVerifierOrderMapping
struct FxVerifierThreadTableEntry * pFxVerifierThreadTableEntry
#define _Must_inspect_result_
#define TRACE_LEVEL_ERROR
PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
FxVerifierLock * PerThreadDispatchLockList
FxVerifierLock * PerThreadPassiveLockList
#define STATUS_INSUFFICIENT_RESOURCES
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock