VOID DoOptionsMenu(VOID) { ULONG SelectedMenuItem; if (!UiDisplayMenu(OptionsMenuList, OptionsMenuItemCount, 0, -1, &SelectedMenuItem, TRUE, NULL)) { // The user pressed ESC return; } // Clear the backdrop UiDrawBackdrop(); switch (SelectedMenuItem) { case SAFE_MODE: SafeMode = TRUE; BootLogging = TRUE; break; case SAFE_MODE_WITH_NETWORKING: SafeModeWithNetworking = TRUE; BootLogging = TRUE; break; case SAFE_MODE_WITH_COMMAND_PROMPT: SafeModeWithCommandPrompt = TRUE; BootLogging = TRUE; break; //case SEPARATOR1: // break; case ENABLE_BOOT_LOGGING: BootLogging = TRUE; break; case ENABLE_VGA_MODE: VgaMode = TRUE; break; case LAST_KNOWN_GOOD_CONFIGURATION: LastKnownGoodConfiguration = TRUE; break; case DIRECTORY_SERVICES_RESTORE_MODE: DirectoryServicesRepairMode = TRUE; break; case DEBUGGING_MODE: DebuggingMode = TRUE; break; case BOOT_NORMALLY: break; //case SEPARATOR2: // break; #ifdef HAS_OPTION_MENU_CUSTOM_BOOT case CUSTOM_BOOT: OptionMenuCustomBoot(); break; #endif #ifdef HAS_OPTION_MENU_REBOOT case REBOOT: OptionMenuReboot(); break; #endif } }
VOID OptionMenuCustomBoot(VOID) { PCSTR CustomBootMenuList[] = { #ifdef _M_IX86 "Disk", "Partition", "Boot Sector File", "Linux", #endif "ReactOS" }; ULONG SelectedMenuItem; if (!UiDisplayMenu("Please choose a boot method:", "", FALSE, CustomBootMenuList, sizeof(CustomBootMenuList) / sizeof(CustomBootMenuList[0]), 0, -1, &SelectedMenuItem, TRUE, NULL)) { /* The user pressed ESC */ return; } switch (SelectedMenuItem) { #ifdef _M_IX86 case 0: // Disk OptionMenuCustomBootDisk(); break; case 1: // Partition OptionMenuCustomBootPartition(); break; case 2: // Boot Sector File OptionMenuCustomBootBootSectorFile(); break; case 3: // Linux OptionMenuCustomBootLinux(); break; case 4: // ReactOS #else case 0: #endif OptionMenuCustomBootReactOS(); break; } }
VOID OptionMenuCustomBoot(VOID) { PCSTR CustomBootMenuList[] = { "Disk", "Partition", "Boot Sector File", "ReactOS", "Linux" }; ULONG CustomBootMenuCount = sizeof(CustomBootMenuList) / sizeof(CustomBootMenuList[0]); ULONG SelectedMenuItem; if (!UiDisplayMenu("Please choose a boot method:", "", FALSE, CustomBootMenuList, CustomBootMenuCount, 0, -1, &SelectedMenuItem, TRUE, NULL)) { // The user pressed ESC return; } switch (SelectedMenuItem) { case 0: // Disk OptionMenuCustomBootDisk(); break; case 1: // Partition OptionMenuCustomBootPartition(); break; case 2: // Boot Sector File OptionMenuCustomBootBootSectorFile(); break; case 3: // ReactOS OptionMenuCustomBootReactOS(); break; case 4: // Linux OptionMenuCustomBootLinux(); break; } }
VOID DoOptionsMenu(VOID) { ULONG SelectedMenuItem; CHAR DebugChannelString[100]; if (!UiDisplayMenu("Select an option:", "", TRUE, OptionsMenuList, OptionsMenuItemCount, 11, // Use "Start ReactOS normally" as default; see the switch below. -1, &SelectedMenuItem, TRUE, NULL)) { /* The user pressed ESC */ return; } /* Clear the backdrop */ UiDrawBackdrop(); switch (SelectedMenuItem) { case 0: // Safe Mode BootOptionChoice = SAFE_MODE; BootLogging = TRUE; break; case 1: // Safe Mode with Networking BootOptionChoice = SAFE_MODE_WITH_NETWORKING; BootLogging = TRUE; break; case 2: // Safe Mode with Command Prompt BootOptionChoice = SAFE_MODE_WITH_COMMAND_PROMPT; BootLogging = TRUE; break; // case 3: // Separator // break; case 4: // Enable Boot Logging BootLogging = TRUE; break; case 5: // Enable VGA Mode VgaMode = TRUE; break; case 6: // Last Known Good Configuration BootOptionChoice = LAST_KNOWN_GOOD_CONFIGURATION; break; case 7: // Directory Services Restore Mode BootOptionChoice = DIRECTORY_SERVICES_RESTORE_MODE; break; case 8: // Debugging Mode DebuggingMode = TRUE; break; case 9: // FreeLdr debugging DebugChannelString[0] = 0; if (UiEditBox(FrldrDbgMsg, DebugChannelString, sizeof(DebugChannelString) / sizeof(DebugChannelString[0]))) { DbgParseDebugChannels(DebugChannelString); } break; // case 10: // Separator // break; case 11: // Start ReactOS normally // Reset all the parameters to their default values. BootOptionChoice = NO_OPTION; BootLogging = FALSE; VgaMode = FALSE; DebuggingMode = FALSE; break; #ifdef HAS_OPTION_MENU_CUSTOM_BOOT case 12: // Custom Boot OptionMenuCustomBoot(); break; #endif #ifdef HAS_OPTION_MENU_REBOOT case 13: // Reboot OptionMenuReboot(); break; #endif } }
VOID RunLoader(VOID) { ULONG_PTR SectionId; ULONG OperatingSystemCount; OperatingSystemItem* OperatingSystemList; PCSTR* OperatingSystemDisplayNames; ULONG DefaultOperatingSystem; LONG TimeOut; ULONG SelectedOperatingSystem; ULONG i; if (!MachInitializeBootDevices()) { UiMessageBoxCritical("Error when detecting hardware."); return; } #ifdef _M_IX86 /* Load additional SCSI driver (if any) */ if (LoadBootDeviceDriver() != ESUCCESS) { UiMessageBoxCritical("Unable to load additional boot device drivers."); } #endif if (!IniFileInitialize()) { UiMessageBoxCritical("Error initializing .ini file."); return; } /* Debugger main initialization */ DebugInit(TRUE); if (!IniOpenSection("FreeLoader", &SectionId)) { UiMessageBoxCritical("Section [FreeLoader] not found in freeldr.ini."); return; } TimeOut = GetTimeOut(); /* UI main initialization */ if (!UiInitialize(TRUE)) { UiMessageBoxCritical("Unable to initialize UI."); return; } OperatingSystemList = InitOperatingSystemList(&OperatingSystemCount); if (!OperatingSystemList) { UiMessageBox("Unable to read operating systems section in freeldr.ini.\nPress ENTER to reboot."); goto Reboot; } if (OperatingSystemCount == 0) { UiMessageBox("There were no operating systems listed in freeldr.ini.\nPress ENTER to reboot."); goto Reboot; } DefaultOperatingSystem = GetDefaultOperatingSystem(OperatingSystemList, OperatingSystemCount); /* Create list of display names */ OperatingSystemDisplayNames = FrLdrTempAlloc(sizeof(PCSTR) * OperatingSystemCount, 'mNSO'); if (!OperatingSystemDisplayNames) goto Reboot; for (i = 0; i < OperatingSystemCount; i++) { OperatingSystemDisplayNames[i] = OperatingSystemList[i].LoadIdentifier; } /* Find all the message box settings and run them */ UiShowMessageBoxesInSection("FreeLoader"); for (;;) { /* Redraw the backdrop */ UiDrawBackdrop(); /* Show the operating system list menu */ if (!UiDisplayMenu("Please select the operating system to start:", "For troubleshooting and advanced startup options for " "ReactOS, press F8.", TRUE, OperatingSystemDisplayNames, OperatingSystemCount, DefaultOperatingSystem, TimeOut, &SelectedOperatingSystem, FALSE, MainBootMenuKeyPressFilter)) { UiMessageBox("Press ENTER to reboot."); goto Reboot; } TimeOut = -1; /* Load the chosen operating system */ LoadOperatingSystem(&OperatingSystemList[SelectedOperatingSystem]); } Reboot: UiUnInitialize("Rebooting..."); return; }