update for HEAD-2003050101
[reactos.git] / ntoskrnl / ke / main.c
index 5de88d2..0b2c079 100644 (file)
@@ -85,43 +85,24 @@ static BOOLEAN
 RtlpCheckFileNameExtension(PCHAR FileName,
                           PCHAR Extension)
 {
-   PCHAR Ext;
-
-   Ext = strrchr(FileName, '.');
-   if ((Extension == NULL) || (*Extension == 0))
-     {
-       if (Ext == NULL)
-         return TRUE;
-       else
-         return FALSE;
-     }
-   if (*Extension != '.')
-     Ext++;
-   
-   if (_stricmp(Ext, Extension) == 0)
-     return TRUE;
-   else
-     return FALSE;
-}
+  PCHAR Ext;
 
+  Ext = strrchr(FileName, '.');
+  if (Ext == NULL)
+    {
+      if ((Extension == NULL) || (*Extension == 0))
+       return TRUE;
+      else
+       return FALSE;
+    }
 
-static BOOLEAN
-RtlpIsSystemHive(PCHAR FileName)
-{
-  PCHAR Name;
+  if (*Extension != '.')
+    Ext++;
 
-  Name = strrchr(FileName, '\\');
-  if (Name == NULL)
-  {
-    Name = FileName;
-  }
+  if (_stricmp(Ext, Extension) == 0)
+    return TRUE;
   else
-  {
-    Name = Name + 1;
-  }
-
-  return((_stricmp(Name, "system.hiv") == 0) ||
-        (_stricmp(Name, "system") == 0));
+    return FALSE;
 }
 
 
@@ -420,14 +401,14 @@ ExpInitializeExecutive(VOID)
   if (KeNumberProcessors > 1)
     {
       sprintf(str,
-             "Found %d system processors. [%u MB Memory]\n",
+             "Found %d system processors. [%lu MB Memory]\n",
              KeNumberProcessors,
              (KeLoaderBlock.MemHigher + 1088)/ 1024);
     }
   else
     {
       sprintf(str,
-             "Found 1 system processor. [%u MB Memory]\n",
+             "Found 1 system processor. [%lu MB Memory]\n",
              (KeLoaderBlock.MemHigher + 1088)/ 1024);
     }
   HalDisplayString(str);
@@ -499,25 +480,51 @@ ExpInitializeExecutive(VOID)
        }
     }
 
-  /*  Pass 2: load registry chunks passed in  */
+  /*  Pass 2: import system hive registry chunk  */
   SetupBoot = TRUE;
   for (i = 1; i < KeLoaderBlock.ModsCount; i++)
     {
       start = KeLoaderModules[i].ModStart;
       length = KeLoaderModules[i].ModEnd - start;
-      name = (PCHAR)KeLoaderModules[i].String;
-      if (RtlpCheckFileNameExtension(name, "") ||
-         RtlpCheckFileNameExtension(name, ".hiv"))
+
+      DPRINT("Module: '%s'\n", (PCHAR)KeLoaderModules[i].String);
+      name = strrchr((PCHAR)KeLoaderModules[i].String, '\\');
+      if (name == NULL)
+       {
+         name = (PCHAR)KeLoaderModules[i].String;
+       }
+      else
        {
-         CPRINT("Process registry chunk at %08lx\n", start);
-         CmImportHive((PCHAR)start, length);
+         name++;
        }
-      if (RtlpIsSystemHive(name))
+
+      if (!_stricmp (name, "system") ||
+         !_stricmp (name, "system.hiv"))
        {
+         CPRINT("Process system hive registry chunk at %08lx\n", start);
          SetupBoot = FALSE;
+         CmImportSystemHive((PCHAR)start, length);
        }
     }
 
+  /*  Pass 3: import hardware hive registry chunk  */
+  for (i = 1; i < KeLoaderBlock.ModsCount; i++)
+    {
+      start = KeLoaderModules[i].ModStart;
+      length = KeLoaderModules[i].ModEnd - start;
+      name = (PCHAR)KeLoaderModules[i].String;
+      if (!_stricmp (name, "hardware") ||
+         !_stricmp (name, "hardware.hiv"))
+       {
+         CPRINT("Process hardware hive registry chunk at %08lx\n", start);
+         CmImportHardwareHive((PCHAR)start, length);
+       }
+    }
+
+  /* Create dummy keys if no hardware hive was found */
+  CmImportHardwareHive (NULL, 0);
+
+
   /* Initialize volatile registry settings */
   if (SetupBoot == FALSE)
     {
@@ -533,7 +540,7 @@ ExpInitializeExecutive(VOID)
 
   IoCreateDriverList();
 
-  /*  Pass 3: process boot loaded drivers  */
+  /*  Pass 4: process boot loaded drivers  */
   BootDriverCount = 0;
   for (i=1; i < KeLoaderBlock.ModsCount; i++)
     {
@@ -620,7 +627,6 @@ ExpInitializeExecutive(VOID)
     {
       KeBugCheckEx(SESSION4_INITIALIZATION_FAILED, Status, 0, 0, 0);
     }
-
   /*
    * Crash the system if the initial process terminates within 5 seconds.
    */
@@ -728,7 +734,7 @@ _main (ULONG MultiBootMagic, PLOADER_PARAMETER_BLOCK _LoaderBlock)
            }
        }
       sprintf(KeLoaderCommandLine, 
-             "multi(0)disk(0)rdisk(%d)partition(%d)%s %s",
+             "multi(0)disk(0)rdisk(%lu)partition(%lu)%s %s",
              DiskNumber, PartNumber + 1, Temp, options);
 
       p = KeLoaderCommandLine;