Skip to content

Commit

Permalink
[CMLIB][NTOS:CM] Deduplicate other common definitions between CMLIB a…
Browse files Browse the repository at this point in the history
…nd the NTOS CM.

Addendum to commit 8c2454e (r70605).

CORE-10802 CORE-10793
  • Loading branch information
HBelusca authored and GeoB99 committed Jul 10, 2022
1 parent 10126e7 commit ba1269b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 95 deletions.
84 changes: 4 additions & 80 deletions ntoskrnl/include/internal/cm.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@
#define CMTRACE(x, fmt, ...) DPRINT(fmt, ##__VA_ARGS__)
#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
//
Expand All @@ -67,19 +61,14 @@
//
// CM_KEY_BODY Types
//
#define CM_KEY_BODY_TYPE 0x6B793032

//
// CM_KEY_VALUE Types
//
#define CM_KEY_VALUE_SMALL 0x4
#define CM_KEY_VALUE_BIG 0x3FD8
#define CM_KEY_VALUE_SPECIAL_SIZE 0x80000000
#define CM_KEY_BODY_TYPE 0x6B793032 // 'ky02'

//
// Number of various lists and hashes
//
#if 0 // See sdk/lib/cmlib/cmlib.h
#define CMP_SECURITY_HASH_LISTS 64
#endif
#define CMP_MAX_CALLBACKS 100

//
Expand Down Expand Up @@ -115,7 +104,7 @@
//
// Maximum size of Value Cache
//
#define MAXIMUM_CACHED_DATA 2 * PAGE_SIZE
#define MAXIMUM_CACHED_DATA (2 * PAGE_SIZE)

//
// Hives to load on startup
Expand Down Expand Up @@ -373,71 +362,6 @@ typedef struct _CM_DELAY_DEREF_KCB_ITEM
PCM_KEY_CONTROL_BLOCK Kcb;
} 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
//
Expand Down
26 changes: 11 additions & 15 deletions sdk/lib/cmlib/cmlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
IN PRTL_BITMAP BitMapHeader);

#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 PKGUARDED_MUTEX PVOID
Expand Down Expand Up @@ -152,7 +152,9 @@
#undef PAGED_CODE
#define PAGED_CODE()
#define REGISTRY_ERROR ((ULONG)0x00000051L)

#else

//
// Debug/Tracing support
//
Expand Down Expand Up @@ -214,17 +216,13 @@
#include "hivedata.h"
#include "cmdata.h"

#if defined(_TYPEDEFS_HOST_H) || defined(_BLDR_)

#define PCM_KEY_SECURITY_CACHE_ENTRY PVOID
#define PCM_KEY_CONTROL_BLOCK PVOID
#define PCM_CELL_REMAP_BLOCK PVOID
/* 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;

// 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.
// See ntoskrnl/include/internal/cm.h
#define CMP_SECURITY_HASH_LISTS 64

//
// Use Count Log and Entry
Expand Down Expand Up @@ -291,8 +289,6 @@ typedef struct _CMHIVE
PKTHREAD CreatorOwner;
} CMHIVE, *PCMHIVE;

#endif // See comment above

typedef struct _HV_HIVE_CELL_PAIR
{
PHHIVE Hive;
Expand All @@ -312,9 +308,9 @@ typedef struct _HV_TRACK_CELL_REF
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));

//
Expand Down

0 comments on commit ba1269b

Please sign in to comment.