[MSI]
[reactos.git] / reactos / 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 #include <freeldr.h>
21
22 PCSTR OptionsMenuList[] =
23 {
24 "Safe Mode",
25 "Safe Mode with Networking",
26 "Safe Mode with Command Prompt",
27
28 "SEPARATOR",
29
30 "Enable Boot Logging",
31 "Enable VGA Mode",
32 "Last Known Good Configuration",
33 "Directory Services Restore Mode",
34 "Debugging Mode",
35
36 "SEPARATOR",
37
38 #ifdef HAS_OPTION_MENU_CUSTOM_BOOT
39 "Custom Boot",
40 #endif
41 #ifdef HAS_OPTION_MENU_REBOOT
42 "Reboot",
43 #endif
44 };
45
46 enum OptionMenuItems
47 {
48 SAFE_MODE = 0,
49 SAFE_MODE_WITH_NETWORKING = 1,
50 SAFE_MODE_WITH_COMMAND_PROMPT = 2,
51
52 SEPARATOR1 = 3,
53
54 ENABLE_BOOT_LOGGING = 4,
55 ENABLE_VGA_MODE = 5,
56 LAST_KNOWN_GOOD_CONFIGURATION = 6,
57 DIRECTORY_SERVICES_RESTORE_MODE = 7,
58 DEBUGGING_MODE = 8,
59
60 SEPARATOR2 = 9,
61
62 #ifdef HAS_OPTION_MENU_CUSTOM_BOOT
63 CUSTOM_BOOT = 10,
64 #endif
65 #ifdef HAS_OPTION_MENU_REBOOT
66 REBOOT = 11,
67 #endif
68 };
69
70 ULONG OptionsMenuItemCount = sizeof(OptionsMenuList) / sizeof(OptionsMenuList[0]);
71
72 BOOLEAN SafeMode = FALSE;
73 BOOLEAN SafeModeWithNetworking = FALSE;
74 BOOLEAN SafeModeWithCommandPrompt = FALSE;
75 BOOLEAN BootLogging = FALSE;
76 BOOLEAN VgaMode = FALSE;
77 BOOLEAN LastKnownGoodConfiguration = FALSE;
78 BOOLEAN DirectoryServicesRepairMode = FALSE;
79 BOOLEAN DebuggingMode = FALSE;
80
81 VOID DoOptionsMenu(VOID)
82 {
83 ULONG SelectedMenuItem;
84
85 if (!UiDisplayMenu(OptionsMenuList, OptionsMenuItemCount, 0, -1, &SelectedMenuItem, TRUE, NULL))
86 {
87 // The user pressed ESC
88 return;
89 }
90
91 // Clear the backdrop
92 UiDrawBackdrop();
93
94 switch (SelectedMenuItem)
95 {
96 case SAFE_MODE:
97 SafeMode = TRUE;
98 BootLogging = TRUE;
99 break;
100 case SAFE_MODE_WITH_NETWORKING:
101 SafeModeWithNetworking = TRUE;
102 BootLogging = TRUE;
103 break;
104 case SAFE_MODE_WITH_COMMAND_PROMPT:
105 SafeModeWithCommandPrompt = TRUE;
106 BootLogging = TRUE;
107 break;
108 //case SEPARATOR1:
109 // break;
110 case ENABLE_BOOT_LOGGING:
111 BootLogging = TRUE;
112 break;
113 case ENABLE_VGA_MODE:
114 VgaMode = TRUE;
115 break;
116 case LAST_KNOWN_GOOD_CONFIGURATION:
117 LastKnownGoodConfiguration = TRUE;
118 break;
119 case DIRECTORY_SERVICES_RESTORE_MODE:
120 DirectoryServicesRepairMode = TRUE;
121 break;
122 case DEBUGGING_MODE:
123 DebuggingMode = TRUE;
124 break;
125 //case SEPARATOR2:
126 // break;
127 #ifdef HAS_OPTION_MENU_CUSTOM_BOOT
128 case CUSTOM_BOOT:
129 OptionMenuCustomBoot();
130 break;
131 #endif
132 #ifdef HAS_OPTION_MENU_REBOOT
133 case REBOOT:
134 OptionMenuReboot();
135 break;
136 #endif
137 }
138 }
139
140 VOID AppendBootTimeOptions(PCHAR BootOptions)
141 {
142 if (SafeMode)
143 strcat(BootOptions, " /SAFEBOOT:MINIMAL /SOS"); //FIXME: NOGUIBOOT should also be specified
144
145 if (SafeModeWithNetworking)
146 strcat(BootOptions, " /SAFEBOOT:NETWORK /SOS"); //FIXME: NOGUIBOOT should also be specified
147
148 if (SafeModeWithCommandPrompt)
149 strcat(BootOptions, " /SAFEBOOT:MINIMAL(ALTERNATESHELL) /SOS"); //FIXME: NOGUIBOOT should also be specified
150
151 if (BootLogging)
152 strcat(BootOptions, " /BOOTLOG");
153
154 if (VgaMode)
155 strcat(BootOptions, " /BASEVIDEO");
156
157 if (LastKnownGoodConfiguration)
158 DbgPrint("Last known good configuration is not supported yet!\n");
159
160 if (DirectoryServicesRepairMode)
161 strcat(BootOptions, " /SAFEBOOT:DSREPAIR /SOS");
162
163 if (DebuggingMode)
164 strcat(BootOptions, " /DEBUG");
165 }