3 * Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
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.
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.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 CHAR SettingValue
[80];
27 ULONG OperatingSystemCount
;
28 PCSTR
*OperatingSystemSectionNames
;
29 PCSTR
*OperatingSystemDisplayNames
;
30 ULONG DefaultOperatingSystem
;
32 ULONG SelectedOperatingSystem
;
34 if (!FsOpenBootVolume())
36 UiMessageBoxCritical("Error opening boot partition for file access.");
40 if (!IniFileInitialize())
42 UiMessageBoxCritical("Error initializing .ini file");
46 if (!IniOpenSection("FreeLoader", &SectionId
))
48 UiMessageBoxCritical("Section [FreeLoader] not found in freeldr.ini.");
51 TimeOut
= GetTimeOut();
53 if (!UiInitialize(TimeOut
))
55 UiMessageBoxCritical("Unable to initialize UI.");
60 if (!InitOperatingSystemList(&OperatingSystemSectionNames
, &OperatingSystemDisplayNames
, &OperatingSystemCount
))
62 UiMessageBox("Press ENTER to reboot.");
66 if (OperatingSystemCount
== 0)
68 UiMessageBox("There were no operating systems listed in freeldr.ini.\nPress ENTER to reboot.");
72 DefaultOperatingSystem
= GetDefaultOperatingSystem(OperatingSystemSectionNames
, OperatingSystemCount
);
75 // Find all the message box settings and run them
77 UiShowMessageBoxesInSection("FreeLoader");
82 // Redraw the backdrop
85 // Show the operating system list menu
86 if (!UiDisplayMenu(OperatingSystemDisplayNames
, OperatingSystemCount
, DefaultOperatingSystem
, TimeOut
, &SelectedOperatingSystem
, FALSE
, MainBootMenuKeyPressFilter
))
88 UiMessageBox("Press ENTER to reboot.");
94 // Try to open the operating system section in the .ini file
95 if (!IniOpenSection(OperatingSystemSectionNames
[SelectedOperatingSystem
], &SectionId
))
97 sprintf(SettingName
, "Section [%s] not found in freeldr.ini.", OperatingSystemSectionNames
[SelectedOperatingSystem
]);
98 UiMessageBox(SettingName
);
102 // Try to read the boot type
103 if (!IniReadSettingByName(SectionId
, "BootType", SettingValue
, sizeof(SettingValue
)))
105 sprintf(SettingName
, "BootType= line not found in section [%s] in freeldr.ini.", OperatingSystemSectionNames
[SelectedOperatingSystem
]);
106 UiMessageBox(SettingName
);
110 // Install the drive mapper according to this sections drive mappings
112 DriveMapMapDrivesInSection(OperatingSystemSectionNames
[SelectedOperatingSystem
]);
114 if (_stricmp(SettingValue
, "ReactOS") == 0)
116 LoadAndBootReactOS(OperatingSystemSectionNames
[SelectedOperatingSystem
]);
118 #ifdef FREELDR_REACTOS_SETUP
119 else if (_stricmp(SettingValue
, "ReactOSSetup") == 0)
121 // In future we could pass the selected OS details through this
122 // to have different install methods, etc.
126 else if (_stricmp(SettingValue
, "ReactOSSetup2") == 0)
134 else if (_stricmp(SettingValue
, "WindowsNT40") == 0)
136 LoadAndBootWindows(OperatingSystemSectionNames
[SelectedOperatingSystem
], _WIN32_WINNT_NT4
);
138 else if (_stricmp(SettingValue
, "Windows2003") == 0)
140 LoadAndBootWindows(OperatingSystemSectionNames
[SelectedOperatingSystem
], _WIN32_WINNT_WS03
);
142 else if (_stricmp(SettingValue
, "Linux") == 0)
144 LoadAndBootLinux(OperatingSystemSectionNames
[SelectedOperatingSystem
], OperatingSystemDisplayNames
[SelectedOperatingSystem
]);
146 else if (_stricmp(SettingValue
, "BootSector") == 0)
148 LoadAndBootBootSector(OperatingSystemSectionNames
[SelectedOperatingSystem
]);
150 else if (_stricmp(SettingValue
, "Partition") == 0)
152 LoadAndBootPartition(OperatingSystemSectionNames
[SelectedOperatingSystem
]);
154 else if (_stricmp(SettingValue
, "Drive") == 0)
156 LoadAndBootDrive(OperatingSystemSectionNames
[SelectedOperatingSystem
]);
163 UiUnInitialize("Rebooting...");
167 ULONG
GetDefaultOperatingSystem(PCSTR OperatingSystemList
[], ULONG OperatingSystemCount
)
169 CHAR DefaultOSText
[80];
175 if (!IniOpenSection("FreeLoader", &SectionId
))
180 DefaultOSName
= CmdLineGetDefaultOS();
181 if (NULL
== DefaultOSName
)
183 if (IniReadSettingByName(SectionId
, "DefaultOS", DefaultOSText
, sizeof(DefaultOSText
)))
185 DefaultOSName
= DefaultOSText
;
189 if (NULL
!= DefaultOSName
)
191 for (Idx
=0; Idx
<OperatingSystemCount
; Idx
++)
193 if (_stricmp(DefaultOSName
, OperatingSystemList
[Idx
]) == 0)
204 LONG
GetTimeOut(VOID
)
206 CHAR TimeOutText
[20];
210 TimeOut
= CmdLineGetTimeOut();
216 if (!IniOpenSection("FreeLoader", &SectionId
))
221 if (IniReadSettingByName(SectionId
, "TimeOut", TimeOutText
, sizeof(TimeOutText
)))
223 TimeOut
= atoi(TimeOutText
);
233 BOOLEAN
MainBootMenuKeyPressFilter(ULONG KeyPress
)
235 if (KeyPress
== KEY_F8
)
242 // We didn't handle the key