mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 19:05:52 +00:00
- Define LIST_ENTRY functions as part of host headers, instead of mkhive-specific defines.
- Use CM_KEY_CONTROL_BLOCK when communicating with new CM implementation ("config"). CM now builds a dummy KCB so that the functions in "config" can go around their business with KCB without needing to know what a ros-specific PKEY_OBJECT is. svn path=/trunk/; revision=29902
This commit is contained in:
parent
dbb8fcae7b
commit
ec2b9a0991
7 changed files with 269 additions and 206 deletions
|
@ -120,6 +120,102 @@ typedef struct _UNICODE_STRING
|
|||
} UNICODE_STRING, *PUNICODE_STRING;
|
||||
#include <host/poppack.h>
|
||||
|
||||
//
|
||||
// List Functions
|
||||
//
|
||||
static inline
|
||||
VOID
|
||||
InitializeListHead(
|
||||
IN PLIST_ENTRY ListHead
|
||||
)
|
||||
{
|
||||
ListHead->Flink = ListHead->Blink = ListHead;
|
||||
}
|
||||
|
||||
static inline
|
||||
VOID
|
||||
InsertHeadList(
|
||||
IN PLIST_ENTRY ListHead,
|
||||
IN PLIST_ENTRY Entry
|
||||
)
|
||||
{
|
||||
PLIST_ENTRY OldFlink;
|
||||
OldFlink = ListHead->Flink;
|
||||
Entry->Flink = OldFlink;
|
||||
Entry->Blink = ListHead;
|
||||
OldFlink->Blink = Entry;
|
||||
ListHead->Flink = Entry;
|
||||
}
|
||||
|
||||
static inline
|
||||
VOID
|
||||
InsertTailList(
|
||||
IN PLIST_ENTRY ListHead,
|
||||
IN PLIST_ENTRY Entry
|
||||
)
|
||||
{
|
||||
PLIST_ENTRY OldBlink;
|
||||
OldBlink = ListHead->Blink;
|
||||
Entry->Flink = ListHead;
|
||||
Entry->Blink = OldBlink;
|
||||
OldBlink->Flink = Entry;
|
||||
ListHead->Blink = Entry;
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
static inline
|
||||
IsListEmpty(
|
||||
IN const LIST_ENTRY * ListHead
|
||||
)
|
||||
{
|
||||
return (BOOLEAN)(ListHead->Flink == ListHead);
|
||||
}
|
||||
|
||||
static inline
|
||||
BOOLEAN
|
||||
RemoveEntryList(
|
||||
IN PLIST_ENTRY Entry)
|
||||
{
|
||||
PLIST_ENTRY OldFlink;
|
||||
PLIST_ENTRY OldBlink;
|
||||
|
||||
OldFlink = Entry->Flink;
|
||||
OldBlink = Entry->Blink;
|
||||
OldFlink->Blink = OldBlink;
|
||||
OldBlink->Flink = OldFlink;
|
||||
return (BOOLEAN)(OldFlink == OldBlink);
|
||||
}
|
||||
|
||||
static inline
|
||||
PLIST_ENTRY
|
||||
RemoveHeadList(
|
||||
IN PLIST_ENTRY ListHead)
|
||||
{
|
||||
PLIST_ENTRY Flink;
|
||||
PLIST_ENTRY Entry;
|
||||
|
||||
Entry = ListHead->Flink;
|
||||
Flink = Entry->Flink;
|
||||
ListHead->Flink = Flink;
|
||||
Flink->Blink = ListHead;
|
||||
return Entry;
|
||||
}
|
||||
|
||||
static inline
|
||||
PLIST_ENTRY
|
||||
RemoveTailList(
|
||||
IN PLIST_ENTRY ListHead)
|
||||
{
|
||||
PLIST_ENTRY Blink;
|
||||
PLIST_ENTRY Entry;
|
||||
|
||||
Entry = ListHead->Blink;
|
||||
Blink = Entry->Blink;
|
||||
ListHead->Blink = Blink;
|
||||
Blink->Flink = ListHead;
|
||||
return Entry;
|
||||
}
|
||||
|
||||
typedef const UNICODE_STRING *PCUNICODE_STRING;
|
||||
|
||||
#define NT_SUCCESS(x) ((x)>=0)
|
||||
|
|
|
@ -114,6 +114,51 @@ typedef struct _KEY_OBJECT
|
|||
CACHED_CHILD_LIST ValueCache;
|
||||
} KEY_OBJECT, *PKEY_OBJECT;
|
||||
|
||||
//
|
||||
// Key Control Block (KCB) for old Cm (just so it can talk to New CM)
|
||||
//
|
||||
typedef struct _CM_KEY_CONTROL_BLOCK
|
||||
{
|
||||
USHORT RefCount;
|
||||
USHORT Flags;
|
||||
ULONG ExtFlags:8;
|
||||
ULONG PrivateAlloc:1;
|
||||
ULONG Delete:1;
|
||||
ULONG DelayedCloseIndex:12;
|
||||
ULONG TotalLevels:10;
|
||||
union
|
||||
{
|
||||
//CM_KEY_HASH KeyHash;
|
||||
struct
|
||||
{
|
||||
ULONG ConvKey;
|
||||
PVOID NextHash;
|
||||
PHHIVE KeyHive;
|
||||
HCELL_INDEX KeyCell;
|
||||
};
|
||||
};
|
||||
struct _CM_KEY_CONTROL_BLOCK *ParentKcb;
|
||||
PVOID NameBlock;
|
||||
PVOID CachedSecurity;
|
||||
CACHED_CHILD_LIST ValueCache;
|
||||
PVOID IndexHint;
|
||||
ULONG HashKey;
|
||||
ULONG SubKeyCount;
|
||||
union
|
||||
{
|
||||
LIST_ENTRY KeyBodyListHead;
|
||||
LIST_ENTRY FreeListEntry;
|
||||
};
|
||||
PVOID KeyBodyArray[4];
|
||||
PVOID DelayCloseEntry;
|
||||
LARGE_INTEGER KcbLastWriteTime;
|
||||
USHORT KcbMaxNameLen;
|
||||
USHORT KcbMaxValueNameLen;
|
||||
ULONG KcbMaxValueDataLen;
|
||||
ULONG InDelayClose;
|
||||
} CM_KEY_CONTROL_BLOCK, *PCM_KEY_CONTROL_BLOCK;
|
||||
|
||||
|
||||
/* Bits 31-22 (top 10 bits) of the cell index is the directory index */
|
||||
#define CmiDirectoryIndex(CellIndex)(CellIndex & 0xffc000000)
|
||||
/* Bits 21-12 (middle 10 bits) of the cell index is the table index */
|
||||
|
@ -222,12 +267,12 @@ CmiScanKeyForValue(IN PEREGISTRY_HIVE RegistryHive,
|
|||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
CmDeleteValueKey(IN PKEY_OBJECT KeyControlBlock,
|
||||
CmDeleteValueKey(IN PCM_KEY_CONTROL_BLOCK Kcb,
|
||||
IN UNICODE_STRING ValueName);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
CmQueryValueKey(IN PKEY_OBJECT KeyObject,
|
||||
CmQueryValueKey(IN PCM_KEY_CONTROL_BLOCK Kcb,
|
||||
IN UNICODE_STRING ValueName,
|
||||
IN KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass,
|
||||
IN PVOID KeyValueInformation,
|
||||
|
@ -236,7 +281,7 @@ CmQueryValueKey(IN PKEY_OBJECT KeyObject,
|
|||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
CmEnumerateValueKey(IN PKEY_OBJECT KeyObject,
|
||||
CmEnumerateValueKey(IN PCM_KEY_CONTROL_BLOCK Kcb,
|
||||
IN ULONG Index,
|
||||
IN KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass,
|
||||
IN PVOID KeyValueInformation,
|
||||
|
@ -245,7 +290,7 @@ CmEnumerateValueKey(IN PKEY_OBJECT KeyObject,
|
|||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
CmSetValueKey(IN PKEY_OBJECT KeyObject,
|
||||
CmSetValueKey(IN PCM_KEY_CONTROL_BLOCK Kcb,
|
||||
IN PUNICODE_STRING ValueName,
|
||||
IN ULONG Type,
|
||||
IN PVOID Data,
|
||||
|
@ -253,7 +298,7 @@ CmSetValueKey(IN PKEY_OBJECT KeyObject,
|
|||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
CmQueryKey(IN PKEY_OBJECT KeyObject,
|
||||
CmQueryKey(IN PCM_KEY_CONTROL_BLOCK Kcb,
|
||||
IN KEY_INFORMATION_CLASS KeyInformationClass,
|
||||
IN PVOID KeyInformation,
|
||||
IN ULONG Length,
|
||||
|
@ -261,7 +306,7 @@ CmQueryKey(IN PKEY_OBJECT KeyObject,
|
|||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
CmEnumerateKey(IN PKEY_OBJECT KeyObject,
|
||||
CmEnumerateKey(IN PCM_KEY_CONTROL_BLOCK Kcb,
|
||||
IN ULONG Index,
|
||||
IN KEY_INFORMATION_CLASS KeyInformationClass,
|
||||
IN PVOID KeyInformation,
|
||||
|
@ -270,7 +315,7 @@ CmEnumerateKey(IN PKEY_OBJECT KeyObject,
|
|||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
CmDeleteKey(IN PKEY_OBJECT KeyObject);
|
||||
CmDeleteKey(IN PCM_KEY_CONTROL_BLOCK Kcb);
|
||||
|
||||
NTSTATUS
|
||||
CmiAllocateHashTableCell(IN PEREGISTRY_HIVE RegistryHive,
|
||||
|
@ -317,8 +362,6 @@ CmpFindValueByName(
|
|||
IN PUNICODE_STRING Name
|
||||
);
|
||||
|
||||
/* NOTE: This function declaration is currently duplicated in both */
|
||||
/* cm/cm.h and config/cm.h. TODO: Pick one single place to declare it. */
|
||||
HCELL_INDEX
|
||||
NTAPI
|
||||
CmpFindSubKeyByName(
|
||||
|
@ -342,8 +385,6 @@ CmFindObject(
|
|||
IN PVOID ParseContext
|
||||
);
|
||||
|
||||
/* NOTE: This function declaration is currently duplicated in both */
|
||||
/* cm/cm.h and config/cm.h. TODO: Pick one single place to declare it. */
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
CmpOpenHiveFiles(IN PCUNICODE_STRING BaseName,
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
/* GLOBALS ******************************************************************/
|
||||
|
||||
extern POBJECT_TYPE CmpKeyObjectType;
|
||||
|
||||
static BOOLEAN CmiRegistryInitialized = FALSE;
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
@ -709,8 +708,13 @@ NtDeleteKey(IN HANDLE KeyHandle)
|
|||
Status = CmiCallRegisteredCallbacks(RegNtPreDeleteKey, &DeleteKeyInfo);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
/* HACK: Setup the Dummy KCB */
|
||||
CM_KEY_CONTROL_BLOCK DummyKcb = {0};
|
||||
DummyKcb.KeyHive = &KeyObject->RegistryHive->Hive;
|
||||
DummyKcb.KeyCell = KeyObject->KeyCellOffset;
|
||||
|
||||
/* Call the internal API */
|
||||
Status = CmDeleteKey(KeyObject);
|
||||
Status = CmDeleteKey(&DummyKcb);
|
||||
|
||||
/* Remove the keep-alive reference */
|
||||
ObDereferenceObject(KeyObject);
|
||||
|
@ -773,8 +777,13 @@ NtEnumerateKey(IN HANDLE KeyHandle,
|
|||
Status = CmiCallRegisteredCallbacks(RegNtPreEnumerateKey, &EnumerateKeyInfo);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
/* HACK: Setup the Dummy KCB */
|
||||
CM_KEY_CONTROL_BLOCK DummyKcb = {0};
|
||||
DummyKcb.KeyHive = &KeyObject->RegistryHive->Hive;
|
||||
DummyKcb.KeyCell = KeyObject->KeyCellOffset;
|
||||
|
||||
/* Call the internal API */
|
||||
Status = CmEnumerateKey(KeyObject,
|
||||
Status = CmEnumerateKey(&DummyKcb,
|
||||
Index,
|
||||
KeyInformationClass,
|
||||
KeyInformation,
|
||||
|
@ -836,8 +845,13 @@ NtEnumerateValueKey(IN HANDLE KeyHandle,
|
|||
&EnumerateValueKeyInfo);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
/* HACK: Setup the Dummy KCB */
|
||||
CM_KEY_CONTROL_BLOCK DummyKcb = {0};
|
||||
DummyKcb.KeyHive = &KeyObject->RegistryHive->Hive;
|
||||
DummyKcb.KeyCell = KeyObject->KeyCellOffset;
|
||||
|
||||
/* Call the internal API */
|
||||
Status = CmEnumerateValueKey(KeyObject,
|
||||
Status = CmEnumerateValueKey(&DummyKcb,
|
||||
Index,
|
||||
KeyValueInformationClass,
|
||||
KeyValueInformation,
|
||||
|
@ -897,8 +911,13 @@ NtQueryKey(IN HANDLE KeyHandle,
|
|||
Status = CmiCallRegisteredCallbacks(RegNtPreQueryKey, &QueryKeyInfo);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
/* HACK: Setup the Dummy KCB */
|
||||
CM_KEY_CONTROL_BLOCK DummyKcb = {0};
|
||||
DummyKcb.KeyHive = &KeyObject->RegistryHive->Hive;
|
||||
DummyKcb.KeyCell = KeyObject->KeyCellOffset;
|
||||
|
||||
/* Call the internal API */
|
||||
Status = CmQueryKey(KeyObject,
|
||||
Status = CmQueryKey(&DummyKcb,
|
||||
KeyInformationClass,
|
||||
KeyInformation,
|
||||
Length,
|
||||
|
@ -957,8 +976,13 @@ NtQueryValueKey(IN HANDLE KeyHandle,
|
|||
Status = CmiCallRegisteredCallbacks(RegNtPreQueryValueKey, &QueryValueKeyInfo);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
/* HACK: Setup the Dummy KCB */
|
||||
CM_KEY_CONTROL_BLOCK DummyKcb = {0};
|
||||
DummyKcb.KeyHive = &KeyObject->RegistryHive->Hive;
|
||||
DummyKcb.KeyCell = KeyObject->KeyCellOffset;
|
||||
|
||||
/* Call the internal API */
|
||||
Status = CmQueryValueKey(KeyObject,
|
||||
Status = CmQueryValueKey(&DummyKcb,
|
||||
*ValueName,
|
||||
KeyValueInformationClass,
|
||||
KeyValueInformation,
|
||||
|
@ -1021,8 +1045,13 @@ NtSetValueKey(IN HANDLE KeyHandle,
|
|||
Status = CmiCallRegisteredCallbacks(RegNtPreSetValueKey, &SetValueKeyInfo);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
/* HACK: Setup the Dummy KCB */
|
||||
CM_KEY_CONTROL_BLOCK DummyKcb = {0};
|
||||
DummyKcb.KeyHive = &KeyObject->RegistryHive->Hive;
|
||||
DummyKcb.KeyCell = KeyObject->KeyCellOffset;
|
||||
|
||||
/* Call the internal API */
|
||||
Status = CmSetValueKey(KeyObject,
|
||||
Status = CmSetValueKey(&DummyKcb,
|
||||
ValueName,
|
||||
Type,
|
||||
Data,
|
||||
|
@ -1071,8 +1100,13 @@ NtDeleteValueKey(IN HANDLE KeyHandle,
|
|||
&DeleteValueKeyInfo);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
/* HACK: Setup the Dummy KCB */
|
||||
CM_KEY_CONTROL_BLOCK DummyKcb = {0};
|
||||
DummyKcb.KeyHive = &KeyObject->RegistryHive->Hive;
|
||||
DummyKcb.KeyCell = KeyObject->KeyCellOffset;
|
||||
|
||||
/* Call the internal API */
|
||||
Status = CmDeleteValueKey(KeyObject, *ValueName);
|
||||
Status = CmDeleteValueKey(&DummyKcb, *ValueName);
|
||||
|
||||
/* Do the post callback */
|
||||
PostOperationInfo.Object = (PVOID)KeyObject;
|
||||
|
|
|
@ -710,7 +710,7 @@ CmpInitSecurityCache(
|
|||
VALUE_SEARCH_RETURN_TYPE
|
||||
NTAPI
|
||||
CmpFindValueByNameFromCache(
|
||||
IN PKEY_OBJECT KeyObject,
|
||||
IN PCM_KEY_CONTROL_BLOCK Kcb,
|
||||
IN PCUNICODE_STRING Name,
|
||||
OUT PCM_CACHED_VALUE **CachedValue,
|
||||
OUT ULONG *Index,
|
||||
|
@ -722,7 +722,7 @@ CmpFindValueByNameFromCache(
|
|||
VALUE_SEARCH_RETURN_TYPE
|
||||
NTAPI
|
||||
CmpQueryKeyValueData(
|
||||
IN PKEY_OBJECT KeyObject,
|
||||
IN PCM_KEY_CONTROL_BLOCK Kcb,
|
||||
IN PCM_CACHED_VALUE *CachedValue,
|
||||
IN PCM_KEY_VALUE ValueKey,
|
||||
IN BOOLEAN ValueIsCached,
|
||||
|
@ -736,7 +736,7 @@ CmpQueryKeyValueData(
|
|||
VALUE_SEARCH_RETURN_TYPE
|
||||
NTAPI
|
||||
CmpGetValueListFromCache(
|
||||
IN PKEY_OBJECT KeyObject,
|
||||
IN PCM_KEY_CONTROL_BLOCK Kcb,
|
||||
OUT PCELL_DATA *CellData,
|
||||
OUT BOOLEAN *IndexIsCached,
|
||||
OUT PHCELL_INDEX ValueListToRelease
|
||||
|
@ -745,7 +745,7 @@ CmpGetValueListFromCache(
|
|||
VALUE_SEARCH_RETURN_TYPE
|
||||
NTAPI
|
||||
CmpGetValueKeyFromCache(
|
||||
IN PKEY_OBJECT KeyObject,
|
||||
IN PCM_KEY_CONTROL_BLOCK Kcb,
|
||||
IN PCELL_DATA CellData,
|
||||
IN ULONG Index,
|
||||
OUT PCM_CACHED_VALUE **CachedValue,
|
||||
|
@ -979,7 +979,7 @@ EnlistKeyBodyWithKCB(
|
|||
#if 0
|
||||
IN PCM_KEY_BODY KeyObject,
|
||||
#else
|
||||
IN PKEY_OBJECT KeyObject,
|
||||
IN PVOID KeyObject,
|
||||
#endif
|
||||
IN ULONG Flags
|
||||
);
|
||||
|
|
|
@ -216,7 +216,7 @@ CmpSetValueKeyExisting(IN PHHIVE Hive,
|
|||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
CmSetValueKey(IN PKEY_OBJECT KeyObject,
|
||||
CmSetValueKey(IN PCM_KEY_CONTROL_BLOCK Kcb,
|
||||
IN PUNICODE_STRING ValueName,
|
||||
IN ULONG Type,
|
||||
IN PVOID Data,
|
||||
|
@ -235,11 +235,11 @@ CmSetValueKey(IN PKEY_OBJECT KeyObject,
|
|||
ExAcquireResourceExclusiveLite(&CmpRegistryLock, TRUE);
|
||||
|
||||
/* Get pointer to key cell */
|
||||
Parent = KeyObject->KeyCell;
|
||||
Hive = &KeyObject->RegistryHive->Hive;
|
||||
Cell = KeyObject->KeyCellOffset;
|
||||
Hive = Kcb->KeyHive;
|
||||
Cell = Kcb->KeyCell;
|
||||
|
||||
/* Prepare to scan the key node */
|
||||
Parent = (PCM_KEY_NODE)HvGetCell(Hive, Cell);
|
||||
Count = Parent->ValueList.Count;
|
||||
Found = FALSE;
|
||||
if (Count > 0)
|
||||
|
@ -343,7 +343,7 @@ Quickie:
|
|||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
CmDeleteValueKey(IN PKEY_OBJECT KeyObject,
|
||||
CmDeleteValueKey(IN PCM_KEY_CONTROL_BLOCK Kcb,
|
||||
IN UNICODE_STRING ValueName)
|
||||
{
|
||||
NTSTATUS Status = STATUS_OBJECT_NAME_NOT_FOUND;
|
||||
|
@ -360,8 +360,8 @@ CmDeleteValueKey(IN PKEY_OBJECT KeyObject,
|
|||
ExAcquireResourceExclusiveLite(&CmpRegistryLock, TRUE);
|
||||
|
||||
/* Get the hive and the cell index */
|
||||
Hive = &KeyObject->RegistryHive->Hive;
|
||||
Cell = KeyObject->KeyCellOffset;
|
||||
Hive = Kcb->KeyHive;
|
||||
Cell = Kcb->KeyCell;
|
||||
|
||||
/* Get the parent key node */
|
||||
Parent = (PCM_KEY_NODE)HvGetCell(Hive, Cell);
|
||||
|
@ -458,7 +458,7 @@ Quickie:
|
|||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
CmQueryValueKey(IN PKEY_OBJECT KeyObject,
|
||||
CmQueryValueKey(IN PCM_KEY_CONTROL_BLOCK Kcb,
|
||||
IN UNICODE_STRING ValueName,
|
||||
IN KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass,
|
||||
IN PVOID KeyValueInformation,
|
||||
|
@ -480,10 +480,10 @@ CmQueryValueKey(IN PKEY_OBJECT KeyObject,
|
|||
ExAcquireResourceExclusiveLite(&CmpRegistryLock, TRUE);
|
||||
|
||||
/* Get the hive */
|
||||
Hive = &KeyObject->RegistryHive->Hive;
|
||||
Hive = Kcb->KeyHive;
|
||||
|
||||
/* Find the key value */
|
||||
Result = CmpFindValueByNameFromCache(KeyObject,
|
||||
Result = CmpFindValueByNameFromCache(Kcb,
|
||||
&ValueName,
|
||||
&CachedValue,
|
||||
&Index,
|
||||
|
@ -496,7 +496,7 @@ CmQueryValueKey(IN PKEY_OBJECT KeyObject,
|
|||
ASSERT(ValueData != NULL);
|
||||
|
||||
/* Query the information requested */
|
||||
Result = CmpQueryKeyValueData(KeyObject,
|
||||
Result = CmpQueryKeyValueData(Kcb,
|
||||
CachedValue,
|
||||
ValueData,
|
||||
ValueCached,
|
||||
|
@ -523,7 +523,7 @@ CmQueryValueKey(IN PKEY_OBJECT KeyObject,
|
|||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
CmEnumerateValueKey(IN PKEY_OBJECT KeyObject,
|
||||
CmEnumerateValueKey(IN PCM_KEY_CONTROL_BLOCK Kcb,
|
||||
IN ULONG Index,
|
||||
IN KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass,
|
||||
IN PVOID KeyValueInformation,
|
||||
|
@ -546,8 +546,8 @@ CmEnumerateValueKey(IN PKEY_OBJECT KeyObject,
|
|||
ExAcquireResourceExclusiveLite(&CmpRegistryLock, TRUE);
|
||||
|
||||
/* Get the hive and parent */
|
||||
Hive = &KeyObject->RegistryHive->Hive;
|
||||
Parent = (PCM_KEY_NODE)HvGetCell(Hive, KeyObject->KeyCellOffset);
|
||||
Hive = Kcb->KeyHive;
|
||||
Parent = (PCM_KEY_NODE)HvGetCell(Hive, Kcb->KeyCell);
|
||||
if (!Parent)
|
||||
{
|
||||
/* Fail */
|
||||
|
@ -556,17 +556,17 @@ CmEnumerateValueKey(IN PKEY_OBJECT KeyObject,
|
|||
}
|
||||
|
||||
/* Make sure the index is valid */
|
||||
//if (Index >= KeyObject->ValueCache.Count)
|
||||
if (Index >= KeyObject->KeyCell->ValueList.Count)
|
||||
//if (Index >= Kcb->ValueCache.Count)
|
||||
if (Index >= Parent->ValueList.Count)
|
||||
{
|
||||
/* Release the cell and fail */
|
||||
HvReleaseCell(Hive, KeyObject->KeyCellOffset);
|
||||
HvReleaseCell(Hive, Kcb->KeyCell);
|
||||
Status = STATUS_NO_MORE_ENTRIES;
|
||||
goto Quickie;
|
||||
}
|
||||
|
||||
/* Find the value list */
|
||||
Result = CmpGetValueListFromCache(KeyObject,
|
||||
Result = CmpGetValueListFromCache(Kcb,
|
||||
&CellData,
|
||||
&IndexIsCached,
|
||||
&CellToRelease);
|
||||
|
@ -581,7 +581,7 @@ CmEnumerateValueKey(IN PKEY_OBJECT KeyObject,
|
|||
}
|
||||
|
||||
/* Now get the key value */
|
||||
Result = CmpGetValueKeyFromCache(KeyObject,
|
||||
Result = CmpGetValueKeyFromCache(Kcb,
|
||||
CellData,
|
||||
Index,
|
||||
&CachedValue,
|
||||
|
@ -600,7 +600,7 @@ CmEnumerateValueKey(IN PKEY_OBJECT KeyObject,
|
|||
}
|
||||
|
||||
/* Query the information requested */
|
||||
Result = CmpQueryKeyValueData(KeyObject,
|
||||
Result = CmpQueryKeyValueData(Kcb,
|
||||
CachedValue,
|
||||
ValueData,
|
||||
ValueIsCached,
|
||||
|
@ -615,7 +615,7 @@ Quickie:
|
|||
if (CellToRelease != HCELL_NIL) HvReleaseCell(Hive, CellToRelease);
|
||||
|
||||
/* Release the parent cell */
|
||||
HvReleaseCell(Hive, KeyObject->KeyCellOffset);
|
||||
HvReleaseCell(Hive, Kcb->KeyCell);
|
||||
|
||||
/* If we have a cell to release, do so */
|
||||
if (CellToRelease2 != HCELL_NIL) HvReleaseCell(Hive, CellToRelease2);
|
||||
|
@ -852,7 +852,7 @@ CmpQueryKeyData(IN PHHIVE Hive,
|
|||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
CmQueryKey(IN PKEY_OBJECT KeyObject,
|
||||
CmQueryKey(IN PCM_KEY_CONTROL_BLOCK Kcb,
|
||||
IN KEY_INFORMATION_CLASS KeyInformationClass,
|
||||
IN PVOID KeyInformation,
|
||||
IN ULONG Length,
|
||||
|
@ -867,8 +867,8 @@ CmQueryKey(IN PKEY_OBJECT KeyObject,
|
|||
ExAcquireResourceExclusiveLite(&CmpRegistryLock, TRUE);
|
||||
|
||||
/* Get the hive and parent */
|
||||
Hive = &KeyObject->RegistryHive->Hive;
|
||||
Parent = (PCM_KEY_NODE)HvGetCell(Hive, KeyObject->KeyCellOffset);
|
||||
Hive = Kcb->KeyHive;
|
||||
Parent = (PCM_KEY_NODE)HvGetCell(Hive, Kcb->KeyCell);
|
||||
if (!Parent)
|
||||
{
|
||||
/* Fail */
|
||||
|
@ -921,7 +921,7 @@ Quickie:
|
|||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
CmEnumerateKey(IN PKEY_OBJECT KeyObject,
|
||||
CmEnumerateKey(IN PCM_KEY_CONTROL_BLOCK Kcb,
|
||||
IN ULONG Index,
|
||||
IN KEY_INFORMATION_CLASS KeyInformationClass,
|
||||
IN PVOID KeyInformation,
|
||||
|
@ -938,8 +938,8 @@ CmEnumerateKey(IN PKEY_OBJECT KeyObject,
|
|||
ExAcquireResourceExclusiveLite(&CmpRegistryLock, TRUE);
|
||||
|
||||
/* Get the hive and parent */
|
||||
Hive = &KeyObject->RegistryHive->Hive;
|
||||
Parent = (PCM_KEY_NODE)HvGetCell(Hive, KeyObject->KeyCellOffset);
|
||||
Hive = Kcb->KeyHive;
|
||||
Parent = (PCM_KEY_NODE)HvGetCell(Hive, Kcb->KeyCell);
|
||||
if (!Parent)
|
||||
{
|
||||
/* Fail */
|
||||
|
@ -951,7 +951,7 @@ CmEnumerateKey(IN PKEY_OBJECT KeyObject,
|
|||
ChildCell = CmpFindSubKeyByNumber(Hive, Parent, Index);
|
||||
|
||||
/* Release the parent cell */
|
||||
HvReleaseCell(Hive, KeyObject->KeyCellOffset);
|
||||
HvReleaseCell(Hive, Kcb->KeyCell);
|
||||
|
||||
/* Check if we found the child */
|
||||
if (ChildCell == HCELL_NIL)
|
||||
|
@ -987,7 +987,7 @@ Quickie:
|
|||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
CmDeleteKey(IN PKEY_OBJECT KeyObject)
|
||||
CmDeleteKey(IN PCM_KEY_CONTROL_BLOCK Kcb)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
PHHIVE Hive;
|
||||
|
@ -999,17 +999,9 @@ CmDeleteKey(IN PKEY_OBJECT KeyObject)
|
|||
ExAcquireResourceExclusiveLite(&CmpRegistryLock, TRUE);
|
||||
|
||||
/* Get the hive and node */
|
||||
Hive = &KeyObject->RegistryHive->Hive;
|
||||
Cell = KeyObject->KeyCellOffset;
|
||||
|
||||
/* Check if we have no parent */
|
||||
if (!KeyObject->ParentKey)
|
||||
{
|
||||
/* This is an attempt to delete \Registry itself! */
|
||||
Status = STATUS_CANNOT_DELETE;
|
||||
goto Quickie;
|
||||
}
|
||||
|
||||
Hive = Kcb->KeyHive;
|
||||
Cell = Kcb->KeyCell;
|
||||
|
||||
/* Get the key node */
|
||||
Node = (PCM_KEY_NODE)HvGetCell(Hive, Cell);
|
||||
if (!Node)
|
||||
|
@ -1019,6 +1011,14 @@ CmDeleteKey(IN PKEY_OBJECT KeyObject)
|
|||
goto Quickie;
|
||||
}
|
||||
|
||||
/* Check if we have no parent */
|
||||
if (!Node->Parent)
|
||||
{
|
||||
/* This is an attempt to delete \Registry itself! */
|
||||
Status = STATUS_CANNOT_DELETE;
|
||||
goto Quickie;
|
||||
}
|
||||
|
||||
/* Check if we don't have any children */
|
||||
if (!(Node->SubKeyCounts[Stable] + Node->SubKeyCounts[Volatile]))
|
||||
{
|
||||
|
@ -1042,7 +1042,7 @@ CmDeleteKey(IN PKEY_OBJECT KeyObject)
|
|||
}
|
||||
|
||||
/* Clear the cell */
|
||||
KeyObject->KeyCellOffset = HCELL_NIL;
|
||||
Kcb->KeyCell = HCELL_NIL;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1050,19 +1050,19 @@ CmDeleteKey(IN PKEY_OBJECT KeyObject)
|
|||
/* Fail */
|
||||
Status = STATUS_CANNOT_DELETE;
|
||||
}
|
||||
|
||||
Quickie:
|
||||
/* Release the cell */
|
||||
HvReleaseCell(Hive, Cell);
|
||||
|
||||
|
||||
/* Make sure we're file-backed */
|
||||
if (!(IsNoFileHive(KeyObject->RegistryHive)) ||
|
||||
!(IsNoFileHive(KeyObject->ParentKey->RegistryHive)))
|
||||
if (!(IsNoFileHive((PEREGISTRY_HIVE)Kcb->KeyHive)) ||
|
||||
!(IsNoFileHive((PEREGISTRY_HIVE)Kcb->ParentKcb->KeyHive)))
|
||||
{
|
||||
/* Sync up the hives */
|
||||
CmiSyncHives();
|
||||
}
|
||||
|
||||
Quickie:
|
||||
/* Release the cell */
|
||||
HvReleaseCell(Hive, Cell);
|
||||
|
||||
/* Release hive lock */
|
||||
ExReleaseResourceLite(&CmpRegistryLock);
|
||||
KeLeaveCriticalRegion();
|
||||
|
|
|
@ -42,7 +42,7 @@ CmpSetValueCached(IN PHCELL_INDEX CellIndex)
|
|||
|
||||
VALUE_SEARCH_RETURN_TYPE
|
||||
NTAPI
|
||||
CmpGetValueListFromCache(IN PKEY_OBJECT KeyObject,
|
||||
CmpGetValueListFromCache(IN PCM_KEY_CONTROL_BLOCK Kcb,
|
||||
OUT PCELL_DATA *CellData,
|
||||
OUT BOOLEAN *IndexIsCached,
|
||||
OUT PHCELL_INDEX ValueListToRelease)
|
||||
|
@ -50,17 +50,19 @@ CmpGetValueListFromCache(IN PKEY_OBJECT KeyObject,
|
|||
PHHIVE Hive;
|
||||
PCACHED_CHILD_LIST ChildList;
|
||||
HCELL_INDEX CellToRelease;
|
||||
PCM_KEY_NODE KeyNode;
|
||||
|
||||
/* Set defaults */
|
||||
*ValueListToRelease = HCELL_NIL;
|
||||
*IndexIsCached = FALSE;
|
||||
|
||||
/* Get the hive */
|
||||
Hive = &KeyObject->RegistryHive->Hive;
|
||||
Hive = Kcb->KeyHive;
|
||||
KeyNode = (PCM_KEY_NODE)HvGetCell(Hive, Kcb->KeyCell);
|
||||
|
||||
/* Get the child value cache */
|
||||
//ChildList = &KeyObject->ValueCache;
|
||||
ChildList = (PCACHED_CHILD_LIST)&KeyObject->KeyCell->ValueList;
|
||||
//ChildList = &Kcb->ValueCache;
|
||||
ChildList = (PCACHED_CHILD_LIST)&KeyNode->ValueList;
|
||||
|
||||
/* Check if the value is cached */
|
||||
if (CmpIsValueCached(ChildList->ValueList))
|
||||
|
@ -87,7 +89,7 @@ CmpGetValueListFromCache(IN PKEY_OBJECT KeyObject,
|
|||
|
||||
VALUE_SEARCH_RETURN_TYPE
|
||||
NTAPI
|
||||
CmpGetValueKeyFromCache(IN PKEY_OBJECT KeyObject,
|
||||
CmpGetValueKeyFromCache(IN PCM_KEY_CONTROL_BLOCK Kcb,
|
||||
IN PCELL_DATA CellData,
|
||||
IN ULONG Index,
|
||||
OUT PCM_CACHED_VALUE **CachedValue,
|
||||
|
@ -106,7 +108,7 @@ CmpGetValueKeyFromCache(IN PKEY_OBJECT KeyObject,
|
|||
*ValueIsCached = FALSE;
|
||||
|
||||
/* Get the hive */
|
||||
Hive = &KeyObject->RegistryHive->Hive;
|
||||
Hive = Kcb->KeyHive;
|
||||
|
||||
/* Check if the index was cached */
|
||||
if (IndexIsCached)
|
||||
|
@ -133,7 +135,7 @@ CmpGetValueKeyFromCache(IN PKEY_OBJECT KeyObject,
|
|||
|
||||
VALUE_SEARCH_RETURN_TYPE
|
||||
NTAPI
|
||||
CmpGetValueDataFromCache(IN PKEY_OBJECT KeyObject,
|
||||
CmpGetValueDataFromCache(IN PCM_KEY_CONTROL_BLOCK Kcb,
|
||||
IN PCM_CACHED_VALUE *CachedValue,
|
||||
IN PCELL_DATA ValueKey,
|
||||
IN BOOLEAN ValueIsCached,
|
||||
|
@ -154,7 +156,7 @@ CmpGetValueDataFromCache(IN PKEY_OBJECT KeyObject,
|
|||
*CellToRelease = HCELL_NIL;
|
||||
|
||||
/* Get the hive */
|
||||
Hive = &KeyObject->RegistryHive->Hive;
|
||||
Hive = Kcb->KeyHive;
|
||||
|
||||
/* Check it the value is cached */
|
||||
if (ValueIsCached)
|
||||
|
@ -185,7 +187,7 @@ CmpGetValueDataFromCache(IN PKEY_OBJECT KeyObject,
|
|||
|
||||
VALUE_SEARCH_RETURN_TYPE
|
||||
NTAPI
|
||||
CmpFindValueByNameFromCache(IN PKEY_OBJECT KeyObject,
|
||||
CmpFindValueByNameFromCache(IN PCM_KEY_CONTROL_BLOCK Kcb,
|
||||
IN PCUNICODE_STRING Name,
|
||||
OUT PCM_CACHED_VALUE **CachedValue,
|
||||
OUT ULONG *Index,
|
||||
|
@ -203,21 +205,25 @@ CmpFindValueByNameFromCache(IN PKEY_OBJECT KeyObject,
|
|||
BOOLEAN IndexIsCached;
|
||||
ULONG i = 0;
|
||||
HCELL_INDEX Cell = HCELL_NIL;
|
||||
PCM_KEY_NODE KeyNode;
|
||||
|
||||
/* Set defaults */
|
||||
*CellToRelease = HCELL_NIL;
|
||||
*Value = NULL;
|
||||
|
||||
/* Get the hive and child list */
|
||||
Hive = &KeyObject->RegistryHive->Hive;
|
||||
//ChildList = &KeyObject->ValueCache;
|
||||
ChildList = (PCACHED_CHILD_LIST)&KeyObject->KeyCell->ValueList;
|
||||
/* Get the hive */
|
||||
Hive = Kcb->KeyHive;
|
||||
KeyNode = (PCM_KEY_NODE)HvGetCell(Hive, Kcb->KeyCell);
|
||||
|
||||
/* Get the child value cache */
|
||||
//ChildList = &Kcb->ValueCache;
|
||||
ChildList = (PCACHED_CHILD_LIST)&KeyNode->ValueList;
|
||||
|
||||
/* Check if the child list has any entries */
|
||||
if (ChildList->Count != 0)
|
||||
{
|
||||
/* Get the value list associated to this child list */
|
||||
SearchResult = CmpGetValueListFromCache(KeyObject,
|
||||
SearchResult = CmpGetValueListFromCache(Kcb,
|
||||
&CellData,
|
||||
&IndexIsCached,
|
||||
&Cell);
|
||||
|
@ -238,7 +244,7 @@ CmpFindValueByNameFromCache(IN PKEY_OBJECT KeyObject,
|
|||
}
|
||||
|
||||
/* Get the key value for this index */
|
||||
SearchResult = CmpGetValueKeyFromCache(KeyObject,
|
||||
SearchResult = CmpGetValueKeyFromCache(Kcb,
|
||||
CellData,
|
||||
i,
|
||||
CachedValue,
|
||||
|
@ -307,7 +313,7 @@ Quickie:
|
|||
|
||||
VALUE_SEARCH_RETURN_TYPE
|
||||
NTAPI
|
||||
CmpQueryKeyValueData(IN PKEY_OBJECT KeyObject,
|
||||
CmpQueryKeyValueData(IN PCM_KEY_CONTROL_BLOCK Kcb,
|
||||
IN PCM_CACHED_VALUE *CachedValue,
|
||||
IN PCM_KEY_VALUE ValueKey,
|
||||
IN BOOLEAN ValueIsCached,
|
||||
|
@ -328,7 +334,7 @@ CmpQueryKeyValueData(IN PKEY_OBJECT KeyObject,
|
|||
VALUE_SEARCH_RETURN_TYPE Result = SearchSuccess;
|
||||
|
||||
/* Get the hive and cell data */
|
||||
Hive = &KeyObject->RegistryHive->Hive;
|
||||
Hive = Kcb->KeyHive;
|
||||
CellData = (PCELL_DATA)ValueKey;
|
||||
|
||||
/* Check if the value is compressed */
|
||||
|
@ -492,7 +498,7 @@ CmpQueryKeyValueData(IN PKEY_OBJECT KeyObject,
|
|||
else
|
||||
{
|
||||
/* Otherwise, we must retrieve it from the value cache */
|
||||
Result = CmpGetValueDataFromCache(KeyObject,
|
||||
Result = CmpGetValueDataFromCache(Kcb,
|
||||
CachedValue,
|
||||
CellData,
|
||||
ValueIsCached,
|
||||
|
@ -587,7 +593,7 @@ CmpQueryKeyValueData(IN PKEY_OBJECT KeyObject,
|
|||
else
|
||||
{
|
||||
/* Otherwise, we must retrieve it from the value cache */
|
||||
Result = CmpGetValueDataFromCache(KeyObject,
|
||||
Result = CmpGetValueDataFromCache(Kcb,
|
||||
CachedValue,
|
||||
CellData,
|
||||
ValueIsCached,
|
||||
|
|
|
@ -63,121 +63,6 @@ extern EREGISTRY_HIVE SystemHive; /* \Registry\Machine\SYSTEM */
|
|||
#define ERROR_MORE_DATA 234L
|
||||
#define ERROR_NO_MORE_ITEMS 259L
|
||||
|
||||
/*
|
||||
* VOID
|
||||
* InitializeListHead (
|
||||
* PLIST_ENTRY ListHead
|
||||
* );
|
||||
*
|
||||
* FUNCTION: Initializes a double linked list
|
||||
* ARGUMENTS:
|
||||
* ListHead = Caller supplied storage for the head of the list
|
||||
*/
|
||||
#define InitializeListHead(ListHead) \
|
||||
{ \
|
||||
(ListHead)->Flink = (ListHead); \
|
||||
(ListHead)->Blink = (ListHead); \
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* VOID
|
||||
* InsertHeadList (
|
||||
* PLIST_ENTRY ListHead,
|
||||
* PLIST_ENTRY Entry
|
||||
* );
|
||||
*
|
||||
* FUNCTION: Inserts an entry in a double linked list
|
||||
* ARGUMENTS:
|
||||
* ListHead = Head of the list
|
||||
* Entry = Entry to insert
|
||||
*/
|
||||
#define InsertHeadList(ListHead, ListEntry) \
|
||||
{ \
|
||||
PLIST_ENTRY OldFlink; \
|
||||
OldFlink = (ListHead)->Flink; \
|
||||
(ListEntry)->Flink = OldFlink; \
|
||||
(ListEntry)->Blink = (ListHead); \
|
||||
OldFlink->Blink = (ListEntry); \
|
||||
(ListHead)->Flink = (ListEntry); \
|
||||
assert((ListEntry) != NULL); \
|
||||
assert((ListEntry)->Blink!=NULL); \
|
||||
assert((ListEntry)->Blink->Flink == (ListEntry)); \
|
||||
assert((ListEntry)->Flink != NULL); \
|
||||
assert((ListEntry)->Flink->Blink == (ListEntry)); \
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* VOID
|
||||
* InsertTailList (
|
||||
* PLIST_ENTRY ListHead,
|
||||
* PLIST_ENTRY Entry
|
||||
* );
|
||||
*
|
||||
* FUNCTION:
|
||||
* Inserts an entry in a double linked list
|
||||
*
|
||||
* ARGUMENTS:
|
||||
* ListHead = Head of the list
|
||||
* Entry = Entry to insert
|
||||
*/
|
||||
#define InsertTailList(ListHead, ListEntry) \
|
||||
{ \
|
||||
PLIST_ENTRY OldBlink; \
|
||||
OldBlink = (ListHead)->Blink; \
|
||||
(ListEntry)->Flink = (ListHead); \
|
||||
(ListEntry)->Blink = OldBlink; \
|
||||
OldBlink->Flink = (ListEntry); \
|
||||
(ListHead)->Blink = (ListEntry); \
|
||||
assert((ListEntry) != NULL); \
|
||||
assert((ListEntry)->Blink != NULL); \
|
||||
assert((ListEntry)->Blink->Flink == (ListEntry)); \
|
||||
assert((ListEntry)->Flink != NULL); \
|
||||
assert((ListEntry)->Flink->Blink == (ListEntry)); \
|
||||
}
|
||||
|
||||
/*
|
||||
*VOID
|
||||
*RemoveEntryList (
|
||||
* PLIST_ENTRY Entry
|
||||
* );
|
||||
*
|
||||
* FUNCTION:
|
||||
* Removes an entry from a double linked list
|
||||
*
|
||||
* ARGUMENTS:
|
||||
* ListEntry = Entry to remove
|
||||
*/
|
||||
#define RemoveEntryList(ListEntry) \
|
||||
{ \
|
||||
PLIST_ENTRY OldFlink; \
|
||||
PLIST_ENTRY OldBlink; \
|
||||
assert((ListEntry) != NULL); \
|
||||
assert((ListEntry)->Blink!=NULL); \
|
||||
assert((ListEntry)->Blink->Flink == (ListEntry)); \
|
||||
assert((ListEntry)->Flink != NULL); \
|
||||
assert((ListEntry)->Flink->Blink == (ListEntry)); \
|
||||
OldFlink = (ListEntry)->Flink; \
|
||||
OldBlink = (ListEntry)->Blink; \
|
||||
OldFlink->Blink = OldBlink; \
|
||||
OldBlink->Flink = OldFlink; \
|
||||
(ListEntry)->Flink = NULL; \
|
||||
(ListEntry)->Blink = NULL; \
|
||||
}
|
||||
|
||||
/*
|
||||
* PURPOSE: Returns the base address structure if the caller knows the
|
||||
* address of a field within the structure
|
||||
* ARGUMENTS:
|
||||
* Address = address of the field
|
||||
* Type = Type of the whole structure
|
||||
* Field = Name of the field whose address is none
|
||||
*/
|
||||
#define CONTAINING_RECORD(address, type, field) \
|
||||
((type *)(((ULONG_PTR)address) - (ULONG_PTR)(&(((type *)0)->field))))
|
||||
|
||||
|
||||
#define REG_NONE 0
|
||||
#define REG_SZ 1
|
||||
#define REG_EXPAND_SZ 2
|
||||
|
@ -241,3 +126,4 @@ RegInitializeRegistry(VOID);
|
|||
|
||||
/* EOF */
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue