ReactOS 0.4.16-dev-2610-ge2c92c0
advopts.c
Go to the documentation of this file.
1/*
2 * PROJECT: NT-compatible ReactOS/Windows OS Loader
3 * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4 * PURPOSE: Advanced Boot Options F8 menu.
5 * COPYRIGHT: Copyright 1998-2003 Brian Palmer <brianp@sginet.com>
6 * Copyright 2010 Cameron Gutman <cameron.gutman@reactos.org>
7 * Copyright 2012-2026 Hermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
8 */
9
10/* INCLUDES *******************************************************************/
11
12#include <freeldr.h>
13#include "ntldropts.h"
14
15/* GLOBALS ********************************************************************/
16
18{
19 "Safe Mode",
20 "Safe Mode with Networking",
21 "Safe Mode with Command Prompt",
22
23 NULL,
24
25 "Enable Boot Logging",
26 "Enable VGA Mode",
27 "Last Known Good Configuration",
28 "Directory Services Restore Mode",
29 "Debugging Mode",
30
31 NULL,
32
33 "Start ReactOS normally",
34#ifdef HAS_OPTION_MENU_EDIT_CMDLINE
35 "Edit Boot Command Line (F10)",
36#endif
37#ifdef HAS_OPTION_MENU_REBOOT
38 "Reboot",
39#endif
40};
41
42/* Advanced NT boot options */
45
46/* FUNCTIONS ******************************************************************/
47
48static VOID
50 _Inout_z_bytecount_(BootOptsDescSize)
51 PSTR BootOptsDesc,
52 _In_ SIZE_T BootOptsDescSize)
53{
54 /* NOTE: Keep in sync with the 'enum BootOption'
55 * in winldr.h and the OptionsMenuList above. */
56 static const PCSTR* OptionNames[] =
57 {
58 /* NO_OPTION */ NULL,
59 /* SAFEBOOT */ &OptionsMenuList[0],
60 /* SAFEBOOT_NETWORK */ &OptionsMenuList[1],
61 /* SAFEBOOT_ALTSHELL */ &OptionsMenuList[2],
62 /* SAFEBOOT_DSREPAIR */ &OptionsMenuList[7],
63 /* LKG_CONFIG */ &OptionsMenuList[6],
64 };
65
66 if (BootOptsDescSize < sizeof(CHAR))
67 return;
68
69 *BootOptsDesc = ANSI_NULL;
70
72 if (BootOptionChoice != NO_OPTION) // && BootOptionChoice < RTL_NUMBER_OF(OptionNames)
73 RtlStringCbCatA(BootOptsDesc, BootOptsDescSize, *OptionNames[BootOptionChoice]);
74
76 {
77 /* Since these safe mode options come by default with boot logging,
78 * don't show "Boot Logging" when one of these is selected;
79 * instead just show the corresponding safe mode option name. */
80 if ( (BootOptionChoice != SAFEBOOT) &&
83 {
84 if (*BootOptsDesc)
85 RtlStringCbCatA(BootOptsDesc, BootOptsDescSize, ", ");
86 RtlStringCbCatA(BootOptsDesc, BootOptsDescSize, OptionsMenuList[4]);
87 }
88 }
89
91 {
92 if (*BootOptsDesc)
93 RtlStringCbCatA(BootOptsDesc, BootOptsDescSize, ", ");
94 RtlStringCbCatA(BootOptsDesc, BootOptsDescSize, OptionsMenuList[5]);
95 }
96
98 {
99 if (*BootOptsDesc)
100 RtlStringCbCatA(BootOptsDesc, BootOptsDescSize, ", ");
101 RtlStringCbCatA(BootOptsDesc, BootOptsDescSize, OptionsMenuList[8]);
102 }
103}
104
105VOID
107 _Inout_ OperatingSystemItem* OperatingSystem)
108{
109 ULONG SelectedMenuItem;
110
111 /* Redraw the backdrop, but don't overwrite boot options */
113 DisplayBootTimeOptions(OperatingSystem);
114
115 if (!UiDisplayMenu("Please select an option:",
116 NULL,
119 10, // Use "Start ReactOS normally" as default; see the switch below.
120 -1,
121 &SelectedMenuItem,
122 TRUE,
123 NULL, NULL))
124 {
125 /* The user pressed ESC */
126 return;
127 }
128
129 switch (SelectedMenuItem)
130 {
131 case 0: // Safe Mode
134 break;
135 case 1: // Safe Mode with Networking
138 break;
139 case 2: // Safe Mode with Command Prompt
142 break;
143 // case 3: // Separator
144 // break;
145 case 4: // Enable Boot Logging
147 break;
148 case 5: // Enable VGA Mode
150 break;
151 case 6: // Last Known Good Configuration
153 break;
154 case 7: // Directory Services Restore Mode
156 break;
157 case 8: // Debugging Mode
159 break;
160 // case 9: // Separator
161 // break;
162 case 10: // Start ReactOS normally
163 // Reset all the parameters to their default values.
165 BootFlags = 0;
166 break;
167#ifdef HAS_OPTION_MENU_EDIT_CMDLINE
168 case 11: // Edit command line
169 EditOperatingSystemEntry(OperatingSystem);
170 break;
171#endif
172#ifdef HAS_OPTION_MENU_REBOOT
173 case 12: // Reboot
175 break;
176#endif
177 }
178
179 /* Update the human-readable boot-option description string */
180 GetBootOptionsDescription(OperatingSystem->AdvBootOptsDesc,
181 sizeof(OperatingSystem->AdvBootOptsDesc));
182}
183
184VOID
186 _Inout_z_bytecount_(BootOptionsSize)
187 PSTR BootOptions,
188 _In_ SIZE_T BootOptionsSize)
189{
190 /* NOTE: Keep in sync with the 'enum BootOption' in winldr.h */
191 static const PCSTR OptionsStr[] =
192 {
193 /* NO_OPTION */ NULL,
194 /* SAFEBOOT */ "SAFEBOOT:MINIMAL SOS NOGUIBOOT",
195 /* SAFEBOOT_NETWORK */ "SAFEBOOT:NETWORK SOS NOGUIBOOT",
196 /* SAFEBOOT_ALTSHELL */ "SAFEBOOT:MINIMAL(ALTERNATESHELL) SOS NOGUIBOOT",
197 /* SAFEBOOT_DSREPAIR */ "SAFEBOOT:DSREPAIR SOS",
198 /* LKG_CONFIG */ NULL,
199 };
200
201 if (BootOptionsSize < sizeof(CHAR))
202 return;
203
204 switch (BootOptionChoice)
205 {
206 case SAFEBOOT:
207 case SAFEBOOT_NETWORK:
210 {
212 NtLdrAddOptions(BootOptions, BootOptionsSize, TRUE, OptionsStr[BootOptionChoice]);
213 break;
214 }
215
216 case LKG_CONFIG:
217 DbgPrint("Last known good configuration is not supported yet!\n");
218 break;
219
220 default:
221 break;
222 }
223
225 NtLdrAddOptions(BootOptions, BootOptionsSize, TRUE, "BOOTLOG");
226
228 NtLdrAddOptions(BootOptions, BootOptionsSize, TRUE, "BASEVIDEO");
229
231 NtLdrAddOptions(BootOptions, BootOptionsSize, TRUE, "DEBUG");
232}
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
static VOID GetBootOptionsDescription(_Inout_z_bytecount_(BootOptsDescSize) PSTR BootOptsDesc, _In_ SIZE_T BootOptsDescSize)
Definition: advopts.c:49
VOID AppendBootTimeOptions(_Inout_z_bytecount_(BootOptionsSize) PSTR BootOptions, _In_ SIZE_T BootOptionsSize)
Definition: advopts.c:185
VOID MenuNTOptions(_Inout_ OperatingSystemItem *OperatingSystem)
Definition: advopts.c:106
static PCSTR OptionsMenuList[]
Definition: advopts.c:17
LOGICAL BootFlags
Definition: advopts.c:44
enum BootOption BootOptionChoice
Definition: advopts.c:43
VOID DisplayBootTimeOptions(_In_ OperatingSystemItem *OperatingSystem)
Definition: options.c:115
VOID UiDrawBackdrop(ULONG DrawHeight)
Definition: ui.c:233
ULONG UiGetScreenHeight(VOID)
Definition: ui.c:655
BOOLEAN UiDisplayMenu(IN PCSTR MenuHeader, IN PCSTR MenuFooter OPTIONAL, IN PCSTR MenuItemList[], IN ULONG MenuItemCount, IN ULONG DefaultMenuItem, IN LONG MenuTimeOut, OUT PULONG SelectedMenuItem, IN BOOLEAN CanEscape, IN UiMenuKeyPressFilterCallback KeyPressFilter OPTIONAL, IN PVOID Context OPTIONAL)
Definition: ui.c:605
VOID OptionMenuReboot(VOID)
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define DbgPrint
Definition: hal.h:12
#define BOOT_DEBUGGING
Definition: winldr.h:61
BootOption
Definition: winldr.h:48
@ SAFEBOOT
Definition: winldr.h:51
@ LKG_CONFIG
Definition: winldr.h:56
@ SAFEBOOT_DSREPAIR
Definition: winldr.h:54
@ SAFEBOOT_NETWORK
Definition: winldr.h:52
@ SAFEBOOT_ALTSHELL
Definition: winldr.h:53
@ NO_OPTION
Definition: winldr.h:49
#define BOOT_LOGGING
Definition: winldr.h:59
#define BOOT_VGA_MODE
Definition: winldr.h:60
#define ASSERT(a)
Definition: mode.c:44
#define _Inout_z_bytecount_(size)
Definition: ms_sal.h:948
#define _Inout_
Definition: no_sal2.h:162
#define _In_
Definition: no_sal2.h:158
#define ANSI_NULL
VOID NtLdrAddOptions(IN OUT PSTR LoadOptions, IN ULONG BufferSize, IN BOOLEAN Append, IN PCSTR NewOptions OPTIONAL)
Definition: ntldropts.c:140
NTSTRSAFEAPI RtlStringCbCatA(_Inout_updates_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCSTR pszSrc)
Definition: ntstrsafe.h:625
char CHAR
Definition: pedump.c:57
char * PSTR
Definition: typedefs.h:51
ULONG_PTR SIZE_T
Definition: typedefs.h:80
const char * PCSTR
Definition: typedefs.h:52
uint32_t ULONG
Definition: typedefs.h:59
ULONG LOGICAL
Definition: umtypes.h:135