mirror of
https://github.com/reactos/reactos.git
synced 2026-05-24 16:20:07 +08:00
[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:
@@ -30,6 +30,10 @@ typedef VOID
|
||||
(*EDIT_OS_ENTRY_PROC)(
|
||||
_Inout_ OperatingSystemItem* OperatingSystem);
|
||||
|
||||
typedef VOID
|
||||
(*OS_MENU_PROC)(
|
||||
_Inout_ OperatingSystemItem* OperatingSystem);
|
||||
|
||||
static VOID
|
||||
EditCustomBootReactOSSetup(
|
||||
_Inout_ OperatingSystemItem* OperatingSystem)
|
||||
@@ -48,26 +52,26 @@ typedef struct _OS_LOADING_METHOD
|
||||
{
|
||||
PCSTR BootType;
|
||||
EDIT_OS_ENTRY_PROC EditOsEntry;
|
||||
OS_MENU_PROC OsMenu OPTIONAL;
|
||||
ARC_ENTRY_POINT OsLoader;
|
||||
} OS_LOADING_METHOD, *POS_LOADING_METHOD;
|
||||
|
||||
static const OS_LOADING_METHOD
|
||||
OSLoadingMethods[] =
|
||||
{
|
||||
{"ReactOSSetup", EditCustomBootReactOSSetup, LoadReactOSSetup},
|
||||
|
||||
#if defined(_M_IX86) || defined(_M_AMD64)
|
||||
#ifndef UEFIBOOT
|
||||
{"BootSector", EditCustomBootSector, LoadAndBootSector},
|
||||
{"Linux" , EditCustomBootLinux , LoadAndBootLinux },
|
||||
{"BootSector", EditCustomBootSector, NULL, LoadAndBootSector},
|
||||
{"Linux" , EditCustomBootLinux , NULL, LoadAndBootLinux },
|
||||
#endif
|
||||
#endif
|
||||
#ifdef _M_IX86
|
||||
{"WindowsNT40" , EditCustomBootNTOS, LoadAndBootWindows},
|
||||
{"WindowsNT40" , EditCustomBootNTOS, NULL, LoadAndBootWindows},
|
||||
#endif
|
||||
{"Windows" , EditCustomBootNTOS, LoadAndBootWindows},
|
||||
{"Windows2003" , EditCustomBootNTOS, LoadAndBootWindows},
|
||||
{"WindowsVista", EditCustomBootNTOS, LoadAndBootWindows},
|
||||
{"Windows" , EditCustomBootNTOS, MenuNTOptions, LoadAndBootWindows},
|
||||
{"Windows2003" , EditCustomBootNTOS, MenuNTOptions, LoadAndBootWindows},
|
||||
{"WindowsVista", EditCustomBootNTOS, MenuNTOptions, LoadAndBootWindows},
|
||||
{"ReactOSSetup", EditCustomBootReactOSSetup, MenuNTOptions, LoadReactOSSetup},
|
||||
};
|
||||
|
||||
/* FUNCTIONS ******************************************************************/
|
||||
@@ -333,19 +337,43 @@ MainBootMenuKeyPressFilter(
|
||||
IN ULONG SelectedMenuItem,
|
||||
IN PVOID Context OPTIONAL)
|
||||
{
|
||||
OperatingSystemItem* OperatingSystem =
|
||||
&((OperatingSystemItem*)Context)[SelectedMenuItem];
|
||||
|
||||
/* Any key-press cancels the global timeout */
|
||||
GetBootMgrInfo()->TimeOut = -1;
|
||||
|
||||
switch (KeyPress)
|
||||
{
|
||||
case KEY_F8:
|
||||
DoOptionsMenu(&((OperatingSystemItem*)Context)[SelectedMenuItem]);
|
||||
DisplayBootTimeOptions();
|
||||
#if 0
|
||||
/* Help */
|
||||
case KEY_F1:
|
||||
DoHelp();
|
||||
return TRUE;
|
||||
#endif
|
||||
|
||||
/* FreeLdr Setup menu */
|
||||
case KEY_F2:
|
||||
FreeLdrSetupMenu(OperatingSystem);
|
||||
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
|
||||
/* Boot entry editor */
|
||||
case KEY_F10:
|
||||
EditOperatingSystemEntry(&((OperatingSystemItem*)Context)[SelectedMenuItem]);
|
||||
EditOperatingSystemEntry(OperatingSystem);
|
||||
return TRUE;
|
||||
#endif
|
||||
|
||||
@@ -360,7 +388,6 @@ VOID RunLoader(VOID)
|
||||
OperatingSystemItem* OperatingSystemList;
|
||||
PCSTR* OperatingSystemDisplayNames;
|
||||
ULONG OperatingSystemCount;
|
||||
ULONG DefaultOperatingSystem;
|
||||
ULONG SelectedOperatingSystem;
|
||||
ULONG i;
|
||||
|
||||
@@ -400,7 +427,7 @@ VOID RunLoader(VOID)
|
||||
}
|
||||
|
||||
OperatingSystemList = InitOperatingSystemList(&OperatingSystemCount,
|
||||
&DefaultOperatingSystem);
|
||||
&SelectedOperatingSystem);
|
||||
if (!OperatingSystemList)
|
||||
{
|
||||
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 */
|
||||
UiDrawBackdrop(UiGetScreenHeight() - 2);
|
||||
DisplayBootTimeOptions(&OperatingSystemList[SelectedOperatingSystem]);
|
||||
|
||||
/* 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.",
|
||||
/* The string is 80 characters long; don't make it longer! */
|
||||
"Press F8 for troubleshooting and advanced startup options."
|
||||
" F2: FreeLdr SETUP",
|
||||
OperatingSystemDisplayNames,
|
||||
OperatingSystemCount,
|
||||
DefaultOperatingSystem,
|
||||
SelectedOperatingSystem,
|
||||
GetBootMgrInfo()->TimeOut,
|
||||
&SelectedOperatingSystem,
|
||||
FALSE,
|
||||
|
||||
@@ -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
|
||||
LoadAndBootWindows(
|
||||
IN ULONG Argc,
|
||||
|
||||
@@ -1,24 +1,16 @@
|
||||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* 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.
|
||||
* PROJECT: FreeLoader
|
||||
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
|
||||
* PURPOSE: FreeLoader Setup and Configuration F2 menu.
|
||||
* COPYRIGHT: Copyright 2022-2026 Hermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
VOID DoOptionsMenu(IN OperatingSystemItem* OperatingSystem);
|
||||
VOID DisplayBootTimeOptions(VOID);
|
||||
VOID AppendBootTimeOptions(PCHAR BootOptions);
|
||||
VOID
|
||||
FreeLdrSetupMenu(
|
||||
_In_ OperatingSystemItem* OperatingSystem);
|
||||
|
||||
VOID
|
||||
DisplayBootTimeOptions(
|
||||
_In_ OperatingSystemItem* OperatingSystem);
|
||||
|
||||
@@ -23,8 +23,9 @@
|
||||
|
||||
typedef struct tagOperatingSystemItem
|
||||
{
|
||||
ULONG_PTR SectionId;
|
||||
PCSTR LoadIdentifier;
|
||||
ULONG_PTR SectionId; //< Boot entry ID
|
||||
PCSTR LoadIdentifier; //< Boot entry identifier
|
||||
CHAR AdvBootOptsDesc[260]; //< Per-OS human-readable boot-option descriptions.
|
||||
} OperatingSystemItem;
|
||||
|
||||
OperatingSystemItem*
|
||||
|
||||
@@ -64,7 +64,6 @@ BOOLEAN
|
||||
GuiDisplayMenu(
|
||||
IN PCSTR MenuHeader,
|
||||
IN PCSTR MenuFooter OPTIONAL,
|
||||
IN BOOLEAN ShowBootOptions,
|
||||
IN PCSTR MenuItemList[],
|
||||
IN ULONG MenuItemCount,
|
||||
IN ULONG DefaultMenuItem,
|
||||
|
||||
231
boot/freeldr/freeldr/ntldr/advopts.c
Normal file
231
boot/freeldr/freeldr/ntldr/advopts.c
Normal 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");
|
||||
}
|
||||
@@ -777,7 +777,7 @@ LoadReactOSSetup(
|
||||
}
|
||||
|
||||
/* Append boot-time options */
|
||||
AppendBootTimeOptions(UserBootOptions);
|
||||
AppendBootTimeOptions(UserBootOptions, sizeof(UserBootOptions));
|
||||
|
||||
/* Post-process the boot options */
|
||||
NtLdrNormalizeOptions(UserBootOptions);
|
||||
|
||||
@@ -1299,7 +1299,7 @@ LoadAndBootWindows(
|
||||
}
|
||||
|
||||
/* Append boot-time options */
|
||||
AppendBootTimeOptions(BootOptions);
|
||||
AppendBootTimeOptions(BootOptions, sizeof(BootOptions));
|
||||
|
||||
/* Post-process the boot options */
|
||||
NtLdrNormalizeOptions(BootOptions);
|
||||
|
||||
@@ -1,47 +1,25 @@
|
||||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* 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.
|
||||
* PROJECT: FreeLoader
|
||||
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
|
||||
* PURPOSE: FreeLoader Setup and Configuration F2 menu.
|
||||
* COPYRIGHT: Copyright 1998-2003 Brian Palmer <brianp@sginet.com>
|
||||
* Copyright 2012 Giannis Adamopoulos <gadamopoulos@reactos.org>
|
||||
* Copyright 2022-2026 Hermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
|
||||
*/
|
||||
|
||||
/* INCLUDES *******************************************************************/
|
||||
|
||||
#include <freeldr.h>
|
||||
#include <debug.h>
|
||||
#include <debug.h> // For DbgParseDebugChannels()
|
||||
|
||||
/* 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",
|
||||
|
||||
NULL,
|
||||
|
||||
"Start ReactOS normally",
|
||||
#ifdef HAS_OPTION_MENU_EDIT_CMDLINE
|
||||
"Edit Boot Command Line (F10)",
|
||||
#endif
|
||||
@@ -53,52 +31,39 @@ PCSTR OptionsMenuList[] =
|
||||
#endif
|
||||
};
|
||||
|
||||
const
|
||||
PCSTR FrldrDbgMsg = "Enable FreeLdr debug channels\n"
|
||||
"Acceptable syntax: [level1]#channel1[,[level2]#channel2]\n"
|
||||
"level can be one of: trace,warn,fixme,err\n"
|
||||
" if the level is omitted all levels\n"
|
||||
" are enabled for the specified channel\n"
|
||||
"# can be either + or -\n"
|
||||
"channel can be one of the following:\n"
|
||||
" all,warning,memory,filesystem,inifile,ui,disk,cache,registry,\n"
|
||||
" reactos,linux,hwdetect,windows,peloader,scsiport,heap\n"
|
||||
"Examples:\n"
|
||||
" trace+windows,trace+reactos\n"
|
||||
" +hwdetect,err-disk\n"
|
||||
" +peloader\n"
|
||||
"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;
|
||||
static PCSTR FrldrDbgMsg =
|
||||
"Enable FreeLdr debug channels\n"
|
||||
"Acceptable syntax: [level1]#channel1[,[level2]#channel2]\n"
|
||||
"level can be one of: trace,warn,fixme,err\n"
|
||||
" if the level is omitted all levels\n"
|
||||
" are enabled for the specified channel\n"
|
||||
"# can be either + or -\n"
|
||||
"channel can be one of the following:\n"
|
||||
" all,warning,memory,filesystem,inifile,ui,disk,cache,registry,\n"
|
||||
" reactos,linux,hwdetect,windows,peloader,scsiport,heap\n"
|
||||
"Examples:\n"
|
||||
" trace+windows,trace+reactos\n"
|
||||
" +hwdetect,err-disk\n"
|
||||
" +peloader\n"
|
||||
"NOTE: all letters must be lowercase, no spaces allowed.";
|
||||
|
||||
/* FUNCTIONS ******************************************************************/
|
||||
|
||||
VOID DoOptionsMenu(IN OperatingSystemItem* OperatingSystem)
|
||||
VOID
|
||||
FreeLdrSetupMenu(
|
||||
_In_ OperatingSystemItem* OperatingSystem)
|
||||
{
|
||||
ULONG SelectedMenuItem;
|
||||
CHAR DebugChannelString[100];
|
||||
ULONG SelectedMenuItem = 0;
|
||||
|
||||
if (!UiDisplayMenu("Select an option:", NULL,
|
||||
doMenu:
|
||||
/* Clear the backdrop */
|
||||
UiDrawBackdrop(UiGetScreenHeight());
|
||||
|
||||
if (!UiDisplayMenu(VERSION " Setup and Configuration",
|
||||
NULL,
|
||||
OptionsMenuList,
|
||||
sizeof(OptionsMenuList) / sizeof(OptionsMenuList[0]),
|
||||
11, // Use "Start ReactOS normally" as default; see the switch below.
|
||||
-1,
|
||||
RTL_NUMBER_OF(OptionsMenuList),
|
||||
SelectedMenuItem, -1,
|
||||
&SelectedMenuItem,
|
||||
TRUE,
|
||||
NULL, NULL))
|
||||
@@ -107,174 +72,54 @@ VOID DoOptionsMenu(IN OperatingSystemItem* OperatingSystem)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Clear the backdrop */
|
||||
UiDrawBackdrop(UiGetScreenHeight());
|
||||
|
||||
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;
|
||||
case 0: // FreeLdr debugging
|
||||
{
|
||||
CHAR DebugChannelString[100] = "";
|
||||
// DebugChannelString[0] = ANSI_NULL;
|
||||
if (UiEditBox(FrldrDbgMsg,
|
||||
DebugChannelString,
|
||||
sizeof(DebugChannelString) / sizeof(DebugChannelString[0])))
|
||||
RTL_NUMBER_OF(DebugChannelString)))
|
||||
{
|
||||
DbgParseDebugChannels(DebugChannelString);
|
||||
}
|
||||
break;
|
||||
// case 10: // Separator
|
||||
}
|
||||
// case 1: // 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_EDIT_CMDLINE
|
||||
case 12: // Edit command line
|
||||
case 2: // Edit command line
|
||||
EditOperatingSystemEntry(OperatingSystem);
|
||||
break;
|
||||
#endif
|
||||
#ifdef HAS_OPTION_MENU_CUSTOM_BOOT
|
||||
case 13: // Custom Boot
|
||||
case 3: // Custom Boot
|
||||
OptionMenuCustomBoot();
|
||||
break;
|
||||
#endif
|
||||
#ifdef HAS_OPTION_MENU_REBOOT
|
||||
case 14: // Reboot
|
||||
case 4: // Reboot
|
||||
OptionMenuReboot();
|
||||
break;
|
||||
#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];
|
||||
|
||||
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]);
|
||||
}
|
||||
if (!OperatingSystem->AdvBootOptsDesc[0])
|
||||
return;
|
||||
|
||||
/* Display the chosen boot options */
|
||||
UiDrawText(0,
|
||||
UiGetScreenHeight() - 2,
|
||||
BootOptions,
|
||||
OperatingSystem->AdvBootOptsDesc,
|
||||
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");
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ list(APPEND ROSLOAD_SOURCE
|
||||
lib/rtl/libsupp.c
|
||||
${REACTOS_SOURCE_DIR}/ntoskrnl/config/cmboot.c
|
||||
${REACTOS_SOURCE_DIR}/ntoskrnl/ke/config.c
|
||||
ntldr/advopts.c
|
||||
ntldr/conversion.c
|
||||
ntldr/headless.c
|
||||
ntldr/inffile.c
|
||||
|
||||
@@ -56,6 +56,7 @@ add_asm_files(uefifreeldr_common_asm ${FREELDR_COMMON_ASM_SOURCE} ${UEFILDR_COMM
|
||||
list(APPEND FREELDR_NTLDR_SOURCE
|
||||
${REACTOS_SOURCE_DIR}/ntoskrnl/config/cmboot.c
|
||||
${REACTOS_SOURCE_DIR}/ntoskrnl/ke/config.c
|
||||
ntldr/advopts.c
|
||||
ntldr/conversion.c
|
||||
ntldr/headless.c
|
||||
ntldr/inffile.c
|
||||
|
||||
@@ -150,7 +150,6 @@ UiDisplayMenu(
|
||||
{
|
||||
return TuiDisplayMenu(MenuHeader,
|
||||
MenuFooter,
|
||||
ShowBootOptions,
|
||||
MenuItemList,
|
||||
MenuItemCount,
|
||||
DefaultMenuItem,
|
||||
|
||||
Reference in New Issue
Block a user