#include <internal/ntoskrnl.h>
#include <reactos/resource.h>
#include <internal/mm.h>
+#include <internal/ifs.h>
#include <internal/module.h>
#include <internal/ldr.h>
#include <internal/ex.h>
RtlpCheckFileNameExtension(PCHAR FileName,
PCHAR Extension)
{
- PCHAR Ext;
+ 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;
+ Ext = strrchr(FileName, '.');
+ if (Ext == NULL)
+ {
+ if ((Extension == NULL) || (*Extension == 0))
+ return TRUE;
+ else
+ return FALSE;
+ }
+
+ if (*Extension != '.')
+ Ext++;
+
+ if (_stricmp(Ext, Extension) == 0)
+ return TRUE;
+ else
+ return FALSE;
}
}
}
+
VOID
ExpInitializeExecutive(VOID)
{
+ LARGE_INTEGER Timeout;
+ HANDLE ProcessHandle;
+ HANDLE ThreadHandle;
ULONG BootDriverCount;
ULONG i;
ULONG start;
PCHAR name;
CHAR str[50];
NTSTATUS Status;
+ BOOLEAN SetupBoot;
/*
* Fail at runtime if someone has changed various structures without
MmInit3();
CcInit();
KdInit2();
+ FsRtlpInitFileLockingImplementation();
/* Report all resources used by hal */
HalReportResourceUsage();
}
}
- /* 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;
+
+ DPRINT("Module: '%s'\n", (PCHAR)KeLoaderModules[i].String);
+ name = strrchr((PCHAR)KeLoaderModules[i].String, '\\');
+ if (name == NULL)
+ {
+ name = (PCHAR)KeLoaderModules[i].String;
+ }
+ else
+ {
+ 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 (RtlpCheckFileNameExtension(name, "") ||
- RtlpCheckFileNameExtension(name, ".hiv"))
+ if (!_stricmp (name, "hardware") ||
+ !_stricmp (name, "hardware.hiv"))
{
- CPRINT("Process registry chunk at %08lx\n", start);
- CmImportHive((PCHAR)start, length);
+ 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 */
- CmInit2((PCHAR)KeLoaderBlock.CommandLine);
+ if (SetupBoot == FALSE)
+ {
+ CmInit2((PCHAR)KeLoaderBlock.CommandLine);
+ }
/*
* Enter the kernel debugger before starting up the boot drivers
IoCreateDriverList();
- /* Pass 3: process boot loaded drivers */
+ /* Pass 4: process boot loaded drivers */
BootDriverCount = 0;
for (i=1; i < KeLoaderBlock.ModsCount; i++)
{
DebugLogInit2();
#endif /* DBGPRINT_FILE_LOG */
+#ifdef KDBG
+ KdbInitProfiling2();
+#endif /* KDBG */
+
PiInitDefaultLocale();
/*
* Launch initial process
*/
- LdrLoadInitialProcess();
+ Status = LdrLoadInitialProcess(&ProcessHandle,
+ &ThreadHandle);
+ if (!NT_SUCCESS(Status))
+ {
+ KeBugCheckEx(SESSION4_INITIALIZATION_FAILED, Status, 0, 0, 0);
+ }
+ /*
+ * Crash the system if the initial process terminates within 5 seconds.
+ */
+ Timeout.QuadPart = -50000000LL;
+ Status = NtWaitForSingleObject(ProcessHandle,
+ FALSE,
+ &Timeout);
+ if (Status != STATUS_TIMEOUT)
+ {
+ KeBugCheckEx(SESSION5_INITIALIZATION_FAILED, Status, 0, 0, 0);
+ }
+
+ NtClose(ThreadHandle);
+ NtClose(ProcessHandle);
PsTerminateSystemThread(STATUS_SUCCESS);
}
}
}
sprintf(KeLoaderCommandLine,
- "multi(0)disk(0)rdisk(%ld)partition(%ld)%s %s",
+ "multi(0)disk(0)rdisk(%lu)partition(%lu)%s %s",
DiskNumber, PartNumber + 1, Temp, options);
p = KeLoaderCommandLine;