Create binary system hive when usetup is running.

svn path=/trunk/; revision=4264
This commit is contained in:
Eric Kohl 2003-03-08 19:26:12 +00:00
parent 6fdd94516b
commit a130f0e169

View file

@ -1,4 +1,4 @@
/* $Id: registry.c,v 1.85 2003/02/15 18:46:28 ekohl Exp $ /* $Id: registry.c,v 1.86 2003/03/08 19:26:12 ekohl Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -325,8 +325,6 @@ CmInitializeRegistry(VOID)
KeInitializeSpinLock(&CmiKeyListLock); KeInitializeSpinLock(&CmiKeyListLock);
/* Create initial predefined symbolic links */
/* Create '\Registry\Machine' key. */ /* Create '\Registry\Machine' key. */
Status = ObCreateObject(&KeyHandle, Status = ObCreateObject(&KeyHandle,
STANDARD_RIGHTS_REQUIRED, STANDARD_RIGHTS_REQUIRED,
@ -485,9 +483,6 @@ CmInitializeRegistry(VOID)
NewKey->NameSize = strlen("RESOURCEMAP"); NewKey->NameSize = strlen("RESOURCEMAP");
memcpy(NewKey->Name, "RESOURCEMAP", strlen("RESOURCEMAP")); memcpy(NewKey->Name, "RESOURCEMAP", strlen("RESOURCEMAP"));
CmiAddKeyToList(CmiHardwareKey, NewKey); CmiAddKeyToList(CmiHardwareKey, NewKey);
/* FIXME: create remaining structure needed for default handles */
/* FIXME: load volatile registry data from ROSDTECT */
} }
@ -725,6 +720,96 @@ CmiConnectHive(PWSTR FileName,
} }
static NTSTATUS
CmiInitializeSystemHive(PWSTR FileName,
PWSTR FullName,
PCHAR KeyName,
PKEY_OBJECT Parent,
BOOLEAN CreateNew)
{
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING ControlSetKeyName;
UNICODE_STRING ControlSetLinkName;
UNICODE_STRING ControlSetValueName;
HANDLE KeyHandle;
NTSTATUS Status;
if (CreateNew == TRUE)
{
Status = CmiConnectHive(FileName,
FullName,
KeyName,
Parent,
TRUE);
if (!NT_SUCCESS(Status))
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);
}
else
{
/* FIXME: Set the SYSTEM hive's file name and mark it non-volatile */
}
return(STATUS_SUCCESS);
}
NTSTATUS NTSTATUS
CmiInitializeHive(PWSTR FileName, CmiInitializeHive(PWSTR FileName,
PWSTR FullName, PWSTR FullName,
@ -737,9 +822,7 @@ CmiInitializeHive(PWSTR FileName,
DPRINT("CmiInitializeHive(%s) called\n", KeyName); DPRINT("CmiInitializeHive(%s) called\n", KeyName);
/* Try to connect the hive */ /* Try to connect the hive */
//Status = CmiConnectHive(FileName, FullName, KeyName, Parent, FALSE);
Status = CmiConnectHive(FileName, FullName, KeyName, Parent, CreateNew); Status = CmiConnectHive(FileName, FullName, KeyName, Parent, CreateNew);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
#if 0 #if 0
@ -853,19 +936,24 @@ CmiInitHives(BOOLEAN SetUpBoot)
/* FIXME: Save boot log */ /* FIXME: Save boot log */
/* FIXME: Rename \Registry\Machine\System */
/* Connect the SYSTEM hive */ /* Connect the SYSTEM hive */
// Status = CmiInitializeHive(SYSTEM_REG_FILE, REG_SYSTEM_KEY_NAME, "System", CmiMachineKey, SetUpBoot); wcscpy(EndPtr, REG_SYSTEM_FILE_NAME);
// assert(NT_SUCCESS(Status)); DPRINT("ConfigPath: %S\n", ConfigPath);
/* FIXME: Synchronize old and new system hive (??) */ Status = CmiInitializeSystemHive(ConfigPath,
REG_SYSTEM_KEY_NAME,
/* FIXME: Delete old system hive */ "System",
CmiMachineKey,
SetUpBoot);
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);
DPRINT1("ConfigPath: %S\n", ConfigPath); DPRINT("ConfigPath: %S\n", ConfigPath);
Status = CmiInitializeHive(ConfigPath, Status = CmiInitializeHive(ConfigPath,
REG_SOFTWARE_KEY_NAME, REG_SOFTWARE_KEY_NAME,
@ -922,8 +1010,6 @@ CmiInitHives(BOOLEAN SetUpBoot)
return(Status); return(Status);
} }
/* FIXME : initialize standards symbolic links */
// CmiCheckRegistry(TRUE); // CmiCheckRegistry(TRUE);
/* Start automatic hive synchronization */ /* Start automatic hive synchronization */