mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 17:44:45 +00:00
Create binary system hive when usetup is running.
svn path=/trunk/; revision=4264
This commit is contained in:
parent
6fdd94516b
commit
a130f0e169
1 changed files with 174 additions and 88 deletions
|
@ -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 */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -603,7 +598,7 @@ CmiCreateCurrentControlSetLink(VOID)
|
||||||
DPRINT("Link target '%S'\n", TargetNameBuffer);
|
DPRINT("Link target '%S'\n", TargetNameBuffer);
|
||||||
|
|
||||||
RtlInitUnicodeStringFromLiteral(&LinkName,
|
RtlInitUnicodeStringFromLiteral(&LinkName,
|
||||||
L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet");
|
L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet");
|
||||||
InitializeObjectAttributes(&ObjectAttributes,
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
&LinkName,
|
&LinkName,
|
||||||
OBJ_CASE_INSENSITIVE | OBJ_OPENIF | OBJ_OPENLINK,
|
OBJ_CASE_INSENSITIVE | OBJ_OPENIF | OBJ_OPENLINK,
|
||||||
|
@ -623,7 +618,7 @@ CmiCreateCurrentControlSetLink(VOID)
|
||||||
}
|
}
|
||||||
|
|
||||||
RtlInitUnicodeStringFromLiteral(&LinkValue,
|
RtlInitUnicodeStringFromLiteral(&LinkValue,
|
||||||
L"SymbolicLinkValue");
|
L"SymbolicLinkValue");
|
||||||
Status = NtSetValueKey(KeyHandle,
|
Status = NtSetValueKey(KeyHandle,
|
||||||
&LinkValue,
|
&LinkValue,
|
||||||
0,
|
0,
|
||||||
|
@ -643,10 +638,10 @@ CmiCreateCurrentControlSetLink(VOID)
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
CmiConnectHive(PWSTR FileName,
|
CmiConnectHive(PWSTR FileName,
|
||||||
PWSTR FullName,
|
PWSTR FullName,
|
||||||
PCHAR KeyName,
|
PCHAR KeyName,
|
||||||
PKEY_OBJECT Parent,
|
PKEY_OBJECT Parent,
|
||||||
BOOLEAN CreateNew)
|
BOOLEAN CreateNew)
|
||||||
{
|
{
|
||||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
PREGISTRY_HIVE RegistryHive = NULL;
|
PREGISTRY_HIVE RegistryHive = NULL;
|
||||||
|
@ -725,21 +720,109 @@ 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,
|
||||||
PCHAR KeyName,
|
PCHAR KeyName,
|
||||||
PKEY_OBJECT Parent,
|
PKEY_OBJECT Parent,
|
||||||
BOOLEAN CreateNew)
|
BOOLEAN CreateNew)
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
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
|
||||||
|
@ -791,58 +874,58 @@ CmiInitHives(BOOLEAN SetUpBoot)
|
||||||
DPRINT("CmiInitHives() called\n");
|
DPRINT("CmiInitHives() called\n");
|
||||||
|
|
||||||
if (SetUpBoot == TRUE)
|
if (SetUpBoot == TRUE)
|
||||||
{
|
|
||||||
RtlInitUnicodeStringFromLiteral(&KeyName,
|
|
||||||
L"\\Registry\\Machine\\HARDWARE");
|
|
||||||
InitializeObjectAttributes(&ObjectAttributes,
|
|
||||||
&KeyName,
|
|
||||||
OBJ_CASE_INSENSITIVE,
|
|
||||||
NULL,
|
|
||||||
NULL);
|
|
||||||
Status = NtOpenKey(&KeyHandle,
|
|
||||||
KEY_ALL_ACCESS,
|
|
||||||
&ObjectAttributes);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
{
|
||||||
DPRINT1("NtOpenKey() failed (Status %lx)\n", Status);
|
RtlInitUnicodeStringFromLiteral(&KeyName,
|
||||||
return(Status);
|
L"\\Registry\\Machine\\HARDWARE");
|
||||||
}
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
|
&KeyName,
|
||||||
|
OBJ_CASE_INSENSITIVE,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
Status = NtOpenKey(&KeyHandle,
|
||||||
|
KEY_ALL_ACCESS,
|
||||||
|
&ObjectAttributes);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DPRINT1("NtOpenKey() failed (Status %lx)\n", Status);
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
|
||||||
RtlInitUnicodeStringFromLiteral(&ValueName,
|
RtlInitUnicodeStringFromLiteral(&ValueName,
|
||||||
L"InstallPath");
|
L"InstallPath");
|
||||||
|
|
||||||
BufferSize = sizeof(KEY_VALUE_PARTIAL_INFORMATION) + 4096;
|
BufferSize = sizeof(KEY_VALUE_PARTIAL_INFORMATION) + 4096;
|
||||||
ValueInfo = ExAllocatePool(PagedPool,
|
ValueInfo = ExAllocatePool(PagedPool,
|
||||||
BufferSize);
|
BufferSize);
|
||||||
if (ValueInfo == NULL)
|
if (ValueInfo == NULL)
|
||||||
{
|
{
|
||||||
|
NtClose(KeyHandle);
|
||||||
|
return(STATUS_INSUFFICIENT_RESOURCES);
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = NtQueryValueKey(KeyHandle,
|
||||||
|
&ValueName,
|
||||||
|
KeyValuePartialInformation,
|
||||||
|
ValueInfo,
|
||||||
|
BufferSize,
|
||||||
|
&ResultSize);
|
||||||
NtClose(KeyHandle);
|
NtClose(KeyHandle);
|
||||||
return(STATUS_INSUFFICIENT_RESOURCES);
|
if (ValueInfo == NULL)
|
||||||
}
|
{
|
||||||
|
ExFreePool(ValueInfo);
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
|
||||||
Status = NtQueryValueKey(KeyHandle,
|
RtlCopyMemory(ConfigPath,
|
||||||
&ValueName,
|
ValueInfo->Data,
|
||||||
KeyValuePartialInformation,
|
ValueInfo->DataLength);
|
||||||
ValueInfo,
|
ConfigPath[ValueInfo->DataLength / sizeof(WCHAR)] = (WCHAR)0;
|
||||||
BufferSize,
|
|
||||||
&ResultSize);
|
|
||||||
NtClose(KeyHandle);
|
|
||||||
if (ValueInfo == NULL)
|
|
||||||
{
|
|
||||||
ExFreePool(ValueInfo);
|
ExFreePool(ValueInfo);
|
||||||
return(Status);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RtlCopyMemory(ConfigPath,
|
|
||||||
ValueInfo->Data,
|
|
||||||
ValueInfo->DataLength);
|
|
||||||
ConfigPath[ValueInfo->DataLength / sizeof(WCHAR)] = (WCHAR)0;
|
|
||||||
ExFreePool(ValueInfo);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wcscpy(ConfigPath, L"\\SystemRoot");
|
wcscpy(ConfigPath, L"\\SystemRoot");
|
||||||
}
|
}
|
||||||
wcscat(ConfigPath, L"\\system32\\config");
|
wcscat(ConfigPath, L"\\system32\\config");
|
||||||
|
|
||||||
DPRINT("ConfigPath: %S\n", ConfigPath);
|
DPRINT("ConfigPath: %S\n", ConfigPath);
|
||||||
|
@ -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,
|
||||||
|
@ -873,10 +961,10 @@ CmiInitHives(BOOLEAN SetUpBoot)
|
||||||
CmiMachineKey,
|
CmiMachineKey,
|
||||||
SetUpBoot);
|
SetUpBoot);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT1("CmiInitializeHive() failed (Status %lx)\n", Status);
|
DPRINT1("CmiInitializeHive() failed (Status %lx)\n", Status);
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Connect the SAM hive */
|
/* Connect the SAM hive */
|
||||||
wcscpy(EndPtr, REG_SAM_FILE_NAME);
|
wcscpy(EndPtr, REG_SAM_FILE_NAME);
|
||||||
|
@ -888,10 +976,10 @@ CmiInitHives(BOOLEAN SetUpBoot)
|
||||||
CmiMachineKey,
|
CmiMachineKey,
|
||||||
SetUpBoot);
|
SetUpBoot);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT1("CmiInitializeHive() failed (Status %lx)\n", Status);
|
DPRINT1("CmiInitializeHive() failed (Status %lx)\n", Status);
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Connect the SECURITY hive */
|
/* Connect the SECURITY hive */
|
||||||
wcscpy(EndPtr, REG_SEC_FILE_NAME);
|
wcscpy(EndPtr, REG_SEC_FILE_NAME);
|
||||||
|
@ -902,10 +990,10 @@ CmiInitHives(BOOLEAN SetUpBoot)
|
||||||
CmiMachineKey,
|
CmiMachineKey,
|
||||||
SetUpBoot);
|
SetUpBoot);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT1("CmiInitializeHive() failed (Status %lx)\n", Status);
|
DPRINT1("CmiInitializeHive() failed (Status %lx)\n", Status);
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Connect the DEFAULT hive */
|
/* Connect the DEFAULT hive */
|
||||||
wcscpy(EndPtr, REG_USER_FILE_NAME);
|
wcscpy(EndPtr, REG_USER_FILE_NAME);
|
||||||
|
@ -917,12 +1005,10 @@ CmiInitHives(BOOLEAN SetUpBoot)
|
||||||
CmiUserKey,
|
CmiUserKey,
|
||||||
SetUpBoot);
|
SetUpBoot);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT1("CmiInitializeHive() failed (Status %lx)\n", Status);
|
DPRINT1("CmiInitializeHive() failed (Status %lx)\n", Status);
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME : initialize standards symbolic links */
|
|
||||||
|
|
||||||
// CmiCheckRegistry(TRUE);
|
// CmiCheckRegistry(TRUE);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue