- More simplification: Get rid of CmImportBinaryHive, CmpImportSystemHive, CmpImportHardwareHive and all of import.c!

- Fix CmpInitializeHive to set any flags that are passed, not assume HIVE_NO_FILE by default.
- "Import" the system and hardware hives using CmpInitializeHive instead of the cmimport.c routines which are gone.
- Get rid of old/unused cmdata.c in /cm.

svn path=/trunk/; revision=26693
This commit is contained in:
Alex Ionescu 2007-05-11 06:24:00 +00:00
parent 59a8c8c5dc
commit 384af65d69
5 changed files with 50 additions and 860 deletions

View file

@ -1,710 +0,0 @@
#include "ntoskrnl.h"
#include "cm.h"
/* SYSTEM CONFIGURATION VECTOR ***********************************************/
ULONG DummyData;
ULONG CmNtGlobalFlag;
ULONG CmNtCSDVersion;
WCHAR CmDefaultLanguageId[12];
ULONG CmDefaultLanguageIdLength = sizeof(CmDefaultLanguageId);
ULONG CmDefaultLanguageIdType;
WCHAR CmInstallUILanguageId[12];
ULONG CmInstallUILanguageIdLength = sizeof(CmInstallUILanguageId);
ULONG CmInstallUILanguageIdType;
WCHAR CmSuiteBuffer[128];
ULONG CmSuiteBufferLength = sizeof(CmSuiteBuffer);
ULONG CmSuiteBufferType;
extern LANGID PsInstallUILanguageId;
extern LANGID PsDefaultUILanguageId;
//CMHIVE CmControlHive;
CM_SYSTEM_CONTROL_VECTOR CmControlVector[] =
{
{
L"Session Manager",
L"ProtectionMode",
&DummyData,
NULL,
NULL
},
{
L"Session Manager",
L"ObjectSecurityMode",
&DummyData,
NULL,
NULL
},
{
L"Session Manager",
L"LUIDDeviceMapsDisabled",
&DummyData,
NULL,
NULL
},
{
L"LSA",
L"AuditBaseDirectories",
&DummyData,
NULL,
NULL
},
{
L"LSA",
L"AuditBaseObjects",
&DummyData,
NULL,
NULL
},
{
L"LSA\\audit",
L"ProcessAccessesToAudit",
&DummyData,
NULL,
NULL
},
{
L"TimeZoneInformation",
L"ActiveTimeBias",
&DummyData,
NULL,
NULL
},
{
L"TimeZoneInformation",
L"Bias",
&DummyData,
NULL,
NULL
},
{
L"TimeZoneInformation",
L"RealTimeIsUniversal",
&DummyData,
NULL,
NULL
},
{
L"Session Manager",
L"GlobalFlag",
&CmNtGlobalFlag,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"PagedPoolQuota",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"NonPagedPoolQuota",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"PagingFileQuota",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"AllocationPreference",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"DynamicMemory",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"Mirroring",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"Mirroring",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"SystemViewSize",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"SessionViewSize",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"SessionImageSize",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"SessionPoolSize",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"PoolUsageMaximum",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"MapAllocationFragment",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"PagedPoolSize",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"NonPagedPoolSize",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"NonPagedPoolMaximumPercent",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"LargeSystemCache",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"LargeStackSize",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"SystemPages",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"LowMemoryThreshold",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"HighMemoryThreshold",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"DisablePagingExecutive",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"ModifiedPageLife",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"SecondLevelDataCache",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"ClearPageFileAtShutdown",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"PoolTagSmallTableSize",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"PoolTagBigTableSize",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"PoolTag",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"PoolTagOverruns",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"SnapUnloads",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"ProtectNonPagedPool",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"TrackLockedPages",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"TrackPtes",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"VerifyDrivers",
&DummyData,
&DummyData,
&DummyData
},
{
L"Session Manager\\Memory Management",
L"VerifyDriverLevel",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"VerifyMode",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"LargePageMinimum",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"EnforceWriteProtection",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"MakeLowMemory",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"WriteWatch",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Executive",
L"AdditionalCriticalWorkerThreads",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Executive",
L"AdditionalDelayedWorkerThreads",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Executive",
L"PriorityQuantumMatrix",
&DummyData,
&DummyData,
NULL
},
{
L"Session Manager\\Kernel",
L"DpcQueueDepth",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Kernel",
L"MinimumDpcRate",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Kernel",
L"AdjustDpcThreshold",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Kernel",
L"IdealDpcRate",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\I/O System",
L"CountOperations",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\I/O System",
L"LargeIrpStackLocations",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\I/O System",
L"IoVerifierLevel",
&DummyData,
NULL,
NULL
},
{
L"Session Manager",
L"ResourceTimeoutCount",
&DummyData,
NULL,
NULL
},
{
L"Session Manager",
L"CriticalSectionTimeout",
&DummyData,
NULL,
NULL
},
{
L"Session Manager",
L"HeapSegmentReserve",
&DummyData,
NULL,
NULL
},
{
L"Session Manager",
L"HeapSegmentCommit",
&DummyData,
NULL,
NULL
},
{
L"Session Manager",
L"HeapDeCommitTotalFreeThreshold",
&DummyData,
NULL,
NULL
},
{
L"Session Manager",
L"HeapDeCommitFreeBlockThreshold",
&DummyData,
NULL,
NULL
},
{
L"ProductOptions",
L"ProductType",
&DummyData,
NULL,
NULL
},
{
L"Terminal Server",
L"TSEnabled",
&DummyData,
NULL,
NULL
},
{
L"Terminal Server",
L"TSAppCompat",
&DummyData,
NULL,
NULL
},
{
L"ProductOptions",
L"ProductSuite",
CmSuiteBuffer,
&CmSuiteBufferLength,
&CmSuiteBufferType
},
{
L"Windows",
L"CSDVersion",
&CmNtCSDVersion,
NULL,
NULL
},
{
L"Nls\\Language",
L"Default",
CmDefaultLanguageId,
&CmDefaultLanguageIdLength,
&CmDefaultLanguageIdType
},
{
L"Nls\\Language",
L"InstallLanguage",
CmInstallUILanguageId,
&CmInstallUILanguageIdLength,
&CmInstallUILanguageIdType
},
{
L"\0\0",
L"RegistrySizeLimit",
&DummyData,
&DummyData,
&DummyData
},
{
L"Session Manager",
L"ForceNpxEmulation",
&DummyData,
NULL,
NULL
},
{
L"Session Manager",
L"PowerPolicySimulate",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Executive",
L"MaxTimeSeparationBeforeCorrect",
&DummyData,
NULL,
NULL
},
{
L"Windows",
L"ShutdownTime",
&DummyData,
&DummyData,
NULL
},
{
L"PriorityControl",
L"Win32PrioritySeparation",
&DummyData,
NULL,
NULL
},
{
L"Session Manager",
L"EnableTimerWatchdog",
&DummyData,
NULL,
NULL
},
{
L"Session Manager",
L"Debugger Retries",
&DummyData,
NULL,
NULL
},
{
L"WMI",
L"MaxEventSize",
&DummyData,
NULL,
NULL
},
{
L"WMI\\Trace",
L"UsePerformanceClock",
&DummyData,
NULL,
NULL
},
{
L"WMI\\Trace",
L"TraceAlignment",
&DummyData,
NULL,
NULL
},
{
NULL,
NULL,
NULL,
NULL,
NULL
}
};

View file

@ -1,136 +0,0 @@
/* $Id$
*
* PROJECT: ReactOS Kernel
* COPYRIGHT: GPL - See COPYING in the top level directory
* FILE: ntoskrnl/cm/import.c
* PURPOSE: Registry-Hive import functions
*
* PROGRAMMERS: Eric Kohl
*/
/* INCLUDES *****************************************************************/
#include <ntoskrnl.h>
#define NDEBUG
#include <internal/debug.h>
#include "cm.h"
#if defined (ALLOC_PRAGMA)
#pragma alloc_text(INIT, CmImportHardwareHive)
#endif
/* GLOBALS ******************************************************************/
/* FUNCTIONS ****************************************************************/
static BOOLEAN
CmImportBinaryHive (PCHAR ChunkBase,
ULONG ChunkSize,
ULONG Flags,
PEREGISTRY_HIVE *RegistryHive)
{
PEREGISTRY_HIVE Hive;
NTSTATUS Status;
*RegistryHive = NULL;
/* Create a new hive */
Hive = ExAllocatePool (NonPagedPool,
sizeof(EREGISTRY_HIVE));
if (Hive == NULL)
{
return FALSE;
}
RtlZeroMemory (Hive,
sizeof(EREGISTRY_HIVE));
/* Set hive flags */
Hive->Flags = Flags;
/* Allocate hive header */
((PHBASE_BLOCK)ChunkBase)->Length = ChunkSize;
Status = HvInitialize(&Hive->Hive, HV_OPERATION_MEMORY, 0, 0,
(ULONG_PTR)ChunkBase, 0,
CmpAllocate, CmpFree,
CmpFileRead, CmpFileWrite, CmpFileSetSize,
CmpFileFlush, NULL);
if (!NT_SUCCESS(Status))
{
DPRINT1 ("Opening hive failed (%x)\n", Status);
ExFreePool (Hive);
return FALSE;
}
CmPrepareHive(&Hive->Hive);
/* Acquire hive list lock exclusively */
KeEnterCriticalRegion();
ExAcquireResourceExclusiveLite(&CmiRegistryLock, TRUE);
DPRINT("Adding new hive\n");
/* Add the new hive to the hive list */
InsertTailList(&CmiHiveListHead, &Hive->HiveList);
/* Release hive list lock */
ExReleaseResourceLite(&CmiRegistryLock);
KeLeaveCriticalRegion();
*RegistryHive = Hive;
return TRUE;
}
BOOLEAN
INIT_FUNCTION
CmImportSystemHive(PCHAR ChunkBase,
ULONG ChunkSize,
OUT PEREGISTRY_HIVE *RegistryHive)
{
*RegistryHive = NULL;
/* Import the binary system hive (non-volatile, offset-based, permanent) */
if (!CmImportBinaryHive (ChunkBase, ChunkSize, 0, RegistryHive))
{
return FALSE;
}
/* Set the hive filename */
RtlCreateUnicodeString (&(*RegistryHive)->HiveFileName,
SYSTEM_REG_FILE);
/* Set the log filename */
RtlCreateUnicodeString (&(*RegistryHive)->LogFileName,
SYSTEM_LOG_FILE);
return TRUE;
}
BOOLEAN
INIT_FUNCTION
CmImportHardwareHive(PCHAR ChunkBase,
ULONG ChunkSize,
OUT PEREGISTRY_HIVE *RegistryHive)
{
*RegistryHive = NULL;
/* Import the binary system hive (volatile, offset-based, permanent) */
if (!CmImportBinaryHive (ChunkBase, ChunkSize, HIVE_NO_FILE, RegistryHive))
{
return FALSE;
}
/* Set the hive filename */
RtlInitUnicodeString (&(*RegistryHive)->HiveFileName,
NULL);
/* Set the log filename */
RtlInitUnicodeString (&(*RegistryHive)->LogFileName,
NULL);
return TRUE;
}
/* EOF */

View file

@ -422,8 +422,8 @@ CmpInitializeHive(OUT PEREGISTRY_HIVE *RegistryHive,
return Status;
}
/* Set flag */
Hive->Flags = HIVE_NO_FILE;
/* Set flags */
Hive->Flags = HiveFlags;
/* Check if we should verify the registry */
if ((OperationType == HINIT_FILE) ||

View file

@ -252,6 +252,7 @@ CmpInitializeSystemHive(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
BOOLEAN Allocate;
UNICODE_STRING KeyName;
PEREGISTRY_HIVE SystemHive;
UNICODE_STRING HiveName = RTL_CONSTANT_STRING(L"SYSTEM");
PAGED_CODE();
/* Setup the ansi string */
@ -279,10 +280,25 @@ CmpInitializeSystemHive(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
if (HiveBase)
{
/* Import it */
Status = CmImportSystemHive(HiveBase,
LoaderBlock->RegistryLength,
&SystemHive);
((PHBASE_BLOCK)HiveBase)->Length = LoaderBlock->RegistryLength;
Status = CmpInitializeHive(&SystemHive,
HINIT_MEMORY,
0, //HIVE_NOLAZYFLUSH,
HFILE_TYPE_LOG,
HiveBase,
NULL,
NULL,
NULL,
&HiveName,
2);
if (!NT_SUCCESS(Status)) return FALSE;
CmPrepareHive(&SystemHive->Hive);
/* Set the hive filename */
RtlCreateUnicodeString(&SystemHive->HiveFileName, SYSTEM_REG_FILE);
/* Set the log filename */
RtlCreateUnicodeString(&SystemHive->LogFileName, SYSTEM_LOG_FILE);
/* We imported, no need to create a new hive */
Allocate = FALSE;
@ -393,6 +409,7 @@ CmpCreateRegistryRoot(VOID)
HANDLE RootKeyHandle;
HCELL_INDEX RootIndex;
NTSTATUS Status;
PCM_KEY_NODE KeyCell;
PAGED_CODE();
/* Setup the root node */
@ -420,17 +437,26 @@ CmpCreateRegistryRoot(VOID)
(PVOID*)&RootKey);
if (!NT_SUCCESS(Status)) return FALSE;
/* Sanity check, and get the key cell */
ASSERT((&CmiVolatileHive->Hive)->ReleaseCellRoutine == NULL);
KeyCell = (PCM_KEY_NODE)HvGetCell(&CmiVolatileHive->Hive, RootIndex);
if (!KeyCell) return FALSE;
/* Setup the root key */
RootKey->RegistryHive = CmiVolatileHive;
RootKey->KeyCellOffset = RootIndex;
RootKey->KeyCell = HvGetCell(&CmiVolatileHive->Hive, RootIndex);
RootKey->KeyCell = KeyCell;
RootKey->ParentKey = RootKey;
RootKey->Flags = 0;
RootKey->SubKeyCounts = 0;
RootKey->SubKeys = NULL;
RootKey->SizeOfSubKeys = 0;
/* Insert it into the object list head */
InsertTailList(&CmiKeyObjectListHead, &RootKey->ListEntry);
Status = RtlpCreateUnicodeString(&RootKey->Name, L"Registry", NonPagedPool);
/* Setup the name */
RtlpCreateUnicodeString(&RootKey->Name, L"Registry", NonPagedPool);
/* Insert the key into the namespace */
Status = ObInsertObject(RootKey,
@ -467,7 +493,6 @@ CmInitSystem1(VOID)
HANDLE ThreadHandle;
CLIENT_ID ThreadId;
PEREGISTRY_HIVE HardwareHive;
BOOLEAN Allocate = FALSE;
PVOID BaseAddress;
ULONG Length;
PAGED_CODE();
@ -513,7 +538,7 @@ CmInitSystem1(VOID)
/* Build the master hive */
Status = CmpInitializeHive(&CmiVolatileHive,
HINIT_CREATE,
HIVE_VOLATILE,
HIVE_VOLATILE | HIVE_NO_FILE,
HFILE_TYPE_PRIMARY,
NULL,
NULL,
@ -595,12 +620,24 @@ CmInitSystem1(VOID)
KEBUGCHECKEX(CONFIG_INITIALIZATION_FAILED, 1, 8, Status, 0);
}
/* Initialize the hardware hive */
/* Import the hardware hive (FIXME: We should create it from scratch) */
BaseAddress = CmpRosGetHardwareHive(&Length);
if (!CmImportHardwareHive(BaseAddress, Length, &HardwareHive))
((PHBASE_BLOCK)BaseAddress)->Length = Length;
Status = CmpInitializeHive(&HardwareHive,
HINIT_MEMORY, //HINIT_CREATE,
HIVE_NO_FILE, //HIVE_VOLATILE,
HFILE_TYPE_PRIMARY,
BaseAddress, // NULL,
NULL,
NULL,
NULL,
NULL,
0);
CmPrepareHive(&HardwareHive->Hive);
if (!NT_SUCCESS(Status))
{
/* Don't actually link anything below */
Allocate = TRUE;
/* Bugcheck */
KEBUGCHECKEX(CONFIG_INITIALIZATION_FAILED, 1, 11, Status, 0);
}
/* Attach it to the machine key */

View file

@ -103,7 +103,6 @@
<file>cmvalue.c</file>
</directory>
<directory name="cm">
<file>import.c</file>
<file>ntfunc.c</file>
<file>regfile.c</file>
<file>registry.c</file>