- Get rid of parent key member in PKEY_OBJECT, and use ParentKcb instead.
authorAleksey Bragin <aleksey@reactos.org>
Wed, 31 Oct 2007 22:22:07 +0000 (22:22 +0000)
committerAleksey Bragin <aleksey@reactos.org>
Wed, 31 Oct 2007 22:22:07 +0000 (22:22 +0000)
- Modify more functions to use KCB instead of PKEY_OBJECT.

svn path=/trunk/; revision=30026

reactos/ntoskrnl/cm/ntfunc.c
reactos/ntoskrnl/cm/registry.c
reactos/ntoskrnl/cm/regobj.c
reactos/ntoskrnl/config/cm.h
reactos/ntoskrnl/config/cmparse.c
reactos/ntoskrnl/config/cmsysini.c

index 0aa76c8..fb33d70 100644 (file)
@@ -313,7 +313,7 @@ NtCreateKey(OUT PHANDLE KeyHandle,
                          KernelMode,
                          Class,
                          CreateOptions,
-                         (PKEY_OBJECT)Object,
+                         ((PKEY_OBJECT)Object)->KeyControlBlock,
                          NULL,
                          (PVOID*)&KeyObject);
     if (!NT_SUCCESS(Status))
@@ -333,13 +333,13 @@ NtCreateKey(OUT PHANDLE KeyHandle,
 
     RtlCreateUnicodeString(&KeyObject->Name, Start);
 
-    ParentNode = (PCM_KEY_NODE)HvGetCell(KeyObject->ParentKey->KeyControlBlock->KeyHive,
-                                         KeyObject->ParentKey->KeyControlBlock->KeyCell);
+    ParentNode = (PCM_KEY_NODE)HvGetCell(KeyObject->KeyControlBlock->ParentKcb->KeyHive,
+                                         KeyObject->KeyControlBlock->ParentKcb->KeyCell);
 
     Node = (PCM_KEY_NODE)HvGetCell(KeyObject->KeyControlBlock->KeyHive,
                                    KeyObject->KeyControlBlock->KeyCell);
     
-    Node->Parent = KeyObject->ParentKey->KeyControlBlock->KeyCell;
+    Node->Parent = KeyObject->KeyControlBlock->ParentKcb->KeyCell;
     Node->Security = ParentNode->Security;
     
     KeyObject->KeyControlBlock->ValueCache.ValueList = Node->ValueList.List;
@@ -347,7 +347,7 @@ NtCreateKey(OUT PHANDLE KeyHandle,
 
     DPRINT("RemainingPath: %wZ\n", &RemainingPath);
 
-    CmiAddKeyToList(KeyObject->ParentKey, KeyObject);
+    CmiAddKeyToList(((PKEY_OBJECT)Object), KeyObject);
 
     VERIFY_KEY_OBJECT(KeyObject);
 
@@ -722,7 +722,7 @@ NtDeleteKey(IN HANDLE KeyHandle)
         /* Remove the keep-alive reference */
         ObDereferenceObject(KeyObject);
         if (KeyObject->KeyControlBlock->KeyHive !=
-            KeyObject->ParentKey->KeyControlBlock->KeyHive)
+            KeyObject->KeyControlBlock->ParentKcb->KeyHive)
         {
             /* Dereference again */
             ObDereferenceObject(KeyObject);
index d4e813d..6b14898 100644 (file)
@@ -213,7 +213,7 @@ CmiConnectHive(IN POBJECT_ATTRIBUTES KeyObjectAttributes,
                          KernelMode,
                          NULL,
                          REG_OPTION_VOLATILE,
-                         ParentKey,
+                         ParentKey->KeyControlBlock,
                          NULL,
                          (PVOID*)&NewKey);
     if (!NT_SUCCESS(Status))
index e32be8a..90389e0 100644 (file)
@@ -625,7 +625,6 @@ VOID
 NTAPI
 CmpDeleteKeyObject(PVOID DeletedObject)
 {
-    PKEY_OBJECT ParentKeyObject;
     PKEY_OBJECT KeyObject;
     REG_KEY_HANDLE_CLOSE_INFORMATION KeyHandleCloseInfo;
     REG_POST_OPERATION_INFORMATION PostOperationInfo;
@@ -634,9 +633,7 @@ CmpDeleteKeyObject(PVOID DeletedObject)
     DPRINT("Delete key object (%p)\n", DeletedObject);
 
     KeyObject = (PKEY_OBJECT) DeletedObject;
-    ParentKeyObject = KeyObject->ParentKey;
 
-    ObReferenceObject (ParentKeyObject);
 
     PostOperationInfo.Object = (PVOID)KeyObject;
     KeyHandleCloseInfo.Object = (PVOID)KeyObject;
@@ -645,7 +642,6 @@ CmpDeleteKeyObject(PVOID DeletedObject)
     {
         PostOperationInfo.Status = Status;
         CmiCallRegisteredCallbacks(RegNtPostKeyHandleClose, &PostOperationInfo);
-        ObDereferenceObject (ParentKeyObject);
         return;
     }
 
@@ -658,8 +654,6 @@ CmpDeleteKeyObject(PVOID DeletedObject)
 
     ASSERT((KeyObject->KeyControlBlock->Delete) == FALSE);
 
-    ObDereferenceObject (ParentKeyObject);
-
     if (KeyObject->SizeOfSubKeys)
     {
         ExFreePool(KeyObject->SubKeys);
@@ -680,14 +674,15 @@ CmpQueryKeyName(PVOID ObjectBody,
                 PULONG ReturnLength,
                 IN KPROCESSOR_MODE PreviousMode)
 {
+    DPRINT1("CmpQueryKeyName() called\n");
+    while (TRUE);
+#if 0
     PKEY_OBJECT KeyObject;
     NTSTATUS Status;
 
-    DPRINT ("CmpQueryKeyName() called\n");
-
     KeyObject = (PKEY_OBJECT)ObjectBody;
 
-    if (KeyObject->ParentKey != KeyObject)
+    if (KeyObject->KeyControlBlock->ParentKcb != KeyObject->KeyControlBlock)
     {
         Status = ObQueryNameString (KeyObject->ParentKey,
                                     ObjectNameInfo,
@@ -734,8 +729,9 @@ CmpQueryKeyName(PVOID ObjectBody,
     {
         DPRINT ("Total path: %wZ\n", &ObjectNameInfo->Name);
     }
+#endif
 
-    return Status;
+    return STATUS_SUCCESS;
 }
 
 VOID
@@ -773,7 +769,7 @@ CmiAddKeyToList(PKEY_OBJECT ParentKey,
                                STANDARD_RIGHTS_REQUIRED,
                                CmpKeyObjectType,
                                KernelMode);
-    NewKey->ParentKey = ParentKey;
+    //NewKey->ParentKey = ParentKey;
 }
 
 /* Preconditions: Must be called with CmpRegistryLock held. */
index 38be196..bb34136 100644 (file)
@@ -507,7 +507,6 @@ typedef struct _KEY_OBJECT
 {\r
     ULONG Type;\r
     UNICODE_STRING Name;\r
-    struct _KEY_OBJECT *ParentKey;\r
     LIST_ENTRY KeyBodyList;\r
     ULONG SubKeyCounts;\r
     ULONG SizeOfSubKeys;\r
@@ -975,7 +974,7 @@ CmpDoCreate(
     IN KPROCESSOR_MODE AccessMode,\r
     IN PUNICODE_STRING Class,\r
     IN ULONG CreateOptions,\r
-    IN PKEY_OBJECT Parent,\r
+    IN PCM_KEY_CONTROL_BLOCK ParentKcb,\r
     IN PCMHIVE OriginatingHive OPTIONAL,\r
     OUT PVOID *Object\r
 );\r
index 6901447..53e8571 100644 (file)
@@ -83,7 +83,7 @@ CmpDoCreateChild(IN PHHIVE Hive,
                  IN PUNICODE_STRING Name,\r
                  IN KPROCESSOR_MODE AccessMode,\r
                  IN PUNICODE_STRING Class,\r
-                 IN PKEY_OBJECT Parent,\r
+                 IN PCM_KEY_CONTROL_BLOCK ParentKcb,\r
                  IN ULONG CreateOptions,\r
                  OUT PHCELL_INDEX KeyCell,\r
                  OUT PVOID *Object)\r
@@ -214,7 +214,7 @@ CmpDoCreateChild(IN PHHIVE Hive,
     Kcb = CmpCreateKeyControlBlock(Hive,\r
                                    *KeyCell,\r
                                    KeyNode,\r
-                                   Parent->KeyControlBlock,\r
+                                   ParentKcb,\r
                                    0,\r
                                    Name);\r
     if (!Kcb)\r
@@ -233,7 +233,6 @@ CmpDoCreateChild(IN PHHIVE Hive,
     KeyBody->SubKeyCounts = 0;\r
     KeyBody->SubKeys = NULL;\r
     KeyBody->SizeOfSubKeys = 0;\r
-    KeyBody->ParentKey = Parent;\r
     InsertTailList(&CmiKeyObjectListHead, &KeyBody->KeyBodyList);\r
 \r
 Quickie:\r
@@ -267,7 +266,7 @@ CmpDoCreate(IN PHHIVE Hive,
             IN KPROCESSOR_MODE AccessMode,\r
             IN PUNICODE_STRING Class OPTIONAL,\r
             IN ULONG CreateOptions,\r
-            IN PKEY_OBJECT Parent,\r
+            IN PCM_KEY_CONTROL_BLOCK ParentKcb,\r
             IN PCMHIVE OriginatingHive OPTIONAL,\r
             OUT PVOID *Object)\r
 {\r
@@ -286,7 +285,7 @@ CmpDoCreate(IN PHHIVE Hive,
     ExAcquirePushLockShared((PVOID)&((PCMHIVE)Hive)->FlusherLock);\r
 \r
     /* Check if the parent is being deleted */\r
-    if (Parent->KeyControlBlock->Delete)\r
+    if (ParentKcb->Delete)\r
     {\r
         /* It has, quit */\r
         ASSERT(FALSE);\r
@@ -314,7 +313,7 @@ CmpDoCreate(IN PHHIVE Hive,
     }\r
 \r
     /* Sanity check */\r
-    ASSERT(Cell == Parent->KeyControlBlock->KeyCell);\r
+    ASSERT(Cell == ParentKcb->KeyCell);\r
 \r
     /* Get the parent type */\r
     ParentType = HvGetCellType(Cell);\r
@@ -327,7 +326,7 @@ CmpDoCreate(IN PHHIVE Hive,
     }\r
 \r
     /* Don't allow children under symlinks */\r
-    if (Parent->KeyControlBlock->Flags & KEY_SYM_LINK)\r
+    if (ParentKcb->Flags & KEY_SYM_LINK)\r
     {\r
         /* Fail */\r
         ASSERT(FALSE);\r
@@ -346,7 +345,7 @@ CmpDoCreate(IN PHHIVE Hive,
                               Name,\r
                               AccessMode,\r
                               Class,\r
-                              Parent,\r
+                              ParentKcb,\r
                               CreateOptions,\r
                               &KeyCell,\r
                               Object);\r
@@ -371,9 +370,10 @@ CmpDoCreate(IN PHHIVE Hive,
         }\r
 \r
         /* Sanity checks */\r
-        ASSERT(KeyBody->ParentKey->KeyControlBlock->KeyCell == Cell);\r
-        ASSERT(KeyBody->ParentKey->KeyControlBlock->KeyHive == Hive);\r
-        ASSERT(KeyBody->ParentKey == Parent);\r
+        ASSERT(KeyBody->KeyControlBlock->ParentKcb->KeyCell == Cell);\r
+        ASSERT(KeyBody->KeyControlBlock->ParentKcb->KeyHive == Hive);\r
+        ASSERT(KeyBody->KeyControlBlock->ParentKcb == ParentKcb);\r
+        //ASSERT(KeyBody->KeyControlBlock->ParentKcb->KcbMaxNameLen == KeyNode->MaxNameLen);\r
 \r
         /* Update the timestamp */\r
         KeQuerySystemTime(&TimeStamp);\r
@@ -384,6 +384,7 @@ CmpDoCreate(IN PHHIVE Hive,
         {\r
             /* Do it */\r
             KeyNode->MaxNameLen = Name->Length;\r
+            KeyBody->KeyControlBlock->ParentKcb->KcbMaxNameLen = Name->Length;\r
         }\r
 \r
         /* Check if we need toupdate class length maximum */\r
index a2f69e5..986210a 100644 (file)
@@ -715,7 +715,6 @@ CmpCreateRegistryRoot(VOID)
     RootKey->ProcessID = PsGetCurrentProcessId();\r
 #else\r
     RtlpCreateUnicodeString(&RootKey->Name, L"Registry", NonPagedPool);\r
-    RootKey->ParentKey = RootKey;\r
     RootKey->SubKeyCounts = 0;\r
     RootKey->SubKeys = NULL;\r
     RootKey->SizeOfSubKeys = 0;\r