[CMLIB][NTOS:CM] Deduplicate other common definitions between CMLIB and the NTOS CM

Addendum to commit 8c2454e (r70605). Credits and courtesy go to Hermès BÉLUSCA - MAÏTO.

CORE-10802 CORE-10793
This commit is contained in:
George Bișoc 2022-07-10 14:35:53 +02:00
parent 10126e7710
commit 54a00aa8eb
No known key found for this signature in database
GPG key ID: 49452AAF629C81F3
2 changed files with 15 additions and 95 deletions

View file

@ -40,12 +40,6 @@
#define CMTRACE(x, fmt, ...) DPRINT(fmt, ##__VA_ARGS__) #define CMTRACE(x, fmt, ...) DPRINT(fmt, ##__VA_ARGS__)
#endif #endif
//
// Hack since bigkeys are not yet supported
//
#define ASSERT_VALUE_BIG(h, s) \
ASSERTMSG("Big keys not supported!\n", !CmpIsKeyValueBig(h, s));
// //
// CM_KEY_CONTROL_BLOCK Signatures // CM_KEY_CONTROL_BLOCK Signatures
// //
@ -67,19 +61,14 @@
// //
// CM_KEY_BODY Types // CM_KEY_BODY Types
// //
#define CM_KEY_BODY_TYPE 0x6B793032 #define CM_KEY_BODY_TYPE 0x6B793032 // 'ky02'
//
// CM_KEY_VALUE Types
//
#define CM_KEY_VALUE_SMALL 0x4
#define CM_KEY_VALUE_BIG 0x3FD8
#define CM_KEY_VALUE_SPECIAL_SIZE 0x80000000
// //
// Number of various lists and hashes // Number of various lists and hashes
// //
#if 0 // See sdk/lib/cmlib/cmlib.h
#define CMP_SECURITY_HASH_LISTS 64 #define CMP_SECURITY_HASH_LISTS 64
#endif
#define CMP_MAX_CALLBACKS 100 #define CMP_MAX_CALLBACKS 100
// //
@ -115,7 +104,7 @@
// //
// Maximum size of Value Cache // Maximum size of Value Cache
// //
#define MAXIMUM_CACHED_DATA 2 * PAGE_SIZE #define MAXIMUM_CACHED_DATA (2 * PAGE_SIZE)
// //
// Hives to load on startup // Hives to load on startup
@ -373,71 +362,6 @@ typedef struct _CM_DELAY_DEREF_KCB_ITEM
PCM_KEY_CONTROL_BLOCK Kcb; PCM_KEY_CONTROL_BLOCK Kcb;
} CM_DELAY_DEREF_KCB_ITEM, *PCM_DELAY_DEREF_KCB_ITEM; } CM_DELAY_DEREF_KCB_ITEM, *PCM_DELAY_DEREF_KCB_ITEM;
//
// Use Count Log and Entry
//
typedef struct _CM_USE_COUNT_LOG_ENTRY
{
HCELL_INDEX Cell;
PVOID Stack[7];
} CM_USE_COUNT_LOG_ENTRY, *PCM_USE_COUNT_LOG_ENTRY;
typedef struct _CM_USE_COUNT_LOG
{
USHORT Next;
USHORT Size;
CM_USE_COUNT_LOG_ENTRY Log[32];
} CM_USE_COUNT_LOG, *PCM_USE_COUNT_LOG;
//
// Configuration Manager Hive Structure
//
typedef struct _CMHIVE
{
HHIVE Hive;
HANDLE FileHandles[HFILE_TYPE_MAX];
LIST_ENTRY NotifyList;
LIST_ENTRY HiveList;
EX_PUSH_LOCK HiveLock;
PKTHREAD HiveLockOwner;
PKGUARDED_MUTEX ViewLock;
PKTHREAD ViewLockOwner;
EX_PUSH_LOCK WriterLock;
PKTHREAD WriterLockOwner;
PERESOURCE FlusherLock;
EX_PUSH_LOCK SecurityLock;
PKTHREAD HiveSecurityLockOwner;
LIST_ENTRY LRUViewListHead;
LIST_ENTRY PinViewListHead;
PFILE_OBJECT FileObject;
UNICODE_STRING FileFullPath;
UNICODE_STRING FileUserName;
USHORT MappedViews;
USHORT PinnedViews;
ULONG UseCount;
ULONG SecurityCount;
ULONG SecurityCacheSize;
LONG SecurityHitHint;
PCM_KEY_SECURITY_CACHE_ENTRY SecurityCache;
LIST_ENTRY SecurityHash[CMP_SECURITY_HASH_LISTS];
PKEVENT UnloadEvent;
PCM_KEY_CONTROL_BLOCK RootKcb;
BOOLEAN Frozen;
PWORK_QUEUE_ITEM UnloadWorkItem;
BOOLEAN GrowOnlyMode;
ULONG GrowOffset;
LIST_ENTRY KcbConvertListHead;
LIST_ENTRY KnodeConvertListHead;
PCM_CELL_REMAP_BLOCK CellRemapArray;
CM_USE_COUNT_LOG UseCountLog;
CM_USE_COUNT_LOG LockHiveLog;
ULONG Flags;
LIST_ENTRY TrustClassEntry;
ULONG FlushCount;
BOOLEAN HiveIsLoading;
PKTHREAD CreatorOwner;
} CMHIVE, *PCMHIVE;
// //
// Cached Value Index // Cached Value Index
// //

View file

@ -122,7 +122,7 @@
IN PRTL_BITMAP BitMapHeader); IN PRTL_BITMAP BitMapHeader);
#define RtlCheckBit(BMH,BP) (((((PLONG)(BMH)->Buffer)[(BP) / 32]) >> ((BP) % 32)) & 0x1) #define RtlCheckBit(BMH,BP) (((((PLONG)(BMH)->Buffer)[(BP) / 32]) >> ((BP) % 32)) & 0x1)
#define UNREFERENCED_PARAMETER(P) {(P)=(P);} #define UNREFERENCED_PARAMETER(P) ((void)(P))
#define PKTHREAD PVOID #define PKTHREAD PVOID
#define PKGUARDED_MUTEX PVOID #define PKGUARDED_MUTEX PVOID
@ -152,7 +152,9 @@
#undef PAGED_CODE #undef PAGED_CODE
#define PAGED_CODE() #define PAGED_CODE()
#define REGISTRY_ERROR ((ULONG)0x00000051L) #define REGISTRY_ERROR ((ULONG)0x00000051L)
#else #else
// //
// Debug/Tracing support // Debug/Tracing support
// //
@ -214,17 +216,13 @@
#include "hivedata.h" #include "hivedata.h"
#include "cmdata.h" #include "cmdata.h"
#if defined(_TYPEDEFS_HOST_H) || defined(_BLDR_) /* Forward declarations */
typedef struct _CM_KEY_SECURITY_CACHE_ENTRY *PCM_KEY_SECURITY_CACHE_ENTRY;
typedef struct _CM_KEY_CONTROL_BLOCK *PCM_KEY_CONTROL_BLOCK;
typedef struct _CM_CELL_REMAP_BLOCK *PCM_CELL_REMAP_BLOCK;
#define PCM_KEY_SECURITY_CACHE_ENTRY PVOID // See ntoskrnl/include/internal/cm.h
#define PCM_KEY_CONTROL_BLOCK PVOID #define CMP_SECURITY_HASH_LISTS 64
#define PCM_CELL_REMAP_BLOCK PVOID
// See also ntoskrnl/include/internal/cm.h
#define CMP_SECURITY_HASH_LISTS 64
// #endif // Commented out until one finds a way to properly include
// this header in the bootloader and in ntoskrnl.
// //
// Use Count Log and Entry // Use Count Log and Entry
@ -291,8 +289,6 @@ typedef struct _CMHIVE
PKTHREAD CreatorOwner; PKTHREAD CreatorOwner;
} CMHIVE, *PCMHIVE; } CMHIVE, *PCMHIVE;
#endif // See comment above
typedef struct _HV_HIVE_CELL_PAIR typedef struct _HV_HIVE_CELL_PAIR
{ {
PHHIVE Hive; PHHIVE Hive;
@ -312,9 +308,9 @@ typedef struct _HV_TRACK_CELL_REF
extern ULONG CmlibTraceLevel; extern ULONG CmlibTraceLevel;
// //
// Hack since bigkeys are not yet supported // Hack since big keys are not yet supported
// //
#define ASSERT_VALUE_BIG(h, s) \ #define ASSERT_VALUE_BIG(h, s) \
ASSERTMSG("Big keys not supported!\n", !CmpIsKeyValueBig(h, s)); ASSERTMSG("Big keys not supported!\n", !CmpIsKeyValueBig(h, s));
// //