mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 18:15:11 +00:00
Enable import of binary system hive.
svn path=/trunk/; revision=4469
This commit is contained in:
parent
1fb9958a68
commit
0ce7c979ac
2 changed files with 132 additions and 18 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: import.c,v 1.12 2003/03/24 19:09:04 ekohl Exp $
|
/* $Id: import.c,v 1.13 2003/04/01 16:37:14 ekohl Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -27,6 +27,9 @@
|
||||||
#include "cm.h"
|
#include "cm.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
extern PKEY_OBJECT CmiMachineKey;
|
||||||
|
|
||||||
|
|
||||||
static PCHAR
|
static PCHAR
|
||||||
checkAndSkipMagic (PCHAR regChunk)
|
checkAndSkipMagic (PCHAR regChunk)
|
||||||
{
|
{
|
||||||
|
@ -613,9 +616,10 @@ CmImportTextHive(PCHAR ChunkBase,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BOOLEAN
|
static BOOLEAN
|
||||||
CmImportSystemHive(PCHAR ChunkBase,
|
CmImportBinarySystemHive(PCHAR ChunkBase,
|
||||||
ULONG ChunkSize)
|
ULONG ChunkSize,
|
||||||
|
PREGISTRY_HIVE *RegistryHive)
|
||||||
{
|
{
|
||||||
PREGISTRY_HIVE Hive;
|
PREGISTRY_HIVE Hive;
|
||||||
PCELL_HEADER FreeBlock;
|
PCELL_HEADER FreeBlock;
|
||||||
|
@ -626,16 +630,9 @@ CmImportSystemHive(PCHAR ChunkBase,
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
ULONG BitmapSize;
|
ULONG BitmapSize;
|
||||||
|
|
||||||
|
*RegistryHive = NULL;
|
||||||
|
|
||||||
// CmImportTextHive (ChunkBase, ChunkSize);
|
if (strncmp (ChunkBase, "regf", 4) != 0)
|
||||||
|
|
||||||
if (strncmp (ChunkBase, "REGEDIT4", 8) == 0)
|
|
||||||
{
|
|
||||||
DPRINT1("Found 'REGEDIT4' magic\n");
|
|
||||||
CmImportTextHive (ChunkBase, ChunkSize);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
else if (strncpy (ChunkBase, "regf", 4) != 0)
|
|
||||||
{
|
{
|
||||||
DPRINT1("Found invalid '%*s' magic\n", 4, ChunkBase);
|
DPRINT1("Found invalid '%*s' magic\n", 4, ChunkBase);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -686,8 +683,9 @@ CmImportSystemHive(PCHAR ChunkBase,
|
||||||
ExFreePool (Hive);
|
ExFreePool (Hive);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
CHECKPOINT1;
|
||||||
|
|
||||||
/* Allocate the first hive block */
|
/* Allocate the hive block */
|
||||||
Hive->BlockList[0] = ExAllocatePool(PagedPool,
|
Hive->BlockList[0] = ExAllocatePool(PagedPool,
|
||||||
Hive->FileSize - 4096);
|
Hive->FileSize - 4096);
|
||||||
if (Hive->BlockList[0] == NULL)
|
if (Hive->BlockList[0] == NULL)
|
||||||
|
@ -699,6 +697,7 @@ CmImportSystemHive(PCHAR ChunkBase,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CHECKPOINT1;
|
||||||
/* Import the hive block */
|
/* Import the hive block */
|
||||||
RtlCopyMemory (Hive->BlockList[0],
|
RtlCopyMemory (Hive->BlockList[0],
|
||||||
ChunkBase + 4096,
|
ChunkBase + 4096,
|
||||||
|
@ -709,6 +708,7 @@ CmImportSystemHive(PCHAR ChunkBase,
|
||||||
Hive->FreeListMax = 0;
|
Hive->FreeListMax = 0;
|
||||||
Hive->FreeList = NULL;
|
Hive->FreeList = NULL;
|
||||||
|
|
||||||
|
CHECKPOINT1;
|
||||||
BlockOffset = 0;
|
BlockOffset = 0;
|
||||||
for (i = 0; i < Hive->BlockListSize; i++)
|
for (i = 0; i < Hive->BlockListSize; i++)
|
||||||
{
|
{
|
||||||
|
@ -759,11 +759,12 @@ CmImportSystemHive(PCHAR ChunkBase,
|
||||||
}
|
}
|
||||||
BlockOffset += Bin->BlockSize;
|
BlockOffset += Bin->BlockSize;
|
||||||
}
|
}
|
||||||
|
CHECKPOINT1;
|
||||||
|
|
||||||
/* Calculate bitmap size in bytes (always a multiple of 32 bits) */
|
/* Calculate bitmap size in bytes (always a multiple of 32 bits) */
|
||||||
BitmapSize = ROUND_UP(Hive->BlockListSize, sizeof(ULONG) * 8) / 8;
|
BitmapSize = ROUND_UP(Hive->BlockListSize, sizeof(ULONG) * 8) / 8;
|
||||||
DPRINT("Hive->BlockListSize: %lu\n", Hive->BlockListSize);
|
DPRINT1("Hive->BlockListSize: %lu\n", Hive->BlockListSize);
|
||||||
DPRINT("BitmapSize: %lu Bytes %lu Bits\n", BitmapSize, BitmapSize * 8);
|
DPRINT1("BitmapSize: %lu Bytes %lu Bits\n", BitmapSize, BitmapSize * 8);
|
||||||
|
|
||||||
/* Allocate bitmap */
|
/* Allocate bitmap */
|
||||||
Hive->BitmapBuffer = (PULONG)ExAllocatePool(PagedPool,
|
Hive->BitmapBuffer = (PULONG)ExAllocatePool(PagedPool,
|
||||||
|
@ -777,6 +778,7 @@ CmImportSystemHive(PCHAR ChunkBase,
|
||||||
ExFreePool (Hive);
|
ExFreePool (Hive);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
CHECKPOINT1;
|
||||||
|
|
||||||
/* Initialize bitmap */
|
/* Initialize bitmap */
|
||||||
RtlInitializeBitMap(&Hive->DirtyBitMap,
|
RtlInitializeBitMap(&Hive->DirtyBitMap,
|
||||||
|
@ -797,11 +799,123 @@ CmImportSystemHive(PCHAR ChunkBase,
|
||||||
|
|
||||||
/* Release hive list lock */
|
/* Release hive list lock */
|
||||||
ExReleaseResourceLite(&CmiHiveListLock);
|
ExReleaseResourceLite(&CmiHiveListLock);
|
||||||
|
CHECKPOINT1;
|
||||||
|
|
||||||
|
*RegistryHive = Hive;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BOOLEAN
|
||||||
|
CmImportSystemHive(PCHAR ChunkBase,
|
||||||
|
ULONG ChunkSize)
|
||||||
|
{
|
||||||
|
PREGISTRY_HIVE RegistryHive;
|
||||||
|
// UNICODE_STRING ParentKeyName;
|
||||||
|
// UNICODE_STRING SubKeyName;
|
||||||
|
// NTSTATUS Status;
|
||||||
|
|
||||||
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
|
PKEY_OBJECT NewKey;
|
||||||
|
HANDLE KeyHandle;
|
||||||
|
UNICODE_STRING KeyName;
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
if (strncmp (ChunkBase, "REGEDIT4", 8) == 0)
|
||||||
|
{
|
||||||
|
DPRINT1("Found 'REGEDIT4' magic\n");
|
||||||
|
CmImportTextHive (ChunkBase, ChunkSize);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
else if (strncmp (ChunkBase, "regf", 4) == 0)
|
||||||
|
{
|
||||||
|
DPRINT1("Found '%*s' magic\n", 4, ChunkBase);
|
||||||
|
if (!CmImportBinarySystemHive (ChunkBase, ChunkSize, &RegistryHive))
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
RtlInitUnicodeString(&KeyName,
|
||||||
|
L"\\Registry\\Machine\\System");
|
||||||
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
|
&KeyName,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
Status = ObCreateObject(&KeyHandle,
|
||||||
|
STANDARD_RIGHTS_REQUIRED,
|
||||||
|
&ObjectAttributes,
|
||||||
|
CmiKeyType,
|
||||||
|
(PVOID*)&NewKey);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DPRINT1("ObCreateObject() failed (Status %lx)\n", Status);
|
||||||
|
KeBugCheck(0);
|
||||||
|
// CmiRemoveRegistryHive(RegistryHive);
|
||||||
|
// return(Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
NewKey->RegistryHive = RegistryHive;
|
||||||
|
NewKey->BlockOffset = RegistryHive->HiveHeader->RootKeyCell;
|
||||||
|
NewKey->KeyCell = CmiGetBlock(RegistryHive, NewKey->BlockOffset, NULL);
|
||||||
|
NewKey->Flags = 0;
|
||||||
|
NewKey->NumberOfSubKeys = 0;
|
||||||
|
NewKey->SubKeys = ExAllocatePool(PagedPool,
|
||||||
|
NewKey->KeyCell->NumberOfSubKeys * sizeof(DWORD));
|
||||||
|
|
||||||
|
if ((NewKey->SubKeys == NULL) && (NewKey->KeyCell->NumberOfSubKeys != 0))
|
||||||
|
{
|
||||||
|
DPRINT1("NumberOfSubKeys %d\n", NewKey->KeyCell->NumberOfSubKeys);
|
||||||
|
KeBugCheck(0);
|
||||||
|
// ZwClose(NewKey);
|
||||||
|
// CmiRemoveRegistryHive(RegistryHive);
|
||||||
|
// return(STATUS_INSUFFICIENT_RESOURCES);
|
||||||
|
}
|
||||||
|
|
||||||
|
NewKey->SizeOfSubKeys = NewKey->KeyCell->NumberOfSubKeys;
|
||||||
|
NewKey->NameSize = strlen("System");
|
||||||
|
NewKey->Name = ExAllocatePool(PagedPool, NewKey->NameSize);
|
||||||
|
|
||||||
|
if ((NewKey->Name == NULL) && (NewKey->NameSize != 0))
|
||||||
|
{
|
||||||
|
DPRINT1("NewKey->NameSize %d\n", NewKey->NameSize);
|
||||||
|
if (NewKey->SubKeys != NULL)
|
||||||
|
ExFreePool(NewKey->SubKeys);
|
||||||
|
KeBugCheck(0);
|
||||||
|
// ZwClose(NewKey);
|
||||||
|
// CmiRemoveRegistryHive(RegistryHive);
|
||||||
|
// return(STATUS_INSUFFICIENT_RESOURCES);
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(NewKey->Name, "System", NewKey->NameSize);
|
||||||
|
CmiAddKeyToList(CmiMachineKey, NewKey);
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
RtlInitUnicodeString (&ParentKeyName,
|
||||||
|
REG_MACHINE_KEY_NAME);
|
||||||
|
RtlInitUnicodeString (&SubKeyName,
|
||||||
|
L"System");
|
||||||
|
|
||||||
|
Status = CmiLinkHive (&ParentKeyName,
|
||||||
|
&SubKeyName,
|
||||||
|
Hive);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
CmImportHardwareHive(PCHAR ChunkBase,
|
CmImportHardwareHive(PCHAR ChunkBase,
|
||||||
ULONG ChunkSize)
|
ULONG ChunkSize)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: registry.c,v 1.87 2003/03/18 20:36:17 ekohl Exp $
|
/* $Id: registry.c,v 1.88 2003/04/01 16:37:14 ekohl Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -43,7 +43,7 @@ KDPC CmiHiveSyncDpc;
|
||||||
KTIMER CmiHiveSyncTimer;
|
KTIMER CmiHiveSyncTimer;
|
||||||
|
|
||||||
static PKEY_OBJECT CmiRootKey = NULL;
|
static PKEY_OBJECT CmiRootKey = NULL;
|
||||||
static PKEY_OBJECT CmiMachineKey = NULL;
|
PKEY_OBJECT CmiMachineKey = NULL;
|
||||||
static PKEY_OBJECT CmiUserKey = NULL;
|
static PKEY_OBJECT CmiUserKey = NULL;
|
||||||
static PKEY_OBJECT CmiHardwareKey = NULL;
|
static PKEY_OBJECT CmiHardwareKey = NULL;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue