25#define GET_HASH_KEY(ConvKey) \
26 ((CMP_HASH_IRRATIONAL * (ConvKey)) % CMP_HASH_PRIME)
31#define COMPUTE_HASH_CHAR(ConvKey, Char) \
32 (37 * ConvKey + RtlUpcaseUnicodeChar(Char))
37#define GET_HASH_INDEX(ConvKey) \
38 (GET_HASH_KEY(ConvKey) % CmpHashTableSize)
39#define GET_HASH_ENTRY(Table, ConvKey) \
40 (&Table[GET_HASH_INDEX(ConvKey)])
41#define ASSERT_VALID_HASH(h) \
42 ASSERT_KCB_VALID(CONTAINING_RECORD((h), CM_KEY_CONTROL_BLOCK, KeyHash))
47#define CMP_IS_CELL_CACHED(c) \
48 (((c) & HCELL_CACHED) && ((c) != HCELL_NIL))
53#define CMP_GET_CACHED_CELL(c) \
54 (ULONG_PTR)((c) & ~HCELL_CACHED)
55#define CMP_GET_CACHED_DATA(c) \
56 (&(((PCM_CACHED_VALUE_INDEX)(CMP_GET_CACHED_CELL(c)))->Data.CellData))
57#define CMP_GET_CACHED_INDEX(c) \
58 (&(((PCM_CACHED_ENTRY)(CMP_GET_CACHED_CELL(c)))->CellIndex))
59#define CMP_GET_CACHED_VALUE(c) \
60 (&(((PCM_CACHED_VALUE)(CMP_GET_CACHED_CELL(c)))->KeyValue))
65#define CMP_ASSERT_REGISTRY_LOCK() \
66 ASSERT((CmpSpecialBootCondition == TRUE) || \
67 (CmpTestRegistryLock() == TRUE))
72#define CMP_ASSERT_REGISTRY_LOCK_OR_LOADING(h) \
73 ASSERT((CmpSpecialBootCondition == TRUE) || \
74 (((PCMHIVE)h)->HiveIsLoading == TRUE) || \
75 (CmpTestRegistryLock() == TRUE))
80#define CMP_ASSERT_EXCLUSIVE_REGISTRY_LOCK() \
81 ASSERT((CmpSpecialBootCondition == TRUE) || \
82 (CmpTestRegistryLockExclusive() == TRUE))
87#define CMP_ASSERT_EXCLUSIVE_REGISTRY_LOCK_OR_LOADING(h) \
88 ASSERT((CmpSpecialBootCondition == TRUE) || \
89 (((PCMHIVE)h)->HiveIsLoading == TRUE) || \
90 (CmpTestRegistryLockExclusive() == TRUE))
95#define ASSERT_KCB_VALID(k) \
96 ASSERT((k)->Signature == CM_KCB_SIGNATURE)
101#define CmpIsKcbLockedExclusive(k) \
102 (GET_HASH_ENTRY(CmpCacheTable, \
103 (k)->ConvKey)->Owner == KeGetCurrentThread())
108#define CmpAcquireKcbLockSharedByIndex(i) \
110 ExAcquirePushLockShared(&CmpCacheTable[(i)].Lock); \
124 CmpCaptureLockBackTraceByIndex(
Index);
162#define CmpAcquireKcbLockShared(k) \
164 ExAcquirePushLockShared(&GET_HASH_ENTRY(CmpCacheTable, \
165 (k)->ConvKey)->Lock); \
232#define CmpAcquireNcbLockExclusive(n) \
234 ExAcquirePushLockExclusive(&GET_HASH_ENTRY(CmpNameCacheTable, \
235 (n)->ConvKey)->Lock); \
241#define CmpAcquireNcbLockExclusiveByKey(k) \
243 ExAcquirePushLockExclusive(&GET_HASH_ENTRY(CmpNameCacheTable, \
250#define CmpReleaseNcbLock(k) \
252 ExReleasePushLock(&GET_HASH_ENTRY(CmpNameCacheTable, \
253 (k)->ConvKey)->Lock); \
259#define CmpReleaseNcbLockByKey(k) \
261 ExReleasePushLock(&GET_HASH_ENTRY(CmpNameCacheTable, \
268#define CMP_ASSERT_HASH_ENTRY_LOCK(k) \
270 ASSERT(((GET_HASH_ENTRY(CmpCacheTable, k)->Owner == \
271 KeGetCurrentThread())) || \
272 (CmpTestRegistryLockExclusive() == TRUE)); \
278#define CMP_ASSERT_KCB_LOCK(k) \
280 ASSERT((CmpIsKcbLockedExclusive(k) == TRUE) || \
281 (CmpTestRegistryLockExclusive() == TRUE)); \
287#define CmpGetAllocPageFromKcb(k) \
288 (PCM_ALLOC_PAGE)(((ULONG_PTR)(k)) & ~(PAGE_SIZE - 1))
293#define CmpGetAllocPageFromDelayAlloc(a) \
294 (PCM_ALLOC_PAGE)(((ULONG_PTR)(a)) & ~(PAGE_SIZE - 1))
299#define CMP_ASSERT_FLUSH_LOCK(h) \
300 ASSERT((CmpSpecialBootCondition == TRUE) || \
301 (((PCMHIVE)h)->HiveIsLoading == TRUE) || \
302 (CmpTestHiveFlusherLockShared((PCMHIVE)h) == TRUE) || \
303 (CmpTestHiveFlusherLockExclusive((PCMHIVE)h) == TRUE) || \
304 (CmpTestRegistryLockExclusive() == TRUE));
FORCEINLINE VOID CmpAcquireKcbLockExclusive(PCM_KEY_CONTROL_BLOCK Kcb)
FORCEINLINE VOID CmpAcquireKcbLockExclusiveByKey(IN ULONG ConvKey)
#define GET_HASH_ENTRY(Table, ConvKey)
FORCEINLINE VOID CmpAcquireKcbLockExclusiveByIndex(ULONG Index)
#define GET_HASH_INDEX(ConvKey)
FORCEINLINE VOID CmpReleaseKcbLockByKey(ULONG ConvKey)
#define CmpIsKcbLockedExclusive(k)
FORCEINLINE VOID CmpAcquireKcbLockSharedByKey(_In_ ULONG ConvKey)
FORCEINLINE VOID CmpConvertKcbSharedToExclusive(IN PCM_KEY_CONTROL_BLOCK k)
FORCEINLINE VOID CmpReleaseKcbLockByIndex(ULONG Index)
FORCEINLINE VOID CmpReleaseKcbLock(PCM_KEY_CONTROL_BLOCK Kcb)
FORCEINLINE BOOLEAN CmpTryToConvertKcbSharedToExclusive(IN PCM_KEY_CONTROL_BLOCK k)
#define CmpAcquireKcbLockSharedByIndex(i)
PCM_KEY_HASH_TABLE_ENTRY CmpCacheTable
FORCEINLINE VOID ExReleasePushLock(PEX_PUSH_LOCK PushLock)
FORCEINLINE VOID ExAcquirePushLockExclusive(PEX_PUSH_LOCK PushLock)
FORCEINLINE BOOLEAN ExConvertPushLockSharedToExclusive(IN PEX_PUSH_LOCK PushLock)
#define KeGetCurrentThread
_Out_writes_bytes_to_opt_ AbsoluteSecurityDescriptorSize PSECURITY_DESCRIPTOR _Inout_ PULONG _Out_writes_bytes_to_opt_ DaclSize PACL _Inout_ PULONG _Out_writes_bytes_to_opt_ SaclSize PACL _Inout_ PULONG _Out_writes_bytes_to_opt_ OwnerSize PSID Owner
_In_ WDFCOLLECTION _In_ ULONG Index
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
NTSYSAPI USHORT NTAPI RtlCaptureStackBackTrace(_In_ ULONG FramesToSkip, _In_ ULONG FramesToCapture, _Out_writes_to_(FramesToCapture, return) PVOID *BackTrace, _Out_opt_ PULONG BackTraceHash)