Author: fireball Date: Sat Oct 27 00:59:42 2007 New Revision: 29902
URL: http://svn.reactos.org/svn/reactos?rev=29902&view=rev Log: - 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.
Modified: trunk/reactos/include/host/typedefs.h trunk/reactos/ntoskrnl/cm/cm.h trunk/reactos/ntoskrnl/cm/ntfunc.c trunk/reactos/ntoskrnl/config/cm.h trunk/reactos/ntoskrnl/config/cmapi.c trunk/reactos/ntoskrnl/config/cmvalche.c trunk/reactos/tools/mkhive/registry.h
Modified: trunk/reactos/include/host/typedefs.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/include/host/typedefs.h?rev... ============================================================================== --- trunk/reactos/include/host/typedefs.h (original) +++ trunk/reactos/include/host/typedefs.h Sat Oct 27 00:59:42 2007 @@ -120,6 +120,102 @@ } 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)
Modified: trunk/reactos/ntoskrnl/cm/cm.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cm/cm.h?rev=29902&... ============================================================================== --- trunk/reactos/ntoskrnl/cm/cm.h (original) +++ trunk/reactos/ntoskrnl/cm/cm.h Sat Oct 27 00:59:42 2007 @@ -114,6 +114,51 @@ 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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
NTSTATUS NTAPI -CmDeleteKey(IN PKEY_OBJECT KeyObject); +CmDeleteKey(IN PCM_KEY_CONTROL_BLOCK Kcb);
NTSTATUS CmiAllocateHashTableCell(IN PEREGISTRY_HIVE RegistryHive, @@ -317,8 +362,6 @@ 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 @@ 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,
Modified: trunk/reactos/ntoskrnl/cm/ntfunc.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cm/ntfunc.c?rev=29... ============================================================================== --- trunk/reactos/ntoskrnl/cm/ntfunc.c (original) +++ trunk/reactos/ntoskrnl/cm/ntfunc.c Sat Oct 27 00:59:42 2007 @@ -24,7 +24,6 @@ /* GLOBALS ******************************************************************/
extern POBJECT_TYPE CmpKeyObjectType; - static BOOLEAN CmiRegistryInitialized = FALSE;
/* FUNCTIONS ****************************************************************/ @@ -709,8 +708,13 @@ 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 @@ 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 @@ &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 @@ 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 @@ 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 @@ 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 @@ &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;
Modified: trunk/reactos/ntoskrnl/config/cm.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/config/cm.h?rev=29... ============================================================================== --- trunk/reactos/ntoskrnl/config/cm.h (original) +++ trunk/reactos/ntoskrnl/config/cm.h Sat Oct 27 00:59:42 2007 @@ -710,7 +710,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ #if 0 IN PCM_KEY_BODY KeyObject, #else - IN PKEY_OBJECT KeyObject, + IN PVOID KeyObject, #endif IN ULONG Flags );
Modified: trunk/reactos/ntoskrnl/config/cmapi.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/config/cmapi.c?rev... ============================================================================== --- trunk/reactos/ntoskrnl/config/cmapi.c (original) +++ trunk/reactos/ntoskrnl/config/cmapi.c Sat Oct 27 00:59:42 2007 @@ -216,7 +216,7 @@
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 @@ 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 @@
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 @@ 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 @@
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 @@ 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 @@ ASSERT(ValueData != NULL);
/* Query the information requested */ - Result = CmpQueryKeyValueData(KeyObject, + Result = CmpQueryKeyValueData(Kcb, CachedValue, ValueData, ValueCached, @@ -523,7 +523,7 @@
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 @@ 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 @@ }
/* 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 @@ }
/* Now get the key value */ - Result = CmpGetValueKeyFromCache(KeyObject, + Result = CmpGetValueKeyFromCache(Kcb, CellData, Index, &CachedValue, @@ -600,7 +600,7 @@ }
/* Query the information requested */ - Result = CmpQueryKeyValueData(KeyObject, + Result = CmpQueryKeyValueData(Kcb, CachedValue, ValueData, ValueIsCached, @@ -615,7 +615,7 @@ 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 @@
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 @@ 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 @@
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 @@ 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 @@ 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 @@
NTSTATUS NTAPI -CmDeleteKey(IN PKEY_OBJECT KeyObject) +CmDeleteKey(IN PCM_KEY_CONTROL_BLOCK Kcb) { NTSTATUS Status; PHHIVE Hive; @@ -999,23 +999,23 @@ 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) { /* Fail */ Status = STATUS_INSUFFICIENT_RESOURCES; + 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; }
@@ -1042,26 +1042,26 @@ }
/* Clear the cell */ - KeyObject->KeyCellOffset = HCELL_NIL; + Kcb->KeyCell = HCELL_NIL; } } else { /* Fail */ Status = STATUS_CANNOT_DELETE; + } + + /* Make sure we're file-backed */ + if (!(IsNoFileHive((PEREGISTRY_HIVE)Kcb->KeyHive)) || + !(IsNoFileHive((PEREGISTRY_HIVE)Kcb->ParentKcb->KeyHive))) + { + /* Sync up the hives */ + CmiSyncHives(); }
Quickie: /* Release the cell */ HvReleaseCell(Hive, Cell); - - /* Make sure we're file-backed */ - if (!(IsNoFileHive(KeyObject->RegistryHive)) || - !(IsNoFileHive(KeyObject->ParentKey->RegistryHive))) - { - /* Sync up the hives */ - CmiSyncHives(); - }
/* Release hive lock */ ExReleaseResourceLite(&CmpRegistryLock);
Modified: trunk/reactos/ntoskrnl/config/cmvalche.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/config/cmvalche.c?... ============================================================================== --- trunk/reactos/ntoskrnl/config/cmvalche.c (original) +++ trunk/reactos/ntoskrnl/config/cmvalche.c Sat Oct 27 00:59:42 2007 @@ -42,7 +42,7 @@
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 @@ 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 @@
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 @@ *ValueIsCached = FALSE;
/* Get the hive */ - Hive = &KeyObject->RegistryHive->Hive; + Hive = Kcb->KeyHive;
/* Check if the index was cached */ if (IndexIsCached) @@ -133,7 +135,7 @@
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 @@ *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 @@
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 @@ 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 @@ }
/* Get the key value for this index */ - SearchResult = CmpGetValueKeyFromCache(KeyObject, + SearchResult = CmpGetValueKeyFromCache(Kcb, CellData, i, CachedValue, @@ -307,7 +313,7 @@
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 @@ 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 @@ else { /* Otherwise, we must retrieve it from the value cache */ - Result = CmpGetValueDataFromCache(KeyObject, + Result = CmpGetValueDataFromCache(Kcb, CachedValue, CellData, ValueIsCached, @@ -587,7 +593,7 @@ else { /* Otherwise, we must retrieve it from the value cache */ - Result = CmpGetValueDataFromCache(KeyObject, + Result = CmpGetValueDataFromCache(Kcb, CachedValue, CellData, ValueIsCached,
Modified: trunk/reactos/tools/mkhive/registry.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/mkhive/registry.h?rev... ============================================================================== --- trunk/reactos/tools/mkhive/registry.h (original) +++ trunk/reactos/tools/mkhive/registry.h Sat Oct 27 00:59:42 2007 @@ -63,121 +63,6 @@ #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 @@
/* EOF */
+