#pragma once
+/* Optional user-provided callback used by the PE loader
+ * when it loads DLLs imported by a main image. */
+typedef VOID
+(NTAPI *PELDR_IMPORTDLL_LOAD_CALLBACK)(
+ _In_ PCSTR FileName);
+
+extern PELDR_IMPORTDLL_LOAD_CALLBACK PeLdrImportDllLoadCallback;
+
BOOLEAN
PeLdrLoadImage(
IN PCHAR FileName,
#include <debug.h>
DBG_DEFAULT_CHANNEL(PELOADER);
+/* GLOBALS *******************************************************************/
+
+PELDR_IMPORTDLL_LOAD_CALLBACK PeLdrImportDllLoadCallback = NULL;
+
+
/* PRIVATE FUNCTIONS *********************************************************/
/* DllName - physical, UnicodeString->Buffer - virtual */
TRACE("Loading referenced DLL: %s\n", FullDllName);
+ if (PeLdrImportDllLoadCallback)
+ PeLdrImportDllLoadCallback(FullDllName);
+
/* Load the image */
Success = PeLdrLoadImage(FullDllName, LoaderBootDriver, &BasePA);
if (!Success)
LARGE_INTEGER Position;
ULONG i, BytesRead;
- TRACE("PeLdrLoadImage(%s, %ld, *)\n", FileName, MemoryType);
+ TRACE("PeLdrLoadImage(%s, %ld)\n", FileName, MemoryType);
/* Open the image file */
Status = ArcOpen((PSTR)FileName, OpenReadOnly, &FileId);
VOID
MempAllocatePTE(ULONG Entry, PHARDWARE_PTE *PhysicalPT, PHARDWARE_PTE *KernelPT)
{
- //Print(L"Creating PDE Entry %X\n", Entry);
+ //TRACE("Creating PDE Entry %X\n", Entry);
// Identity mapping
*PhysicalPT = (PHARDWARE_PTE)&PhysicalPageTablesBuffer[PhysicalPageTables*MM_PAGE_SIZE];
// We cannot map this as it requires more than 1 PDE
// and in fact it's not possible at all ;)
//
- //Print(L"skipping...\n");
+ //TRACE("skipping...\n");
return TRUE;
}
return EINVAL;
}
+ /* Let the user know we started loading */
UiDrawBackdrop();
UiDrawStatusText("Setup is loading...");
UiDrawProgressBarCenter(1, 100, "Loading ReactOS Setup...");
TRACE("BootOptions: '%s'\n", BootOptions);
+ /* Handle the SOS option */
+ SosEnabled = !!NtLdrGetOption(BootOptions, "SOS");
+ if (SosEnabled)
+ UiResetForSOS();
+
/* Allocate and minimally-initialize the Loader Parameter Block */
AllocateAndInitLPB(_WIN32_WINNT_WS03, &LoaderBlock);
SetupBlock->Flags = SETUPLDR_TEXT_MODE;
/* Load the "setupreg.hiv" setup system hive */
- UiDrawProgressBarCenter(15, 100, "Loading setup system hive...");
+ if (!SosEnabled) UiDrawProgressBarCenter(15, 100, "Loading setup system hive...");
Success = WinLdrInitSystemHive(LoaderBlock, BootPath, TRUE);
TRACE("Setup SYSTEM hive %s\n", (Success ? "loaded" : "not loaded"));
/* Bail out if failure */
// debug stuff
VOID DumpMemoryAllocMap(VOID);
+/* PE loader import-DLL loading callback */
+static VOID
+NTAPI
+NtLdrImportDllLoadCallback(
+ _In_ PCSTR FileName)
+{
+ NtLdrOutputLoadMsg(FileName, NULL);
+}
+
+VOID
+NtLdrOutputLoadMsg(
+ _In_ PCSTR FileName,
+ _In_opt_ PCSTR Description)
+{
+ if (SosEnabled)
+ {
+ printf(" %s\n", FileName);
+ TRACE("Loading: %s\n", FileName);
+ }
+ else
+ {
+ /* Inform the user we load a file */
+ CHAR ProgressString[256];
+
+ RtlStringCbPrintfA(ProgressString, sizeof(ProgressString),
+ "Loading %s...",
+ (Description ? Description : FileName));
+ // UiDrawProgressBarCenter(1, 100, ProgressString);
+ UiDrawStatusText(ProgressString);
+ }
+}
+
// Init "phase 0"
VOID
AllocateAndInitLPB(
// It's not loaded, we have to load it
RtlStringCbPrintfA(FullPath, sizeof(FullPath), "%s%wZ", BootPath, FilePath);
+
+ NtLdrOutputLoadMsg(FullPath, NULL);
Success = PeLdrLoadImage(FullPath, LoaderBootDriver, &DriverBase);
if (!Success)
return FALSE;
ARC_STATUS Status;
ULONG BytesRead;
- //CHAR ProgressString[256];
-
- /* Inform user we are loading files */
- //RtlStringCbPrintfA(ProgressString, sizeof(ProgressString), "Loading %s...", FileName);
- //UiDrawProgressBarCenter(1, 100, ProgressString);
-
- TRACE("Loading module %s\n", ModuleName);
*Size = 0;
/* Open the image file */
+ NtLdrOutputLoadMsg(ModuleName, NULL);
Status = ArcOpen((PSTR)ModuleName, OpenReadOnly, &FileId);
if (Status != ESUCCESS)
{
PVOID BaseAddress = NULL;
RtlStringCbPrintfA(ProgressString, sizeof(ProgressString), "Loading %s...", File);
- UiDrawProgressBarCenter(Percentage, 100, ProgressString);
+ if (!SosEnabled) UiDrawProgressBarCenter(Percentage, 100, ProgressString);
RtlStringCbCopyA(FullFileName, sizeof(FullFileName), Path);
RtlStringCbCatA(FullFileName, sizeof(FullFileName), File);
+ NtLdrOutputLoadMsg(FullFileName, NULL);
Success = PeLdrLoadImage(FullFileName, MemoryType, &BaseAddress);
if (!Success)
{
FIXME("LoadWindowsCore: 3GB - TRUE (not implemented)\n");
VirtualBias = TRUE;
}
- if (NtLdrGetOption(BootOptions, "SOS"))
- {
- /* We found the SOS option. */
- FIXME("LoadWindowsCore: SOS - TRUE (not implemented)\n");
- SosEnabled = TRUE;
- }
if (OperatingSystemVersion > _WIN32_WINNT_NT4)
{
return EINVAL;
}
+ /* Let the user know we started loading */
UiDrawBackdrop();
+ UiDrawStatusText("Loading...");
UiDrawProgressBarCenter(1, 100, "Loading NT...");
/* Retrieve the system path */
}
}
- /* Let user know we started loading */
- //UiDrawStatusText("Loading...");
+ /* Handle the SOS option */
+ SosEnabled = !!NtLdrGetOption(BootOptions, "SOS");
+ if (SosEnabled)
+ UiResetForSOS();
/* Allocate and minimally-initialize the Loader Parameter Block */
AllocateAndInitLPB(OperatingSystemVersion, &LoaderBlock);
/* Load the system hive */
- UiDrawProgressBarCenter(15, 100, "Loading system hive...");
+ if (!SosEnabled) UiDrawProgressBarCenter(15, 100, "Loading system hive...");
Success = WinLdrInitSystemHive(LoaderBlock, BootPath, FALSE);
TRACE("SYSTEM hive %s\n", (Success ? "loaded" : "not loaded"));
/* Bail out if failure */
SystemRoot = strstr(BootPath, "\\");
/* Detect hardware */
- UiDrawProgressBarCenter(20, 100, "Detecting hardware...");
+ if (!SosEnabled) UiDrawProgressBarCenter(20, 100, "Detecting hardware...");
LoaderBlock->ConfigurationRoot = MachHwDetect();
+ /* Initialize the PE loader import-DLL callback, so that we can obtain
+ * feedback (for example during SOS) on the PE images that get loaded. */
+ PeLdrImportDllLoadCallback = NtLdrImportDllLoadCallback;
+
/* Load the operating system core: the Kernel, the HAL and the Kernel Debugger Transport DLL */
Success = LoadWindowsCore(OperatingSystemVersion,
LoaderBlock,
&KernelDTE);
if (!Success)
{
+ /* Reset the PE loader import-DLL callback */
+ PeLdrImportDllLoadCallback = NULL;
+
UiMessageBox("Error loading NTOS core.");
return ENOEXEC;
}
+ /* Cleanup INI file */
+ IniCleanup();
+
+/****
+ **** WE HAVE NOW REACHED THE POINT OF NO RETURN !!
+ ****/
+
/* Load boot drivers */
- UiDrawProgressBarCenter(100, 100, "Loading boot drivers...");
+ if (!SosEnabled) UiDrawProgressBarCenter(100, 100, "Loading boot drivers...");
Success = WinLdrLoadBootDrivers(LoaderBlock, BootPath);
TRACE("Boot drivers loading %s\n", Success ? "successful" : "failed");
- /* Cleanup ini file */
- IniCleanup();
+ /* Reset the PE loader import-DLL callback */
+ PeLdrImportDllLoadCallback = NULL;
/* Initialize Phase 1 - no drivers loading anymore */
WinLdrInitializePhase1(LoaderBlock,
// winldr.c
+extern BOOLEAN SosEnabled;
+
+FORCEINLINE
+VOID
+UiResetForSOS(VOID)
+{
+#ifdef _M_ARM
+ /* Re-initialize the UI */
+ UiInitialize(TRUE);
+#else
+ /* Reset the UI and switch to MiniTui */
+ UiVtbl.UnInitialize();
+ UiVtbl = MiniTuiVtbl;
+ UiVtbl.Initialize();
+#endif
+}
+
+VOID
+NtLdrOutputLoadMsg(
+ _In_ PCSTR FileName,
+ _In_opt_ PCSTR Description);
+
PVOID WinLdrLoadModule(PCSTR ModuleName, PULONG Size,
TYPE_OF_MEMORY MemoryType);
RtlStringCbCopyA(FullHiveName, sizeof(FullHiveName), DirectoryPath);
RtlStringCbCatA(FullHiveName, sizeof(FullHiveName), HiveName);
+ NtLdrOutputLoadMsg(FullHiveName, NULL);
Status = ArcOpen(FullHiveName, OpenReadOnly, &FileId);
if (Status != ESUCCESS)
{
/* Open file with ANSI and store its size */
RtlStringCbCopyA(FileName, sizeof(FileName), DirectoryPath);
RtlStringCbCatA(FileName, sizeof(FileName), AnsiFileName);
+
+ NtLdrOutputLoadMsg(FileName, NULL);
Status = ArcOpen(FileName, OpenReadOnly, &FileId);
if (Status != ESUCCESS)
{
}
else
{
- //Print(L"Loading %s...\n", Filename);
RtlStringCbCopyA(FileName, sizeof(FileName), DirectoryPath);
RtlStringCbCatA(FileName, sizeof(FileName), OemFileName);
+
+ NtLdrOutputLoadMsg(FileName, NULL);
Status = ArcOpen(FileName, OpenReadOnly, &FileId);
if (Status != ESUCCESS)
{
TRACE("OemFileSize: %d\n", OemFileSize);
/* And finally open the language codepage file and store its length */
- //Print(L"Loading %s...\n", Filename);
RtlStringCbCopyA(FileName, sizeof(FileName), DirectoryPath);
RtlStringCbCatA(FileName, sizeof(FileName), LanguageFileName);
+
+ NtLdrOutputLoadMsg(FileName, NULL);
Status = ArcOpen(FileName, OpenReadOnly, &FileId);
if (Status != ESUCCESS)
{
/* Now actually read the data into memory, starting with Ansi file */
RtlStringCbCopyA(FileName, sizeof(FileName), DirectoryPath);
RtlStringCbCatA(FileName, sizeof(FileName), AnsiFileName);
+
+ NtLdrOutputLoadMsg(FileName, NULL);
Status = ArcOpen(FileName, OpenReadOnly, &FileId);
if (Status != ESUCCESS)
{
{
RtlStringCbCopyA(FileName, sizeof(FileName), DirectoryPath);
RtlStringCbCatA(FileName, sizeof(FileName), OemFileName);
+
+ NtLdrOutputLoadMsg(FileName, NULL);
Status = ArcOpen(FileName, OpenReadOnly, &FileId);
if (Status != ESUCCESS)
{
/* Finally the language file */
RtlStringCbCopyA(FileName, sizeof(FileName), DirectoryPath);
RtlStringCbCatA(FileName, sizeof(FileName), LanguageFileName);
+
+ NtLdrOutputLoadMsg(FileName, NULL);
Status = ArcOpen(FileName, OpenReadOnly, &FileId);
if (Status != ESUCCESS)
{