Cleaned-up and simplified hive import and registry initialization.

svn path=/trunk/; revision=4487
This commit is contained in:
Eric Kohl 2003-04-04 14:05:29 +00:00
parent 69b46e8303
commit 82389bc005
3 changed files with 320 additions and 383 deletions

View file

@ -546,7 +546,11 @@ CmiAddFree(PREGISTRY_HIVE RegistryHive,
BOOLEAN MergeFreeBlocks); BOOLEAN MergeFreeBlocks);
NTSTATUS NTSTATUS
CmiInitHives(BOOLEAN SetUpBoot); CmiConnectHive(PREGISTRY_HIVE RegistryHive,
PUNICODE_STRING KeyName);
NTSTATUS
CmiInitHives(BOOLEAN SetupBoot);
ULONG ULONG
CmiGetPackedNameLength(IN PUNICODE_STRING Name, CmiGetPackedNameLength(IN PUNICODE_STRING Name,

View file

@ -1,4 +1,4 @@
/* $Id: import.c,v 1.14 2003/04/01 19:01:58 ekohl Exp $ /* $Id: import.c,v 1.15 2003/04/04 14:05:29 ekohl Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -7,9 +7,6 @@
* PROGRAMMERS: Rex Jolliff * PROGRAMMERS: Rex Jolliff
*/ */
#ifdef WIN32_REGDBG
#include "cm_win32.h"
#else
#include <ctype.h> #include <ctype.h>
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
@ -25,10 +22,9 @@
#include <internal/debug.h> #include <internal/debug.h>
#include "cm.h" #include "cm.h"
#endif
extern PKEY_OBJECT CmiMachineKey;
/* FUNCTIONS ****************************************************************/
static PCHAR static PCHAR
checkAndSkipMagic (PCHAR regChunk) checkAndSkipMagic (PCHAR regChunk)
@ -634,7 +630,7 @@ CmImportBinarySystemHive(PCHAR ChunkBase,
if (strncmp (ChunkBase, "regf", 4) != 0) if (strncmp (ChunkBase, "regf", 4) != 0)
{ {
DPRINT1("Found invalid '%*s' magic\n", 4, ChunkBase); DPRINT1 ("Found invalid '%*s' magic\n", 4, ChunkBase);
return FALSE; return FALSE;
} }
@ -672,7 +668,7 @@ CmImportBinarySystemHive(PCHAR ChunkBase,
Hive->BlockListSize = (Hive->FileSize / 4096) - 1; Hive->BlockListSize = (Hive->FileSize / 4096) - 1;
/* Allocate block list */ /* Allocate block list */
DPRINT1("Space needed for block list describing hive: 0x%x\n", DPRINT("Space needed for block list describing hive: 0x%x\n",
sizeof(PHBIN *) * Hive->BlockListSize); sizeof(PHBIN *) * Hive->BlockListSize);
Hive->BlockList = ExAllocatePool(NonPagedPool, Hive->BlockList = ExAllocatePool(NonPagedPool,
sizeof(PHBIN *) * Hive->BlockListSize); sizeof(PHBIN *) * Hive->BlockListSize);
@ -683,7 +679,6 @@ CmImportBinarySystemHive(PCHAR ChunkBase,
ExFreePool (Hive); ExFreePool (Hive);
return FALSE; return FALSE;
} }
CHECKPOINT1;
/* Allocate the hive block */ /* Allocate the hive block */
Hive->BlockList[0] = ExAllocatePool(PagedPool, Hive->BlockList[0] = ExAllocatePool(PagedPool,
@ -697,7 +692,6 @@ CHECKPOINT1;
return FALSE; return FALSE;
} }
CHECKPOINT1;
/* Import the hive block */ /* Import the hive block */
RtlCopyMemory (Hive->BlockList[0], RtlCopyMemory (Hive->BlockList[0],
ChunkBase + 4096, ChunkBase + 4096,
@ -708,7 +702,6 @@ CHECKPOINT1;
Hive->FreeListMax = 0; Hive->FreeListMax = 0;
Hive->FreeList = NULL; Hive->FreeList = NULL;
CHECKPOINT1;
BlockOffset = 0; BlockOffset = 0;
for (i = 0; i < Hive->BlockListSize; i++) for (i = 0; i < Hive->BlockListSize; i++)
{ {
@ -759,12 +752,11 @@ CHECKPOINT1;
} }
BlockOffset += Bin->BlockSize; BlockOffset += Bin->BlockSize;
} }
CHECKPOINT1;
/* Calculate bitmap size in bytes (always a multiple of 32 bits) */ /* Calculate bitmap size in bytes (always a multiple of 32 bits) */
BitmapSize = ROUND_UP(Hive->BlockListSize, sizeof(ULONG) * 8) / 8; BitmapSize = ROUND_UP(Hive->BlockListSize, sizeof(ULONG) * 8) / 8;
DPRINT1("Hive->BlockListSize: %lu\n", Hive->BlockListSize); DPRINT("Hive->BlockListSize: %lu\n", Hive->BlockListSize);
DPRINT1("BitmapSize: %lu Bytes %lu Bits\n", BitmapSize, BitmapSize * 8); DPRINT("BitmapSize: %lu Bytes %lu Bits\n", BitmapSize, BitmapSize * 8);
/* Allocate bitmap */ /* Allocate bitmap */
Hive->BitmapBuffer = (PULONG)ExAllocatePool(PagedPool, Hive->BitmapBuffer = (PULONG)ExAllocatePool(PagedPool,
@ -778,7 +770,6 @@ CHECKPOINT1;
ExFreePool (Hive); ExFreePool (Hive);
return FALSE; return FALSE;
} }
CHECKPOINT1;
/* Initialize bitmap */ /* Initialize bitmap */
RtlInitializeBitMap(&Hive->DirtyBitMap, RtlInitializeBitMap(&Hive->DirtyBitMap,
@ -799,7 +790,6 @@ CHECKPOINT1;
/* Release hive list lock */ /* Release hive list lock */
ExReleaseResourceLite(&CmiHiveListLock); ExReleaseResourceLite(&CmiHiveListLock);
CHECKPOINT1;
*RegistryHive = Hive; *RegistryHive = Hive;
@ -812,89 +802,37 @@ CmImportSystemHive(PCHAR ChunkBase,
ULONG ChunkSize) ULONG ChunkSize)
{ {
PREGISTRY_HIVE RegistryHive; PREGISTRY_HIVE RegistryHive;
// UNICODE_STRING ParentKeyName;
// UNICODE_STRING SubKeyName;
// NTSTATUS Status;
OBJECT_ATTRIBUTES ObjectAttributes;
PKEY_OBJECT NewKey;
HANDLE KeyHandle;
UNICODE_STRING KeyName; UNICODE_STRING KeyName;
NTSTATUS Status; NTSTATUS Status;
if (strncmp (ChunkBase, "REGEDIT4", 8) == 0) if (strncmp (ChunkBase, "REGEDIT4", 8) == 0)
{ {
DPRINT1("Found 'REGEDIT4' magic\n"); DPRINT ("Found 'REGEDIT4' magic\n");
CmImportTextHive (ChunkBase, ChunkSize); CmImportTextHive (ChunkBase, ChunkSize);
return TRUE; return TRUE;
} }
else if (strncmp (ChunkBase, "regf", 4) == 0) else if (strncmp (ChunkBase, "regf", 4) == 0)
{ {
DPRINT1("Found '%*s' magic\n", 4, ChunkBase); DPRINT ("Found '%.*s' magic\n", 4, ChunkBase);
/* Import the binary system hive */
if (!CmImportBinarySystemHive (ChunkBase, ChunkSize, &RegistryHive)) if (!CmImportBinarySystemHive (ChunkBase, ChunkSize, &RegistryHive))
{ {
return FALSE; return FALSE;
} }
/* Attach it to the machine key */
RtlInitUnicodeString (&KeyName,
RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\System");
L"\\Registry\\Machine\\System"); Status = CmiConnectHive (RegistryHive,
InitializeObjectAttributes(&ObjectAttributes, &KeyName);
&KeyName,
0,
NULL,
NULL);
Status = ObCreateObject(&KeyHandle,
STANDARD_RIGHTS_REQUIRED,
&ObjectAttributes,
CmiKeyType,
(PVOID*)&NewKey);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
DPRINT1("ObCreateObject() failed (Status %lx)\n", Status); DPRINT1("CmiConnectHive() failed (Status %lx)\n", Status);
KeBugCheck(0);
// CmiRemoveRegistryHive(RegistryHive); // CmiRemoveRegistryHive(RegistryHive);
// return(Status); return FALSE;
} }
NewKey->RegistryHive = RegistryHive;
NewKey->BlockOffset = RegistryHive->HiveHeader->RootKeyCell;
NewKey->KeyCell = CmiGetBlock(RegistryHive, NewKey->BlockOffset, NULL);
NewKey->Flags = 0;
NewKey->NumberOfSubKeys = 0;
NewKey->SubKeys = ExAllocatePool(PagedPool,
NewKey->KeyCell->NumberOfSubKeys * sizeof(DWORD));
if ((NewKey->SubKeys == NULL) && (NewKey->KeyCell->NumberOfSubKeys != 0))
{
DPRINT1("NumberOfSubKeys %d\n", NewKey->KeyCell->NumberOfSubKeys);
KeBugCheck(0);
// ZwClose(NewKey);
// CmiRemoveRegistryHive(RegistryHive);
// return(STATUS_INSUFFICIENT_RESOURCES);
}
NewKey->SizeOfSubKeys = NewKey->KeyCell->NumberOfSubKeys;
NewKey->NameSize = strlen("System");
NewKey->Name = ExAllocatePool(PagedPool, NewKey->NameSize);
if ((NewKey->Name == NULL) && (NewKey->NameSize != 0))
{
DPRINT1("NewKey->NameSize %d\n", NewKey->NameSize);
if (NewKey->SubKeys != NULL)
ExFreePool(NewKey->SubKeys);
KeBugCheck(0);
// ZwClose(NewKey);
// CmiRemoveRegistryHive(RegistryHive);
// return(STATUS_INSUFFICIENT_RESOURCES);
}
memcpy(NewKey->Name, "System", NewKey->NameSize);
CmiAddKeyToList(CmiMachineKey, NewKey);
/* Set the hive filename */ /* Set the hive filename */
RtlCreateUnicodeString (&RegistryHive->HiveFileName, RtlCreateUnicodeString (&RegistryHive->HiveFileName,
SYSTEM_REG_FILE); SYSTEM_REG_FILE);
@ -903,21 +841,6 @@ CmImportSystemHive(PCHAR ChunkBase,
RtlCreateUnicodeString (&RegistryHive->LogFileName, RtlCreateUnicodeString (&RegistryHive->LogFileName,
SYSTEM_LOG_FILE); SYSTEM_LOG_FILE);
#if 0
RtlInitUnicodeString (&ParentKeyName,
REG_MACHINE_KEY_NAME);
RtlInitUnicodeString (&SubKeyName,
L"System");
Status = CmiLinkHive (&ParentKeyName,
&SubKeyName,
Hive);
if (!NT_SUCCESS(Status))
{
return FALSE;
}
#endif
return TRUE; return TRUE;
} }

View file

@ -1,4 +1,4 @@
/* $Id: registry.c,v 1.89 2003/04/01 19:01:58 ekohl Exp $ /* $Id: registry.c,v 1.90 2003/04/04 14:05:29 ekohl Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -11,9 +11,6 @@
* Created 22/05/98 * Created 22/05/98
*/ */
#ifdef WIN32_REGDBG
#include "cm_win32.h"
#else
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
#include <roscfg.h> #include <roscfg.h>
#include <limits.h> #include <limits.h>
@ -26,9 +23,8 @@
#include <internal/debug.h> #include <internal/debug.h>
#include "cm.h" #include "cm.h"
#endif
/* ------------------------------------------------- File Statics */ /* GLOBALS ******************************************************************/
POBJECT_TYPE CmiKeyType = NULL; POBJECT_TYPE CmiKeyType = NULL;
PREGISTRY_HIVE CmiVolatileHive = NULL; PREGISTRY_HIVE CmiVolatileHive = NULL;
@ -42,11 +38,6 @@ volatile BOOLEAN CmiHiveSyncPending = FALSE;
KDPC CmiHiveSyncDpc; KDPC CmiHiveSyncDpc;
KTIMER CmiHiveSyncTimer; KTIMER CmiHiveSyncTimer;
static PKEY_OBJECT CmiRootKey = NULL;
PKEY_OBJECT CmiMachineKey = NULL;
static PKEY_OBJECT CmiUserKey = NULL;
static PKEY_OBJECT CmiHardwareKey = NULL;
static GENERIC_MAPPING CmiKeyMapping = static GENERIC_MAPPING CmiKeyMapping =
{KEY_READ, KEY_WRITE, KEY_EXECUTE, KEY_ALL_ACCESS}; {KEY_READ, KEY_WRITE, KEY_EXECUTE, KEY_ALL_ACCESS};
@ -260,11 +251,18 @@ CmInitializeRegistry(VOID)
{ {
OBJECT_ATTRIBUTES ObjectAttributes; OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING RootKeyName; UNICODE_STRING RootKeyName;
PKEY_OBJECT RootKey;
PKEY_OBJECT MachineKey;
PKEY_OBJECT UserKey;
HANDLE RootKeyHandle; HANDLE RootKeyHandle;
PKEY_OBJECT NewKey;
HANDLE KeyHandle; HANDLE KeyHandle;
NTSTATUS Status; NTSTATUS Status;
/* FIXME: remove the hardware keys before the hardware hive is imported */
PKEY_OBJECT HardwareKey;
PKEY_OBJECT NewKey;
/* Initialize the Key object type */ /* Initialize the Key object type */
CmiKeyType = ExAllocatePool(NonPagedPool, sizeof(OBJECT_TYPE)); CmiKeyType = ExAllocatePool(NonPagedPool, sizeof(OBJECT_TYPE));
assert(CmiKeyType); assert(CmiKeyType);
@ -302,187 +300,186 @@ CmInitializeRegistry(VOID)
STANDARD_RIGHTS_REQUIRED, STANDARD_RIGHTS_REQUIRED,
&ObjectAttributes, &ObjectAttributes,
CmiKeyType, CmiKeyType,
(PVOID *) &NewKey); (PVOID *) &RootKey);
assert(NT_SUCCESS(Status)); assert(NT_SUCCESS(Status));
CmiRootKey = NewKey;
Status = ObReferenceObjectByHandle(RootKeyHandle, Status = ObReferenceObjectByHandle(RootKeyHandle,
STANDARD_RIGHTS_REQUIRED, STANDARD_RIGHTS_REQUIRED,
CmiKeyType, CmiKeyType,
KernelMode, KernelMode,
(PVOID *) &CmiRootKey, (PVOID *)&RootKey,
NULL); NULL);
assert(NT_SUCCESS(Status)); assert(NT_SUCCESS(Status));
CmiRootKey->RegistryHive = CmiVolatileHive; RootKey->RegistryHive = CmiVolatileHive;
NewKey->BlockOffset = CmiVolatileHive->HiveHeader->RootKeyCell; RootKey->BlockOffset = CmiVolatileHive->HiveHeader->RootKeyCell;
NewKey->KeyCell = CmiGetBlock(CmiVolatileHive, NewKey->BlockOffset, NULL); RootKey->KeyCell = CmiGetBlock(CmiVolatileHive, RootKey->BlockOffset, NULL);
CmiRootKey->Flags = 0; RootKey->Flags = 0;
CmiRootKey->NumberOfSubKeys = 0; RootKey->NumberOfSubKeys = 0;
CmiRootKey->SubKeys = NULL; RootKey->SubKeys = NULL;
CmiRootKey->SizeOfSubKeys = 0; RootKey->SizeOfSubKeys = 0;
CmiRootKey->Name = ExAllocatePool(PagedPool, strlen("Registry")); RootKey->NameSize = strlen("Registry");
CmiRootKey->NameSize = strlen("Registry"); RootKey->Name = ExAllocatePool(PagedPool, RootKey->NameSize);
memcpy(CmiRootKey->Name, "Registry", strlen("Registry")); RtlCopyMemory(RootKey->Name, "Registry", RootKey->NameSize);
KeInitializeSpinLock(&CmiKeyListLock); KeInitializeSpinLock(&CmiKeyListLock);
/* Create '\Registry\Machine' key. */ /* Create '\Registry\Machine' key. */
Status = ObCreateObject(&KeyHandle, Status = ObCreateObject(&KeyHandle,
STANDARD_RIGHTS_REQUIRED, STANDARD_RIGHTS_REQUIRED,
NULL, NULL,
CmiKeyType, CmiKeyType,
(PVOID*) &NewKey); (PVOID*)&MachineKey);
assert(NT_SUCCESS(Status)); assert(NT_SUCCESS(Status));
Status = CmiAddSubKey(CmiVolatileHive, Status = CmiAddSubKey(CmiVolatileHive,
CmiRootKey, RootKey,
NewKey, MachineKey,
L"Machine", L"Machine",
wcslen(L"Machine") * sizeof(WCHAR), wcslen(L"Machine") * sizeof(WCHAR),
0, 0,
NULL, NULL,
0); 0);
assert(NT_SUCCESS(Status)); assert(NT_SUCCESS(Status));
NewKey->RegistryHive = CmiVolatileHive; MachineKey->RegistryHive = CmiVolatileHive;
NewKey->Flags = 0; MachineKey->Flags = 0;
NewKey->NumberOfSubKeys = 0; MachineKey->NumberOfSubKeys = 0;
NewKey->SubKeys = NULL; MachineKey->SubKeys = NULL;
NewKey->SizeOfSubKeys = NewKey->KeyCell->NumberOfSubKeys; MachineKey->SizeOfSubKeys = MachineKey->KeyCell->NumberOfSubKeys;
NewKey->Name = ExAllocatePool(PagedPool, strlen("Machine")); MachineKey->NameSize = strlen("Machine");
NewKey->NameSize = strlen("Machine"); MachineKey->Name = ExAllocatePool(PagedPool, MachineKey->NameSize);
memcpy(NewKey->Name, "Machine", strlen("Machine")); RtlCopyMemory(MachineKey->Name, "Machine", MachineKey->NameSize);
CmiAddKeyToList(CmiRootKey, NewKey); CmiAddKeyToList(RootKey, MachineKey);
CmiMachineKey = NewKey;
/* Create '\Registry\User' key. */ /* Create '\Registry\User' key. */
Status = ObCreateObject(&KeyHandle, Status = ObCreateObject(&KeyHandle,
STANDARD_RIGHTS_REQUIRED, STANDARD_RIGHTS_REQUIRED,
NULL, NULL,
CmiKeyType, CmiKeyType,
(PVOID*) &NewKey); (PVOID*)&UserKey);
assert(NT_SUCCESS(Status)); assert(NT_SUCCESS(Status));
Status = CmiAddSubKey(CmiVolatileHive, Status = CmiAddSubKey(CmiVolatileHive,
CmiRootKey, RootKey,
NewKey, UserKey,
L"User", L"User",
wcslen(L"User") * sizeof(WCHAR), wcslen(L"User") * sizeof(WCHAR),
0, 0,
NULL, NULL,
0); 0);
assert(NT_SUCCESS(Status)); assert(NT_SUCCESS(Status));
NewKey->RegistryHive = CmiVolatileHive; UserKey->RegistryHive = CmiVolatileHive;
NewKey->Flags = 0; UserKey->Flags = 0;
NewKey->NumberOfSubKeys = 0; UserKey->NumberOfSubKeys = 0;
NewKey->SubKeys = NULL; UserKey->SubKeys = NULL;
NewKey->SizeOfSubKeys = NewKey->KeyCell->NumberOfSubKeys; UserKey->SizeOfSubKeys = UserKey->KeyCell->NumberOfSubKeys;
NewKey->Name = ExAllocatePool(PagedPool, strlen("User")); UserKey->NameSize = strlen("User");
NewKey->NameSize = strlen("User"); UserKey->Name = ExAllocatePool(PagedPool, UserKey->NameSize);
memcpy(NewKey->Name, "User", strlen("User")); RtlCopyMemory(UserKey->Name, "User", UserKey->NameSize);
CmiAddKeyToList(CmiRootKey, NewKey); CmiAddKeyToList(RootKey, UserKey);
CmiUserKey = NewKey;
/* FIXME: remove the hardware keys before the hardware hive is imported */
/* Create '\Registry\Machine\HARDWARE' key. */ /* Create '\Registry\Machine\HARDWARE' key. */
Status = ObCreateObject(&KeyHandle, Status = ObCreateObject(&KeyHandle,
STANDARD_RIGHTS_REQUIRED, STANDARD_RIGHTS_REQUIRED,
NULL, NULL,
CmiKeyType, CmiKeyType,
(PVOID*)&NewKey); (PVOID*)&HardwareKey);
assert(NT_SUCCESS(Status)); assert(NT_SUCCESS(Status));
Status = CmiAddSubKey(CmiVolatileHive, Status = CmiAddSubKey(CmiVolatileHive,
CmiMachineKey, MachineKey,
NewKey, HardwareKey,
L"HARDWARE", L"HARDWARE",
wcslen(L"HARDWARE") * sizeof(WCHAR), wcslen(L"HARDWARE") * sizeof(WCHAR),
0, 0,
NULL, NULL,
0); 0);
assert(NT_SUCCESS(Status)); assert(NT_SUCCESS(Status));
NewKey->RegistryHive = CmiVolatileHive; HardwareKey->RegistryHive = CmiVolatileHive;
NewKey->Flags = 0; HardwareKey->Flags = 0;
NewKey->NumberOfSubKeys = 0; HardwareKey->NumberOfSubKeys = 0;
NewKey->SubKeys = NULL; HardwareKey->SubKeys = NULL;
NewKey->SizeOfSubKeys = NewKey->KeyCell->NumberOfSubKeys; HardwareKey->SizeOfSubKeys = HardwareKey->KeyCell->NumberOfSubKeys;
NewKey->Name = ExAllocatePool(PagedPool, strlen("HARDWARE")); HardwareKey->NameSize = strlen("HARDWARE");
NewKey->NameSize = strlen("HARDWARE"); HardwareKey->Name = ExAllocatePool(PagedPool, strlen("HARDWARE"));
memcpy(NewKey->Name, "HARDWARE", strlen("HARDWARE")); RtlCopyMemory(HardwareKey->Name, "HARDWARE", HardwareKey->NameSize);
CmiAddKeyToList(CmiMachineKey, NewKey); CmiAddKeyToList(MachineKey, HardwareKey);
CmiHardwareKey = NewKey;
/* Create '\Registry\Machine\HARDWARE\DESCRIPTION' key. */ /* Create '\Registry\Machine\HARDWARE\DESCRIPTION' key. */
Status = ObCreateObject(&KeyHandle, Status = ObCreateObject(&KeyHandle,
STANDARD_RIGHTS_REQUIRED, STANDARD_RIGHTS_REQUIRED,
NULL, NULL,
CmiKeyType, CmiKeyType,
(PVOID*) &NewKey); (PVOID*)&NewKey);
assert(NT_SUCCESS(Status)); assert(NT_SUCCESS(Status));
Status = CmiAddSubKey(CmiVolatileHive, Status = CmiAddSubKey(CmiVolatileHive,
CmiHardwareKey, HardwareKey,
NewKey, NewKey,
L"DESCRIPTION", L"DESCRIPTION",
wcslen(L"DESCRIPTION") * sizeof(WCHAR), wcslen(L"DESCRIPTION") * sizeof(WCHAR),
0, 0,
NULL, NULL,
0); 0);
assert(NT_SUCCESS(Status)); assert(NT_SUCCESS(Status));
NewKey->RegistryHive = CmiVolatileHive; NewKey->RegistryHive = CmiVolatileHive;
NewKey->Flags = 0; NewKey->Flags = 0;
NewKey->NumberOfSubKeys = 0; NewKey->NumberOfSubKeys = 0;
NewKey->SubKeys = NULL; NewKey->SubKeys = NULL;
NewKey->SizeOfSubKeys = NewKey->KeyCell->NumberOfSubKeys; NewKey->SizeOfSubKeys = NewKey->KeyCell->NumberOfSubKeys;
NewKey->Name = ExAllocatePool(PagedPool, strlen("DESCRIPTION"));
NewKey->NameSize = strlen("DESCRIPTION"); NewKey->NameSize = strlen("DESCRIPTION");
memcpy(NewKey->Name, "DESCRIPTION", strlen("DESCRIPTION")); NewKey->Name = ExAllocatePool(PagedPool, NewKey->NameSize);
CmiAddKeyToList(CmiHardwareKey, NewKey); RtlCopyMemory(NewKey->Name, "DESCRIPTION", NewKey->NameSize);
CmiAddKeyToList(HardwareKey, NewKey);
/* Create '\Registry\Machine\HARDWARE\DEVICEMAP' key. */ /* Create '\Registry\Machine\HARDWARE\DEVICEMAP' key. */
Status = ObCreateObject(&KeyHandle, Status = ObCreateObject(&KeyHandle,
STANDARD_RIGHTS_REQUIRED, STANDARD_RIGHTS_REQUIRED,
NULL, NULL,
CmiKeyType, CmiKeyType,
(PVOID*) &NewKey); (PVOID*)&NewKey);
assert(NT_SUCCESS(Status)); assert(NT_SUCCESS(Status));
Status = CmiAddSubKey(CmiVolatileHive, Status = CmiAddSubKey(CmiVolatileHive,
CmiHardwareKey, HardwareKey,
NewKey, NewKey,
L"DEVICEMAP", L"DEVICEMAP",
wcslen(L"DEVICEMAP") * sizeof(WCHAR), wcslen(L"DEVICEMAP") * sizeof(WCHAR),
0, 0,
NULL, NULL,
0); 0);
assert(NT_SUCCESS(Status)); assert(NT_SUCCESS(Status));
NewKey->RegistryHive = CmiVolatileHive; NewKey->RegistryHive = CmiVolatileHive;
NewKey->Flags = 0; NewKey->Flags = 0;
NewKey->NumberOfSubKeys = 0; NewKey->NumberOfSubKeys = 0;
NewKey->SubKeys = NULL; NewKey->SubKeys = NULL;
NewKey->SizeOfSubKeys = NewKey->KeyCell->NumberOfSubKeys; NewKey->SizeOfSubKeys = NewKey->KeyCell->NumberOfSubKeys;
NewKey->Name = ExAllocatePool(PagedPool, strlen("DEVICEMAP"));
NewKey->NameSize = strlen("DEVICEMAP"); NewKey->NameSize = strlen("DEVICEMAP");
memcpy(NewKey->Name, "DEVICEMAP", strlen("DEVICEMAP")); NewKey->Name = ExAllocatePool(PagedPool, NewKey->NameSize);
CmiAddKeyToList(CmiHardwareKey,NewKey); RtlCopyMemory(NewKey->Name, "DEVICEMAP", NewKey->NameSize);
CmiAddKeyToList(HardwareKey,NewKey);
/* Create '\Registry\Machine\HARDWARE\RESOURCEMAP' key. */ /* Create '\Registry\Machine\HARDWARE\RESOURCEMAP' key. */
Status = ObCreateObject(&KeyHandle, Status = ObCreateObject(&KeyHandle,
STANDARD_RIGHTS_REQUIRED, STANDARD_RIGHTS_REQUIRED,
NULL, NULL,
CmiKeyType, CmiKeyType,
(PVOID*) &NewKey); (PVOID*)&NewKey);
assert(NT_SUCCESS(Status)); assert(NT_SUCCESS(Status));
Status = CmiAddSubKey(CmiVolatileHive, Status = CmiAddSubKey(CmiVolatileHive,
CmiHardwareKey, HardwareKey,
NewKey, NewKey,
L"RESOURCEMAP", L"RESOURCEMAP",
wcslen(L"RESOURCEMAP") * sizeof(WCHAR), wcslen(L"RESOURCEMAP") * sizeof(WCHAR),
0, 0,
NULL, NULL,
0); 0);
assert(NT_SUCCESS(Status)); assert(NT_SUCCESS(Status));
NewKey->RegistryHive = CmiVolatileHive; NewKey->RegistryHive = CmiVolatileHive;
NewKey->Flags = 0; NewKey->Flags = 0;
NewKey->NumberOfSubKeys = 0; NewKey->NumberOfSubKeys = 0;
NewKey->SubKeys = NULL; NewKey->SubKeys = NULL;
NewKey->SizeOfSubKeys = NewKey->KeyCell->NumberOfSubKeys; NewKey->SizeOfSubKeys = NewKey->KeyCell->NumberOfSubKeys;
NewKey->Name = ExAllocatePool(PagedPool, strlen("RESOURCEMAP"));
NewKey->NameSize = strlen("RESOURCEMAP"); NewKey->NameSize = strlen("RESOURCEMAP");
memcpy(NewKey->Name, "RESOURCEMAP", strlen("RESOURCEMAP")); NewKey->Name = ExAllocatePool(PagedPool, NewKey->NameSize);
CmiAddKeyToList(CmiHardwareKey, NewKey); RtlCopyMemory(NewKey->Name, "RESOURCEMAP", NewKey->NameSize);
CmiAddKeyToList(HardwareKey, NewKey);
} }
@ -499,12 +496,10 @@ CmInit2(PCHAR CommandLine)
/* Create the 'CurrentControlSet' link. */ /* Create the 'CurrentControlSet' link. */
Status = CmiCreateCurrentControlSetLink(); Status = CmiCreateCurrentControlSetLink();
#ifndef WIN32_REGDBG
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
KeBugCheck(CONFIG_INITIALIZATION_FAILED); KeBugCheck(CONFIG_INITIALIZATION_FAILED);
} }
#endif
/* Set PICE 'Start' value to 1, if PICE debugging is enabled */ /* Set PICE 'Start' value to 1, if PICE debugging is enabled */
PiceStart = 4; PiceStart = 4;
@ -527,7 +522,7 @@ CmInit2(PCHAR CommandLine)
} }
p1 = p2; p1 = p2;
} }
#ifndef WIN32_REGDBG
Status = RtlWriteRegistryValue(RTL_REGISTRY_SERVICES, Status = RtlWriteRegistryValue(RTL_REGISTRY_SERVICES,
L"\\Pice", L"\\Pice",
L"Start", L"Start",
@ -538,7 +533,6 @@ CmInit2(PCHAR CommandLine)
{ {
KeBugCheck(CONFIG_INITIALIZATION_FAILED); KeBugCheck(CONFIG_INITIALIZATION_FAILED);
} }
#endif
} }
@ -638,20 +632,52 @@ CmiCreateCurrentControlSetLink(VOID)
NTSTATUS NTSTATUS
CmiConnectHive(PREGISTRY_HIVE RegistryHive, CmiConnectHive(PREGISTRY_HIVE RegistryHive,
PUNICODE_STRING FullName, PUNICODE_STRING KeyName)
PCHAR KeyName,
PKEY_OBJECT Parent)
{ {
OBJECT_ATTRIBUTES ObjectAttributes; OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING ParentKeyName;
PKEY_OBJECT ParentKey;
PKEY_OBJECT NewKey; PKEY_OBJECT NewKey;
HANDLE KeyHandle; HANDLE KeyHandle;
NTSTATUS Status; NTSTATUS Status;
PWSTR SubName;
DPRINT("CmiConnectHive(%p, %wZ, %s, %p) called.\n", DPRINT("CmiConnectHive(%p, %wZ) called.\n",
RegistryHive, FullName, KeyName, Parent); RegistryHive, KeyName);
SubName = wcsrchr (KeyName->Buffer, L'\\');
if (SubName == NULL)
{
return STATUS_UNSUCCESSFUL;
}
ParentKeyName.Length = (USHORT)(SubName - KeyName->Buffer) * sizeof(WCHAR);
ParentKeyName.MaximumLength = ParentKeyName.MaximumLength + sizeof(WCHAR);
ParentKeyName.Buffer = ExAllocatePool (NonPagedPool,
ParentKeyName.MaximumLength);
RtlCopyMemory (ParentKeyName.Buffer,
KeyName->Buffer,
ParentKeyName.Length);
ParentKeyName.Buffer[ParentKeyName.Length / sizeof(WCHAR)] = 0;
SubName++;
Status = ObReferenceObjectByName (&ParentKeyName,
OBJ_CASE_INSENSITIVE,
NULL,
STANDARD_RIGHTS_REQUIRED,
CmiKeyType,
KernelMode,
NULL,
(PVOID*)&ParentKey);
RtlFreeUnicodeString (&ParentKeyName);
if (!NT_SUCCESS(Status))
{
DPRINT1 ("ObReferenceObjectByName() failed (Status %lx)\n", Status);
return Status;
}
InitializeObjectAttributes(&ObjectAttributes, InitializeObjectAttributes(&ObjectAttributes,
FullName, KeyName,
0, 0,
NULL, NULL,
NULL); NULL);
@ -663,9 +689,9 @@ CmiConnectHive(PREGISTRY_HIVE RegistryHive,
(PVOID*)&NewKey); (PVOID*)&NewKey);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
DPRINT1("ObCreateObject() failed (Status %lx)\n", Status); DPRINT1 ("ObCreateObject() failed (Status %lx)\n", Status);
KeBugCheck(0); ObDereferenceObject (ParentKey);
return(Status); return Status;
} }
NewKey->RegistryHive = RegistryHive; NewKey->RegistryHive = RegistryHive;
@ -674,30 +700,36 @@ CmiConnectHive(PREGISTRY_HIVE RegistryHive,
NewKey->Flags = 0; NewKey->Flags = 0;
NewKey->NumberOfSubKeys = 0; NewKey->NumberOfSubKeys = 0;
NewKey->SubKeys = ExAllocatePool(PagedPool, NewKey->SubKeys = ExAllocatePool(PagedPool,
NewKey->KeyCell->NumberOfSubKeys * sizeof(DWORD)); NewKey->KeyCell->NumberOfSubKeys * sizeof(ULONG));
if ((NewKey->SubKeys == NULL) && (NewKey->KeyCell->NumberOfSubKeys != 0)) if ((NewKey->SubKeys == NULL) && (NewKey->KeyCell->NumberOfSubKeys != 0))
{ {
DPRINT("NumberOfSubKeys %d\n", NewKey->KeyCell->NumberOfSubKeys); DPRINT("NumberOfSubKeys %d\n", NewKey->KeyCell->NumberOfSubKeys);
ZwClose(NewKey); NtClose(NewKey);
ObDereferenceObject (ParentKey);
return(STATUS_INSUFFICIENT_RESOURCES); return(STATUS_INSUFFICIENT_RESOURCES);
} }
NewKey->SizeOfSubKeys = NewKey->KeyCell->NumberOfSubKeys; NewKey->SizeOfSubKeys = NewKey->KeyCell->NumberOfSubKeys;
NewKey->Name = ExAllocatePool(PagedPool, strlen(KeyName)); NewKey->NameSize = wcslen (SubName);
NewKey->Name = ExAllocatePool(PagedPool, NewKey->NameSize);
if ((NewKey->Name == NULL) && (strlen(KeyName) != 0)) if ((NewKey->Name == NULL) && (NewKey->NameSize != 0))
{ {
DPRINT("strlen(KeyName) %d\n", strlen(KeyName)); DPRINT("NewKey->NameSize %d\n", NewKey->NameSize);
if (NewKey->SubKeys != NULL) if (NewKey->SubKeys != NULL)
ExFreePool(NewKey->SubKeys); ExFreePool(NewKey->SubKeys);
ZwClose(NewKey); NtClose(KeyHandle);
ObDereferenceObject (ParentKey);
return(STATUS_INSUFFICIENT_RESOURCES); return(STATUS_INSUFFICIENT_RESOURCES);
} }
NewKey->NameSize = strlen(KeyName); wcstombs (NewKey->Name,
memcpy(NewKey->Name, KeyName, strlen(KeyName)); SubName,
CmiAddKeyToList(Parent, NewKey); NewKey->NameSize);
CmiAddKeyToList (ParentKey, NewKey);
ObDereferenceObject (ParentKey);
VERIFY_KEY_OBJECT(NewKey); VERIFY_KEY_OBJECT(NewKey);
@ -706,11 +738,8 @@ CmiConnectHive(PREGISTRY_HIVE RegistryHive,
static NTSTATUS static NTSTATUS
CmiInitializeSystemHive(PWSTR FileName, CmiInitializeSystemHive (PWSTR FileName,
PUNICODE_STRING FullName, PUNICODE_STRING KeyName)
PCHAR KeyName,
PKEY_OBJECT Parent,
BOOLEAN CreateNew)
{ {
OBJECT_ATTRIBUTES ObjectAttributes; OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING ControlSetKeyName; UNICODE_STRING ControlSetKeyName;
@ -720,96 +749,88 @@ CmiInitializeSystemHive(PWSTR FileName,
NTSTATUS Status; NTSTATUS Status;
PREGISTRY_HIVE RegistryHive; PREGISTRY_HIVE RegistryHive;
if (CreateNew == TRUE) Status = CmiCreateRegistryHive (FileName,
&RegistryHive,
TRUE);
if (!NT_SUCCESS(Status))
{ {
Status = CmiCreateRegistryHive(FileName, DPRINT1 ("CmiCreateRegistryHive() failed (Status %lx)\n", Status);
&RegistryHive, return Status;
TRUE);
if (!NT_SUCCESS(Status))
{
DPRINT1("CmiCreateRegistryHive() failed (Status %lx)\n", Status);
KeBugCheck(0);
return(Status);
}
Status = CmiConnectHive(RegistryHive,
FullName,
KeyName,
Parent);
if (!NT_SUCCESS(Status))
{
DPRINT1("CmiConnectHive() failed (Status %lx)\n", Status);
CmiRemoveRegistryHive(RegistryHive);
return(Status);
}
/* Create 'ControlSet001' key */
RtlInitUnicodeStringFromLiteral(&ControlSetKeyName,
L"\\Registry\\Machine\\SYSTEM\\ControlSet001");
InitializeObjectAttributes(&ObjectAttributes,
&ControlSetKeyName,
OBJ_CASE_INSENSITIVE,
NULL,
NULL);
Status = NtCreateKey(&KeyHandle,
KEY_ALL_ACCESS,
&ObjectAttributes,
0,
NULL,
REG_OPTION_NON_VOLATILE,
NULL);
if (!NT_SUCCESS(Status))
{
DPRINT1("NtCreateKey() failed (Status %lx)\n", Status);
return(Status);
}
NtClose(KeyHandle);
/* Link 'CurrentControlSet' to 'ControlSet001' key */
RtlInitUnicodeStringFromLiteral(&ControlSetLinkName,
L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet");
InitializeObjectAttributes(&ObjectAttributes,
&ControlSetLinkName,
OBJ_CASE_INSENSITIVE | OBJ_OPENIF | OBJ_OPENLINK,
NULL,
NULL);
Status = NtCreateKey(&KeyHandle,
KEY_ALL_ACCESS | KEY_CREATE_LINK,
&ObjectAttributes,
0,
NULL,
REG_OPTION_VOLATILE | REG_OPTION_CREATE_LINK,
NULL);
if (!NT_SUCCESS(Status))
{
DPRINT1("NtCreateKey() failed (Status %lx)\n", Status);
return(Status);
}
RtlInitUnicodeStringFromLiteral(&ControlSetValueName,
L"SymbolicLinkValue");
Status = NtSetValueKey(KeyHandle,
&ControlSetValueName,
0,
REG_LINK,
(PVOID)ControlSetKeyName.Buffer,
ControlSetKeyName.Length);
if (!NT_SUCCESS(Status))
{
DPRINT1("NtSetValueKey() failed (Status %lx)\n", Status);
}
NtClose(KeyHandle);
} }
return(STATUS_SUCCESS); Status = CmiConnectHive (RegistryHive,
KeyName);
if (!NT_SUCCESS(Status))
{
DPRINT1 ("CmiConnectHive() failed (Status %lx)\n", Status);
CmiRemoveRegistryHive (RegistryHive);
return Status;
}
/* Create 'ControlSet001' key */
RtlInitUnicodeStringFromLiteral (&ControlSetKeyName,
L"\\Registry\\Machine\\SYSTEM\\ControlSet001");
InitializeObjectAttributes (&ObjectAttributes,
&ControlSetKeyName,
OBJ_CASE_INSENSITIVE,
NULL,
NULL);
Status = NtCreateKey (&KeyHandle,
KEY_ALL_ACCESS,
&ObjectAttributes,
0,
NULL,
REG_OPTION_NON_VOLATILE,
NULL);
if (!NT_SUCCESS(Status))
{
DPRINT1 ("NtCreateKey() failed (Status %lx)\n", Status);
return Status;
}
NtClose (KeyHandle);
/* Link 'CurrentControlSet' to 'ControlSet001' key */
RtlInitUnicodeStringFromLiteral (&ControlSetLinkName,
L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet");
InitializeObjectAttributes (&ObjectAttributes,
&ControlSetLinkName,
OBJ_CASE_INSENSITIVE | OBJ_OPENIF | OBJ_OPENLINK,
NULL,
NULL);
Status = NtCreateKey (&KeyHandle,
KEY_ALL_ACCESS | KEY_CREATE_LINK,
&ObjectAttributes,
0,
NULL,
REG_OPTION_VOLATILE | REG_OPTION_CREATE_LINK,
NULL);
if (!NT_SUCCESS(Status))
{
DPRINT1 ("NtCreateKey() failed (Status %lx)\n", Status);
return Status;
}
RtlInitUnicodeStringFromLiteral (&ControlSetValueName,
L"SymbolicLinkValue");
Status = NtSetValueKey (KeyHandle,
&ControlSetValueName,
0,
REG_LINK,
(PVOID)ControlSetKeyName.Buffer,
ControlSetKeyName.Length);
if (!NT_SUCCESS(Status))
{
DPRINT1 ("NtSetValueKey() failed (Status %lx)\n", Status);
}
NtClose (KeyHandle);
return STATUS_SUCCESS;
} }
NTSTATUS NTSTATUS
CmiInitializeHive(PWSTR FileName, CmiInitializeHive(PWSTR FileName,
PUNICODE_STRING FullName, PUNICODE_STRING KeyName,
PCHAR KeyName,
PKEY_OBJECT Parent,
BOOLEAN CreateNew) BOOLEAN CreateNew)
{ {
PREGISTRY_HIVE RegistryHive; PREGISTRY_HIVE RegistryHive;
@ -832,9 +853,7 @@ CmiInitializeHive(PWSTR FileName,
/* Connect the hive */ /* Connect the hive */
Status = CmiConnectHive(RegistryHive, Status = CmiConnectHive(RegistryHive,
FullName, KeyName);
KeyName,
Parent);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
DPRINT1("CmiConnectHive() failed (Status %lx)\n", Status); DPRINT1("CmiConnectHive() failed (Status %lx)\n", Status);
@ -849,7 +868,7 @@ CmiInitializeHive(PWSTR FileName,
NTSTATUS NTSTATUS
CmiInitHives(BOOLEAN SetUpBoot) CmiInitHives(BOOLEAN SetupBoot)
{ {
PKEY_VALUE_PARTIAL_INFORMATION ValueInfo; PKEY_VALUE_PARTIAL_INFORMATION ValueInfo;
OBJECT_ATTRIBUTES ObjectAttributes; OBJECT_ATTRIBUTES ObjectAttributes;
@ -865,12 +884,10 @@ CmiInitHives(BOOLEAN SetUpBoot)
ULONG ResultSize; ULONG ResultSize;
PWSTR EndPtr; PWSTR EndPtr;
UNICODE_STRING ParentKeyName;
DPRINT("CmiInitHives() called\n"); DPRINT("CmiInitHives() called\n");
if (SetUpBoot == TRUE) if (SetupBoot == TRUE)
{ {
RtlInitUnicodeStringFromLiteral(&KeyName, RtlInitUnicodeStringFromLiteral(&KeyName,
L"\\Registry\\Machine\\HARDWARE"); L"\\Registry\\Machine\\HARDWARE");
@ -933,34 +950,32 @@ CmiInitHives(BOOLEAN SetUpBoot)
/* FIXME: Save boot log */ /* FIXME: Save boot log */
/* Connect the SYSTEM hive */ /* Connect the SYSTEM hive only if it has been created */
wcscpy(EndPtr, REG_SYSTEM_FILE_NAME); if (SetupBoot == TRUE)
DPRINT("ConfigPath: %S\n", ConfigPath);
RtlInitUnicodeString (&ParentKeyName,
REG_SYSTEM_KEY_NAME);
Status = CmiInitializeSystemHive(ConfigPath,
&ParentKeyName,
"System",
CmiMachineKey,
SetUpBoot);
if (!NT_SUCCESS(Status))
{ {
DPRINT1("CmiInitializeSystemHive() failed (Status %lx)\n", Status); wcscpy(EndPtr, REG_SYSTEM_FILE_NAME);
return(Status); DPRINT ("ConfigPath: %S\n", ConfigPath);
RtlInitUnicodeString (&KeyName,
REG_SYSTEM_KEY_NAME);
Status = CmiInitializeSystemHive (ConfigPath,
&KeyName);
if (!NT_SUCCESS(Status))
{
DPRINT1("CmiInitializeSystemHive() failed (Status %lx)\n", Status);
return(Status);
}
} }
/* Connect the SOFTWARE hive */ /* Connect the SOFTWARE hive */
wcscpy(EndPtr, REG_SOFTWARE_FILE_NAME); wcscpy(EndPtr, REG_SOFTWARE_FILE_NAME);
DPRINT("ConfigPath: %S\n", ConfigPath); DPRINT ("ConfigPath: %S\n", ConfigPath);
RtlInitUnicodeString (&ParentKeyName, RtlInitUnicodeString (&KeyName,
REG_SOFTWARE_KEY_NAME); REG_SOFTWARE_KEY_NAME);
Status = CmiInitializeHive(ConfigPath, Status = CmiInitializeHive(ConfigPath,
&ParentKeyName, &KeyName,
"Software", SetupBoot);
CmiMachineKey,
SetUpBoot);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
DPRINT1("CmiInitializeHive() failed (Status %lx)\n", Status); DPRINT1("CmiInitializeHive() failed (Status %lx)\n", Status);
@ -969,15 +984,13 @@ CmiInitHives(BOOLEAN SetUpBoot)
/* Connect the SAM hive */ /* Connect the SAM hive */
wcscpy(EndPtr, REG_SAM_FILE_NAME); wcscpy(EndPtr, REG_SAM_FILE_NAME);
DPRINT1("ConfigPath: %S\n", ConfigPath); DPRINT ("ConfigPath: %S\n", ConfigPath);
RtlInitUnicodeString (&ParentKeyName, RtlInitUnicodeString (&KeyName,
REG_SAM_KEY_NAME); REG_SAM_KEY_NAME);
Status = CmiInitializeHive(ConfigPath, Status = CmiInitializeHive(ConfigPath,
&ParentKeyName, &KeyName,
"Sam", SetupBoot);
CmiMachineKey,
SetUpBoot);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
DPRINT1("CmiInitializeHive() failed (Status %lx)\n", Status); DPRINT1("CmiInitializeHive() failed (Status %lx)\n", Status);
@ -986,14 +999,13 @@ CmiInitHives(BOOLEAN SetUpBoot)
/* Connect the SECURITY hive */ /* Connect the SECURITY hive */
wcscpy(EndPtr, REG_SEC_FILE_NAME); wcscpy(EndPtr, REG_SEC_FILE_NAME);
DPRINT1("ConfigPath: %S\n", ConfigPath); DPRINT ("ConfigPath: %S\n", ConfigPath);
RtlInitUnicodeString (&ParentKeyName,
RtlInitUnicodeString (&KeyName,
REG_SEC_KEY_NAME); REG_SEC_KEY_NAME);
Status = CmiInitializeHive(ConfigPath, Status = CmiInitializeHive(ConfigPath,
&ParentKeyName, &KeyName,
"Security", SetupBoot);
CmiMachineKey,
SetUpBoot);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
DPRINT1("CmiInitializeHive() failed (Status %lx)\n", Status); DPRINT1("CmiInitializeHive() failed (Status %lx)\n", Status);
@ -1002,15 +1014,13 @@ CmiInitHives(BOOLEAN SetUpBoot)
/* Connect the DEFAULT hive */ /* Connect the DEFAULT hive */
wcscpy(EndPtr, REG_USER_FILE_NAME); wcscpy(EndPtr, REG_USER_FILE_NAME);
DPRINT1("ConfigPath: %S\n", ConfigPath); DPRINT ("ConfigPath: %S\n", ConfigPath);
RtlInitUnicodeString (&ParentKeyName, RtlInitUnicodeString (&KeyName,
REG_USER_KEY_NAME); REG_USER_KEY_NAME);
Status = CmiInitializeHive(ConfigPath, Status = CmiInitializeHive(ConfigPath,
&ParentKeyName, &KeyName,
".Default", SetupBoot);
CmiUserKey,
SetUpBoot);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
DPRINT1("CmiInitializeHive() failed (Status %lx)\n", Status); DPRINT1("CmiInitializeHive() failed (Status %lx)\n", Status);