[ros-diffs] [ion] 26710: - 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.

ion at svn.reactos.org ion at svn.reactos.org
Sat May 12 01:35:19 CEST 2007


Author: ion
Date: Sat May 12 03:35:19 2007
New Revision: 26710

URL: http://svn.reactos.org/svn/reactos?rev=26710&view=rev
Log:
- 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.

Modified:
    trunk/reactos/ntoskrnl/cm/cm.h
    trunk/reactos/ntoskrnl/cm/ntfunc.c
    trunk/reactos/ntoskrnl/cm/registry.c
    trunk/reactos/ntoskrnl/cm/regobj.c
    trunk/reactos/ntoskrnl/config/cm.h
    trunk/reactos/ntoskrnl/config/cmdata.c
    trunk/reactos/ntoskrnl/config/cmhook.c
    trunk/reactos/ntoskrnl/config/cmkcbncb.c
    trunk/reactos/ntoskrnl/config/cmsysini.c

Modified: trunk/reactos/ntoskrnl/cm/cm.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cm/cm.h?rev=26710&r1=26709&r2=26710&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/cm/cm.h (original)
+++ trunk/reactos/ntoskrnl/cm/cm.h Sat May 12 03:35:19 2007
@@ -112,7 +112,7 @@
 
 extern LIST_ENTRY CmpHiveListHead;
 
-extern ERESOURCE CmiRegistryLock;
+extern ERESOURCE CmpRegistryLock;
 extern EX_PUSH_LOCK CmpHiveListHeadLock;
 
 /* Registry Callback Function */
@@ -422,80 +422,6 @@
 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,

Modified: trunk/reactos/ntoskrnl/cm/ntfunc.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cm/ntfunc.c?rev=26710&r1=26709&r2=26710&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/cm/ntfunc.c (original)
+++ trunk/reactos/ntoskrnl/cm/ntfunc.c Sat May 12 03:35:19 2007
@@ -345,7 +345,7 @@
 
   /* Acquire hive lock */
   KeEnterCriticalRegion();
-  ExAcquireResourceExclusiveLite(&CmiRegistryLock, TRUE);
+  ExAcquireResourceExclusiveLite(&CmpRegistryLock, TRUE);
 
   InsertTailList(&CmiKeyObjectListHead, &KeyObject->ListEntry);
 
@@ -361,7 +361,7 @@
     {
       DPRINT1("CmiAddSubKey() failed (Status %lx)\n", Status);
       /* Release hive lock */
-      ExReleaseResourceLite(&CmiRegistryLock);
+      ExReleaseResourceLite(&CmpRegistryLock);
       KeLeaveCriticalRegion();
       ObDereferenceObject(KeyObject);
 
@@ -393,7 +393,7 @@
   VERIFY_KEY_OBJECT(KeyObject);
 
   /* Release hive lock */
-  ExReleaseResourceLite(&CmiRegistryLock);
+  ExReleaseResourceLite(&CmpRegistryLock);
   KeLeaveCriticalRegion();
 
   PostCreateKeyInfo.Object = KeyObject;
@@ -475,7 +475,7 @@
 
   /* Acquire hive lock */
   KeEnterCriticalRegion();
-  ExAcquireResourceExclusiveLite(&CmiRegistryLock, TRUE);
+  ExAcquireResourceExclusiveLite(&CmpRegistryLock, TRUE);
 
   VERIFY_KEY_OBJECT(KeyObject);
 
@@ -493,7 +493,7 @@
     }
 
   /* Release hive lock */
-  ExReleaseResourceLite(&CmiRegistryLock);
+  ExReleaseResourceLite(&CmpRegistryLock);
   KeLeaveCriticalRegion();
 
   DPRINT("PointerCount %lu\n", ObGetObjectPointerCount((PVOID)KeyObject));
@@ -591,7 +591,7 @@
 
   /* Acquire hive lock */
   KeEnterCriticalRegion();
-  ExAcquireResourceSharedLite(&CmiRegistryLock, TRUE);
+  ExAcquireResourceSharedLite(&CmpRegistryLock, TRUE);
 
   VERIFY_KEY_OBJECT(KeyObject);
 
@@ -603,7 +603,7 @@
   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 @@
 
   if (KeyCell->SubKeyLists[Storage] == HCELL_NULL)
     {
-      ExReleaseResourceLite(&CmiRegistryLock);
+      ExReleaseResourceLite(&CmpRegistryLock);
       KeLeaveCriticalRegion();
       PostOperationInfo.Status = STATUS_NO_MORE_ENTRIES;
       CmiCallRegisteredCallbacks(RegNtPostEnumerateKey, &PostOperationInfo);
@@ -815,7 +815,7 @@
 	break;
     }
 
-  ExReleaseResourceLite(&CmiRegistryLock);
+  ExReleaseResourceLite(&CmpRegistryLock);
   KeLeaveCriticalRegion();
 
   PostOperationInfo.Status = Status;
@@ -892,7 +892,7 @@
 
   /* Acquire hive lock */
   KeEnterCriticalRegion();
-  ExAcquireResourceSharedLite(&CmiRegistryLock, TRUE);
+  ExAcquireResourceSharedLite(&CmpRegistryLock, TRUE);
 
   VERIFY_KEY_OBJECT(KeyObject);
 
@@ -908,7 +908,7 @@
 
   if (!NT_SUCCESS(Status))
     {
-      ExReleaseResourceLite(&CmiRegistryLock);
+      ExReleaseResourceLite(&CmpRegistryLock);
       KeLeaveCriticalRegion();
       ObDereferenceObject(KeyObject);
       PostOperationInfo.Status = Status;
@@ -1089,7 +1089,7 @@
       Status = STATUS_UNSUCCESSFUL;
     }
 
-  ExReleaseResourceLite(&CmiRegistryLock);
+  ExReleaseResourceLite(&CmpRegistryLock);
   KeLeaveCriticalRegion();
   ObDereferenceObject(KeyObject);
   PostOperationInfo.Status = Status;
@@ -1131,7 +1131,7 @@
 
   /* Acquire hive lock */
   KeEnterCriticalRegion();
-  ExAcquireResourceExclusiveLite(&CmiRegistryLock, TRUE);
+  ExAcquireResourceExclusiveLite(&CmpRegistryLock, TRUE);
 
   if (IsNoFileHive(RegistryHive))
     {
@@ -1143,7 +1143,7 @@
       Status = CmiFlushRegistryHive(RegistryHive);
     }
 
-  ExReleaseResourceLite(&CmiRegistryLock);
+  ExReleaseResourceLite(&CmpRegistryLock);
   KeLeaveCriticalRegion();
 
   ObDereferenceObject(KeyObject);
@@ -1367,7 +1367,7 @@
 
   /* Acquire hive lock */
   KeEnterCriticalRegion();
-  ExAcquireResourceSharedLite(&CmiRegistryLock, TRUE);
+  ExAcquireResourceSharedLite(&CmpRegistryLock, TRUE);
 
   VERIFY_KEY_OBJECT(KeyObject);
 
@@ -1525,7 +1525,7 @@
 	break;
     }
 
-  ExReleaseResourceLite(&CmiRegistryLock);
+  ExReleaseResourceLite(&CmpRegistryLock);
   KeLeaveCriticalRegion();
 
   PostOperationInfo.Status = Status;
@@ -1595,7 +1595,7 @@
 
   /* Acquire hive lock */
   KeEnterCriticalRegion();
-  ExAcquireResourceSharedLite(&CmiRegistryLock, TRUE);
+  ExAcquireResourceSharedLite(&CmpRegistryLock, TRUE);
 
   VERIFY_KEY_OBJECT(KeyObject);
 
@@ -1789,7 +1789,7 @@
     }
 
 ByeBye:;
-  ExReleaseResourceLite(&CmiRegistryLock);
+  ExReleaseResourceLite(&CmpRegistryLock);
   KeLeaveCriticalRegion();
 
   PostOperationInfo.Status = Status;
@@ -1855,7 +1855,7 @@
 
   /* Acquire hive lock exclucively */
   KeEnterCriticalRegion();
-  ExAcquireResourceExclusiveLite(&CmiRegistryLock, TRUE);
+  ExAcquireResourceExclusiveLite(&CmpRegistryLock, TRUE);
 
   VERIFY_KEY_OBJECT(KeyObject);
 
@@ -1882,7 +1882,7 @@
     {
       DPRINT("Cannot add value. Status 0x%X\n", Status);
 
-      ExReleaseResourceLite(&CmiRegistryLock);
+      ExReleaseResourceLite(&CmpRegistryLock);
       KeLeaveCriticalRegion();
       PostOperationInfo.Status = Status;
       CmiCallRegisteredCallbacks(RegNtPostSetValueKey, &PostOperationInfo);
@@ -1938,7 +1938,7 @@
 	    {
 	      DPRINT("CmiAllocateBlock() failed (Status %lx)\n", Status);
 
-	      ExReleaseResourceLite(&CmiRegistryLock);
+	      ExReleaseResourceLite(&CmpRegistryLock);
 	      KeLeaveCriticalRegion();
               PostOperationInfo.Status = Status;
               CmiCallRegisteredCallbacks(RegNtPostSetValueKey, &PostOperationInfo);
@@ -1973,7 +1973,7 @@
   KeQuerySystemTime (&KeyCell->LastWriteTime);
   HvMarkCellDirty (&RegistryHive->Hive, KeyObject->KeyCellOffset);
 
-  ExReleaseResourceLite(&CmiRegistryLock);
+  ExReleaseResourceLite(&CmpRegistryLock);
   KeLeaveCriticalRegion();
   PostOperationInfo.Status = Status;
   CmiCallRegisteredCallbacks(RegNtPostSetValueKey, &PostOperationInfo);
@@ -2040,7 +2040,7 @@
 
   /* Acquire hive lock */
   KeEnterCriticalRegion();
-  ExAcquireResourceExclusiveLite(&CmiRegistryLock, TRUE);
+  ExAcquireResourceExclusiveLite(&CmpRegistryLock, TRUE);
 
   VERIFY_KEY_OBJECT(KeyObject);
 
@@ -2053,7 +2053,7 @@
   HvMarkCellDirty (&KeyObject->RegistryHive->Hive, KeyObject->KeyCellOffset);
 
   /* Release hive lock */
-  ExReleaseResourceLite(&CmiRegistryLock);
+  ExReleaseResourceLite(&CmpRegistryLock);
   KeLeaveCriticalRegion();
 
   ReleaseCapturedUnicodeString(&CapturedValueName,
@@ -2173,7 +2173,7 @@
 
   /* Acquire hive lock */
   KeEnterCriticalRegion();
-  ExAcquireResourceExclusiveLite(&CmiRegistryLock, TRUE);
+  ExAcquireResourceExclusiveLite(&CmpRegistryLock, TRUE);
 
   Status = CmiLoadHive (KeyObjectAttributes,
 			NamePointer,
@@ -2184,7 +2184,7 @@
     }
 
   /* Release hive lock */
-  ExReleaseResourceLite(&CmiRegistryLock);
+  ExReleaseResourceLite(&CmpRegistryLock);
   KeLeaveCriticalRegion();
 
   if (Buffer != NULL)
@@ -2247,7 +2247,7 @@
 
   /* Acquire hive lock */
   KeEnterCriticalRegion();
-  ExAcquireResourceSharedLite(&CmiRegistryLock, TRUE);
+  ExAcquireResourceSharedLite(&CmpRegistryLock, TRUE);
 
   VERIFY_KEY_OBJECT(KeyObject);
 
@@ -2319,7 +2319,7 @@
   *ReturnLength = BufferLength;
 
   /* Release hive lock */
-  ExReleaseResourceLite(&CmiRegistryLock);
+  ExReleaseResourceLite(&CmpRegistryLock);
   KeLeaveCriticalRegion();
 
   PostOperationInfo.Status = Status;

Modified: trunk/reactos/ntoskrnl/cm/registry.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cm/registry.c?rev=26710&r1=26709&r2=26710&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/cm/registry.c (original)
+++ trunk/reactos/ntoskrnl/cm/registry.c Sat May 12 03:35:19 2007
@@ -34,7 +34,7 @@
 
 LIST_ENTRY CmpHiveListHead;
 
-ERESOURCE CmiRegistryLock;
+ERESOURCE CmpRegistryLock;
 
 KTIMER CmiWorkerTimer;
 LIST_ENTRY CmiKeyObjectListHead;
@@ -81,7 +81,7 @@
 
       /* Acquire hive lock */
       KeEnterCriticalRegion();
-      ExAcquireResourceExclusiveLite(&CmiRegistryLock, TRUE);
+      ExAcquireResourceExclusiveLite(&CmpRegistryLock, TRUE);
 
       CmiTimer++;
 
@@ -107,7 +107,7 @@
 	    CurrentEntry = CurrentEntry->Blink;
 	 }
       }
-      ExReleaseResourceLite(&CmiRegistryLock);
+      ExReleaseResourceLite(&CmpRegistryLock);
       KeLeaveCriticalRegion();
 
       DPRINT("Removed %d key objects\n", Count);
@@ -190,215 +190,6 @@
 
     /* Connect the hive */
     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

Modified: trunk/reactos/ntoskrnl/cm/regobj.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cm/regobj.c?rev=26710&r1=26709&r2=26710&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/cm/regobj.c (original)
+++ trunk/reactos/ntoskrnl/cm/regobj.c Sat May 12 03:35:19 2007
@@ -403,7 +403,7 @@
 
   /* Acquire hive lock */
   KeEnterCriticalRegion();
-  ExAcquireResourceExclusiveLite(&CmiRegistryLock, TRUE);
+  ExAcquireResourceExclusiveLite(&CmpRegistryLock, TRUE);
 
   Status = CmiScanKeyList(ParsedKey,
 			  &KeyName,
@@ -411,7 +411,7 @@
 			  &FoundObject);
   if (!NT_SUCCESS(Status))
   {
-     ExReleaseResourceLite(&CmiRegistryLock);
+     ExReleaseResourceLite(&CmpRegistryLock);
      KeLeaveCriticalRegion();
      RtlFreeUnicodeString(&KeyName);
      return Status;
@@ -427,7 +427,7 @@
                                 Attributes);
       if (!NT_SUCCESS(Status))
         {
-          ExReleaseResourceLite(&CmiRegistryLock);
+          ExReleaseResourceLite(&CmpRegistryLock);
           KeLeaveCriticalRegion();
           RtlFreeUnicodeString(&KeyName);
           return(STATUS_UNSUCCESSFUL);
@@ -442,7 +442,7 @@
                                     &LinkPath);
           if (NT_SUCCESS(Status))
             {
-              ExReleaseResourceLite(&CmiRegistryLock);
+              ExReleaseResourceLite(&CmpRegistryLock);
               KeLeaveCriticalRegion();
 
               DPRINT("LinkPath '%wZ'\n", &LinkPath);
@@ -493,7 +493,7 @@
                               (PVOID*)&FoundObject);
       if (!NT_SUCCESS(Status))
         {
-          ExReleaseResourceLite(&CmiRegistryLock);
+          ExReleaseResourceLite(&CmpRegistryLock);
           KeLeaveCriticalRegion();
           RtlFreeUnicodeString(&KeyName);
           return(Status);
@@ -540,7 +540,7 @@
 	    {
 	      DPRINT("LinkPath '%wZ'\n", &LinkPath);
 
-              ExReleaseResourceLite(&CmiRegistryLock);
+              ExReleaseResourceLite(&CmpRegistryLock);
               KeLeaveCriticalRegion();
 
 	      ObDereferenceObject(FoundObject);
@@ -583,7 +583,7 @@
   InsertHeadList(&CmiKeyObjectListHead, &FoundObject->ListEntry);
   FoundObject->TimeStamp = CmiTimer;
 
-  ExReleaseResourceLite(&CmiRegistryLock);
+  ExReleaseResourceLite(&CmpRegistryLock);
   KeLeaveCriticalRegion();
 
   DPRINT("CmpParseKey: %wZ\n", &FoundObject->Name);
@@ -628,7 +628,7 @@
 
   /* Acquire hive lock */
   KeEnterCriticalRegion();
-  ExAcquireResourceExclusiveLite(&CmiRegistryLock, TRUE);
+  ExAcquireResourceExclusiveLite(&CmpRegistryLock, TRUE);
 
   if (!NT_SUCCESS(CmiRemoveKeyFromList(KeyObject)))
     {
@@ -669,7 +669,7 @@
       ExFreePool(KeyObject->SubKeys);
     }
 
-  ExReleaseResourceLite(&CmiRegistryLock);
+  ExReleaseResourceLite(&CmpRegistryLock);
   KeLeaveCriticalRegion();
   PostOperationInfo.Status = STATUS_SUCCESS;
   CmiCallRegisteredCallbacks(RegNtPostKeyHandleClose, &PostOperationInfo);

Modified: trunk/reactos/ntoskrnl/config/cm.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/config/cm.h?rev=26710&r1=26709&r2=26710&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/config/cm.h (original)
+++ trunk/reactos/ntoskrnl/config/cm.h Sat May 12 03:35:19 2007
@@ -641,9 +641,10 @@
 //
 // 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 @@
     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 @@
 // Notification Routines
 //
 VOID
+NTAPI
 CmpReportNotify(
     IN PCM_KEY_CONTROL_BLOCK Kcb,
     IN PHHIVE Hive,
@@ -714,6 +721,12 @@
     IN ULONG Filter
 );
 
+VOID
+NTAPI
+CmpInitCallback(
+    VOID
+);
+
 //
 // KCB Cache/Delay Routines
 //
@@ -725,13 +738,19 @@
 
 VOID
 NTAPI
-CmpInitializeCmAllocations(
+CmpInitCmPrivateDelayAlloc(
     VOID
 );
 
 VOID
 NTAPI
-CmpInitializeKcbDelayedDeref(
+CmpInitCmPrivateAlloc(
+    VOID
+);
+
+VOID
+NTAPI
+CmpInitDelayDerefKCBEngine(
     VOID
 );
 
@@ -1004,6 +1023,18 @@
     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 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 ULONG CmpBootType;
 extern HANDLE CmpRegistryRootHandle;
 extern BOOLEAN ExpInTextModeSetup;
+extern BOOLEAN InitIsWinPEMode;
 
 //
 // Inlined functions

Modified: trunk/reactos/ntoskrnl/config/cmdata.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/config/cmdata.c?rev=26710&r1=26709&r2=26710&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/config/cmdata.c (original)
+++ trunk/reactos/ntoskrnl/config/cmdata.c Sat May 12 03:35:19 2007
@@ -36,7 +36,7 @@
 ULONG CmpConfigurationAreaSize = PAGE_SIZE * 4;
 PCM_FULL_RESOURCE_DESCRIPTOR CmpConfigurationData;
 
-EX_PUSH_LOCK CmpHiveListHeadLock;
+EX_PUSH_LOCK CmpHiveListHeadLock, CmpLoadHiveLock;
 
 HIVE_LIST_ENTRY CmpMachineHiveList[5];
 

Modified: trunk/reactos/ntoskrnl/config/cmhook.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/config/cmhook.c?rev=26710&r1=26709&r2=26710&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/config/cmhook.c (original)
+++ trunk/reactos/ntoskrnl/config/cmhook.c Sat May 12 03:35:19 2007
@@ -15,6 +15,9 @@
 
 /* GLOBALS *******************************************************************/
 
+ULONG CmpCallBackCount = 0;
+EX_CALLBACK CmpCallBackVector[100];
+
 LIST_ENTRY CmiCallbackHead;
 FAST_MUTEX CmiCallbackLock;
 
@@ -29,6 +32,28 @@
 } REGISTRY_CALLBACK, *PREGISTRY_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,

Modified: trunk/reactos/ntoskrnl/config/cmkcbncb.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/config/cmkcbncb.c?rev=26710&r1=26709&r2=26710&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/config/cmkcbncb.c (original)
+++ trunk/reactos/ntoskrnl/config/cmkcbncb.c Sat May 12 03:35:19 2007
@@ -15,7 +15,164 @@
 
 /* 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

Modified: trunk/reactos/ntoskrnl/config/cmsysini.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/config/cmsysini.c?rev=26710&r1=26709&r2=26710&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/config/cmsysini.c (original)
+++ trunk/reactos/ntoskrnl/config/cmsysini.c Sat May 12 03:35:19 2007
@@ -12,6 +12,10 @@
 #include "cm.h"
 #define NDEBUG
 #include "debug.h"
+
+KGUARDED_MUTEX CmpSelfHealQueueLock;
+LIST_ENTRY CmpSelfHealQueueListHead;
+PEPROCESS CmpSystemProcess;
 
 /* FUNCTIONS *****************************************************************/
 
@@ -624,3 +628,237 @@
     /* 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;
+}




More information about the Ros-diffs mailing list