Create hardware keys only if hardware hive was not imported.

svn path=/trunk/; revision=4544
This commit is contained in:
Eric Kohl 2003-04-17 11:07:47 +00:00
parent ac3799c79c
commit 70ce973518
4 changed files with 110 additions and 119 deletions

View file

@ -1,4 +1,4 @@
/* $Id: import.c,v 1.16 2003/04/12 18:41:43 ekohl Exp $
/* $Id: import.c,v 1.17 2003/04/17 11:07:21 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -23,6 +23,9 @@
#include "cm.h"
/* GLOBALS ******************************************************************/
static BOOLEAN CmiHardwareHiveImported = FALSE;
/* FUNCTIONS ****************************************************************/
@ -865,12 +868,106 @@ CmImportHardwareHive(PCHAR ChunkBase,
{
#if 0
PREGISTRY_HIVE RegistryHive;
UNICODE_STRING KeyName;
NTSTATUS Status;
#endif
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING KeyName;
HANDLE HardwareKey;
ULONG Disposition;
NTSTATUS Status;
DPRINT ("CmImportHardwareHive() called\n");
if (ChunkBase == NULL &&
ChunkSize == 0 &&
CmiHardwareHiveImported == FALSE)
{
/* Create '\Registry\Machine\HARDWARE' key. */
RtlInitUnicodeString(&KeyName,
L"\\Registry\\Machine\\HARDWARE");
InitializeObjectAttributes (&ObjectAttributes,
&KeyName,
0,
NULL,
NULL);
Status = NtCreateKey (&HardwareKey,
KEY_ALL_ACCESS,
&ObjectAttributes,
0,
NULL,
REG_OPTION_VOLATILE,
&Disposition);
if (!NT_SUCCESS(Status))
{
return FALSE;
}
NtClose (HardwareKey);
/* Create '\Registry\Machine\HARDWARE\DESCRIPTION' key. */
RtlInitUnicodeString(&KeyName,
L"\\Registry\\Machine\\HARDWARE\\DESCRIPTION");
InitializeObjectAttributes (&ObjectAttributes,
&KeyName,
0,
NULL,
NULL);
Status = NtCreateKey (&HardwareKey,
KEY_ALL_ACCESS,
&ObjectAttributes,
0,
NULL,
REG_OPTION_VOLATILE,
&Disposition);
if (!NT_SUCCESS(Status))
{
return FALSE;
}
NtClose (HardwareKey);
/* Create '\Registry\Machine\HARDWARE\DEVICEMAP' key. */
RtlInitUnicodeString(&KeyName,
L"\\Registry\\Machine\\HARDWARE\\DEVICEMAP");
InitializeObjectAttributes (&ObjectAttributes,
&KeyName,
0,
NULL,
NULL);
Status = NtCreateKey (&HardwareKey,
KEY_ALL_ACCESS,
&ObjectAttributes,
0,
NULL,
REG_OPTION_VOLATILE,
&Disposition);
if (!NT_SUCCESS(Status))
{
return FALSE;
}
NtClose (HardwareKey);
/* Create '\Registry\Machine\HARDWARE\RESOURCEMAP' key. */
RtlInitUnicodeString(&KeyName,
L"\\Registry\\Machine\\HARDWARE\\RESOURCEMAP");
InitializeObjectAttributes (&ObjectAttributes,
&KeyName,
0,
NULL,
NULL);
Status = NtCreateKey (&HardwareKey,
KEY_ALL_ACCESS,
&ObjectAttributes,
0,
NULL,
REG_OPTION_VOLATILE,
&Disposition);
if (!NT_SUCCESS(Status))
{
return FALSE;
}
NtClose (HardwareKey);
return TRUE;
}
#if 0
if (strncmp (ChunkBase, "regf", 4) != 0)
{
@ -908,6 +1005,8 @@ CmImportHardwareHive(PCHAR ChunkBase,
NULL);
#endif
CmiHardwareHiveImported = TRUE;
return TRUE;
}

View file

@ -3081,7 +3081,7 @@ CmiAddFree(PREGISTRY_HIVE RegistryHive,
return STATUS_INSUFFICIENT_RESOURCES;
tmpListOffset = ExAllocatePool(PagedPool,
sizeof(BLOCK_OFFSET *) * (RegistryHive->FreeListMax + 32));
sizeof(BLOCK_OFFSET) * (RegistryHive->FreeListMax + 32));
if (tmpListOffset == NULL)
{
@ -3096,7 +3096,7 @@ CmiAddFree(PREGISTRY_HIVE RegistryHive,
sizeof(PCELL_HEADER) * (RegistryHive->FreeListMax));
RtlMoveMemory(tmpListOffset,
RegistryHive->FreeListOffset,
sizeof(BLOCK_OFFSET *) * (RegistryHive->FreeListMax));
sizeof(BLOCK_OFFSET) * (RegistryHive->FreeListMax));
ExFreePool(RegistryHive->FreeList);
ExFreePool(RegistryHive->FreeListOffset);
}

View file

@ -1,4 +1,4 @@
/* $Id: registry.c,v 1.92 2003/04/12 15:09:57 ekohl Exp $
/* $Id: registry.c,v 1.93 2003/04/17 11:07:21 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -258,11 +258,6 @@ CmInitializeRegistry(VOID)
HANDLE KeyHandle;
NTSTATUS Status;
/* FIXME: remove the hardware keys before the hardware hive is imported */
PKEY_OBJECT HardwareKey;
PKEY_OBJECT NewKey;
/* Initialize the Key object type */
CmiKeyType = ExAllocatePool(NonPagedPool, sizeof(OBJECT_TYPE));
assert(CmiKeyType);
@ -373,113 +368,6 @@ CmInitializeRegistry(VOID)
UserKey->Name = ExAllocatePool(PagedPool, UserKey->NameSize);
RtlCopyMemory(UserKey->Name, "User", UserKey->NameSize);
CmiAddKeyToList(RootKey, UserKey);
/* FIXME: remove the hardware keys before the hardware hive is imported */
/* Create '\Registry\Machine\HARDWARE' key. */
Status = ObCreateObject(&KeyHandle,
STANDARD_RIGHTS_REQUIRED,
NULL,
CmiKeyType,
(PVOID*)&HardwareKey);
assert(NT_SUCCESS(Status));
Status = CmiAddSubKey(CmiVolatileHive,
MachineKey,
HardwareKey,
L"HARDWARE",
wcslen(L"HARDWARE") * sizeof(WCHAR),
0,
NULL,
0);
assert(NT_SUCCESS(Status));
HardwareKey->RegistryHive = CmiVolatileHive;
HardwareKey->Flags = 0;
HardwareKey->NumberOfSubKeys = 0;
HardwareKey->SubKeys = NULL;
HardwareKey->SizeOfSubKeys = HardwareKey->KeyCell->NumberOfSubKeys;
HardwareKey->NameSize = strlen("HARDWARE");
HardwareKey->Name = ExAllocatePool(PagedPool, strlen("HARDWARE"));
RtlCopyMemory(HardwareKey->Name, "HARDWARE", HardwareKey->NameSize);
CmiAddKeyToList(MachineKey, HardwareKey);
/* Create '\Registry\Machine\HARDWARE\DESCRIPTION' key. */
Status = ObCreateObject(&KeyHandle,
STANDARD_RIGHTS_REQUIRED,
NULL,
CmiKeyType,
(PVOID*)&NewKey);
assert(NT_SUCCESS(Status));
Status = CmiAddSubKey(CmiVolatileHive,
HardwareKey,
NewKey,
L"DESCRIPTION",
wcslen(L"DESCRIPTION") * sizeof(WCHAR),
0,
NULL,
0);
assert(NT_SUCCESS(Status));
NewKey->RegistryHive = CmiVolatileHive;
NewKey->Flags = 0;
NewKey->NumberOfSubKeys = 0;
NewKey->SubKeys = NULL;
NewKey->SizeOfSubKeys = NewKey->KeyCell->NumberOfSubKeys;
NewKey->NameSize = strlen("DESCRIPTION");
NewKey->Name = ExAllocatePool(PagedPool, NewKey->NameSize);
RtlCopyMemory(NewKey->Name, "DESCRIPTION", NewKey->NameSize);
CmiAddKeyToList(HardwareKey, NewKey);
/* Create '\Registry\Machine\HARDWARE\DEVICEMAP' key. */
Status = ObCreateObject(&KeyHandle,
STANDARD_RIGHTS_REQUIRED,
NULL,
CmiKeyType,
(PVOID*)&NewKey);
assert(NT_SUCCESS(Status));
Status = CmiAddSubKey(CmiVolatileHive,
HardwareKey,
NewKey,
L"DEVICEMAP",
wcslen(L"DEVICEMAP") * sizeof(WCHAR),
0,
NULL,
0);
assert(NT_SUCCESS(Status));
NewKey->RegistryHive = CmiVolatileHive;
NewKey->Flags = 0;
NewKey->NumberOfSubKeys = 0;
NewKey->SubKeys = NULL;
NewKey->SizeOfSubKeys = NewKey->KeyCell->NumberOfSubKeys;
NewKey->NameSize = strlen("DEVICEMAP");
NewKey->Name = ExAllocatePool(PagedPool, NewKey->NameSize);
RtlCopyMemory(NewKey->Name, "DEVICEMAP", NewKey->NameSize);
CmiAddKeyToList(HardwareKey,NewKey);
/* Create '\Registry\Machine\HARDWARE\RESOURCEMAP' key. */
Status = ObCreateObject(&KeyHandle,
STANDARD_RIGHTS_REQUIRED,
NULL,
CmiKeyType,
(PVOID*)&NewKey);
assert(NT_SUCCESS(Status));
Status = CmiAddSubKey(CmiVolatileHive,
HardwareKey,
NewKey,
L"RESOURCEMAP",
wcslen(L"RESOURCEMAP") * sizeof(WCHAR),
0,
NULL,
0);
assert(NT_SUCCESS(Status));
NewKey->RegistryHive = CmiVolatileHive;
NewKey->Flags = 0;
NewKey->NumberOfSubKeys = 0;
NewKey->SubKeys = NULL;
NewKey->SizeOfSubKeys = NewKey->KeyCell->NumberOfSubKeys;
NewKey->NameSize = strlen("RESOURCEMAP");
NewKey->Name = ExAllocatePool(PagedPool, NewKey->NameSize);
RtlCopyMemory(NewKey->Name, "RESOURCEMAP", NewKey->NameSize);
CmiAddKeyToList(HardwareKey, NewKey);
}

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: main.c,v 1.150 2003/04/01 16:35:22 ekohl Exp $
/* $Id: main.c,v 1.151 2003/04/17 11:07:47 ekohl Exp $
*
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/ke/main.c
@ -521,6 +521,10 @@ ExpInitializeExecutive(VOID)
}
}
/* Create dummy keys if no hardware hive was found */
CmImportHardwareHive (NULL, 0);
/* Initialize volatile registry settings */
if (SetupBoot == FALSE)
{