diff --git a/reactos/ntoskrnl/cm/regobj.c b/reactos/ntoskrnl/cm/regobj.c index 3f81755861a..a6aa284a869 100644 --- a/reactos/ntoskrnl/cm/regobj.c +++ b/reactos/ntoskrnl/cm/regobj.c @@ -365,6 +365,7 @@ CmpParseKey(IN PVOID ParsedObject, UNICODE_STRING TargetPath; UNICODE_STRING KeyName; PWSTR *Path = &RemainingName->Buffer; + PCM_KEY_CONTROL_BLOCK ParentKcb = NULL, Kcb; ParsedKey = ParsedObject; @@ -415,22 +416,25 @@ CmpParseKey(IN PVOID ParsedObject, RtlFreeUnicodeString(&KeyName); return Status; } + + ParentKcb = ParsedKey->KeyControlBlock; + if (FoundObject == NULL) { - Status = CmiScanForSubKey(ParsedKey->RegistryHive, - ParsedKey->KeyCell, - &SubKeyCell, - &BlockOffset, - &KeyName, - 0, - Attributes); - if (!NT_SUCCESS(Status)) + /* Search for the subkey */ + BlockOffset = CmpFindSubKeyByName(&ParsedKey->RegistryHive->Hive, + ParsedKey->KeyCell, + &KeyName); + if (BlockOffset == HCELL_NIL) { ExReleaseResourceLite(&CmpRegistryLock); KeLeaveCriticalRegion(); RtlFreeUnicodeString(&KeyName); return(STATUS_UNSUCCESSFUL); } + + /* Get the node */ + SubKeyCell = (PCM_KEY_NODE)HvGetCell(&ParsedKey->RegistryHive->Hive, BlockOffset); if ((SubKeyCell->Flags & KEY_SYM_LINK) && !((Attributes & OBJ_OPENLINK) && (EndPtr == NULL))) @@ -514,7 +518,23 @@ CmpParseKey(IN PVOID ParsedObject, /* Add the keep-alive reference */ ObReferenceObject(FoundObject); - + + /* Create the KCB */ + Kcb = CmpCreateKeyControlBlock(&ParsedKey->RegistryHive->Hive, + BlockOffset, + SubKeyCell, + ParentKcb, + 0, + &KeyName); + if (!Kcb) + { + ExReleaseResourceLite(&CmpRegistryLock); + KeLeaveCriticalRegion(); + RtlFreeUnicodeString(&KeyName); + return STATUS_INSUFFICIENT_RESOURCES; + } + + FoundObject->KeyControlBlock = Kcb; FoundObject->Flags = 0; FoundObject->KeyCell = SubKeyCell; FoundObject->KeyCellOffset = BlockOffset; diff --git a/reactos/ntoskrnl/config/cm.h b/reactos/ntoskrnl/config/cm.h index a02ac844506..23a4af6eeb1 100644 --- a/reactos/ntoskrnl/config/cm.h +++ b/reactos/ntoskrnl/config/cm.h @@ -520,6 +520,7 @@ typedef struct _KEY_OBJECT ULONG TimeStamp; LIST_ENTRY HiveList; CACHED_CHILD_LIST ValueCache; + PCM_KEY_CONTROL_BLOCK KeyControlBlock; } KEY_OBJECT, *PKEY_OBJECT; extern PCMHIVE CmiVolatileHive; extern LIST_ENTRY CmiKeyObjectListHead, CmiConnectedHiveList; diff --git a/reactos/ntoskrnl/config/cmparse.c b/reactos/ntoskrnl/config/cmparse.c index 752926c313d..56a488d1d1c 100644 --- a/reactos/ntoskrnl/config/cmparse.c +++ b/reactos/ntoskrnl/config/cmparse.c @@ -96,6 +96,7 @@ CmpDoCreateChild(IN PHHIVE Hive, ULONG StorageType; LARGE_INTEGER SystemTime; BOOLEAN Hack = FALSE; + PCM_KEY_CONTROL_BLOCK Kcb; /* ReactOS Hack */ if (Name->Buffer[0] == OBJ_NAME_PATH_SEPARATOR) @@ -208,8 +209,27 @@ CmpDoCreateChild(IN PHHIVE Hive, KeyNode->MaxClassLen = 0; KeyNode->NameLength = CmpCopyName(Hive, KeyNode->Name, Name); if (KeyNode->NameLength < Name->Length) KeyNode->Flags |= KEY_COMP_NAME; + + /* Create the KCB */ + Kcb = CmpCreateKeyControlBlock(Hive, + *KeyCell, + KeyNode, + Parent->KeyControlBlock, + 0, + Name); + if (!Kcb) + { + /* Fail */ + ObDereferenceObjectDeferDelete(*Object); + Status = STATUS_INSUFFICIENT_RESOURCES; + goto Quickie; + } + + /* Sanity check */ + ASSERT(Kcb->RefCount == 1); /* Now fill out the Cm object */ + KeyBody->KeyControlBlock = Kcb; KeyBody->KeyCell = KeyNode; KeyBody->KeyCellOffset = *KeyCell; KeyBody->Flags = 0; diff --git a/reactos/ntoskrnl/config/cmsysini.c b/reactos/ntoskrnl/config/cmsysini.c index 23eb91a493d..c59c34f1c36 100644 --- a/reactos/ntoskrnl/config/cmsysini.c +++ b/reactos/ntoskrnl/config/cmsysini.c @@ -669,7 +669,6 @@ CmpCreateRegistryRoot(VOID) if (!CmpCreateRootNode(&CmiVolatileHive->Hive, L"REGISTRY", &RootIndex)) { /* We failed */ - DPRINT1("Fail\n"); return FALSE; } @@ -716,6 +715,7 @@ CmpCreateRegistryRoot(VOID) RootKey->ProcessID = PsGetCurrentProcessId(); #else RtlpCreateUnicodeString(&RootKey->Name, L"Registry", NonPagedPool); + RootKey->KeyControlBlock = Kcb; RootKey->RegistryHive = CmiVolatileHive; RootKey->KeyCellOffset = RootIndex; RootKey->KeyCell = KeyCell;