[freeldr] List in menu all entries from [Operating Systems] section, even if they don't have an associated section

Try to infer the boot type if not specified
See issue #4455 for more details.

svn path=/trunk/; revision=43467
This commit is contained in:
Hervé Poussineau 2009-10-14 21:04:44 +00:00
parent 9fcbb3422d
commit 7b529de220
3 changed files with 45 additions and 56 deletions

View file

@ -21,12 +21,12 @@
VOID RunLoader(VOID)
{
CHAR SettingName[80];
CHAR SettingValue[80];
ULONG_PTR SectionId;
ULONG OperatingSystemCount;
PCSTR *OperatingSystemSectionNames;
PCSTR *OperatingSystemDisplayNames;
PCSTR SectionName;
ULONG DefaultOperatingSystem;
LONG TimeOut;
ULONG SelectedOperatingSystem;
@ -93,28 +93,48 @@ VOID RunLoader(VOID)
TimeOut = -1;
// Try to open the operating system section in the .ini file
if (!IniOpenSection(OperatingSystemSectionNames[SelectedOperatingSystem], &SectionId))
SettingValue[0] = ANSI_NULL;
SectionName = OperatingSystemSectionNames[SelectedOperatingSystem];
if (IniOpenSection(SectionName, &SectionId))
{
sprintf(SettingName, "Section [%s] not found in freeldr.ini.", OperatingSystemSectionNames[SelectedOperatingSystem]);
UiMessageBox(SettingName);
continue;
// Try to read the boot type
IniReadSettingByName(SectionId, "BootType", SettingValue, sizeof(SettingValue));
}
// Try to read the boot type
if (!IniReadSettingByName(SectionId, "BootType", SettingValue, sizeof(SettingValue)))
if (SettingValue[0] == ANSI_NULL && SectionName[0] != ANSI_NULL)
{
sprintf(SettingName, "BootType= line not found in section [%s] in freeldr.ini.", OperatingSystemSectionNames[SelectedOperatingSystem]);
UiMessageBox(SettingName);
continue;
// Try to infere boot type value
#ifdef __i386__
CHAR LastChar;
LastChar = SectionName[strlen(SectionName) - 1];
if (LastChar == '\\' ||
(strstr(SectionName, ")partition(") != NULL &&
strstr(SectionName, ")partition(0)") == NULL))
{
strcpy(SettingValue, "Partition");
}
else if (LastChar == ')' || LastChar == ':')
{
strcpy(SettingValue, "Drive");
}
else if (TRUE)
{
strcpy(SettingValue, "BootSector");
}
else
#endif
{
strcpy(SettingValue, "Windows2003");
}
}
// Install the drive mapper according to this sections drive mappings
#ifdef __i386__
DriveMapMapDrivesInSection(OperatingSystemSectionNames[SelectedOperatingSystem]);
DriveMapMapDrivesInSection(SectionName);
#endif
if (_stricmp(SettingValue, "ReactOS") == 0)
{
LoadAndBootReactOS(OperatingSystemSectionNames[SelectedOperatingSystem]);
LoadAndBootReactOS(SectionName);
}
#ifdef FREELDR_REACTOS_SETUP
else if (_stricmp(SettingValue, "ReactOSSetup") == 0)
@ -134,27 +154,27 @@ VOID RunLoader(VOID)
#ifdef __i386__
else if (_stricmp(SettingValue, "WindowsNT40") == 0)
{
LoadAndBootWindows(OperatingSystemSectionNames[SelectedOperatingSystem], _WIN32_WINNT_NT4);
LoadAndBootWindows(SectionName, _WIN32_WINNT_NT4);
}
else if (_stricmp(SettingValue, "Windows2003") == 0)
{
LoadAndBootWindows(OperatingSystemSectionNames[SelectedOperatingSystem], _WIN32_WINNT_WS03);
LoadAndBootWindows(SectionName, _WIN32_WINNT_WS03);
}
else if (_stricmp(SettingValue, "Linux") == 0)
{
LoadAndBootLinux(OperatingSystemSectionNames[SelectedOperatingSystem], OperatingSystemDisplayNames[SelectedOperatingSystem]);
LoadAndBootLinux(SectionName, OperatingSystemDisplayNames[SelectedOperatingSystem]);
}
else if (_stricmp(SettingValue, "BootSector") == 0)
{
LoadAndBootBootSector(OperatingSystemSectionNames[SelectedOperatingSystem]);
LoadAndBootBootSector(SectionName);
}
else if (_stricmp(SettingValue, "Partition") == 0)
{
LoadAndBootPartition(OperatingSystemSectionNames[SelectedOperatingSystem]);
LoadAndBootPartition(SectionName);
}
else if (_stricmp(SettingValue, "Drive") == 0)
{
LoadAndBootDrive(OperatingSystemSectionNames[SelectedOperatingSystem]);
LoadAndBootDrive(SectionName);
}
#endif
}

View file

@ -27,7 +27,6 @@ BOOLEAN InitOperatingSystemList(PCSTR **SectionNamesPointer, PCSTR **DisplayName
CHAR SettingValue[260];
ULONG OperatingSystemCount;
ULONG_PTR SectionId;
ULONG_PTR OperatingSystemSectionId;
ULONG SectionSettingCount;
PCHAR *OperatingSystemSectionNames;
PCHAR *OperatingSystemDisplayNames;
@ -60,17 +59,14 @@ BOOLEAN InitOperatingSystemList(PCSTR **SectionNamesPointer, PCSTR **DisplayName
{
IniReadSettingByNumber(SectionId, Idx, SettingName, sizeof(SettingName), SettingValue, sizeof(SettingValue));
if (IniOpenSection(SettingName, &OperatingSystemSectionId))
{
// Copy the section name
strcpy(OperatingSystemSectionNames[CurrentOperatingSystemIndex], SettingName);
// Copy the section name
strcpy(OperatingSystemSectionNames[CurrentOperatingSystemIndex], SettingName);
// Copy the display name
RemoveQuotes(SettingValue);
strcpy(OperatingSystemDisplayNames[CurrentOperatingSystemIndex], SettingValue);
// Copy the display name
RemoveQuotes(SettingValue);
strcpy(OperatingSystemDisplayNames[CurrentOperatingSystemIndex], SettingValue);
CurrentOperatingSystemIndex++;
}
CurrentOperatingSystemIndex++;
}
*OperatingSystemCountPointer = OperatingSystemCount;
@ -82,32 +78,7 @@ BOOLEAN InitOperatingSystemList(PCSTR **SectionNamesPointer, PCSTR **DisplayName
ULONG CountOperatingSystems(ULONG SectionId)
{
ULONG Idx;
CHAR SettingName[260];
CHAR SettingValue[260];
ULONG OperatingSystemCount = 0;
ULONG SectionSettingCount;
//
// Loop through and count the operating systems
//
SectionSettingCount = IniGetNumSectionItems(SectionId);
for (Idx=0; Idx<SectionSettingCount; Idx++)
{
IniReadSettingByNumber(SectionId, Idx, SettingName, sizeof(SettingName), SettingValue, sizeof(SettingValue));
if (IniOpenSection(SettingName, NULL))
{
OperatingSystemCount++;
}
else
{
sprintf(SettingName, "Operating System '%s' is listed in\nfreeldr.ini but doesn't have a [section].", SettingValue);
UiMessageBox(SettingName);
}
}
return OperatingSystemCount;
return IniGetNumSectionItems(SectionId);
}
BOOLEAN AllocateListMemory(PCHAR **SectionNamesPointer, PCHAR **DisplayNamesPointer, ULONG OperatingSystemCount)

View file

@ -412,8 +412,6 @@ VOID UiShowMessageBoxesInSection(PCSTR SectionName)
if (!IniOpenSection(SectionName, &SectionId))
{
sprintf(SettingName, "Section %s not found in freeldr.ini.\n", SectionName);
UiMessageBox(SettingName);
return;
}