[FREELDR][NTLDR] Move the ReactOS/NT-specific advanced boot menu to its separate file

CORE-9023

Make also the advanced boot menu depend on the operating system type.
It can be opened by pressing F8, or F5, as in the Windows' bootloader.

The FreeLoader-specific options are moved to a separate menu,
accessible via the F2 key from the main menu.

Work-in-progress: display the boot options that correspond to the
currently-selected boot entry.
This commit is contained in:
Hermès Bélusca-Maïto
2022-04-19 00:09:49 +02:00
parent 1ac657ed0e
commit 9ff4e4b9ef
12 changed files with 381 additions and 252 deletions

View File

@@ -30,6 +30,10 @@ typedef VOID
(*EDIT_OS_ENTRY_PROC)( (*EDIT_OS_ENTRY_PROC)(
_Inout_ OperatingSystemItem* OperatingSystem); _Inout_ OperatingSystemItem* OperatingSystem);
typedef VOID
(*OS_MENU_PROC)(
_Inout_ OperatingSystemItem* OperatingSystem);
static VOID static VOID
EditCustomBootReactOSSetup( EditCustomBootReactOSSetup(
_Inout_ OperatingSystemItem* OperatingSystem) _Inout_ OperatingSystemItem* OperatingSystem)
@@ -48,26 +52,26 @@ typedef struct _OS_LOADING_METHOD
{ {
PCSTR BootType; PCSTR BootType;
EDIT_OS_ENTRY_PROC EditOsEntry; EDIT_OS_ENTRY_PROC EditOsEntry;
OS_MENU_PROC OsMenu OPTIONAL;
ARC_ENTRY_POINT OsLoader; ARC_ENTRY_POINT OsLoader;
} OS_LOADING_METHOD, *POS_LOADING_METHOD; } OS_LOADING_METHOD, *POS_LOADING_METHOD;
static const OS_LOADING_METHOD static const OS_LOADING_METHOD
OSLoadingMethods[] = OSLoadingMethods[] =
{ {
{"ReactOSSetup", EditCustomBootReactOSSetup, LoadReactOSSetup},
#if defined(_M_IX86) || defined(_M_AMD64) #if defined(_M_IX86) || defined(_M_AMD64)
#ifndef UEFIBOOT #ifndef UEFIBOOT
{"BootSector", EditCustomBootSector, LoadAndBootSector}, {"BootSector", EditCustomBootSector, NULL, LoadAndBootSector},
{"Linux" , EditCustomBootLinux , LoadAndBootLinux }, {"Linux" , EditCustomBootLinux , NULL, LoadAndBootLinux },
#endif #endif
#endif #endif
#ifdef _M_IX86 #ifdef _M_IX86
{"WindowsNT40" , EditCustomBootNTOS, LoadAndBootWindows}, {"WindowsNT40" , EditCustomBootNTOS, NULL, LoadAndBootWindows},
#endif #endif
{"Windows" , EditCustomBootNTOS, LoadAndBootWindows}, {"Windows" , EditCustomBootNTOS, MenuNTOptions, LoadAndBootWindows},
{"Windows2003" , EditCustomBootNTOS, LoadAndBootWindows}, {"Windows2003" , EditCustomBootNTOS, MenuNTOptions, LoadAndBootWindows},
{"WindowsVista", EditCustomBootNTOS, LoadAndBootWindows}, {"WindowsVista", EditCustomBootNTOS, MenuNTOptions, LoadAndBootWindows},
{"ReactOSSetup", EditCustomBootReactOSSetup, MenuNTOptions, LoadReactOSSetup},
}; };
/* FUNCTIONS ******************************************************************/ /* FUNCTIONS ******************************************************************/
@@ -333,19 +337,43 @@ MainBootMenuKeyPressFilter(
IN ULONG SelectedMenuItem, IN ULONG SelectedMenuItem,
IN PVOID Context OPTIONAL) IN PVOID Context OPTIONAL)
{ {
OperatingSystemItem* OperatingSystem =
&((OperatingSystemItem*)Context)[SelectedMenuItem];
/* Any key-press cancels the global timeout */ /* Any key-press cancels the global timeout */
GetBootMgrInfo()->TimeOut = -1; GetBootMgrInfo()->TimeOut = -1;
switch (KeyPress) switch (KeyPress)
{ {
case KEY_F8: #if 0
DoOptionsMenu(&((OperatingSystemItem*)Context)[SelectedMenuItem]); /* Help */
DisplayBootTimeOptions(); case KEY_F1:
DoHelp();
return TRUE;
#endif
/* FreeLdr Setup menu */
case KEY_F2:
FreeLdrSetupMenu(OperatingSystem);
return TRUE; return TRUE;
/* Boot entry-specific advanced boot menu */
case KEY_F5:
case KEY_F8:
{
/* Find the suitable OS menu procedure and display it */
const OS_LOADING_METHOD* OSLoadingMethod =
GetOSLoadingMethod(OperatingSystem->SectionId);
if (OSLoadingMethod && OSLoadingMethod->OsMenu)
OSLoadingMethod->OsMenu(OperatingSystem);
DisplayBootTimeOptions(OperatingSystem); // TODO: Do this also elsewhere
return TRUE;
}
#ifdef HAS_OPTION_MENU_EDIT_CMDLINE #ifdef HAS_OPTION_MENU_EDIT_CMDLINE
/* Boot entry editor */
case KEY_F10: case KEY_F10:
EditOperatingSystemEntry(&((OperatingSystemItem*)Context)[SelectedMenuItem]); EditOperatingSystemEntry(OperatingSystem);
return TRUE; return TRUE;
#endif #endif
@@ -360,7 +388,6 @@ VOID RunLoader(VOID)
OperatingSystemItem* OperatingSystemList; OperatingSystemItem* OperatingSystemList;
PCSTR* OperatingSystemDisplayNames; PCSTR* OperatingSystemDisplayNames;
ULONG OperatingSystemCount; ULONG OperatingSystemCount;
ULONG DefaultOperatingSystem;
ULONG SelectedOperatingSystem; ULONG SelectedOperatingSystem;
ULONG i; ULONG i;
@@ -400,7 +427,7 @@ VOID RunLoader(VOID)
} }
OperatingSystemList = InitOperatingSystemList(&OperatingSystemCount, OperatingSystemList = InitOperatingSystemList(&OperatingSystemCount,
&DefaultOperatingSystem); &SelectedOperatingSystem);
if (!OperatingSystemList) if (!OperatingSystemList)
{ {
UiMessageBox("Unable to read operating systems section in freeldr.ini.\nPress ENTER to reboot."); UiMessageBox("Unable to read operating systems section in freeldr.ini.\nPress ENTER to reboot.");
@@ -429,14 +456,16 @@ VOID RunLoader(VOID)
{ {
/* Redraw the backdrop, but don't overwrite boot options */ /* Redraw the backdrop, but don't overwrite boot options */
UiDrawBackdrop(UiGetScreenHeight() - 2); UiDrawBackdrop(UiGetScreenHeight() - 2);
DisplayBootTimeOptions(&OperatingSystemList[SelectedOperatingSystem]);
/* Show the operating system list menu */ /* Show the operating system list menu */
if (!UiDisplayMenu("Please select the operating system to start:", if (!UiDisplayMenu("Please select the operating system to start:",
"For troubleshooting and advanced startup options for " /* The string is 80 characters long; don't make it longer! */
"ReactOS, press F8.", "Press F8 for troubleshooting and advanced startup options."
" F2: FreeLdr SETUP",
OperatingSystemDisplayNames, OperatingSystemDisplayNames,
OperatingSystemCount, OperatingSystemCount,
DefaultOperatingSystem, SelectedOperatingSystem,
GetBootMgrInfo()->TimeOut, GetBootMgrInfo()->TimeOut,
&SelectedOperatingSystem, &SelectedOperatingSystem,
FALSE, FALSE,

View File

@@ -43,6 +43,37 @@ typedef struct _ARC_DISK_SIGNATURE_EX
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/* The boot options are mutually exclusive */
enum BootOption
{
NO_OPTION = 0,
SAFEBOOT,
SAFEBOOT_NETWORK,
SAFEBOOT_ALTSHELL,
SAFEBOOT_DSREPAIR,
LKG_CONFIG,
};
#define BOOT_LOGGING (1 << 0)
#define BOOT_VGA_MODE (1 << 1)
#define BOOT_DEBUGGING (1 << 2)
extern enum BootOption BootOptionChoice;
extern LOGICAL BootFlags;
VOID
MenuNTOptions(
_Inout_ OperatingSystemItem* OperatingSystem);
VOID
AppendBootTimeOptions(
_Inout_z_bytecount_(BootOptionsSize)
PSTR BootOptions,
_In_ SIZE_T BootOptionsSize);
ARC_STATUS ARC_STATUS
LoadAndBootWindows( LoadAndBootWindows(
IN ULONG Argc, IN ULONG Argc,

View File

@@ -1,24 +1,16 @@
/* /*
* FreeLoader * PROJECT: FreeLoader
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com> * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
* * PURPOSE: FreeLoader Setup and Configuration F2 menu.
* This program is free software; you can redistribute it and/or modify * COPYRIGHT: Copyright 2022-2026 Hermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
#pragma once #pragma once
VOID DoOptionsMenu(IN OperatingSystemItem* OperatingSystem); VOID
VOID DisplayBootTimeOptions(VOID); FreeLdrSetupMenu(
VOID AppendBootTimeOptions(PCHAR BootOptions); _In_ OperatingSystemItem* OperatingSystem);
VOID
DisplayBootTimeOptions(
_In_ OperatingSystemItem* OperatingSystem);

View File

@@ -23,8 +23,9 @@
typedef struct tagOperatingSystemItem typedef struct tagOperatingSystemItem
{ {
ULONG_PTR SectionId; ULONG_PTR SectionId; //< Boot entry ID
PCSTR LoadIdentifier; PCSTR LoadIdentifier; //< Boot entry identifier
CHAR AdvBootOptsDesc[260]; //< Per-OS human-readable boot-option descriptions.
} OperatingSystemItem; } OperatingSystemItem;
OperatingSystemItem* OperatingSystemItem*

View File

@@ -64,7 +64,6 @@ BOOLEAN
GuiDisplayMenu( GuiDisplayMenu(
IN PCSTR MenuHeader, IN PCSTR MenuHeader,
IN PCSTR MenuFooter OPTIONAL, IN PCSTR MenuFooter OPTIONAL,
IN BOOLEAN ShowBootOptions,
IN PCSTR MenuItemList[], IN PCSTR MenuItemList[],
IN ULONG MenuItemCount, IN ULONG MenuItemCount,
IN ULONG DefaultMenuItem, IN ULONG DefaultMenuItem,

View File

@@ -0,0 +1,231 @@
/*
* PROJECT: NT-compatible ReactOS/Windows OS Loader
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
* PURPOSE: Advanced Boot Options F8 menu.
* COPYRIGHT: Copyright 1998-2003 Brian Palmer <brianp@sginet.com>
* Copyright 2010 Cameron Gutman <cameron.gutman@reactos.org>
* Copyright 2012-2026 Hermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
*/
/* INCLUDES *******************************************************************/
#include <freeldr.h>
/* GLOBALS ********************************************************************/
static PCSTR OptionsMenuList[] =
{
"Safe Mode",
"Safe Mode with Networking",
"Safe Mode with Command Prompt",
NULL,
"Enable Boot Logging",
"Enable VGA Mode",
"Last Known Good Configuration",
"Directory Services Restore Mode",
"Debugging Mode",
NULL,
"Start ReactOS normally",
#ifdef HAS_OPTION_MENU_EDIT_CMDLINE
"Edit Boot Command Line (F10)",
#endif
#ifdef HAS_OPTION_MENU_REBOOT
"Reboot",
#endif
};
/* Advanced NT boot options */
enum BootOption BootOptionChoice = NO_OPTION;
LOGICAL BootFlags = 0;
/* FUNCTIONS ******************************************************************/
static VOID
GetBootOptionsDescription(
_Inout_z_bytecount_(BootOptsDescSize)
PSTR BootOptsDesc,
_In_ SIZE_T BootOptsDescSize)
{
/* NOTE: Keep in sync with the 'enum BootOption'
* in winldr.h and the OptionsMenuList above. */
static const PCSTR* OptionNames[] =
{
/* NO_OPTION */ NULL,
/* SAFEBOOT */ &OptionsMenuList[0],
/* SAFEBOOT_NETWORK */ &OptionsMenuList[1],
/* SAFEBOOT_ALTSHELL */ &OptionsMenuList[2],
/* SAFEBOOT_DSREPAIR */ &OptionsMenuList[7],
/* LKG_CONFIG */ &OptionsMenuList[6],
};
if (BootOptsDescSize < sizeof(CHAR))
return;
*BootOptsDesc = ANSI_NULL;
ASSERT(BootOptionChoice < RTL_NUMBER_OF(OptionNames));
if (BootOptionChoice != NO_OPTION) // && BootOptionChoice < RTL_NUMBER_OF(OptionNames)
RtlStringCbCatA(BootOptsDesc, BootOptsDescSize, *OptionNames[BootOptionChoice]);
if (BootFlags & BOOT_LOGGING)
{
/* Since these safe mode options come by default with boot logging,
* don't show "Boot Logging" when one of these is selected;
* instead just show the corresponding safe mode option name. */
if ( (BootOptionChoice != SAFEBOOT) &&
(BootOptionChoice != SAFEBOOT_NETWORK) &&
(BootOptionChoice != SAFEBOOT_ALTSHELL) )
{
if (*BootOptsDesc)
RtlStringCbCatA(BootOptsDesc, BootOptsDescSize, ", ");
RtlStringCbCatA(BootOptsDesc, BootOptsDescSize, OptionsMenuList[4]);
}
}
if (BootFlags & BOOT_VGA_MODE)
{
if (*BootOptsDesc)
RtlStringCbCatA(BootOptsDesc, BootOptsDescSize, ", ");
RtlStringCbCatA(BootOptsDesc, BootOptsDescSize, OptionsMenuList[5]);
}
if (BootFlags & BOOT_DEBUGGING)
{
if (*BootOptsDesc)
RtlStringCbCatA(BootOptsDesc, BootOptsDescSize, ", ");
RtlStringCbCatA(BootOptsDesc, BootOptsDescSize, OptionsMenuList[8]);
}
}
VOID
MenuNTOptions(
_Inout_ OperatingSystemItem* OperatingSystem)
{
ULONG SelectedMenuItem;
/* Redraw the backdrop, but don't overwrite boot options */
UiDrawBackdrop(UiGetScreenHeight() - 2);
DisplayBootTimeOptions(OperatingSystem);
if (!UiDisplayMenu("Please select an option:",
NULL,
OptionsMenuList,
RTL_NUMBER_OF(OptionsMenuList),
10, // Use "Start ReactOS normally" as default; see the switch below.
-1,
&SelectedMenuItem,
TRUE,
NULL, NULL))
{
/* The user pressed ESC */
return;
}
switch (SelectedMenuItem)
{
case 0: // Safe Mode
BootOptionChoice = SAFEBOOT;
BootFlags |= BOOT_LOGGING;
break;
case 1: // Safe Mode with Networking
BootOptionChoice = SAFEBOOT_NETWORK;
BootFlags |= BOOT_LOGGING;
break;
case 2: // Safe Mode with Command Prompt
BootOptionChoice = SAFEBOOT_ALTSHELL;
BootFlags |= BOOT_LOGGING;
break;
// case 3: // Separator
// break;
case 4: // Enable Boot Logging
BootFlags |= BOOT_LOGGING;
break;
case 5: // Enable VGA Mode
BootFlags |= BOOT_VGA_MODE;
break;
case 6: // Last Known Good Configuration
BootOptionChoice = LKG_CONFIG;
break;
case 7: // Directory Services Restore Mode
BootOptionChoice = SAFEBOOT_DSREPAIR;
break;
case 8: // Debugging Mode
BootFlags |= BOOT_DEBUGGING;
break;
// case 9: // Separator
// break;
case 10: // Start ReactOS normally
// Reset all the parameters to their default values.
BootOptionChoice = NO_OPTION;
BootFlags = 0;
break;
#ifdef HAS_OPTION_MENU_EDIT_CMDLINE
case 11: // Edit command line
EditOperatingSystemEntry(OperatingSystem);
break;
#endif
#ifdef HAS_OPTION_MENU_REBOOT
case 12: // Reboot
OptionMenuReboot();
break;
#endif
}
/* Update the human-readable boot-option description string */
GetBootOptionsDescription(OperatingSystem->AdvBootOptsDesc,
sizeof(OperatingSystem->AdvBootOptsDesc));
}
VOID
AppendBootTimeOptions(
_Inout_z_bytecount_(BootOptionsSize)
PSTR BootOptions,
_In_ SIZE_T BootOptionsSize)
{
/* NOTE: Keep in sync with the 'enum BootOption' in winldr.h */
static const PCSTR OptionsStr[] =
{
/* NO_OPTION */ NULL,
/* SAFEBOOT */ "SAFEBOOT:MINIMAL SOS NOGUIBOOT",
/* SAFEBOOT_NETWORK */ "SAFEBOOT:NETWORK SOS NOGUIBOOT",
/* SAFEBOOT_ALTSHELL */ "SAFEBOOT:MINIMAL(ALTERNATESHELL) SOS NOGUIBOOT",
/* SAFEBOOT_DSREPAIR */ "SAFEBOOT:DSREPAIR SOS",
/* LKG_CONFIG */ NULL,
};
if (BootOptionsSize < sizeof(CHAR))
return;
switch (BootOptionChoice)
{
case SAFEBOOT:
case SAFEBOOT_NETWORK:
case SAFEBOOT_ALTSHELL:
case SAFEBOOT_DSREPAIR:
{
ASSERT(BootOptionChoice < RTL_NUMBER_OF(OptionsStr));
NtLdrAddOptions(BootOptions, BootOptionsSize, TRUE, OptionsStr[BootOptionChoice]);
break;
}
case LKG_CONFIG:
DbgPrint("Last known good configuration is not supported yet!\n");
break;
default:
break;
}
if (BootFlags & BOOT_LOGGING)
NtLdrAddOptions(BootOptions, BootOptionsSize, TRUE, "BOOTLOG");
if (BootFlags & BOOT_VGA_MODE)
NtLdrAddOptions(BootOptions, BootOptionsSize, TRUE, "BASEVIDEO");
if (BootFlags & BOOT_DEBUGGING)
NtLdrAddOptions(BootOptions, BootOptionsSize, TRUE, "DEBUG");
}

View File

@@ -777,7 +777,7 @@ LoadReactOSSetup(
} }
/* Append boot-time options */ /* Append boot-time options */
AppendBootTimeOptions(UserBootOptions); AppendBootTimeOptions(UserBootOptions, sizeof(UserBootOptions));
/* Post-process the boot options */ /* Post-process the boot options */
NtLdrNormalizeOptions(UserBootOptions); NtLdrNormalizeOptions(UserBootOptions);

View File

@@ -1299,7 +1299,7 @@ LoadAndBootWindows(
} }
/* Append boot-time options */ /* Append boot-time options */
AppendBootTimeOptions(BootOptions); AppendBootTimeOptions(BootOptions, sizeof(BootOptions));
/* Post-process the boot options */ /* Post-process the boot options */
NtLdrNormalizeOptions(BootOptions); NtLdrNormalizeOptions(BootOptions);

View File

@@ -1,47 +1,25 @@
/* /*
* FreeLoader * PROJECT: FreeLoader
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com> * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
* * PURPOSE: FreeLoader Setup and Configuration F2 menu.
* This program is free software; you can redistribute it and/or modify * COPYRIGHT: Copyright 1998-2003 Brian Palmer <brianp@sginet.com>
* it under the terms of the GNU General Public License as published by * Copyright 2012 Giannis Adamopoulos <gadamopoulos@reactos.org>
* the Free Software Foundation; either version 2 of the License, or * Copyright 2022-2026 Hermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
/* INCLUDES *******************************************************************/ /* INCLUDES *******************************************************************/
#include <freeldr.h> #include <freeldr.h>
#include <debug.h> #include <debug.h> // For DbgParseDebugChannels()
/* GLOBALS ********************************************************************/ /* GLOBALS ********************************************************************/
PCSTR OptionsMenuList[] = static PCSTR OptionsMenuList[] =
{ {
"Safe Mode",
"Safe Mode with Networking",
"Safe Mode with Command Prompt",
NULL,
"Enable Boot Logging",
"Enable VGA Mode",
"Last Known Good Configuration",
"Directory Services Restore Mode",
"Debugging Mode",
"FreeLdr debugging", "FreeLdr debugging",
NULL, NULL,
"Start ReactOS normally",
#ifdef HAS_OPTION_MENU_EDIT_CMDLINE #ifdef HAS_OPTION_MENU_EDIT_CMDLINE
"Edit Boot Command Line (F10)", "Edit Boot Command Line (F10)",
#endif #endif
@@ -53,52 +31,39 @@ PCSTR OptionsMenuList[] =
#endif #endif
}; };
const static PCSTR FrldrDbgMsg =
PCSTR FrldrDbgMsg = "Enable FreeLdr debug channels\n" "Enable FreeLdr debug channels\n"
"Acceptable syntax: [level1]#channel1[,[level2]#channel2]\n" "Acceptable syntax: [level1]#channel1[,[level2]#channel2]\n"
"level can be one of: trace,warn,fixme,err\n" "level can be one of: trace,warn,fixme,err\n"
" if the level is omitted all levels\n" " if the level is omitted all levels\n"
" are enabled for the specified channel\n" " are enabled for the specified channel\n"
"# can be either + or -\n" "# can be either + or -\n"
"channel can be one of the following:\n" "channel can be one of the following:\n"
" all,warning,memory,filesystem,inifile,ui,disk,cache,registry,\n" " all,warning,memory,filesystem,inifile,ui,disk,cache,registry,\n"
" reactos,linux,hwdetect,windows,peloader,scsiport,heap\n" " reactos,linux,hwdetect,windows,peloader,scsiport,heap\n"
"Examples:\n" "Examples:\n"
" trace+windows,trace+reactos\n" " trace+windows,trace+reactos\n"
" +hwdetect,err-disk\n" " +hwdetect,err-disk\n"
" +peloader\n" " +peloader\n"
"NOTE: all letters must be lowercase, no spaces allowed."; "NOTE: all letters must be lowercase, no spaces allowed.";
/* The boot options are mutually exclusive */
enum BootOption
{
NO_OPTION = 0,
SAFE_MODE,
SAFE_MODE_WITH_NETWORKING,
SAFE_MODE_WITH_COMMAND_PROMPT,
LAST_KNOWN_GOOD_CONFIGURATION,
DIRECTORY_SERVICES_RESTORE_MODE,
};
static enum BootOption BootOptionChoice = NO_OPTION;
static BOOLEAN BootLogging = FALSE;
static BOOLEAN VgaMode = FALSE;
static BOOLEAN DebuggingMode = FALSE;
/* FUNCTIONS ******************************************************************/ /* FUNCTIONS ******************************************************************/
VOID DoOptionsMenu(IN OperatingSystemItem* OperatingSystem) VOID
FreeLdrSetupMenu(
_In_ OperatingSystemItem* OperatingSystem)
{ {
ULONG SelectedMenuItem; ULONG SelectedMenuItem = 0;
CHAR DebugChannelString[100];
if (!UiDisplayMenu("Select an option:", NULL, doMenu:
/* Clear the backdrop */
UiDrawBackdrop(UiGetScreenHeight());
if (!UiDisplayMenu(VERSION " Setup and Configuration",
NULL,
OptionsMenuList, OptionsMenuList,
sizeof(OptionsMenuList) / sizeof(OptionsMenuList[0]), RTL_NUMBER_OF(OptionsMenuList),
11, // Use "Start ReactOS normally" as default; see the switch below. SelectedMenuItem, -1,
-1,
&SelectedMenuItem, &SelectedMenuItem,
TRUE, TRUE,
NULL, NULL)) NULL, NULL))
@@ -107,174 +72,54 @@ VOID DoOptionsMenu(IN OperatingSystemItem* OperatingSystem)
return; return;
} }
/* Clear the backdrop */
UiDrawBackdrop(UiGetScreenHeight());
switch (SelectedMenuItem) switch (SelectedMenuItem)
{ {
case 0: // Safe Mode case 0: // FreeLdr debugging
BootOptionChoice = SAFE_MODE; {
BootLogging = TRUE; CHAR DebugChannelString[100] = "";
break; // DebugChannelString[0] = ANSI_NULL;
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, if (UiEditBox(FrldrDbgMsg,
DebugChannelString, DebugChannelString,
sizeof(DebugChannelString) / sizeof(DebugChannelString[0]))) RTL_NUMBER_OF(DebugChannelString)))
{ {
DbgParseDebugChannels(DebugChannelString); DbgParseDebugChannels(DebugChannelString);
} }
break; break;
// case 10: // Separator }
// case 1: // Separator
// break; // 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_EDIT_CMDLINE #ifdef HAS_OPTION_MENU_EDIT_CMDLINE
case 12: // Edit command line case 2: // Edit command line
EditOperatingSystemEntry(OperatingSystem); EditOperatingSystemEntry(OperatingSystem);
break; break;
#endif #endif
#ifdef HAS_OPTION_MENU_CUSTOM_BOOT #ifdef HAS_OPTION_MENU_CUSTOM_BOOT
case 13: // Custom Boot case 3: // Custom Boot
OptionMenuCustomBoot(); OptionMenuCustomBoot();
break; break;
#endif #endif
#ifdef HAS_OPTION_MENU_REBOOT #ifdef HAS_OPTION_MENU_REBOOT
case 14: // Reboot case 4: // Reboot
OptionMenuReboot(); OptionMenuReboot();
break; break;
#endif #endif
} }
goto doMenu;
} }
VOID DisplayBootTimeOptions(VOID) /*
* Display selected human-readable boot-option descriptions at the bottom of the screen.
*/
VOID
DisplayBootTimeOptions(
_In_ OperatingSystemItem* OperatingSystem)
{ {
CHAR BootOptions[260]; if (!OperatingSystem->AdvBootOptsDesc[0])
return;
switch (BootOptionChoice)
{
case SAFE_MODE:
strcpy(BootOptions, OptionsMenuList[0]);
break;
case SAFE_MODE_WITH_NETWORKING:
strcpy(BootOptions, OptionsMenuList[1]);
break;
case SAFE_MODE_WITH_COMMAND_PROMPT:
strcpy(BootOptions, OptionsMenuList[2]);
break;
case LAST_KNOWN_GOOD_CONFIGURATION:
strcpy(BootOptions, OptionsMenuList[6]);
break;
case DIRECTORY_SERVICES_RESTORE_MODE:
strcpy(BootOptions, OptionsMenuList[7]);
break;
default:
BootOptions[0] = ANSI_NULL;
break;
}
if (BootLogging)
{
if ( (BootOptionChoice != SAFE_MODE) &&
(BootOptionChoice != SAFE_MODE_WITH_NETWORKING) &&
(BootOptionChoice != SAFE_MODE_WITH_COMMAND_PROMPT) )
{
if (BootOptions[0] != ANSI_NULL)
strcat(BootOptions, ", ");
strcat(BootOptions, OptionsMenuList[4]);
}
}
if (VgaMode)
{
if (BootOptions[0] != ANSI_NULL)
strcat(BootOptions, ", ");
strcat(BootOptions, OptionsMenuList[5]);
}
if (DebuggingMode)
{
if (BootOptions[0] != ANSI_NULL)
strcat(BootOptions, ", ");
strcat(BootOptions, OptionsMenuList[8]);
}
/* Display the chosen boot options */ /* Display the chosen boot options */
UiDrawText(0, UiDrawText(0,
UiGetScreenHeight() - 2, UiGetScreenHeight() - 2,
BootOptions, OperatingSystem->AdvBootOptsDesc,
ATTR(COLOR_LIGHTBLUE, UiGetMenuBgColor())); ATTR(COLOR_LIGHTBLUE, UiGetMenuBgColor()));
} }
VOID AppendBootTimeOptions(PCHAR BootOptions)
{
switch (BootOptionChoice)
{
case SAFE_MODE:
strcat(BootOptions, " /SAFEBOOT:MINIMAL /SOS /NOGUIBOOT");
break;
case SAFE_MODE_WITH_NETWORKING:
strcat(BootOptions, " /SAFEBOOT:NETWORK /SOS /NOGUIBOOT");
break;
case SAFE_MODE_WITH_COMMAND_PROMPT:
strcat(BootOptions, " /SAFEBOOT:MINIMAL(ALTERNATESHELL) /SOS /NOGUIBOOT");
break;
case LAST_KNOWN_GOOD_CONFIGURATION:
DbgPrint("Last known good configuration is not supported yet!\n");
break;
case DIRECTORY_SERVICES_RESTORE_MODE:
strcat(BootOptions, " /SAFEBOOT:DSREPAIR /SOS");
break;
default:
break;
}
if (BootLogging)
strcat(BootOptions, " /BOOTLOG");
if (VgaMode)
strcat(BootOptions, " /BASEVIDEO");
if (DebuggingMode)
strcat(BootOptions, " /DEBUG");
}

View File

@@ -18,6 +18,7 @@ list(APPEND ROSLOAD_SOURCE
lib/rtl/libsupp.c lib/rtl/libsupp.c
${REACTOS_SOURCE_DIR}/ntoskrnl/config/cmboot.c ${REACTOS_SOURCE_DIR}/ntoskrnl/config/cmboot.c
${REACTOS_SOURCE_DIR}/ntoskrnl/ke/config.c ${REACTOS_SOURCE_DIR}/ntoskrnl/ke/config.c
ntldr/advopts.c
ntldr/conversion.c ntldr/conversion.c
ntldr/headless.c ntldr/headless.c
ntldr/inffile.c ntldr/inffile.c

View File

@@ -56,6 +56,7 @@ add_asm_files(uefifreeldr_common_asm ${FREELDR_COMMON_ASM_SOURCE} ${UEFILDR_COMM
list(APPEND FREELDR_NTLDR_SOURCE list(APPEND FREELDR_NTLDR_SOURCE
${REACTOS_SOURCE_DIR}/ntoskrnl/config/cmboot.c ${REACTOS_SOURCE_DIR}/ntoskrnl/config/cmboot.c
${REACTOS_SOURCE_DIR}/ntoskrnl/ke/config.c ${REACTOS_SOURCE_DIR}/ntoskrnl/ke/config.c
ntldr/advopts.c
ntldr/conversion.c ntldr/conversion.c
ntldr/headless.c ntldr/headless.c
ntldr/inffile.c ntldr/inffile.c

View File

@@ -150,7 +150,6 @@ UiDisplayMenu(
{ {
return TuiDisplayMenu(MenuHeader, return TuiDisplayMenu(MenuHeader,
MenuFooter, MenuFooter,
ShowBootOptions,
MenuItemList, MenuItemList,
MenuItemCount, MenuItemCount,
DefaultMenuItem, DefaultMenuItem,