32#if defined(EVENT_TRACING)
33#include "FxVerifierLock.tmh"
122 if( FxDriverGlobals->FxVerifierLock ) {
124 FxDriverGlobals->ThreadTableLock.Initialize();
141 if( FxDriverGlobals->FxVerifierLock ) {
144 FxDriverGlobals->ThreadTableLock.Uninitialize();
178 "Thread 0x%p already owns lock 0x%p for object 0x%p, WDFOBJECT 0x%p",
189 Mx::MxEnterCriticalRegion();
196 m_Lock.AcquireAtDpcLevel();
214 m_Lock.Acquire(PreviousIrql);
230 if( perThreadList ==
NULL ) {
318 "Thread 0x%p Is Attempting to release a Lock 0x%p "
319 "for Object 0x%p it does not own!",
330 if( perThreadList ==
NULL ) {
334 "Unlock: Can't get per thread entry for thread %p",
343 Mx::MxLeaveCriticalRegion();
346 m_Lock.ReleaseFromDpcLevel();
349 m_Lock.Release(PreviousIrql);
366 "Thread has entry, but no locks recorded as "
367 "held for passive!");
369 "this 0x%p, perThreadList 0x%p",
370 this, perThreadList);
378 Mx::MxLeaveCriticalRegion();
387 "Thread has entry, but no locks recorded as held "
390 "this 0x%p, perThreadList 0x%p",
391 this, perThreadList);
399 m_Lock.ReleaseFromDpcLevel();
402 m_Lock.Release(PreviousIrql);
488 "Record entry for VerifierLock 0x%p is missing "
489 "on list 0x%p for Thread 0x%p",
566 "Record entry for VerifierLock 0x%p is missing "
567 "on list 0x%p for Thread 0x%p",
581 Mx::MxLeaveCriticalRegion();
584 m_Lock.ReleaseFromDpcLevel();
587 m_Lock.Release(PreviousIrql);
624 while(
p->ObjectType != 0 ) {
635 "Object Type 0x%x does not have a lock order "
636 "defined in fx\\inc\\FxVerifierLock.hpp",
678 Hash = ((
Hash >> 16) & 0x0000FFFF) ^ (
Hash & 0x0000FFFF);
694 if(
entry->m_ThreadTableEntry.Thread == curThread ) {
701 return &
entry->m_ThreadTableEntry;
709 "Thread 0x%p does not have an entry",curThread);
721 pLock->m_ThreadTableEntry.Thread = curThread;
722 pLock->m_ThreadTableEntry.PerThreadPassiveLockList =
NULL;
723 pLock->m_ThreadTableEntry.PerThreadDispatchLockList =
NULL;
731 return &
pLock->m_ThreadTableEntry;
864 if(
pLock->m_ThreadTableEntry.Thread ==
NULL ) {
875 if(
pLock->m_ThreadTableEntry.Thread != curThread ) {
877 "OldEntry Thread 0x%p not Current! 0x%p",
883 Hash = ((
Hash >> 16) & 0x0000FFFF) ^ (
Hash & 0x0000FFFF);
895 if( (
pLock->m_ThreadTableEntry.PerThreadPassiveLockList ==
NULL) &&
896 (
pLock->m_ThreadTableEntry.PerThreadDispatchLockList ==
NULL) ) {
904 pLock->m_ThreadTableEntry.PerThreadPassiveLockList =
NULL;
905 pLock->m_ThreadTableEntry.PerThreadDispatchLockList =
NULL;
913 if(
pLock->m_ThreadTableEntry.PerThreadPassiveLockList !=
NULL ) {
914 pNewLock =
pLock->m_ThreadTableEntry.PerThreadPassiveLockList;
917 pNewLock =
pLock->m_ThreadTableEntry.PerThreadDispatchLockList;
945 FxDriverGlobals->ThreadTableLock.Acquire(&oldIrql);
947 if( FxDriverGlobals->ThreadTable !=
NULL ) {
948 FxDriverGlobals->ThreadTableLock.Release(oldIrql);
959 FxDriverGlobals->Tag);
961 if( newTable ==
NULL ) {
962 FxDriverGlobals->ThreadTableLock.Release(oldIrql);
964 "No Memory to allocate thread table");
972 FxDriverGlobals->ThreadTable = newTable;
974 FxDriverGlobals->ThreadTableLock.Release(oldIrql);
988 FxDriverGlobals->ThreadTableLock.Acquire(&oldIrql);
990 if( FxDriverGlobals->ThreadTable ==
NULL ) {
991 FxDriverGlobals->ThreadTableLock.Release(oldIrql);
997 FxDriverGlobals->ThreadTable =
NULL;
999 FxDriverGlobals->ThreadTableLock.Release(oldIrql);
1016 "Thread 0x%p Attempted to acquire lock on Object 0x%p, "
1017 "ObjectType 0x%x, at Level 0x%x out of sequence.",
1018 curThread,
Lock->m_ParentObject,
1019 Lock->m_ParentObject->GetType(),
1022 next = PerThreadList;
1025 "Highest Lock Currently held is level 0x%x for "
1026 "Object 0x%p, ObjectType 0x%x",
1028 next->m_ParentObject,
1029 next->m_ParentObject->GetType());
1032 "List of Already Acquired Locks and Objects:");
1037 "Object 0x%p, ObjectType 0x%x, LockLevel 0x%x",
1038 next->m_ParentObject,
1039 next->m_ParentObject->GetType(),
struct outqueuenode * head
PVOID __inline GetObjectHandle(VOID)
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
FxVerifierThreadTableEntry m_ThreadTableEntry
VOID Unlock(__in KIRQL PreviousIrql, __in BOOLEAN AtDpc)
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)
FxObject * m_ParentObject
void InitializeLockOrder(VOID)
VOID Lock(__out PKIRQL PreviousIrql, __in BOOLEAN AtDpc)
__inline VOID AcquireUnsafe()
__inline VOID ReleaseUnsafe()
static __inline MxThread MxGetCurrentThread()
static __inline KIRQL MxGetCurrentIrql()
static __inline VOID MxDelayExecutionThread(__in KPROCESSOR_MODE WaitMode, __in BOOLEAN Alertable, __in PLARGE_INTEGER Interval)
static int Hash(const char *)
#define RemoveEntryList(Entry)
#define InsertTailList(ListHead, Entry)
#define InitializeListHead(ListHead)
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
FxVerifierDbgBreakPoint(pFxDriverGlobals)
void FxPoolFree(__in_xcount(ptr is at an offset from AllocationStart) PVOID ptr)
#define FxVerifierBugCheck(FxDriverGlobals, Error,...)
void FxVerifierLockDestroy(__in PFX_DRIVER_GLOBALS FxDriverGlobals)
FxVerifierOrderMapping FxVerifierCallbackOrderTable[]
void FxVerifierLockInitialize(__in PFX_DRIVER_GLOBALS FxDriverGlobals)
FxVerifierOrderMapping FxVerifierOrderTable[]
#define FX_VERIFIER_LOCK_ENTRIES()
#define FX_LOCK_ORDER_UNKNOWN
#define VERIFIER_THREAD_HASHTABLE_SIZE
#define FX_VERIFIER_CALLBACKLOCK_ENTRIES()
#define UNREFERENCED_PARAMETER(P)
static unsigned __int64 next
#define TRACE_LEVEL_FATAL
#define TRACE_LEVEL_ERROR
PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
FxVerifierLock * PerThreadDispatchLockList
FxVerifierLock * PerThreadPassiveLockList
struct _LIST_ENTRY * PLIST_ENTRY
#define CONTAINING_RECORD(address, type, field)
_In_ WDFCOLLECTION _In_ ULONG Index
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock