mirror of
https://github.com/reactos/reactos.git
synced 2025-05-21 18:16:07 +00:00
[MKHIVE] Remove key name in our custom registry tree; use cell index instead
svn path=/trunk/; revision=64547
This commit is contained in:
parent
6b033493e6
commit
0744b08c52
2 changed files with 41 additions and 42 deletions
|
@ -67,24 +67,15 @@ CreateInMemoryStructure(
|
||||||
Key->SubKeyCount = 0;
|
Key->SubKeyCount = 0;
|
||||||
Key->ValueCount = 0;
|
Key->ValueCount = 0;
|
||||||
|
|
||||||
Key->NameSize = KeyName->Length;
|
|
||||||
/* FIXME: It's not enough to allocate this way, because later
|
|
||||||
this memory gets overwritten with bigger names */
|
|
||||||
Key->Name = malloc (Key->NameSize);
|
|
||||||
if (!Key->Name)
|
|
||||||
return NULL;
|
|
||||||
memcpy(Key->Name, KeyName->Buffer, KeyName->Length);
|
|
||||||
|
|
||||||
Key->DataType = 0;
|
Key->DataType = 0;
|
||||||
Key->DataSize = 0;
|
Key->DataSize = 0;
|
||||||
Key->Data = NULL;
|
Key->Data = NULL;
|
||||||
|
|
||||||
Key->RegistryHive = RegistryHive;
|
Key->RegistryHive = RegistryHive;
|
||||||
Key->KeyCellOffset = KeyCellOffset;
|
Key->KeyCellOffset = Key->KeyCellOffsetInParentHive = KeyCellOffset;
|
||||||
Key->KeyCell = (PCM_KEY_NODE)HvGetCell (&RegistryHive->Hive, Key->KeyCellOffset);
|
Key->KeyCell = (PCM_KEY_NODE)HvGetCell (&RegistryHive->Hive, Key->KeyCellOffset);
|
||||||
if (!Key->KeyCell)
|
if (!Key->KeyCell)
|
||||||
{
|
{
|
||||||
free(Key->Name);
|
|
||||||
free(Key);
|
free(Key);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -110,6 +101,7 @@ RegpOpenOrCreateKey(
|
||||||
PLIST_ENTRY Ptr;
|
PLIST_ENTRY Ptr;
|
||||||
PCM_KEY_NODE SubKeyCell;
|
PCM_KEY_NODE SubKeyCell;
|
||||||
HCELL_INDEX BlockOffset;
|
HCELL_INDEX BlockOffset;
|
||||||
|
BOOLEAN ParentIsSystem = FALSE;
|
||||||
|
|
||||||
DPRINT("RegpCreateOpenKey('%S')\n", KeyName);
|
DPRINT("RegpCreateOpenKey('%S')\n", KeyName);
|
||||||
|
|
||||||
|
@ -148,23 +140,14 @@ RegpOpenOrCreateKey(
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Redirect from 'CurrentControlSet' to 'ControlSet001' */
|
/* Redirect from 'CurrentControlSet' to 'ControlSet001' */
|
||||||
if (!strncmpW(LocalKeyName, L"CurrentControlSet", 17) &&
|
if (!strncmpiW(LocalKeyName, L"CurrentControlSet", 17) && ParentIsSystem)
|
||||||
ParentKey->NameSize == 12 &&
|
|
||||||
!memcmp(ParentKey->Name, L"SYSTEM", 12))
|
|
||||||
RtlInitUnicodeString(&KeyString, L"ControlSet001");
|
|
||||||
|
|
||||||
/* Check subkey in memory structure */
|
|
||||||
Ptr = ParentKey->SubKeyList.Flink;
|
|
||||||
while (Ptr != &ParentKey->SubKeyList)
|
|
||||||
{
|
{
|
||||||
CurrentKey = CONTAINING_RECORD(Ptr, KEY, KeyList);
|
RtlInitUnicodeString(&KeyString, L"ControlSet001");
|
||||||
if (CurrentKey->NameSize == KeyString.Length
|
ParentIsSystem = FALSE;
|
||||||
&& strncmpiW(CurrentKey->Name, KeyString.Buffer, KeyString.Length / sizeof(WCHAR)) == 0)
|
}
|
||||||
{
|
else
|
||||||
goto nextsubkey;
|
{
|
||||||
}
|
ParentIsSystem = (strncmpiW(LocalKeyName, L"SYSTEM", 6) == 0);
|
||||||
|
|
||||||
Ptr = Ptr->Flink;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = CmiScanForSubKey(
|
Status = CmiScanForSubKey(
|
||||||
|
@ -174,6 +157,24 @@ RegpOpenOrCreateKey(
|
||||||
OBJ_CASE_INSENSITIVE,
|
OBJ_CASE_INSENSITIVE,
|
||||||
&SubKeyCell,
|
&SubKeyCell,
|
||||||
&BlockOffset);
|
&BlockOffset);
|
||||||
|
if (NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
/* Check subkey in memory structure */
|
||||||
|
Ptr = ParentKey->SubKeyList.Flink;
|
||||||
|
while (Ptr != &ParentKey->SubKeyList)
|
||||||
|
{
|
||||||
|
CurrentKey = CONTAINING_RECORD(Ptr, KEY, KeyList);
|
||||||
|
if (CurrentKey->KeyCellOffsetInParentHive == BlockOffset)
|
||||||
|
{
|
||||||
|
goto nextsubkey;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ptr = Ptr->Flink;
|
||||||
|
}
|
||||||
|
/* If we go there, this means that key exists, but we don't know it */
|
||||||
|
ASSERT(FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
if (AllowCreation && Status == STATUS_OBJECT_NAME_NOT_FOUND)
|
if (AllowCreation && Status == STATUS_OBJECT_NAME_NOT_FOUND)
|
||||||
{
|
{
|
||||||
Status = CmiAddSubKey(
|
Status = CmiAddSubKey(
|
||||||
|
@ -184,22 +185,23 @@ RegpOpenOrCreateKey(
|
||||||
0,
|
0,
|
||||||
&SubKeyCell,
|
&SubKeyCell,
|
||||||
&BlockOffset);
|
&BlockOffset);
|
||||||
|
if (NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
/* Now, SubKeyCell/BlockOffset are valid */
|
||||||
|
CurrentKey = CreateInMemoryStructure(
|
||||||
|
ParentKey->RegistryHive,
|
||||||
|
BlockOffset,
|
||||||
|
&KeyString);
|
||||||
|
if (!CurrentKey)
|
||||||
|
return ERROR_OUTOFMEMORY;
|
||||||
|
/* Add CurrentKey in ParentKey */
|
||||||
|
InsertTailList(&ParentKey->SubKeyList, &CurrentKey->KeyList);
|
||||||
|
ParentKey->SubKeyCount++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
return ERROR_UNSUCCESSFUL;
|
return ERROR_UNSUCCESSFUL;
|
||||||
|
|
||||||
/* Now, SubKeyCell/BlockOffset are valid */
|
|
||||||
CurrentKey = CreateInMemoryStructure(
|
|
||||||
ParentKey->RegistryHive,
|
|
||||||
BlockOffset,
|
|
||||||
&KeyString);
|
|
||||||
if (!CurrentKey)
|
|
||||||
return ERROR_OUTOFMEMORY;
|
|
||||||
|
|
||||||
/* Add CurrentKey in ParentKey */
|
|
||||||
InsertTailList(&ParentKey->SubKeyList, &CurrentKey->KeyList);
|
|
||||||
ParentKey->SubKeyCount++;
|
|
||||||
|
|
||||||
nextsubkey:
|
nextsubkey:
|
||||||
ParentKey = CurrentKey;
|
ParentKey = CurrentKey;
|
||||||
if (End)
|
if (End)
|
||||||
|
@ -700,7 +702,6 @@ RegShutdownRegistry(VOID)
|
||||||
{
|
{
|
||||||
/* FIXME: clean up the complete hive */
|
/* FIXME: clean up the complete hive */
|
||||||
|
|
||||||
free(RootKey->Name);
|
|
||||||
free(RootKey);
|
free(RootKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,15 +29,13 @@ typedef struct _REG_KEY
|
||||||
ULONG SubKeyCount;
|
ULONG SubKeyCount;
|
||||||
ULONG ValueCount;
|
ULONG ValueCount;
|
||||||
|
|
||||||
ULONG NameSize;
|
|
||||||
PWCHAR Name;
|
|
||||||
|
|
||||||
/* default data */
|
/* default data */
|
||||||
ULONG DataType;
|
ULONG DataType;
|
||||||
ULONG DataSize;
|
ULONG DataSize;
|
||||||
PCHAR Data;
|
PCHAR Data;
|
||||||
|
|
||||||
/* Information on hard disk structure */
|
/* Information on hard disk structure */
|
||||||
|
HCELL_INDEX KeyCellOffsetInParentHive;
|
||||||
HCELL_INDEX KeyCellOffset;
|
HCELL_INDEX KeyCellOffset;
|
||||||
PCM_KEY_NODE KeyCell;
|
PCM_KEY_NODE KeyCell;
|
||||||
PCMHIVE RegistryHive;
|
PCMHIVE RegistryHive;
|
||||||
|
|
Loading…
Reference in a new issue