AllocateAndInitLPB(PLOADER_PARAMETER_BLOCK *OutLoaderBlock)
{
PLOADER_PARAMETER_BLOCK LoaderBlock;
- ULONG SystemBlockSize;
/* Allocate and zero-init the LPB */
- SystemBlockSize = sizeof(LOADER_SYSTEM_BLOCK) +
- reactos_disk_count * sizeof(ARC_DISK_SIGNATURE_EX);
- WinLdrSystemBlock = MmAllocateMemoryWithType(SystemBlockSize,
+ WinLdrSystemBlock = MmAllocateMemoryWithType(sizeof(LOADER_SYSTEM_BLOCK),
LoaderSystemBlock);
if (WinLdrSystemBlock == NULL)
{
//CHAR SystemRoot[] = "\\WINNT\\";
//CHAR ArcBoot[] = "multi(0)disk(0)rdisk(0)partition(1)";
- CHAR HalPath[] = "\\";
- CHAR ArcBoot[256];
- CHAR MiscFiles[256];
- ULONG i, PathSeparator;
+ LPSTR LoadOptions, NewLoadOptions;
+ CHAR HalPath[] = "\\";
+ CHAR ArcBoot[256];
+ CHAR MiscFiles[256];
+ ULONG i;
+ ULONG_PTR PathSeparator;
PLOADER_PARAMETER_EXTENSION Extension;
/* Construct SystemRoot and ArcBoot from SystemPath */
strncpy(LoaderBlock->NtHalPathName, HalPath, MAX_PATH);
LoaderBlock->NtHalPathName = PaToVa(LoaderBlock->NtHalPathName);
- /* Fill load options */
- LoaderBlock->LoadOptions = WinLdrSystemBlock->LoadOptions;
+ /* Fill LoadOptions and strip the '/' commutator symbol in front of each option */
+ NewLoadOptions = LoadOptions = LoaderBlock->LoadOptions = WinLdrSystemBlock->LoadOptions;
strncpy(LoaderBlock->LoadOptions, Options, MAX_OPTIONS_LENGTH);
+
+ do
+ {
+ while (*LoadOptions == '/')
+ ++LoadOptions;
+
+ *NewLoadOptions++ = *LoadOptions;
+ } while (*LoadOptions++);
+
LoaderBlock->LoadOptions = PaToVa(LoaderBlock->LoadOptions);
/* Arc devices */
/* Convert ARC disk information from freeldr to a correct format */
for (i = 0; i < reactos_disk_count; i++)
{
- PARC_DISK_SIGNATURE ArcDiskSig;
+ PARC_DISK_SIGNATURE_EX ArcDiskSig;
- /* Get the ARC structure */
- ArcDiskSig = &WinLdrSystemBlock->ArcDiskSignature[i].DiskSignature;
+ /* Allocate the ARC structure */
+ ArcDiskSig = HeapAllocate(FrLdrDefaultHeap,
+ sizeof(ARC_DISK_SIGNATURE_EX),
+ 'giSD');
/* Copy the data over */
- ArcDiskSig->Signature = reactos_arc_disk_info[i].Signature;
- ArcDiskSig->CheckSum = reactos_arc_disk_info[i].CheckSum;
+ ArcDiskSig->DiskSignature.Signature = reactos_arc_disk_info[i].Signature;
+ ArcDiskSig->DiskSignature.CheckSum = reactos_arc_disk_info[i].CheckSum;
/* Copy the ARC Name */
- ArcDiskSig->ArcName = WinLdrSystemBlock->ArcDiskSignature[i].ArcName;
strncpy(ArcDiskSig->ArcName, reactos_arc_disk_info[i].ArcName, MAX_PATH);
- ArcDiskSig->ArcName = PaToVa(ArcDiskSig->ArcName);
+ ArcDiskSig->DiskSignature.ArcName = PaToVa(ArcDiskSig->ArcName);
/* Mark partition table as valid */
- ArcDiskSig->ValidPartitionTable = TRUE;
+ ArcDiskSig->DiskSignature.ValidPartitionTable = TRUE;
/* Insert into the list */
InsertTailList(&LoaderBlock->ArcDiskInformation->DiskSignatureListHead,
- &ArcDiskSig->ListEntry);
+ &ArcDiskSig->DiskSignature.ListEntry);
}
/* Convert all list's to Virtual address */
TRACE("WinLdrInitializePhase1() completed\n");
}
-BOOLEAN
-WinLdrLoadDeviceDriver(PLOADER_PARAMETER_BLOCK LoaderBlock,
+static BOOLEAN
+WinLdrLoadDeviceDriver(PLIST_ENTRY LoadOrderListHead,
LPSTR BootPath,
PUNICODE_STRING FilePath,
ULONG Flags,
DriverPath[0] = 0;
}
- TRACE("DriverPath: %s, DllName: %s, LPB %p\n", DriverPath, DllName, LoaderBlock);
+ TRACE("DriverPath: %s, DllName: %s, LPB\n", DriverPath, DllName);
// Check if driver is already loaded
- Status = WinLdrCheckForLoadedDll(&LoaderBlock->LoadOrderListHead, DllName, DriverDTE);
+ Status = WinLdrCheckForLoadedDll(LoadOrderListHead, DllName, DriverDTE);
if (Status)
{
// We've got the pointer to its DTE, just return success
return FALSE;
// Allocate a DTE for it
- Status = WinLdrAllocateDataTableEntry(&LoaderBlock->LoadOrderListHead, DllName, DllName, DriverBase, DriverDTE);
+ Status = WinLdrAllocateDataTableEntry(LoadOrderListHead, DllName, DllName, DriverBase, DriverDTE);
if (!Status)
{
ERR("WinLdrAllocateDataTableEntry() failed\n");
// Look for any dependencies it may have, and load them too
sprintf(FullPath,"%s%s", BootPath, DriverPath);
- Status = WinLdrScanImportDescriptorTable(&LoaderBlock->LoadOrderListHead, FullPath, *DriverDTE);
+ Status = WinLdrScanImportDescriptorTable(LoadOrderListHead, FullPath, *DriverDTE);
if (!Status)
{
ERR("WinLdrScanImportDescriptorTable() failed for %s\n", FullPath);
// Paths are relative (FIXME: Are they always relative?)
// Load it
- Status = WinLdrLoadDeviceDriver(LoaderBlock, BootPath, &BootDriver->FilePath,
+ Status = WinLdrLoadDeviceDriver(&LoaderBlock->LoadOrderListHead, BootPath, &BootDriver->FilePath,
0, &BootDriver->LdrEntry);
// If loading failed - cry loudly
}
VOID
-LoadAndBootWindows(PCSTR OperatingSystemName,
- PSTR SettingsValue,
- USHORT OperatingSystemVersion)
+LoadAndBootWindows(IN OperatingSystemItem* OperatingSystem,
+ IN USHORT OperatingSystemVersion)
{
+ ULONG_PTR SectionId;
+ PCSTR SectionName = OperatingSystem->SystemPartition;
+ CHAR SettingsValue[80];
BOOLEAN HasSection;
- char BootPath[MAX_PATH];
+ CHAR BootPath[MAX_PATH];
CHAR FileName[MAX_PATH];
CHAR BootOptions[256];
PCHAR File;
BOOLEAN Status;
- ULONG_PTR SectionId;
PLOADER_PARAMETER_BLOCK LoaderBlock;
+ // Get OS setting value
+ SettingsValue[0] = ANSI_NULL;
+ IniOpenSection("Operating Systems", &SectionId);
+ IniReadSettingByName(SectionId, SectionName, SettingsValue, sizeof(SettingsValue));
+
// Open the operating system section
// specified in the .ini file
- HasSection = IniOpenSection(OperatingSystemName, &SectionId);
+ HasSection = IniOpenSection(SectionName, &SectionId);
UiDrawBackdrop();
UiDrawProgressBarCenter(1, 100, "Loading NT...");
if (!HasSection ||
!IniReadSettingByName(SectionId, "SystemPath", BootPath, sizeof(BootPath)))
{
- strcpy(BootPath, OperatingSystemName);
+ strcpy(BootPath, SectionName);
}
/* Special case for LiveCD */
if (!HasSection || !IniReadSettingByName(SectionId, "Options", BootOptions, sizeof(BootOptions)))
{
/* Get options after the title */
- const CHAR*p = SettingsValue;
+ PCSTR p = SettingsValue;
while (*p == ' ' || *p == '"')
p++;
while (*p != '\0' && *p != '"')
AllocateAndInitLPB(&LoaderBlock);
#ifdef _M_IX86
- /* Setup redirection support */
+ /* Setup redirection support */
WinLdrSetupEms(BootOptions);
#endif
WinLdrpDumpMemoryDescriptors(LoaderBlockVA);
WinLdrpDumpBootDriver(LoaderBlockVA);
+#ifndef _M_AMD64
WinLdrpDumpArcDisks(LoaderBlockVA);
+#endif
//FIXME: If I substitute this debugging checkpoint, GCC will "optimize away" the code below
//while (1) {};