[SHELL32] SHChangeNotify: Use tree for CDirectoryList (#6784)
[reactos.git] / boot / freeldr / freeldr / options.c
1 /*
2 * FreeLoader
3 * Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 /* INCLUDES *******************************************************************/
21
22 #include <freeldr.h>
23 #include <debug.h>
24
25 /* GLOBALS ********************************************************************/
26
27 PCSTR OptionsMenuList[] =
28 {
29 "Safe Mode",
30 "Safe Mode with Networking",
31 "Safe Mode with Command Prompt",
32
33 NULL,
34
35 "Enable Boot Logging",
36 "Enable VGA Mode",
37 "Last Known Good Configuration",
38 "Directory Services Restore Mode",
39 "Debugging Mode",
40 "FreeLdr debugging",
41
42 NULL,
43
44 "Start ReactOS normally",
45 #ifdef HAS_OPTION_MENU_EDIT_CMDLINE
46 "Edit Boot Command Line (F10)",
47 #endif
48 #ifdef HAS_OPTION_MENU_CUSTOM_BOOT
49 "Custom Boot",
50 #endif
51 #ifdef HAS_OPTION_MENU_REBOOT
52 "Reboot",
53 #endif
54 };
55
56 const
57 PCSTR FrldrDbgMsg = "Enable FreeLdr debug channels\n"
58 "Acceptable syntax: [level1]#channel1[,[level2]#channel2]\n"
59 "level can be one of: trace,warn,fixme,err\n"
60 " if the level is omitted all levels\n"
61 " are enabled for the specified channel\n"
62 "# can be either + or -\n"
63 "channel can be one of the following:\n"
64 " all,warning,memory,filesystem,inifile,ui,disk,cache,registry,\n"
65 " reactos,linux,hwdetect,windows,peloader,scsiport,heap\n"
66 "Examples:\n"
67 " trace+windows,trace+reactos\n"
68 " +hwdetect,err-disk\n"
69 " +peloader\n"
70 "NOTE: all letters must be lowercase, no spaces allowed.";
71
72 /* The boot options are mutually exclusive */
73 enum BootOption
74 {
75 NO_OPTION = 0,
76
77 SAFE_MODE,
78 SAFE_MODE_WITH_NETWORKING,
79 SAFE_MODE_WITH_COMMAND_PROMPT,
80
81 LAST_KNOWN_GOOD_CONFIGURATION,
82 DIRECTORY_SERVICES_RESTORE_MODE,
83 };
84
85 static enum BootOption BootOptionChoice = NO_OPTION;
86 static BOOLEAN BootLogging = FALSE;
87 static BOOLEAN VgaMode = FALSE;
88 static BOOLEAN DebuggingMode = FALSE;
89
90 /* FUNCTIONS ******************************************************************/
91
92 VOID DoOptionsMenu(IN OperatingSystemItem* OperatingSystem)
93 {
94 ULONG SelectedMenuItem;
95 CHAR DebugChannelString[100];
96
97 if (!UiDisplayMenu("Select an option:", NULL,
98 TRUE,
99 OptionsMenuList,
100 sizeof(OptionsMenuList) / sizeof(OptionsMenuList[0]),
101 11, // Use "Start ReactOS normally" as default; see the switch below.
102 -1,
103 &SelectedMenuItem,
104 TRUE,
105 NULL, NULL))
106 {
107 /* The user pressed ESC */
108 return;
109 }
110
111 /* Clear the backdrop */
112 UiDrawBackdrop();
113
114 switch (SelectedMenuItem)
115 {
116 case 0: // Safe Mode
117 BootOptionChoice = SAFE_MODE;
118 BootLogging = TRUE;
119 break;
120 case 1: // Safe Mode with Networking
121 BootOptionChoice = SAFE_MODE_WITH_NETWORKING;
122 BootLogging = TRUE;
123 break;
124 case 2: // Safe Mode with Command Prompt
125 BootOptionChoice = SAFE_MODE_WITH_COMMAND_PROMPT;
126 BootLogging = TRUE;
127 break;
128 // case 3: // Separator
129 // break;
130 case 4: // Enable Boot Logging
131 BootLogging = TRUE;
132 break;
133 case 5: // Enable VGA Mode
134 VgaMode = TRUE;
135 break;
136 case 6: // Last Known Good Configuration
137 BootOptionChoice = LAST_KNOWN_GOOD_CONFIGURATION;
138 break;
139 case 7: // Directory Services Restore Mode
140 BootOptionChoice = DIRECTORY_SERVICES_RESTORE_MODE;
141 break;
142 case 8: // Debugging Mode
143 DebuggingMode = TRUE;
144 break;
145 case 9: // FreeLdr debugging
146 DebugChannelString[0] = 0;
147 if (UiEditBox(FrldrDbgMsg,
148 DebugChannelString,
149 sizeof(DebugChannelString) / sizeof(DebugChannelString[0])))
150 {
151 DbgParseDebugChannels(DebugChannelString);
152 }
153 break;
154 // case 10: // Separator
155 // break;
156 case 11: // Start ReactOS normally
157 // Reset all the parameters to their default values.
158 BootOptionChoice = NO_OPTION;
159 BootLogging = FALSE;
160 VgaMode = FALSE;
161 DebuggingMode = FALSE;
162 break;
163 #ifdef HAS_OPTION_MENU_EDIT_CMDLINE
164 case 12: // Edit command line
165 EditOperatingSystemEntry(OperatingSystem);
166 break;
167 #endif
168 #ifdef HAS_OPTION_MENU_CUSTOM_BOOT
169 case 13: // Custom Boot
170 OptionMenuCustomBoot();
171 break;
172 #endif
173 #ifdef HAS_OPTION_MENU_REBOOT
174 case 14: // Reboot
175 OptionMenuReboot();
176 break;
177 #endif
178 }
179 }
180
181 VOID DisplayBootTimeOptions(VOID)
182 {
183 CHAR BootOptions[260] = "";
184
185 switch (BootOptionChoice)
186 {
187 case SAFE_MODE:
188 strcat(BootOptions, OptionsMenuList[0]);
189 break;
190
191 case SAFE_MODE_WITH_NETWORKING:
192 strcat(BootOptions, OptionsMenuList[1]);
193 break;
194
195 case SAFE_MODE_WITH_COMMAND_PROMPT:
196 strcat(BootOptions, OptionsMenuList[2]);
197 break;
198
199 case LAST_KNOWN_GOOD_CONFIGURATION:
200 strcat(BootOptions, OptionsMenuList[6]);
201 break;
202
203 case DIRECTORY_SERVICES_RESTORE_MODE:
204 strcat(BootOptions, OptionsMenuList[7]);
205 break;
206
207 default:
208 break;
209 }
210
211 if (BootLogging)
212 {
213 if ( (BootOptionChoice != SAFE_MODE) &&
214 (BootOptionChoice != SAFE_MODE_WITH_NETWORKING) &&
215 (BootOptionChoice != SAFE_MODE_WITH_COMMAND_PROMPT) )
216 {
217 if (BootOptionChoice != NO_OPTION)
218 {
219 strcat(BootOptions, ", ");
220 }
221 strcat(BootOptions, OptionsMenuList[4]);
222 }
223 }
224
225 if (VgaMode)
226 {
227 if ((BootOptionChoice != NO_OPTION) ||
228 BootLogging)
229 {
230 strcat(BootOptions, ", ");
231 }
232 strcat(BootOptions, OptionsMenuList[5]);
233 }
234
235 if (DebuggingMode)
236 {
237 if ((BootOptionChoice != NO_OPTION) ||
238 BootLogging || VgaMode)
239 {
240 strcat(BootOptions, ", ");
241 }
242 strcat(BootOptions, OptionsMenuList[8]);
243 }
244
245 /* Display the chosen boot options */
246 UiDrawText(0,
247 UiScreenHeight - 2,
248 BootOptions,
249 ATTR(COLOR_LIGHTBLUE, UiMenuBgColor));
250 }
251
252 VOID AppendBootTimeOptions(PCHAR BootOptions)
253 {
254 switch (BootOptionChoice)
255 {
256 case SAFE_MODE:
257 strcat(BootOptions, " /SAFEBOOT:MINIMAL /SOS /NOGUIBOOT");
258 break;
259
260 case SAFE_MODE_WITH_NETWORKING:
261 strcat(BootOptions, " /SAFEBOOT:NETWORK /SOS /NOGUIBOOT");
262 break;
263
264 case SAFE_MODE_WITH_COMMAND_PROMPT:
265 strcat(BootOptions, " /SAFEBOOT:MINIMAL(ALTERNATESHELL) /SOS /NOGUIBOOT");
266 break;
267
268 case LAST_KNOWN_GOOD_CONFIGURATION:
269 DbgPrint("Last known good configuration is not supported yet!\n");
270 break;
271
272 case DIRECTORY_SERVICES_RESTORE_MODE:
273 strcat(BootOptions, " /SAFEBOOT:DSREPAIR /SOS");
274 break;
275
276 default:
277 break;
278 }
279
280 if (BootLogging)
281 strcat(BootOptions, " /BOOTLOG");
282
283 if (VgaMode)
284 strcat(BootOptions, " /BASEVIDEO");
285
286 if (DebuggingMode)
287 strcat(BootOptions, " /DEBUG");
288 }