VOID LoadAndBootWindows(IN OperatingSystemItem* OperatingSystem, IN USHORT OperatingSystemVersion) { ULONG_PTR SectionId; PCSTR SectionName = OperatingSystem->SystemPartition; CHAR SettingsValue[80]; BOOLEAN HasSection; CHAR BootPath[MAX_PATH]; CHAR FileName[MAX_PATH]; CHAR BootOptions[256]; PCHAR File; BOOLEAN Status; 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(SectionName, &SectionId); UiDrawBackdrop(); UiDrawProgressBarCenter(1, 100, "Loading NT..."); /* Read the system path is set in the .ini file */ if (!HasSection || !IniReadSettingByName(SectionId, "SystemPath", BootPath, sizeof(BootPath))) { strcpy(BootPath, SectionName); } /* Special case for LiveCD */ if (!_strnicmp(BootPath, "LiveCD", strlen("LiveCD"))) { strcpy(FileName, BootPath + strlen("LiveCD")); MachDiskGetBootPath(BootPath, sizeof(BootPath)); strcat(BootPath, FileName); } /* Append a backslash */ if ((strlen(BootPath)==0) || BootPath[strlen(BootPath)] != '\\') strcat(BootPath, "\\"); /* Read booting options */ if (!HasSection || !IniReadSettingByName(SectionId, "Options", BootOptions, sizeof(BootOptions))) { /* Get options after the title */ PCSTR p = SettingsValue; while (*p == ' ' || *p == '"') p++; while (*p != '\0' && *p != '"') p++; strcpy(BootOptions, p); TRACE("BootOptions: '%s'\n", BootOptions); } /* Append boot-time options */ AppendBootTimeOptions(BootOptions); /* Check if a ramdisk file was given */ File = strstr(BootOptions, "/RDPATH="); if (File) { /* Copy the file name and everything else after it */ strcpy(FileName, File + 8); /* Null-terminate */ *strstr(FileName, " ") = ANSI_NULL; /* Load the ramdisk */ RamDiskLoadVirtualFile(FileName); } /* Let user know we started loading */ //UiDrawStatusText("Loading..."); TRACE("BootPath: '%s'\n", BootPath); /* Allocate and minimalistic-initialize LPB */ AllocateAndInitLPB(&LoaderBlock); #ifdef _M_IX86 /* Setup redirection support */ WinLdrSetupEms(BootOptions); #endif /* Load Hive */ UiDrawBackdrop(); UiDrawProgressBarCenter(15, 100, "Loading system hive..."); Status = WinLdrInitSystemHive(LoaderBlock, BootPath); TRACE("SYSTEM hive %s\n", (Status ? "loaded" : "not loaded")); /* Load NLS data, OEM font, and prepare boot drivers list */ Status = WinLdrScanSystemHive(LoaderBlock, BootPath); TRACE("SYSTEM hive %s\n", (Status ? "scanned" : "not scanned")); /* Finish loading */ LoadAndBootWindowsCommon(OperatingSystemVersion, LoaderBlock, BootOptions, BootPath, 0); }
VOID LoadAndBootWindows(IN OperatingSystemItem* OperatingSystem, IN USHORT OperatingSystemVersion) { ULONG_PTR SectionId; PCSTR SectionName = OperatingSystem->SystemPartition; CHAR SettingsValue[80]; BOOLEAN HasSection; CHAR BootPath[MAX_PATH]; CHAR FileName[MAX_PATH]; CHAR BootOptions[256]; PCHAR File; BOOLEAN Success; 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(SectionName, &SectionId); UiDrawBackdrop(); UiDrawProgressBarCenter(1, 100, "Loading NT..."); /* Read the system path is set in the .ini file */ if (!HasSection || !IniReadSettingByName(SectionId, "SystemPath", BootPath, sizeof(BootPath))) { strcpy(BootPath, SectionName); } /* * Check whether BootPath is a full path * and if not, create a full boot path. * * See FsOpenFile for the technique used. */ if (strrchr(BootPath, ')') == NULL) { /* Temporarily save the boot path */ strcpy(FileName, BootPath); /* This is not a full path. Use the current (i.e. boot) device. */ MachDiskGetBootPath(BootPath, sizeof(BootPath)); /* Append a path separator if needed */ if (FileName[0] != '\\' && FileName[0] != '/') strcat(BootPath, "\\"); /* Append the remaining path */ strcat(BootPath, FileName); } /* Append a backslash if needed */ if ((strlen(BootPath) == 0) || BootPath[strlen(BootPath) - 1] != '\\') strcat(BootPath, "\\"); /* Read booting options */ if (!HasSection || !IniReadSettingByName(SectionId, "Options", BootOptions, sizeof(BootOptions))) { /* Get options after the title */ PCSTR p = SettingsValue; while (*p == ' ' || *p == '"') p++; while (*p != '\0' && *p != '"') p++; strcpy(BootOptions, p); TRACE("BootOptions: '%s'\n", BootOptions); } /* Append boot-time options */ AppendBootTimeOptions(BootOptions); /* Check if a ramdisk file was given */ File = strstr(BootOptions, "/RDPATH="); if (File) { /* Copy the file name and everything else after it */ strcpy(FileName, File + 8); /* Null-terminate */ *strstr(FileName, " ") = ANSI_NULL; /* Load the ramdisk */ if (!RamDiskLoadVirtualFile(FileName)) { UiMessageBox("Failed to load RAM disk file %s", FileName); return; } } /* Let user know we started loading */ //UiDrawStatusText("Loading..."); TRACE("BootPath: '%s'\n", BootPath); /* Allocate and minimalistic-initialize LPB */ AllocateAndInitLPB(&LoaderBlock); /* Load Hive */ UiDrawBackdrop(); UiDrawProgressBarCenter(15, 100, "Loading system hive..."); Success = WinLdrInitSystemHive(LoaderBlock, BootPath); TRACE("SYSTEM hive %s\n", (Success ? "loaded" : "not loaded")); /* Load NLS data, OEM font, and prepare boot drivers list */ Success = WinLdrScanSystemHive(LoaderBlock, BootPath); TRACE("SYSTEM hive %s\n", (Success ? "scanned" : "not scanned")); /* Finish loading */ LoadAndBootWindowsCommon(OperatingSystemVersion, LoaderBlock, BootOptions, BootPath, FALSE); }