mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 01:15:09 +00:00
- Move CmInitSystem1 to cmsysini.c and merge in existing code from Cm rewrite branch.
- Merge code into cmkcbncb.c related to KCB/Cache initialization (This is "Dead" code for now, since it's not used, just initailized.) - Rename CmiRegistryLock to CmpRegistryLock. - The new /config registry code is now totally isolated from the old /cm code, although some of the old structures are still used until the actual rewrite is fully merged/finished. svn path=/trunk/; revision=26710
This commit is contained in:
parent
10f84bdddc
commit
6ef9f575cb
9 changed files with 500 additions and 331 deletions
|
@ -112,7 +112,7 @@ extern KSPIN_LOCK CmiKeyListLock;
|
|||
|
||||
extern LIST_ENTRY CmpHiveListHead;
|
||||
|
||||
extern ERESOURCE CmiRegistryLock;
|
||||
extern ERESOURCE CmpRegistryLock;
|
||||
extern EX_PUSH_LOCK CmpHiveListHeadLock;
|
||||
|
||||
/* Registry Callback Function */
|
||||
|
@ -422,80 +422,6 @@ VOID
|
|||
CmiCheckKey(BOOLEAN Verbose,
|
||||
HANDLE Key);
|
||||
|
||||
BOOLEAN
|
||||
INIT_FUNCTION
|
||||
CmImportSystemHive(PCHAR ChunkBase,
|
||||
ULONG ChunkSize,
|
||||
OUT PEREGISTRY_HIVE *RegistryHive);
|
||||
|
||||
BOOLEAN
|
||||
INIT_FUNCTION
|
||||
CmImportHardwareHive(PCHAR ChunkBase,
|
||||
ULONG ChunkSize,
|
||||
OUT PEREGISTRY_HIVE *RegistryHive);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
CmpSetSystemValues(IN PLOADER_PARAMETER_BLOCK LoaderBlock);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
CmpCreateControlSet(IN PLOADER_PARAMETER_BLOCK LoaderBlock);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
CmpInitializeMachineDependentConfiguration(IN PLOADER_PARAMETER_BLOCK LoaderBlock);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
CmpInitializeHive(PEREGISTRY_HIVE *RegistryHive,
|
||||
ULONG OperationType,
|
||||
ULONG HiveFlags,
|
||||
ULONG FileType,
|
||||
PVOID HiveData OPTIONAL,
|
||||
HANDLE Primary,
|
||||
HANDLE Log,
|
||||
HANDLE External,
|
||||
PUNICODE_STRING FileName OPTIONAL,
|
||||
ULONG CheckFlags);
|
||||
|
||||
USHORT
|
||||
NTAPI
|
||||
CmpCopyName(IN PHHIVE Hive,
|
||||
IN PWCHAR Destination,
|
||||
IN PUNICODE_STRING Source);
|
||||
|
||||
USHORT
|
||||
NTAPI
|
||||
CmpNameSize(IN PHHIVE Hive,
|
||||
IN PUNICODE_STRING Name);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
CmpInitializeHardwareConfiguration(IN PLOADER_PARAMETER_BLOCK LoaderBlock);
|
||||
|
||||
PSECURITY_DESCRIPTOR
|
||||
NTAPI
|
||||
CmpHiveRootSecurityDescriptor(VOID);
|
||||
|
||||
BOOLEAN
|
||||
NTAPI
|
||||
CmpInitializeSystemHive(IN PLOADER_PARAMETER_BLOCK LoaderBlock);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
CmpCreateObjectTypes(VOID);
|
||||
|
||||
BOOLEAN
|
||||
NTAPI
|
||||
CmpCreateRootNode(IN PHHIVE Hive,
|
||||
IN PCWSTR Name,
|
||||
OUT PHCELL_INDEX Index);
|
||||
|
||||
BOOLEAN
|
||||
NTAPI
|
||||
CmpCreateRegistryRoot(VOID);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
CmpOpenHiveFiles(IN PUNICODE_STRING BaseName,
|
||||
|
|
|
@ -345,7 +345,7 @@ NtCreateKey(OUT PHANDLE KeyHandle,
|
|||
|
||||
/* Acquire hive lock */
|
||||
KeEnterCriticalRegion();
|
||||
ExAcquireResourceExclusiveLite(&CmiRegistryLock, TRUE);
|
||||
ExAcquireResourceExclusiveLite(&CmpRegistryLock, TRUE);
|
||||
|
||||
InsertTailList(&CmiKeyObjectListHead, &KeyObject->ListEntry);
|
||||
|
||||
|
@ -361,7 +361,7 @@ NtCreateKey(OUT PHANDLE KeyHandle,
|
|||
{
|
||||
DPRINT1("CmiAddSubKey() failed (Status %lx)\n", Status);
|
||||
/* Release hive lock */
|
||||
ExReleaseResourceLite(&CmiRegistryLock);
|
||||
ExReleaseResourceLite(&CmpRegistryLock);
|
||||
KeLeaveCriticalRegion();
|
||||
ObDereferenceObject(KeyObject);
|
||||
|
||||
|
@ -393,7 +393,7 @@ NtCreateKey(OUT PHANDLE KeyHandle,
|
|||
VERIFY_KEY_OBJECT(KeyObject);
|
||||
|
||||
/* Release hive lock */
|
||||
ExReleaseResourceLite(&CmiRegistryLock);
|
||||
ExReleaseResourceLite(&CmpRegistryLock);
|
||||
KeLeaveCriticalRegion();
|
||||
|
||||
PostCreateKeyInfo.Object = KeyObject;
|
||||
|
@ -475,7 +475,7 @@ NtDeleteKey(IN HANDLE KeyHandle)
|
|||
|
||||
/* Acquire hive lock */
|
||||
KeEnterCriticalRegion();
|
||||
ExAcquireResourceExclusiveLite(&CmiRegistryLock, TRUE);
|
||||
ExAcquireResourceExclusiveLite(&CmpRegistryLock, TRUE);
|
||||
|
||||
VERIFY_KEY_OBJECT(KeyObject);
|
||||
|
||||
|
@ -493,7 +493,7 @@ NtDeleteKey(IN HANDLE KeyHandle)
|
|||
}
|
||||
|
||||
/* Release hive lock */
|
||||
ExReleaseResourceLite(&CmiRegistryLock);
|
||||
ExReleaseResourceLite(&CmpRegistryLock);
|
||||
KeLeaveCriticalRegion();
|
||||
|
||||
DPRINT("PointerCount %lu\n", ObGetObjectPointerCount((PVOID)KeyObject));
|
||||
|
@ -591,7 +591,7 @@ NtEnumerateKey(IN HANDLE KeyHandle,
|
|||
|
||||
/* Acquire hive lock */
|
||||
KeEnterCriticalRegion();
|
||||
ExAcquireResourceSharedLite(&CmiRegistryLock, TRUE);
|
||||
ExAcquireResourceSharedLite(&CmpRegistryLock, TRUE);
|
||||
|
||||
VERIFY_KEY_OBJECT(KeyObject);
|
||||
|
||||
|
@ -603,7 +603,7 @@ NtEnumerateKey(IN HANDLE KeyHandle,
|
|||
if (Index >= KeyCell->SubKeyCounts[HvStable] +
|
||||
KeyCell->SubKeyCounts[HvVolatile])
|
||||
{
|
||||
ExReleaseResourceLite(&CmiRegistryLock);
|
||||
ExReleaseResourceLite(&CmpRegistryLock);
|
||||
KeLeaveCriticalRegion();
|
||||
PostOperationInfo.Status = STATUS_NO_MORE_ENTRIES;
|
||||
CmiCallRegisteredCallbacks(RegNtPostEnumerateKey, &PostOperationInfo);
|
||||
|
@ -626,7 +626,7 @@ NtEnumerateKey(IN HANDLE KeyHandle,
|
|||
|
||||
if (KeyCell->SubKeyLists[Storage] == HCELL_NULL)
|
||||
{
|
||||
ExReleaseResourceLite(&CmiRegistryLock);
|
||||
ExReleaseResourceLite(&CmpRegistryLock);
|
||||
KeLeaveCriticalRegion();
|
||||
PostOperationInfo.Status = STATUS_NO_MORE_ENTRIES;
|
||||
CmiCallRegisteredCallbacks(RegNtPostEnumerateKey, &PostOperationInfo);
|
||||
|
@ -815,7 +815,7 @@ NtEnumerateKey(IN HANDLE KeyHandle,
|
|||
break;
|
||||
}
|
||||
|
||||
ExReleaseResourceLite(&CmiRegistryLock);
|
||||
ExReleaseResourceLite(&CmpRegistryLock);
|
||||
KeLeaveCriticalRegion();
|
||||
|
||||
PostOperationInfo.Status = Status;
|
||||
|
@ -892,7 +892,7 @@ NtEnumerateValueKey(IN HANDLE KeyHandle,
|
|||
|
||||
/* Acquire hive lock */
|
||||
KeEnterCriticalRegion();
|
||||
ExAcquireResourceSharedLite(&CmiRegistryLock, TRUE);
|
||||
ExAcquireResourceSharedLite(&CmpRegistryLock, TRUE);
|
||||
|
||||
VERIFY_KEY_OBJECT(KeyObject);
|
||||
|
||||
|
@ -908,7 +908,7 @@ NtEnumerateValueKey(IN HANDLE KeyHandle,
|
|||
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
ExReleaseResourceLite(&CmiRegistryLock);
|
||||
ExReleaseResourceLite(&CmpRegistryLock);
|
||||
KeLeaveCriticalRegion();
|
||||
ObDereferenceObject(KeyObject);
|
||||
PostOperationInfo.Status = Status;
|
||||
|
@ -1089,7 +1089,7 @@ NtEnumerateValueKey(IN HANDLE KeyHandle,
|
|||
Status = STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
|
||||
ExReleaseResourceLite(&CmiRegistryLock);
|
||||
ExReleaseResourceLite(&CmpRegistryLock);
|
||||
KeLeaveCriticalRegion();
|
||||
ObDereferenceObject(KeyObject);
|
||||
PostOperationInfo.Status = Status;
|
||||
|
@ -1131,7 +1131,7 @@ NtFlushKey(IN HANDLE KeyHandle)
|
|||
|
||||
/* Acquire hive lock */
|
||||
KeEnterCriticalRegion();
|
||||
ExAcquireResourceExclusiveLite(&CmiRegistryLock, TRUE);
|
||||
ExAcquireResourceExclusiveLite(&CmpRegistryLock, TRUE);
|
||||
|
||||
if (IsNoFileHive(RegistryHive))
|
||||
{
|
||||
|
@ -1143,7 +1143,7 @@ NtFlushKey(IN HANDLE KeyHandle)
|
|||
Status = CmiFlushRegistryHive(RegistryHive);
|
||||
}
|
||||
|
||||
ExReleaseResourceLite(&CmiRegistryLock);
|
||||
ExReleaseResourceLite(&CmpRegistryLock);
|
||||
KeLeaveCriticalRegion();
|
||||
|
||||
ObDereferenceObject(KeyObject);
|
||||
|
@ -1367,7 +1367,7 @@ NtQueryKey(IN HANDLE KeyHandle,
|
|||
|
||||
/* Acquire hive lock */
|
||||
KeEnterCriticalRegion();
|
||||
ExAcquireResourceSharedLite(&CmiRegistryLock, TRUE);
|
||||
ExAcquireResourceSharedLite(&CmpRegistryLock, TRUE);
|
||||
|
||||
VERIFY_KEY_OBJECT(KeyObject);
|
||||
|
||||
|
@ -1525,7 +1525,7 @@ NtQueryKey(IN HANDLE KeyHandle,
|
|||
break;
|
||||
}
|
||||
|
||||
ExReleaseResourceLite(&CmiRegistryLock);
|
||||
ExReleaseResourceLite(&CmpRegistryLock);
|
||||
KeLeaveCriticalRegion();
|
||||
|
||||
PostOperationInfo.Status = Status;
|
||||
|
@ -1595,7 +1595,7 @@ NtQueryValueKey(IN HANDLE KeyHandle,
|
|||
|
||||
/* Acquire hive lock */
|
||||
KeEnterCriticalRegion();
|
||||
ExAcquireResourceSharedLite(&CmiRegistryLock, TRUE);
|
||||
ExAcquireResourceSharedLite(&CmpRegistryLock, TRUE);
|
||||
|
||||
VERIFY_KEY_OBJECT(KeyObject);
|
||||
|
||||
|
@ -1789,7 +1789,7 @@ NtQueryValueKey(IN HANDLE KeyHandle,
|
|||
}
|
||||
|
||||
ByeBye:;
|
||||
ExReleaseResourceLite(&CmiRegistryLock);
|
||||
ExReleaseResourceLite(&CmpRegistryLock);
|
||||
KeLeaveCriticalRegion();
|
||||
|
||||
PostOperationInfo.Status = Status;
|
||||
|
@ -1855,7 +1855,7 @@ NtSetValueKey(IN HANDLE KeyHandle,
|
|||
|
||||
/* Acquire hive lock exclucively */
|
||||
KeEnterCriticalRegion();
|
||||
ExAcquireResourceExclusiveLite(&CmiRegistryLock, TRUE);
|
||||
ExAcquireResourceExclusiveLite(&CmpRegistryLock, TRUE);
|
||||
|
||||
VERIFY_KEY_OBJECT(KeyObject);
|
||||
|
||||
|
@ -1882,7 +1882,7 @@ NtSetValueKey(IN HANDLE KeyHandle,
|
|||
{
|
||||
DPRINT("Cannot add value. Status 0x%X\n", Status);
|
||||
|
||||
ExReleaseResourceLite(&CmiRegistryLock);
|
||||
ExReleaseResourceLite(&CmpRegistryLock);
|
||||
KeLeaveCriticalRegion();
|
||||
PostOperationInfo.Status = Status;
|
||||
CmiCallRegisteredCallbacks(RegNtPostSetValueKey, &PostOperationInfo);
|
||||
|
@ -1938,7 +1938,7 @@ NtSetValueKey(IN HANDLE KeyHandle,
|
|||
{
|
||||
DPRINT("CmiAllocateBlock() failed (Status %lx)\n", Status);
|
||||
|
||||
ExReleaseResourceLite(&CmiRegistryLock);
|
||||
ExReleaseResourceLite(&CmpRegistryLock);
|
||||
KeLeaveCriticalRegion();
|
||||
PostOperationInfo.Status = Status;
|
||||
CmiCallRegisteredCallbacks(RegNtPostSetValueKey, &PostOperationInfo);
|
||||
|
@ -1973,7 +1973,7 @@ NtSetValueKey(IN HANDLE KeyHandle,
|
|||
KeQuerySystemTime (&KeyCell->LastWriteTime);
|
||||
HvMarkCellDirty (&RegistryHive->Hive, KeyObject->KeyCellOffset);
|
||||
|
||||
ExReleaseResourceLite(&CmiRegistryLock);
|
||||
ExReleaseResourceLite(&CmpRegistryLock);
|
||||
KeLeaveCriticalRegion();
|
||||
PostOperationInfo.Status = Status;
|
||||
CmiCallRegisteredCallbacks(RegNtPostSetValueKey, &PostOperationInfo);
|
||||
|
@ -2040,7 +2040,7 @@ Fail:
|
|||
|
||||
/* Acquire hive lock */
|
||||
KeEnterCriticalRegion();
|
||||
ExAcquireResourceExclusiveLite(&CmiRegistryLock, TRUE);
|
||||
ExAcquireResourceExclusiveLite(&CmpRegistryLock, TRUE);
|
||||
|
||||
VERIFY_KEY_OBJECT(KeyObject);
|
||||
|
||||
|
@ -2053,7 +2053,7 @@ Fail:
|
|||
HvMarkCellDirty (&KeyObject->RegistryHive->Hive, KeyObject->KeyCellOffset);
|
||||
|
||||
/* Release hive lock */
|
||||
ExReleaseResourceLite(&CmiRegistryLock);
|
||||
ExReleaseResourceLite(&CmpRegistryLock);
|
||||
KeLeaveCriticalRegion();
|
||||
|
||||
ReleaseCapturedUnicodeString(&CapturedValueName,
|
||||
|
@ -2173,7 +2173,7 @@ NtLoadKey2 (IN POBJECT_ATTRIBUTES KeyObjectAttributes,
|
|||
|
||||
/* Acquire hive lock */
|
||||
KeEnterCriticalRegion();
|
||||
ExAcquireResourceExclusiveLite(&CmiRegistryLock, TRUE);
|
||||
ExAcquireResourceExclusiveLite(&CmpRegistryLock, TRUE);
|
||||
|
||||
Status = CmiLoadHive (KeyObjectAttributes,
|
||||
NamePointer,
|
||||
|
@ -2184,7 +2184,7 @@ NtLoadKey2 (IN POBJECT_ATTRIBUTES KeyObjectAttributes,
|
|||
}
|
||||
|
||||
/* Release hive lock */
|
||||
ExReleaseResourceLite(&CmiRegistryLock);
|
||||
ExReleaseResourceLite(&CmpRegistryLock);
|
||||
KeLeaveCriticalRegion();
|
||||
|
||||
if (Buffer != NULL)
|
||||
|
@ -2247,7 +2247,7 @@ NtQueryMultipleValueKey (IN HANDLE KeyHandle,
|
|||
|
||||
/* Acquire hive lock */
|
||||
KeEnterCriticalRegion();
|
||||
ExAcquireResourceSharedLite(&CmiRegistryLock, TRUE);
|
||||
ExAcquireResourceSharedLite(&CmpRegistryLock, TRUE);
|
||||
|
||||
VERIFY_KEY_OBJECT(KeyObject);
|
||||
|
||||
|
@ -2319,7 +2319,7 @@ NtQueryMultipleValueKey (IN HANDLE KeyHandle,
|
|||
*ReturnLength = BufferLength;
|
||||
|
||||
/* Release hive lock */
|
||||
ExReleaseResourceLite(&CmiRegistryLock);
|
||||
ExReleaseResourceLite(&CmpRegistryLock);
|
||||
KeLeaveCriticalRegion();
|
||||
|
||||
PostOperationInfo.Status = Status;
|
||||
|
|
|
@ -34,7 +34,7 @@ PEREGISTRY_HIVE CmiVolatileHive = NULL;
|
|||
|
||||
LIST_ENTRY CmpHiveListHead;
|
||||
|
||||
ERESOURCE CmiRegistryLock;
|
||||
ERESOURCE CmpRegistryLock;
|
||||
|
||||
KTIMER CmiWorkerTimer;
|
||||
LIST_ENTRY CmiKeyObjectListHead;
|
||||
|
@ -81,7 +81,7 @@ CmiWorkerThread(PVOID Param)
|
|||
|
||||
/* Acquire hive lock */
|
||||
KeEnterCriticalRegion();
|
||||
ExAcquireResourceExclusiveLite(&CmiRegistryLock, TRUE);
|
||||
ExAcquireResourceExclusiveLite(&CmpRegistryLock, TRUE);
|
||||
|
||||
CmiTimer++;
|
||||
|
||||
|
@ -107,7 +107,7 @@ CmiWorkerThread(PVOID Param)
|
|||
CurrentEntry = CurrentEntry->Blink;
|
||||
}
|
||||
}
|
||||
ExReleaseResourceLite(&CmiRegistryLock);
|
||||
ExReleaseResourceLite(&CmpRegistryLock);
|
||||
KeLeaveCriticalRegion();
|
||||
|
||||
DPRINT("Removed %d key objects\n", Count);
|
||||
|
@ -192,215 +192,6 @@ CmpLinkHiveToMaster(IN PUNICODE_STRING LinkName,
|
|||
return CmiConnectHive(&ObjectAttributes, RegistryHive);
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
INIT_FUNCTION
|
||||
NTAPI
|
||||
CmInitSystem1(VOID)
|
||||
{
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
UNICODE_STRING KeyName;
|
||||
HANDLE KeyHandle;
|
||||
NTSTATUS Status;
|
||||
LARGE_INTEGER DueTime;
|
||||
HANDLE ThreadHandle;
|
||||
CLIENT_ID ThreadId;
|
||||
PEREGISTRY_HIVE HardwareHive;
|
||||
PVOID BaseAddress;
|
||||
ULONG Length;
|
||||
PSECURITY_DESCRIPTOR SecurityDescriptor;
|
||||
PAGED_CODE();
|
||||
|
||||
/* Initialize the hive list and lock */
|
||||
InitializeListHead(&CmpHiveListHead);
|
||||
ExInitializePushLock((PVOID)&CmpHiveListHeadLock);
|
||||
|
||||
/* Initialize registry lock */
|
||||
ExInitializeResourceLite(&CmiRegistryLock);
|
||||
|
||||
/* Initialize the key object list */
|
||||
InitializeListHead(&CmiKeyObjectListHead);
|
||||
InitializeListHead(&CmiConnectedHiveList);
|
||||
|
||||
/* Initialize the worker timer */
|
||||
KeInitializeTimerEx(&CmiWorkerTimer, SynchronizationTimer);
|
||||
|
||||
/* Initialize the worker thread */
|
||||
Status = PsCreateSystemThread(&ThreadHandle,
|
||||
THREAD_ALL_ACCESS,
|
||||
NULL,
|
||||
NULL,
|
||||
&ThreadId,
|
||||
CmiWorkerThread,
|
||||
NULL);
|
||||
if (!NT_SUCCESS(Status)) return FALSE;
|
||||
|
||||
/* Start the timer */
|
||||
DueTime.QuadPart = -1;
|
||||
KeSetTimerEx(&CmiWorkerTimer, DueTime, 5000, NULL); /* 5sec */
|
||||
|
||||
InitializeListHead(&CmiCallbackHead);
|
||||
ExInitializeFastMutex(&CmiCallbackLock);
|
||||
|
||||
/* Create the key object types */
|
||||
Status = CmpCreateObjectTypes();
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
/* Bugcheck */
|
||||
KEBUGCHECKEX(CONFIG_INITIALIZATION_FAILED, 1, 1, Status, 0);
|
||||
}
|
||||
|
||||
/* Build the master hive */
|
||||
Status = CmpInitializeHive(&CmiVolatileHive,
|
||||
HINIT_CREATE,
|
||||
HIVE_VOLATILE | HIVE_NO_FILE,
|
||||
HFILE_TYPE_PRIMARY,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
0);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
/* Bugcheck */
|
||||
KEBUGCHECKEX(CONFIG_INITIALIZATION_FAILED, 1, 2, Status, 0);
|
||||
}
|
||||
|
||||
/* Create the \REGISTRY key node */
|
||||
if (!CmpCreateRegistryRoot())
|
||||
{
|
||||
/* Bugcheck */
|
||||
KEBUGCHECKEX(CONFIG_INITIALIZATION_FAILED, 1, 3, 0, 0);
|
||||
}
|
||||
|
||||
/* Create the default security descriptor */
|
||||
SecurityDescriptor = CmpHiveRootSecurityDescriptor();
|
||||
|
||||
/* Create '\Registry\Machine' key. */
|
||||
RtlInitUnicodeString(&KeyName, L"\\REGISTRY\\MACHINE");
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&KeyName,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
SecurityDescriptor);
|
||||
Status = NtCreateKey(&KeyHandle,
|
||||
KEY_READ | KEY_WRITE,
|
||||
&ObjectAttributes,
|
||||
0,
|
||||
NULL,
|
||||
0,
|
||||
NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
/* Bugcheck */
|
||||
KEBUGCHECKEX(CONFIG_INITIALIZATION_FAILED, 1, 5, Status, 0);
|
||||
}
|
||||
|
||||
/* Close the handle */
|
||||
NtClose(KeyHandle);
|
||||
|
||||
/* Create '\Registry\User' key. */
|
||||
RtlInitUnicodeString(&KeyName, L"\\REGISTRY\\USER");
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&KeyName,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
SecurityDescriptor);
|
||||
Status = NtCreateKey(&KeyHandle,
|
||||
KEY_READ | KEY_WRITE,
|
||||
&ObjectAttributes,
|
||||
0,
|
||||
NULL,
|
||||
0,
|
||||
NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
/* Bugcheck */
|
||||
KEBUGCHECKEX(CONFIG_INITIALIZATION_FAILED, 1, 6, Status, 0);
|
||||
}
|
||||
|
||||
/* Close the handle */
|
||||
NtClose(KeyHandle);
|
||||
|
||||
/* Initialize the system hive */
|
||||
if (!CmpInitializeSystemHive(KeLoaderBlock))
|
||||
{
|
||||
/* Bugcheck */
|
||||
KEBUGCHECKEX(CONFIG_INITIALIZATION_FAILED, 1, 7, 0, 0);
|
||||
}
|
||||
|
||||
/* Create the 'CurrentControlSet' link. */
|
||||
Status = CmpCreateControlSet(KeLoaderBlock);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
/* Bugcheck */
|
||||
KEBUGCHECKEX(CONFIG_INITIALIZATION_FAILED, 1, 8, Status, 0);
|
||||
}
|
||||
|
||||
/* Import the hardware hive (FIXME: We should create it from scratch) */
|
||||
BaseAddress = CmpRosGetHardwareHive(&Length);
|
||||
((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))
|
||||
{
|
||||
/* Bugcheck */
|
||||
KEBUGCHECKEX(CONFIG_INITIALIZATION_FAILED, 1, 11, Status, 0);
|
||||
}
|
||||
|
||||
/* Attach it to the machine key */
|
||||
RtlInitUnicodeString(&KeyName, REG_HARDWARE_KEY_NAME);
|
||||
Status = CmpLinkHiveToMaster(&KeyName,
|
||||
NULL,
|
||||
HardwareHive,
|
||||
FALSE,
|
||||
SecurityDescriptor);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
/* Bugcheck */
|
||||
KEBUGCHECKEX(CONFIG_INITIALIZATION_FAILED, 1, 12, Status, 0);
|
||||
}
|
||||
|
||||
/* Fill out the Hardware key with the ARC Data from the Loader */
|
||||
Status = CmpInitializeHardwareConfiguration(KeLoaderBlock);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
/* Bugcheck */
|
||||
KEBUGCHECKEX(CONFIG_INITIALIZATION_FAILED, 1, 13, Status, 0);
|
||||
}
|
||||
|
||||
/* Initialize machine-dependent information into the registry */
|
||||
Status = CmpInitializeMachineDependentConfiguration(KeLoaderBlock);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
/* Bugcheck */
|
||||
KEBUGCHECKEX(CONFIG_INITIALIZATION_FAILED, 1, 14, Status, 0);
|
||||
}
|
||||
|
||||
/* Initialize volatile registry settings */
|
||||
Status = CmpSetSystemValues(KeLoaderBlock);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
/* Bugcheck */
|
||||
KEBUGCHECKEX(CONFIG_INITIALIZATION_FAILED, 1, 15, Status, 0);
|
||||
}
|
||||
|
||||
/* Free the load options */
|
||||
ExFreePool(CmpLoadOptions.Buffer);
|
||||
|
||||
/* If we got here, all went well */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
CmiConnectHive(IN POBJECT_ATTRIBUTES KeyObjectAttributes,
|
||||
IN PEREGISTRY_HIVE RegistryHive)
|
||||
|
|
|
@ -403,7 +403,7 @@ CmpParseKey(IN PVOID ParsedObject,
|
|||
|
||||
/* Acquire hive lock */
|
||||
KeEnterCriticalRegion();
|
||||
ExAcquireResourceExclusiveLite(&CmiRegistryLock, TRUE);
|
||||
ExAcquireResourceExclusiveLite(&CmpRegistryLock, TRUE);
|
||||
|
||||
Status = CmiScanKeyList(ParsedKey,
|
||||
&KeyName,
|
||||
|
@ -411,7 +411,7 @@ CmpParseKey(IN PVOID ParsedObject,
|
|||
&FoundObject);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
ExReleaseResourceLite(&CmiRegistryLock);
|
||||
ExReleaseResourceLite(&CmpRegistryLock);
|
||||
KeLeaveCriticalRegion();
|
||||
RtlFreeUnicodeString(&KeyName);
|
||||
return Status;
|
||||
|
@ -427,7 +427,7 @@ CmpParseKey(IN PVOID ParsedObject,
|
|||
Attributes);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
ExReleaseResourceLite(&CmiRegistryLock);
|
||||
ExReleaseResourceLite(&CmpRegistryLock);
|
||||
KeLeaveCriticalRegion();
|
||||
RtlFreeUnicodeString(&KeyName);
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
|
@ -442,7 +442,7 @@ CmpParseKey(IN PVOID ParsedObject,
|
|||
&LinkPath);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
ExReleaseResourceLite(&CmiRegistryLock);
|
||||
ExReleaseResourceLite(&CmpRegistryLock);
|
||||
KeLeaveCriticalRegion();
|
||||
|
||||
DPRINT("LinkPath '%wZ'\n", &LinkPath);
|
||||
|
@ -493,7 +493,7 @@ CmpParseKey(IN PVOID ParsedObject,
|
|||
(PVOID*)&FoundObject);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
ExReleaseResourceLite(&CmiRegistryLock);
|
||||
ExReleaseResourceLite(&CmpRegistryLock);
|
||||
KeLeaveCriticalRegion();
|
||||
RtlFreeUnicodeString(&KeyName);
|
||||
return(Status);
|
||||
|
@ -540,7 +540,7 @@ OBJECT_TO_OBJECT_HEADER(FoundObject)->ObjectCreateInfo = NULL;
|
|||
{
|
||||
DPRINT("LinkPath '%wZ'\n", &LinkPath);
|
||||
|
||||
ExReleaseResourceLite(&CmiRegistryLock);
|
||||
ExReleaseResourceLite(&CmpRegistryLock);
|
||||
KeLeaveCriticalRegion();
|
||||
|
||||
ObDereferenceObject(FoundObject);
|
||||
|
@ -583,7 +583,7 @@ OBJECT_TO_OBJECT_HEADER(FoundObject)->ObjectCreateInfo = NULL;
|
|||
InsertHeadList(&CmiKeyObjectListHead, &FoundObject->ListEntry);
|
||||
FoundObject->TimeStamp = CmiTimer;
|
||||
|
||||
ExReleaseResourceLite(&CmiRegistryLock);
|
||||
ExReleaseResourceLite(&CmpRegistryLock);
|
||||
KeLeaveCriticalRegion();
|
||||
|
||||
DPRINT("CmpParseKey: %wZ\n", &FoundObject->Name);
|
||||
|
@ -628,7 +628,7 @@ CmpDeleteKeyObject(PVOID DeletedObject)
|
|||
|
||||
/* Acquire hive lock */
|
||||
KeEnterCriticalRegion();
|
||||
ExAcquireResourceExclusiveLite(&CmiRegistryLock, TRUE);
|
||||
ExAcquireResourceExclusiveLite(&CmpRegistryLock, TRUE);
|
||||
|
||||
if (!NT_SUCCESS(CmiRemoveKeyFromList(KeyObject)))
|
||||
{
|
||||
|
@ -669,7 +669,7 @@ CmpDeleteKeyObject(PVOID DeletedObject)
|
|||
ExFreePool(KeyObject->SubKeys);
|
||||
}
|
||||
|
||||
ExReleaseResourceLite(&CmiRegistryLock);
|
||||
ExReleaseResourceLite(&CmpRegistryLock);
|
||||
KeLeaveCriticalRegion();
|
||||
PostOperationInfo.Status = STATUS_SUCCESS;
|
||||
CmiCallRegisteredCallbacks(RegNtPostKeyHandleClose, &PostOperationInfo);
|
||||
|
|
|
@ -641,9 +641,10 @@ typedef struct _CM_SYSTEM_CONTROL_VECTOR
|
|||
//
|
||||
// BUGBUG Old Hive Stuff for Temporary Support
|
||||
//
|
||||
#define SYSTEM_REG_FILE L"\\SystemRoot\\System32\\Config\\SYSTEM"
|
||||
#define SYSTEM_LOG_FILE L"\\SystemRoot\\System32\\Config\\SYSTEM.log"
|
||||
#define REG_SYSTEM_KEY_NAME L"\\Registry\\Machine\\SYSTEM"
|
||||
#define SYSTEM_REG_FILE L"\\SystemRoot\\System32\\Config\\SYSTEM"
|
||||
#define SYSTEM_LOG_FILE L"\\SystemRoot\\System32\\Config\\SYSTEM.log"
|
||||
#define REG_SYSTEM_KEY_NAME L"\\Registry\\Machine\\SYSTEM"
|
||||
#define REG_HARDWARE_KEY_NAME L"\\Registry\\Machine\\HARDWARE"
|
||||
typedef struct _EREGISTRY_HIVE
|
||||
{
|
||||
HHIVE Hive;
|
||||
|
@ -673,6 +674,11 @@ typedef struct _KEY_OBJECT
|
|||
LIST_ENTRY HiveList;
|
||||
} KEY_OBJECT, *PKEY_OBJECT;
|
||||
extern PEREGISTRY_HIVE CmiVolatileHive;
|
||||
extern LIST_ENTRY CmiKeyObjectListHead, CmiConnectedHiveList;
|
||||
extern KTIMER CmiWorkerTimer;
|
||||
VOID NTAPI CmiWorkerThread(IN PVOID Param);
|
||||
PVOID NTAPI CmpRosGetHardwareHive(OUT PULONG Length);
|
||||
#define HIVE_NO_FILE 0x00000002
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//
|
||||
|
@ -707,6 +713,7 @@ CmCheckRegistry(
|
|||
// Notification Routines
|
||||
//
|
||||
VOID
|
||||
NTAPI
|
||||
CmpReportNotify(
|
||||
IN PCM_KEY_CONTROL_BLOCK Kcb,
|
||||
IN PHHIVE Hive,
|
||||
|
@ -714,6 +721,12 @@ CmpReportNotify(
|
|||
IN ULONG Filter
|
||||
);
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
CmpInitCallback(
|
||||
VOID
|
||||
);
|
||||
|
||||
//
|
||||
// KCB Cache/Delay Routines
|
||||
//
|
||||
|
@ -725,13 +738,19 @@ CmpInitializeCache(
|
|||
|
||||
VOID
|
||||
NTAPI
|
||||
CmpInitializeCmAllocations(
|
||||
CmpInitCmPrivateDelayAlloc(
|
||||
VOID
|
||||
);
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
CmpInitializeKcbDelayedDeref(
|
||||
CmpInitCmPrivateAlloc(
|
||||
VOID
|
||||
);
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
CmpInitDelayDerefKCBEngine(
|
||||
VOID
|
||||
);
|
||||
|
||||
|
@ -1004,6 +1023,18 @@ CmpInitializeRegistryNode(
|
|||
IN PUSHORT DeviceIndexTable
|
||||
);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
CmpInitializeMachineDependentConfiguration(
|
||||
IN PLOADER_PARAMETER_BLOCK LoaderBlock
|
||||
);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
CmpInitializeHardwareConfiguration(
|
||||
IN PLOADER_PARAMETER_BLOCK LoaderBlock
|
||||
);
|
||||
|
||||
//
|
||||
// Wrapper Routines
|
||||
//
|
||||
|
@ -1070,7 +1101,7 @@ extern BOOLEAN CmpSpecialBootCondition;
|
|||
extern BOOLEAN CmpFlushOnLockRelease;
|
||||
extern BOOLEAN CmpShareSystemHives;
|
||||
extern BOOLEAN CmpMiniNTBoot;
|
||||
extern EX_PUSH_LOCK CmpHiveListHeadLock;
|
||||
extern EX_PUSH_LOCK CmpHiveListHeadLock, CmpLoadHiveLock;
|
||||
extern LIST_ENTRY CmpHiveListHead;
|
||||
extern POBJECT_TYPE CmpKeyObjectType;
|
||||
extern ERESOURCE CmpRegistryLock;
|
||||
|
@ -1099,6 +1130,7 @@ extern BOOLEAN CmpSelfHeal;
|
|||
extern ULONG CmpBootType;
|
||||
extern HANDLE CmpRegistryRootHandle;
|
||||
extern BOOLEAN ExpInTextModeSetup;
|
||||
extern BOOLEAN InitIsWinPEMode;
|
||||
|
||||
//
|
||||
// Inlined functions
|
||||
|
|
|
@ -36,7 +36,7 @@ CMHIVE CmControlHive;
|
|||
ULONG CmpConfigurationAreaSize = PAGE_SIZE * 4;
|
||||
PCM_FULL_RESOURCE_DESCRIPTOR CmpConfigurationData;
|
||||
|
||||
EX_PUSH_LOCK CmpHiveListHeadLock;
|
||||
EX_PUSH_LOCK CmpHiveListHeadLock, CmpLoadHiveLock;
|
||||
|
||||
HIVE_LIST_ENTRY CmpMachineHiveList[5];
|
||||
|
||||
|
|
|
@ -15,6 +15,9 @@
|
|||
|
||||
/* GLOBALS *******************************************************************/
|
||||
|
||||
ULONG CmpCallBackCount = 0;
|
||||
EX_CALLBACK CmpCallBackVector[100];
|
||||
|
||||
LIST_ENTRY CmiCallbackHead;
|
||||
FAST_MUTEX CmiCallbackLock;
|
||||
|
||||
|
@ -30,6 +33,28 @@ typedef struct _REGISTRY_CALLBACK
|
|||
|
||||
/* PRIVATE FUNCTIONS *********************************************************/
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
CmpInitCallback(VOID)
|
||||
{
|
||||
ULONG i;
|
||||
PAGED_CODE();
|
||||
|
||||
/* Reset counter */
|
||||
CmpCallBackCount = 0;
|
||||
|
||||
/* Loop all the callbacks */
|
||||
for (i = 0; i < CMP_MAX_CALLBACKS; i++)
|
||||
{
|
||||
/* Initialize this one */
|
||||
ExInitializeCallBack(&CmpCallBackVector[i]);
|
||||
}
|
||||
|
||||
/* ROS: Initialize old-style callbacks for now */
|
||||
InitializeListHead(&CmiCallbackHead);
|
||||
ExInitializeFastMutex(&CmiCallbackLock);
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
CmiCallRegisteredCallbacks(IN REG_NOTIFY_CLASS Argument1,
|
||||
IN PVOID Argument2)
|
||||
|
|
|
@ -15,8 +15,165 @@
|
|||
|
||||
/* GLOBALS *******************************************************************/
|
||||
|
||||
ULONG CmpHashTableSize = 2048;
|
||||
PCM_KEY_HASH_TABLE_ENTRY *CmpCacheTable;
|
||||
PCM_NAME_HASH_TABLE_ENTRY *CmpNameCacheTable;
|
||||
|
||||
LIST_ENTRY CmpFreeKCBListHead;
|
||||
|
||||
BOOLEAN CmpAllocInited;
|
||||
KGUARDED_MUTEX CmpAllocBucketLock, CmpDelayAllocBucketLock;
|
||||
WORK_QUEUE_ITEM CmpDelayDerefKCBWorkItem;
|
||||
LIST_ENTRY CmpFreeDelayItemsListHead;
|
||||
|
||||
ULONG CmpDelayedCloseSize;
|
||||
ULONG CmpDelayedCloseElements;
|
||||
KGUARDED_MUTEX CmpDelayedCloseTableLock;
|
||||
BOOLEAN CmpDelayCloseWorkItemActive;
|
||||
WORK_QUEUE_ITEM CmpDelayCloseWorkItem;
|
||||
LIST_ENTRY CmpDelayedLRUListHead;
|
||||
ULONG CmpDelayCloseIntervalInSeconds = 5;
|
||||
KDPC CmpDelayCloseDpc;
|
||||
KTIMER CmpDelayCloseTimer;
|
||||
|
||||
KGUARDED_MUTEX CmpDelayDerefKCBLock;
|
||||
BOOLEAN CmpDelayDerefKCBWorkItemActive;
|
||||
LIST_ENTRY CmpDelayDerefKCBListHead;
|
||||
ULONG CmpDelayDerefKCBIntervalInSeconds = 5;
|
||||
KDPC CmpDelayDerefKCBDpc;
|
||||
KTIMER CmpDelayDerefKCBTimer;
|
||||
|
||||
BOOLEAN CmpHoldLazyFlush;
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
CmpDelayCloseDpcRoutine(IN PKDPC Dpc,
|
||||
IN PVOID DeferredContext,
|
||||
IN PVOID SystemArgument1,
|
||||
IN PVOID SystemArgument2)
|
||||
{
|
||||
/* Sanity check */
|
||||
ASSERT(CmpDelayCloseWorkItemActive);
|
||||
|
||||
/* Queue the work item */
|
||||
ExQueueWorkItem(&CmpDelayCloseWorkItem, DelayedWorkQueue);
|
||||
}
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
CmpDelayCloseWorker(IN PVOID Context)
|
||||
{
|
||||
PAGED_CODE();
|
||||
|
||||
/* Sanity check */
|
||||
ASSERT(CmpDelayCloseWorkItemActive);
|
||||
|
||||
/* FIXME: TODO */
|
||||
}
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
CmpInitializeCache(VOID)
|
||||
{
|
||||
ULONG Length;
|
||||
|
||||
/* Calculate length for the table */
|
||||
Length = CmpHashTableSize * sizeof(PCM_KEY_HASH);
|
||||
|
||||
/* Allocate it */
|
||||
CmpCacheTable = ExAllocatePoolWithTag(PagedPool, Length, TAG_CM);
|
||||
if (!CmpCacheTable) KeBugCheck(CONFIG_INITIALIZATION_FAILED);
|
||||
RtlZeroMemory(CmpCacheTable, Length);
|
||||
|
||||
/* Calculate length for the name cache */
|
||||
Length = CmpHashTableSize * sizeof(PCM_NAME_HASH);
|
||||
|
||||
/* Now allocate the name cache table */
|
||||
CmpNameCacheTable = ExAllocatePoolWithTag(PagedPool, Length, TAG_CM);
|
||||
if (!CmpCacheTable) KeBugCheck(CONFIG_INITIALIZATION_FAILED);
|
||||
RtlZeroMemory(CmpNameCacheTable, Length);
|
||||
|
||||
/* Setup the delayed close lock */
|
||||
KeInitializeGuardedMutex(&CmpDelayedCloseTableLock);
|
||||
|
||||
/* Setup the work item */
|
||||
ExInitializeWorkItem(&CmpDelayCloseWorkItem, CmpDelayCloseWorker, NULL);
|
||||
|
||||
/* Setup the DPC and its timer */
|
||||
KeInitializeDpc(&CmpDelayCloseDpc, CmpDelayCloseDpcRoutine, NULL);
|
||||
KeInitializeTimer(&CmpDelayCloseTimer);
|
||||
}
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
CmpInitCmPrivateDelayAlloc(VOID)
|
||||
{
|
||||
/* Initialize the delay allocation list and lock */
|
||||
KeInitializeGuardedMutex(&CmpDelayAllocBucketLock);
|
||||
InitializeListHead(&CmpFreeDelayItemsListHead);
|
||||
}
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
CmpInitCmPrivateAlloc(VOID)
|
||||
{
|
||||
/* Make sure we didn't already do this */
|
||||
if (!CmpAllocInited)
|
||||
{
|
||||
/* Setup the lock and list */
|
||||
KeInitializeGuardedMutex(&CmpAllocBucketLock);
|
||||
InitializeListHead(&CmpFreeKCBListHead);
|
||||
CmpAllocInited = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
CmpDelayDerefKCBDpcRoutine(IN PKDPC Dpc,
|
||||
IN PVOID DeferredContext,
|
||||
IN PVOID SystemArgument1,
|
||||
IN PVOID SystemArgument2)
|
||||
{
|
||||
/* Sanity check */
|
||||
ASSERT(CmpDelayDerefKCBWorkItemActive);
|
||||
|
||||
/* Queue the work item */
|
||||
ExQueueWorkItem(&CmpDelayDerefKCBWorkItem, DelayedWorkQueue);
|
||||
}
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
CmpDelayDerefKCBWorker(IN PVOID Context)
|
||||
{
|
||||
PAGED_CODE();
|
||||
|
||||
/* Sanity check */
|
||||
ASSERT(CmpDelayDerefKCBWorkItemActive);
|
||||
|
||||
/* FIXME: TODO */
|
||||
ASSERT(FALSE);
|
||||
}
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
CmpInitDelayDerefKCBEngine(VOID)
|
||||
{
|
||||
/* Initialize lock and list */
|
||||
KeInitializeGuardedMutex(&CmpDelayDerefKCBLock);
|
||||
InitializeListHead(&CmpDelayDerefKCBListHead);
|
||||
|
||||
/* Setup the work item */
|
||||
ExInitializeWorkItem(&CmpDelayDerefKCBWorkItem,
|
||||
CmpDelayDerefKCBWorker,
|
||||
NULL);
|
||||
|
||||
/* Setup the DPC and timer for it */
|
||||
KeInitializeDpc(&CmpDelayDerefKCBDpc, CmpDelayDerefKCBDpcRoutine, NULL);
|
||||
KeInitializeTimer(&CmpDelayDerefKCBTimer);
|
||||
}
|
||||
|
||||
PCM_KEY_CONTROL_BLOCK
|
||||
NTAPI
|
||||
CmpCreateKeyControlBlock(IN PHHIVE Hive,
|
||||
|
|
|
@ -13,6 +13,10 @@
|
|||
#define NDEBUG
|
||||
#include "debug.h"
|
||||
|
||||
KGUARDED_MUTEX CmpSelfHealQueueLock;
|
||||
LIST_ENTRY CmpSelfHealQueueListHead;
|
||||
PEPROCESS CmpSystemProcess;
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
NTSTATUS
|
||||
|
@ -624,3 +628,237 @@ CmpCreateRegistryRoot(VOID)
|
|||
/* Completely sucessful */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
NTAPI
|
||||
CmInitSystem1(VOID)
|
||||
{
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
UNICODE_STRING KeyName;
|
||||
HANDLE KeyHandle;
|
||||
NTSTATUS Status;
|
||||
LARGE_INTEGER DueTime;
|
||||
HANDLE ThreadHandle;
|
||||
CLIENT_ID ThreadId;
|
||||
PEREGISTRY_HIVE HardwareHive;
|
||||
PVOID BaseAddress;
|
||||
ULONG Length;
|
||||
PSECURITY_DESCRIPTOR SecurityDescriptor;
|
||||
PAGED_CODE();
|
||||
|
||||
/* Check if this is PE-boot */
|
||||
if (InitIsWinPEMode)
|
||||
{
|
||||
/* Set registry to PE mode */
|
||||
CmpMiniNTBoot = TRUE;
|
||||
CmpShareSystemHives = TRUE;
|
||||
}
|
||||
|
||||
/* Initialize the hive list and lock */
|
||||
InitializeListHead(&CmpHiveListHead);
|
||||
ExInitializePushLock((PVOID)&CmpHiveListHeadLock);
|
||||
ExInitializePushLock((PVOID)&CmpLoadHiveLock);
|
||||
|
||||
/* Initialize registry lock */
|
||||
ExInitializeResourceLite(&CmpRegistryLock);
|
||||
|
||||
/* Initialize the cache */
|
||||
CmpInitializeCache();
|
||||
|
||||
/* Initialize allocation and delayed dereferencing */
|
||||
CmpInitCmPrivateAlloc();
|
||||
CmpInitCmPrivateDelayAlloc();
|
||||
CmpInitDelayDerefKCBEngine();
|
||||
|
||||
/* Initialize callbacks */
|
||||
CmpInitCallback();
|
||||
|
||||
/* Initialize self healing */
|
||||
KeInitializeGuardedMutex(&CmpSelfHealQueueLock);
|
||||
InitializeListHead(&CmpSelfHealQueueListHead);
|
||||
|
||||
/* Save the current process and lock the registry */
|
||||
CmpSystemProcess = PsGetCurrentProcess();
|
||||
|
||||
#if 1
|
||||
/* OLD CM: Initialize the key object list */
|
||||
InitializeListHead(&CmiKeyObjectListHead);
|
||||
InitializeListHead(&CmiConnectedHiveList);
|
||||
|
||||
/* OLD CM: Initialize the worker timer */
|
||||
KeInitializeTimerEx(&CmiWorkerTimer, SynchronizationTimer);
|
||||
|
||||
/* OLD CM: Initialize the worker thread */
|
||||
Status = PsCreateSystemThread(&ThreadHandle,
|
||||
THREAD_ALL_ACCESS,
|
||||
NULL,
|
||||
NULL,
|
||||
&ThreadId,
|
||||
CmiWorkerThread,
|
||||
NULL);
|
||||
if (!NT_SUCCESS(Status)) return FALSE;
|
||||
|
||||
/* OLD CM: Start the timer */
|
||||
DueTime.QuadPart = -1;
|
||||
KeSetTimerEx(&CmiWorkerTimer, DueTime, 5000, NULL); /* 5sec */
|
||||
#endif
|
||||
|
||||
/* Create the key object types */
|
||||
Status = CmpCreateObjectTypes();
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
/* Bugcheck */
|
||||
KEBUGCHECKEX(CONFIG_INITIALIZATION_FAILED, 1, 1, Status, 0);
|
||||
}
|
||||
|
||||
/* Build the master hive */
|
||||
Status = CmpInitializeHive((PCMHIVE*)&CmiVolatileHive,
|
||||
HINIT_CREATE,
|
||||
HIVE_VOLATILE | HIVE_NO_FILE,
|
||||
HFILE_TYPE_PRIMARY,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
0);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
/* Bugcheck */
|
||||
KEBUGCHECKEX(CONFIG_INITIALIZATION_FAILED, 1, 2, Status, 0);
|
||||
}
|
||||
|
||||
/* Create the \REGISTRY key node */
|
||||
if (!CmpCreateRegistryRoot())
|
||||
{
|
||||
/* Bugcheck */
|
||||
KEBUGCHECKEX(CONFIG_INITIALIZATION_FAILED, 1, 3, 0, 0);
|
||||
}
|
||||
|
||||
/* Create the default security descriptor */
|
||||
SecurityDescriptor = CmpHiveRootSecurityDescriptor();
|
||||
|
||||
/* Create '\Registry\Machine' key. */
|
||||
RtlInitUnicodeString(&KeyName, L"\\REGISTRY\\MACHINE");
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&KeyName,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
SecurityDescriptor);
|
||||
Status = NtCreateKey(&KeyHandle,
|
||||
KEY_READ | KEY_WRITE,
|
||||
&ObjectAttributes,
|
||||
0,
|
||||
NULL,
|
||||
0,
|
||||
NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
/* Bugcheck */
|
||||
KEBUGCHECKEX(CONFIG_INITIALIZATION_FAILED, 1, 5, Status, 0);
|
||||
}
|
||||
|
||||
/* Close the handle */
|
||||
NtClose(KeyHandle);
|
||||
|
||||
/* Create '\Registry\User' key. */
|
||||
RtlInitUnicodeString(&KeyName, L"\\REGISTRY\\USER");
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&KeyName,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
SecurityDescriptor);
|
||||
Status = NtCreateKey(&KeyHandle,
|
||||
KEY_READ | KEY_WRITE,
|
||||
&ObjectAttributes,
|
||||
0,
|
||||
NULL,
|
||||
0,
|
||||
NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
/* Bugcheck */
|
||||
KEBUGCHECKEX(CONFIG_INITIALIZATION_FAILED, 1, 6, Status, 0);
|
||||
}
|
||||
|
||||
/* Close the handle */
|
||||
NtClose(KeyHandle);
|
||||
|
||||
/* Initialize the system hive */
|
||||
if (!CmpInitializeSystemHive(KeLoaderBlock))
|
||||
{
|
||||
/* Bugcheck */
|
||||
KEBUGCHECKEX(CONFIG_INITIALIZATION_FAILED, 1, 7, 0, 0);
|
||||
}
|
||||
|
||||
/* Create the 'CurrentControlSet' link. */
|
||||
Status = CmpCreateControlSet(KeLoaderBlock);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
/* Bugcheck */
|
||||
KEBUGCHECKEX(CONFIG_INITIALIZATION_FAILED, 1, 8, Status, 0);
|
||||
}
|
||||
|
||||
/* Import the hardware hive (FIXME: We should create it from scratch) */
|
||||
BaseAddress = CmpRosGetHardwareHive(&Length);
|
||||
((PHBASE_BLOCK)BaseAddress)->Length = Length;
|
||||
Status = CmpInitializeHive((PCMHIVE*)&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))
|
||||
{
|
||||
/* Bugcheck */
|
||||
KEBUGCHECKEX(CONFIG_INITIALIZATION_FAILED, 1, 11, Status, 0);
|
||||
}
|
||||
|
||||
/* Attach it to the machine key */
|
||||
RtlInitUnicodeString(&KeyName, REG_HARDWARE_KEY_NAME);
|
||||
Status = CmpLinkHiveToMaster(&KeyName,
|
||||
NULL,
|
||||
(PCMHIVE)HardwareHive,
|
||||
FALSE,
|
||||
SecurityDescriptor);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
/* Bugcheck */
|
||||
KEBUGCHECKEX(CONFIG_INITIALIZATION_FAILED, 1, 12, Status, 0);
|
||||
}
|
||||
|
||||
/* Fill out the Hardware key with the ARC Data from the Loader */
|
||||
Status = CmpInitializeHardwareConfiguration(KeLoaderBlock);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
/* Bugcheck */
|
||||
KEBUGCHECKEX(CONFIG_INITIALIZATION_FAILED, 1, 13, Status, 0);
|
||||
}
|
||||
|
||||
/* Initialize machine-dependent information into the registry */
|
||||
Status = CmpInitializeMachineDependentConfiguration(KeLoaderBlock);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
/* Bugcheck */
|
||||
KEBUGCHECKEX(CONFIG_INITIALIZATION_FAILED, 1, 14, Status, 0);
|
||||
}
|
||||
|
||||
/* Initialize volatile registry settings */
|
||||
Status = CmpSetSystemValues(KeLoaderBlock);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
/* Bugcheck */
|
||||
KEBUGCHECKEX(CONFIG_INITIALIZATION_FAILED, 1, 15, Status, 0);
|
||||
}
|
||||
|
||||
/* Free the load options */
|
||||
ExFreePool(CmpLoadOptions.Buffer);
|
||||
|
||||
/* If we got here, all went well */
|
||||
return TRUE;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue