mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
Remobed duplicate functionality and cleaned-up the registry code.
svn path=/trunk/; revision=4813
This commit is contained in:
parent
d197898a75
commit
8eb47000b7
3 changed files with 74 additions and 158 deletions
|
@ -423,9 +423,7 @@ CmiScanKeyList(IN PKEY_OBJECT Parent,
|
|||
IN ULONG Attributes);
|
||||
|
||||
NTSTATUS
|
||||
CmiCreateRegistryHive(PWSTR Filename,
|
||||
PREGISTRY_HIVE *RegistryHive,
|
||||
BOOLEAN CreateNew);
|
||||
CmiCreateVolatileHive(PREGISTRY_HIVE *RegistryHive);
|
||||
|
||||
NTSTATUS
|
||||
CmiLoadHive(POBJECT_ATTRIBUTES KeyObjectAttributes,
|
||||
|
|
|
@ -848,8 +848,7 @@ CmiCreateHiveBitmap(PREGISTRY_HIVE Hive)
|
|||
|
||||
static NTSTATUS
|
||||
CmiInitNonVolatileRegistryHive (PREGISTRY_HIVE RegistryHive,
|
||||
PWSTR Filename,
|
||||
BOOLEAN CreateNew)
|
||||
PWSTR Filename)
|
||||
{
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
ULONG CreateDisposition;
|
||||
|
@ -906,21 +905,7 @@ CmiInitNonVolatileRegistryHive(PREGISTRY_HIVE RegistryHive,
|
|||
NULL,
|
||||
NULL);
|
||||
|
||||
/*
|
||||
* Note:
|
||||
* This is a workaround to prevent a BSOD because of missing registry hives.
|
||||
* The workaround is only useful for developers. An implementation for the
|
||||
* ordinary user must bail out on missing registry hives because they are
|
||||
* essential to booting and configuring the OS.
|
||||
*/
|
||||
#if 0
|
||||
if (CreateNew == TRUE)
|
||||
CreateDisposition = FILE_OPEN_IF;
|
||||
else
|
||||
CreateDisposition = FILE_OPEN;
|
||||
#endif
|
||||
CreateDisposition = FILE_OPEN_IF;
|
||||
|
||||
Status = NtCreateFile(&FileHandle,
|
||||
FILE_ALL_ACCESS,
|
||||
&ObjectAttributes,
|
||||
|
@ -940,10 +925,6 @@ CmiInitNonVolatileRegistryHive(PREGISTRY_HIVE RegistryHive,
|
|||
return(Status);
|
||||
}
|
||||
|
||||
/* Note: Another workaround! See the note above! */
|
||||
#if 0
|
||||
if ((CreateNew) && (IoSB.Information == FILE_CREATED))
|
||||
#endif
|
||||
if (IoSB.Information != FILE_OPENED)
|
||||
{
|
||||
Status = CmiCreateNewRegFile(FileHandle);
|
||||
|
@ -1068,80 +1049,57 @@ CmiInitNonVolatileRegistryHive(PREGISTRY_HIVE RegistryHive,
|
|||
}
|
||||
|
||||
|
||||
static NTSTATUS
|
||||
CmiInitVolatileRegistryHive(PREGISTRY_HIVE RegistryHive)
|
||||
NTSTATUS
|
||||
CmiCreateVolatileHive(PREGISTRY_HIVE *RegistryHive)
|
||||
{
|
||||
PKEY_CELL RootKeyCell;
|
||||
|
||||
RegistryHive->Flags |= (HIVE_NO_FILE | HIVE_POINTER);
|
||||
|
||||
CmiCreateDefaultHiveHeader(RegistryHive->HiveHeader);
|
||||
|
||||
RootKeyCell = (PKEY_CELL) ExAllocatePool(NonPagedPool, sizeof(KEY_CELL));
|
||||
|
||||
if (RootKeyCell == NULL)
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
|
||||
CmiCreateDefaultRootKeyCell(RootKeyCell);
|
||||
|
||||
RegistryHive->HiveHeader->RootKeyCell = (BLOCK_OFFSET) RootKeyCell;
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS
|
||||
CmiCreateRegistryHive(PWSTR Filename,
|
||||
PREGISTRY_HIVE *RegistryHive,
|
||||
BOOLEAN CreateNew)
|
||||
{
|
||||
PREGISTRY_HIVE Hive;
|
||||
NTSTATUS Status;
|
||||
|
||||
DPRINT("CmiCreateRegistryHive(Filename %S)\n", Filename);
|
||||
|
||||
*RegistryHive = NULL;
|
||||
|
||||
Hive = ExAllocatePool(NonPagedPool, sizeof(REGISTRY_HIVE));
|
||||
Hive = ExAllocatePool (NonPagedPool,
|
||||
sizeof(REGISTRY_HIVE));
|
||||
if (Hive == NULL)
|
||||
return(STATUS_INSUFFICIENT_RESOURCES);
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
|
||||
RtlZeroMemory (Hive,
|
||||
sizeof(REGISTRY_HIVE));
|
||||
|
||||
DPRINT("Hive %x\n", Hive);
|
||||
|
||||
RtlZeroMemory(Hive, sizeof(REGISTRY_HIVE));
|
||||
|
||||
Hive->HiveHeader = (PHIVE_HEADER)
|
||||
ExAllocatePool(NonPagedPool, sizeof(HIVE_HEADER));
|
||||
|
||||
Hive->HiveHeader = (PHIVE_HEADER)ExAllocatePool (NonPagedPool,
|
||||
sizeof(HIVE_HEADER));
|
||||
if (Hive->HiveHeader == NULL)
|
||||
{
|
||||
ExFreePool (Hive);
|
||||
return(STATUS_INSUFFICIENT_RESOURCES);
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
|
||||
if (Filename != NULL)
|
||||
{
|
||||
Status = CmiInitNonVolatileRegistryHive(Hive, Filename, CreateNew);
|
||||
}
|
||||
else
|
||||
{
|
||||
Status = CmiInitVolatileRegistryHive(Hive);
|
||||
}
|
||||
Hive->Flags = (HIVE_NO_FILE | HIVE_POINTER);
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
CmiCreateDefaultHiveHeader (Hive->HiveHeader);
|
||||
|
||||
RootKeyCell = (PKEY_CELL)ExAllocatePool (NonPagedPool,
|
||||
sizeof(KEY_CELL));
|
||||
if (RootKeyCell == NULL)
|
||||
{
|
||||
ExFreePool(Hive->HiveHeader);
|
||||
ExFreePool(Hive);
|
||||
return(Status);
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
|
||||
CmiCreateDefaultRootKeyCell (RootKeyCell);
|
||||
Hive->HiveHeader->RootKeyCell = (BLOCK_OFFSET)RootKeyCell;
|
||||
|
||||
ExInitializeResourceLite (&Hive->HiveResource);
|
||||
|
||||
/* Acquire hive list lock exclusively */
|
||||
ExAcquireResourceExclusiveLite(&CmiHiveListLock, TRUE);
|
||||
ExAcquireResourceExclusiveLite (&CmiHiveListLock,
|
||||
TRUE);
|
||||
|
||||
/* Add the new hive to the hive list */
|
||||
InsertTailList(&CmiHiveListHead, &Hive->HiveList);
|
||||
InsertTailList (&CmiHiveListHead,
|
||||
&Hive->HiveList);
|
||||
|
||||
/* Release hive list lock */
|
||||
ExReleaseResourceLite (&CmiHiveListLock);
|
||||
|
@ -1150,9 +1108,7 @@ CmiCreateRegistryHive(PWSTR Filename,
|
|||
|
||||
*RegistryHive = Hive;
|
||||
|
||||
DPRINT("CmiCreateRegistryHive(Filename %S) - Finished.\n", Filename);
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1180,6 +1136,7 @@ CmiLoadHive(IN POBJECT_ATTRIBUTES KeyObjectAttributes,
|
|||
sizeof(REGISTRY_HIVE));
|
||||
|
||||
DPRINT ("Hive %x\n", Hive);
|
||||
Hive->Flags = (Flags & REG_NO_LAZY_FLUSH) ? HIVE_NO_SYNCH : 0;
|
||||
|
||||
Hive->HiveHeader = (PHIVE_HEADER)ExAllocatePool(NonPagedPool,
|
||||
sizeof(HIVE_HEADER));
|
||||
|
@ -1191,8 +1148,7 @@ CmiLoadHive(IN POBJECT_ATTRIBUTES KeyObjectAttributes,
|
|||
}
|
||||
|
||||
Status = CmiInitNonVolatileRegistryHive (Hive,
|
||||
FileName->Buffer,
|
||||
TRUE);
|
||||
FileName->Buffer);
|
||||
if (!NT_SUCCESS (Status))
|
||||
{
|
||||
DPRINT1 ("CmiInitNonVolatileRegistryHive() failed (Status %lx)\n", Status);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: registry.c,v 1.100 2003/06/01 15:10:52 ekohl Exp $
|
||||
/* $Id: registry.c,v 1.101 2003/06/01 17:39:14 ekohl Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -283,7 +283,7 @@ CmInitializeRegistry(VOID)
|
|||
ExInitializeResourceLite(&CmiHiveListLock);
|
||||
|
||||
/* Build volatile registry store */
|
||||
Status = CmiCreateRegistryHive(NULL, &CmiVolatileHive, FALSE);
|
||||
Status = CmiCreateVolatileHive (&CmiVolatileHive);
|
||||
assert(NT_SUCCESS(Status));
|
||||
|
||||
/* Create '\Registry' key. */
|
||||
|
@ -670,8 +670,7 @@ CmiDisconnectHive (IN POBJECT_ATTRIBUTES KeyObjectAttributes,
|
|||
|
||||
|
||||
static NTSTATUS
|
||||
CmiInitializeSystemHive (POBJECT_ATTRIBUTES KeyObjectAttributes,
|
||||
PWSTR FileName)
|
||||
CmiInitControlSetLink (VOID)
|
||||
{
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
UNICODE_STRING ControlSetKeyName;
|
||||
|
@ -679,25 +678,6 @@ CmiInitializeSystemHive (POBJECT_ATTRIBUTES KeyObjectAttributes,
|
|||
UNICODE_STRING ControlSetValueName;
|
||||
HANDLE KeyHandle;
|
||||
NTSTATUS Status;
|
||||
PREGISTRY_HIVE RegistryHive;
|
||||
|
||||
Status = CmiCreateRegistryHive (FileName,
|
||||
&RegistryHive,
|
||||
TRUE);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1 ("CmiCreateRegistryHive() failed (Status %lx)\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = CmiConnectHive (KeyObjectAttributes,
|
||||
RegistryHive);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1 ("CmiConnectHive() failed (Status %lx)\n", Status);
|
||||
CmiRemoveRegistryHive (RegistryHive);
|
||||
return Status;
|
||||
}
|
||||
|
||||
/* Create 'ControlSet001' key */
|
||||
RtlInitUnicodeStringFromLiteral (&ControlSetKeyName,
|
||||
|
@ -760,50 +740,12 @@ CmiInitializeSystemHive (POBJECT_ATTRIBUTES KeyObjectAttributes,
|
|||
}
|
||||
|
||||
|
||||
NTSTATUS
|
||||
CmiInitializeHive(POBJECT_ATTRIBUTES KeyObjectAttributes,
|
||||
PWSTR FileName,
|
||||
BOOLEAN CreateNew)
|
||||
{
|
||||
PREGISTRY_HIVE RegistryHive;
|
||||
NTSTATUS Status;
|
||||
|
||||
DPRINT("CmiInitializeHive(%s) called\n", KeyName);
|
||||
|
||||
Status = CmiCreateRegistryHive(FileName,
|
||||
&RegistryHive,
|
||||
CreateNew);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("CmiCreateRegistryHive() failed (Status %lx)\n", Status);
|
||||
|
||||
/* FIXME: Try to load the backup hive */
|
||||
|
||||
KeBugCheck(0);
|
||||
return(Status);
|
||||
}
|
||||
|
||||
/* Connect the hive */
|
||||
Status = CmiConnectHive(KeyObjectAttributes, //KeyName,
|
||||
RegistryHive);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("CmiConnectHive() failed (Status %lx)\n", Status);
|
||||
CmiRemoveRegistryHive(RegistryHive);
|
||||
return(Status);
|
||||
}
|
||||
|
||||
DPRINT("CmiInitializeHive() done\n");
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS
|
||||
CmiInitHives(BOOLEAN SetupBoot)
|
||||
{
|
||||
PKEY_VALUE_PARTIAL_INFORMATION ValueInfo;
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
UNICODE_STRING FileName;
|
||||
UNICODE_STRING KeyName;
|
||||
UNICODE_STRING ValueName;
|
||||
HANDLE KeyHandle;
|
||||
|
@ -895,17 +837,30 @@ CmiInitHives(BOOLEAN SetupBoot)
|
|||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
NULL);
|
||||
Status = CmiInitializeSystemHive (&ObjectAttributes,
|
||||
|
||||
RtlInitUnicodeString (&FileName,
|
||||
ConfigPath);
|
||||
Status = CmiLoadHive (&ObjectAttributes,
|
||||
&FileName,
|
||||
0);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("CmiInitializeSystemHive() failed (Status %lx)\n", Status);
|
||||
DPRINT1 ("CmiLoadHive() failed (Status %lx)\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = CmiInitControlSetLink ();
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("CmiInitControlSetLink() failed (Status %lx)\n", Status);
|
||||
return(Status);
|
||||
}
|
||||
}
|
||||
|
||||
/* Connect the SOFTWARE hive */
|
||||
wcscpy(EndPtr, REG_SOFTWARE_FILE_NAME);
|
||||
RtlInitUnicodeString (&FileName,
|
||||
ConfigPath);
|
||||
DPRINT ("ConfigPath: %S\n", ConfigPath);
|
||||
|
||||
RtlInitUnicodeString (&KeyName,
|
||||
|
@ -915,9 +870,10 @@ CmiInitHives(BOOLEAN SetupBoot)
|
|||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
NULL);
|
||||
Status = CmiInitializeHive(&ObjectAttributes,
|
||||
ConfigPath,
|
||||
SetupBoot);
|
||||
|
||||
Status = CmiLoadHive (&ObjectAttributes,
|
||||
&FileName,
|
||||
0);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("CmiInitializeHive() failed (Status %lx)\n", Status);
|
||||
|
@ -926,6 +882,8 @@ CmiInitHives(BOOLEAN SetupBoot)
|
|||
|
||||
/* Connect the SAM hive */
|
||||
wcscpy(EndPtr, REG_SAM_FILE_NAME);
|
||||
RtlInitUnicodeString (&FileName,
|
||||
ConfigPath);
|
||||
DPRINT ("ConfigPath: %S\n", ConfigPath);
|
||||
|
||||
RtlInitUnicodeString (&KeyName,
|
||||
|
@ -935,9 +893,9 @@ CmiInitHives(BOOLEAN SetupBoot)
|
|||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
NULL);
|
||||
Status = CmiInitializeHive(&ObjectAttributes,
|
||||
ConfigPath,
|
||||
SetupBoot);
|
||||
Status = CmiLoadHive (&ObjectAttributes,
|
||||
&FileName,
|
||||
0);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("CmiInitializeHive() failed (Status %lx)\n", Status);
|
||||
|
@ -946,6 +904,8 @@ CmiInitHives(BOOLEAN SetupBoot)
|
|||
|
||||
/* Connect the SECURITY hive */
|
||||
wcscpy(EndPtr, REG_SEC_FILE_NAME);
|
||||
RtlInitUnicodeString (&FileName,
|
||||
ConfigPath);
|
||||
DPRINT ("ConfigPath: %S\n", ConfigPath);
|
||||
|
||||
RtlInitUnicodeString (&KeyName,
|
||||
|
@ -955,9 +915,9 @@ CmiInitHives(BOOLEAN SetupBoot)
|
|||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
NULL);
|
||||
Status = CmiInitializeHive(&ObjectAttributes,
|
||||
ConfigPath,
|
||||
SetupBoot);
|
||||
Status = CmiLoadHive (&ObjectAttributes,
|
||||
&FileName,
|
||||
0);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("CmiInitializeHive() failed (Status %lx)\n", Status);
|
||||
|
@ -966,6 +926,8 @@ CmiInitHives(BOOLEAN SetupBoot)
|
|||
|
||||
/* Connect the DEFAULT hive */
|
||||
wcscpy(EndPtr, REG_DEFAULT_USER_FILE_NAME);
|
||||
RtlInitUnicodeString (&FileName,
|
||||
ConfigPath);
|
||||
DPRINT ("ConfigPath: %S\n", ConfigPath);
|
||||
|
||||
RtlInitUnicodeString (&KeyName,
|
||||
|
@ -975,9 +937,9 @@ CmiInitHives(BOOLEAN SetupBoot)
|
|||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
NULL);
|
||||
Status = CmiInitializeHive(&ObjectAttributes,
|
||||
ConfigPath,
|
||||
SetupBoot);
|
||||
Status = CmiLoadHive (&ObjectAttributes,
|
||||
&FileName,
|
||||
0);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("CmiInitializeHive() failed (Status %lx)\n", Status);
|
||||
|
|
Loading…
Reference in a new issue