-/* $Id: import.c,v 1.25 2003/11/27 00:48:11 gdalsnes Exp $
+/* $Id$
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/cm/import.c
* PURPOSE: Registry-Hive import functions
+ *
* PROGRAMMERS: Eric Kohl
*/
/* INCLUDES *****************************************************************/
-
-#include <ddk/ntddk.h>
-#include <string.h>
-#include <ctype.h>
-#include <roscfg.h>
-
+#include <ntoskrnl.h>
#define NDEBUG
#include <internal/debug.h>
#include "cm.h"
+#if defined (ALLOC_PRAGMA)
+#pragma alloc_text(INIT, CmImportHardwareHive)
+#endif
+
/* GLOBALS ******************************************************************/
static BOOLEAN CmiHardwareHiveImported = FALSE;
/* Allocate block list */
DPRINT("Space needed for block list describing hive: 0x%x\n",
- Hive->BlockListSize * sizeof(PHBIN *));
+ Hive->BlockListSize * sizeof(BLOCK_LIST_ENTRY));
Hive->BlockList = ExAllocatePool (NonPagedPool,
- Hive->BlockListSize * sizeof(PHBIN *));
+ Hive->BlockListSize * sizeof(BLOCK_LIST_ENTRY));
if (Hive->BlockList == NULL)
{
DPRINT1 ("Allocating block list failed\n");
return FALSE;
}
RtlZeroMemory (Hive->BlockList,
- Hive->BlockListSize * sizeof(PHBIN *));
+ Hive->BlockListSize * sizeof(BLOCK_LIST_ENTRY));
/* Import the bins */
Status = CmiImportHiveBins(Hive,
ExFreePool (Hive->BlockList);
ExFreePool (Hive->HiveHeader);
ExFreePool (Hive);
- return Status;
+ return (BOOLEAN)Status;
}
/* Initialize the free cell list */
ExFreePool (Hive->HiveHeader);
ExFreePool (Hive);
- return Status;
+ return (BOOLEAN)Status;
}
if (!(Hive->Flags & HIVE_NO_FILE))
ExFreePool (Hive->HiveHeader);
ExFreePool (Hive);
- return Status;
+ return (BOOLEAN)Status;
}
}
- /* Initialize the hive's executive resource */
- ExInitializeResourceLite(&Hive->HiveResource);
-
/* Acquire hive list lock exclusively */
KeEnterCriticalRegion();
- ExAcquireResourceExclusiveLite(&CmiHiveListLock, TRUE);
+ ExAcquireResourceExclusiveLite(&CmiRegistryLock, TRUE);
/* Add the new hive to the hive list */
InsertTailList(&CmiHiveListHead, &Hive->HiveList);
/* Release hive list lock */
- ExReleaseResourceLite(&CmiHiveListLock);
+ ExReleaseResourceLite(&CmiRegistryLock);
KeLeaveCriticalRegion();
*RegistryHive = Hive;
/* Import the binary system hive (non-volatile, offset-based, permanent) */
if (!CmImportBinaryHive (ChunkBase, ChunkSize, 0, &RegistryHive))
{
- DPRINT1 ("CmiImportBinaryHive() failed\n", Status);
+ DPRINT1 ("CmiImportBinaryHive() failed\n");
return FALSE;
}
/* Attach it to the machine key */
RtlInitUnicodeString (&KeyName,
- L"\\Registry\\Machine\\System");
+ REG_SYSTEM_KEY_NAME);
InitializeObjectAttributes (&ObjectAttributes,
&KeyName,
OBJ_CASE_INSENSITIVE,
RegistryHive);
if (!NT_SUCCESS(Status))
{
- DPRINT1 ("CmiConnectHive() failed (Status %lx)\n", Status);
+ DPRINT1 ("CmiConnectHive(%wZ) failed (Status %lx)\n", &KeyName, Status);
// CmiRemoveRegistryHive(RegistryHive);
return FALSE;
}
/* Set the hive filename */
RtlCreateUnicodeString (&RegistryHive->HiveFileName,
- SYSTEM_REG_FILE);
+ SYSTEM_REG_FILE);
/* Set the log filename */
RtlCreateUnicodeString (&RegistryHive->LogFileName,
- SYSTEM_LOG_FILE);
+ SYSTEM_LOG_FILE);
return TRUE;
}
{
/* Create '\Registry\Machine\HARDWARE' key. */
RtlInitUnicodeString (&KeyName,
- L"\\Registry\\Machine\\HARDWARE");
+ REG_HARDWARE_KEY_NAME);
InitializeObjectAttributes (&ObjectAttributes,
&KeyName,
OBJ_CASE_INSENSITIVE,
NULL,
NULL);
- Status = NtCreateKey (&HardwareKey,
+ Status = ZwCreateKey (&HardwareKey,
KEY_ALL_ACCESS,
&ObjectAttributes,
0,
&Disposition);
if (!NT_SUCCESS(Status))
{
- return FALSE;
+ DPRINT1("NtCreateKey() failed, status: 0x%x\n", Status);
+ return FALSE;
}
- NtClose (HardwareKey);
+ ZwClose (HardwareKey);
/* Create '\Registry\Machine\HARDWARE\DESCRIPTION' key. */
RtlInitUnicodeString(&KeyName,
- L"\\Registry\\Machine\\HARDWARE\\DESCRIPTION");
+ REG_DESCRIPTION_KEY_NAME);
InitializeObjectAttributes (&ObjectAttributes,
&KeyName,
OBJ_CASE_INSENSITIVE,
NULL,
NULL);
- Status = NtCreateKey (&HardwareKey,
+ Status = ZwCreateKey (&HardwareKey,
KEY_ALL_ACCESS,
&ObjectAttributes,
0,
&Disposition);
if (!NT_SUCCESS(Status))
{
- return FALSE;
+ DPRINT1("NtCreateKey() failed, status: 0x%x\n", Status);
+ return FALSE;
}
- NtClose (HardwareKey);
+ ZwClose (HardwareKey);
/* Create '\Registry\Machine\HARDWARE\DEVICEMAP' key. */
RtlInitUnicodeString (&KeyName,
- L"\\Registry\\Machine\\HARDWARE\\DEVICEMAP");
+ REG_DEVICEMAP_KEY_NAME);
InitializeObjectAttributes (&ObjectAttributes,
&KeyName,
OBJ_CASE_INSENSITIVE,
NULL,
NULL);
- Status = NtCreateKey (&HardwareKey,
+ Status = ZwCreateKey (&HardwareKey,
KEY_ALL_ACCESS,
&ObjectAttributes,
0,
&Disposition);
if (!NT_SUCCESS(Status))
{
- return FALSE;
+ DPRINT1("NtCreateKey() failed, status: 0x%x\n", Status);
+ return FALSE;
}
- NtClose (HardwareKey);
+ ZwClose (HardwareKey);
/* Create '\Registry\Machine\HARDWARE\RESOURCEMAP' key. */
RtlInitUnicodeString(&KeyName,
- L"\\Registry\\Machine\\HARDWARE\\RESOURCEMAP");
+ REG_RESOURCEMAP_KEY_NAME);
InitializeObjectAttributes (&ObjectAttributes,
&KeyName,
OBJ_CASE_INSENSITIVE,
NULL,
NULL);
- Status = NtCreateKey (&HardwareKey,
+ Status = ZwCreateKey (&HardwareKey,
KEY_ALL_ACCESS,
&ObjectAttributes,
0,
&Disposition);
if (!NT_SUCCESS(Status))
{
- return FALSE;
+ DPRINT1("NtCreateKey() failed, status: 0x%x\n", Status);
+ return FALSE;
}
- NtClose (HardwareKey);
+ ZwClose (HardwareKey);
return TRUE;
}
/* Import the binary system hive (volatile, offset-based, permanent) */
if (!CmImportBinaryHive (ChunkBase, ChunkSize, HIVE_NO_FILE, &RegistryHive))
{
- DPRINT1 ("CmiImportBinaryHive() failed\n", Status);
+ DPRINT1 ("CmiImportBinaryHive() failed\n");
return FALSE;
}
/* Attach it to the machine key */
RtlInitUnicodeString (&KeyName,
- L"\\Registry\\Machine\\HARDWARE");
+ REG_HARDWARE_KEY_NAME);
InitializeObjectAttributes (&ObjectAttributes,
&KeyName,
OBJ_CASE_INSENSITIVE,
RegistryHive);
if (!NT_SUCCESS(Status))
{
- DPRINT1 ("CmiConnectHive() failed (Status %lx)\n", Status);
+ DPRINT1 ("CmiConnectHive(%wZ) failed (Status %lx)\n", &KeyName, Status);
// CmiRemoveRegistryHive(RegistryHive);
return FALSE;
}