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

View file

@ -27,7 +27,6 @@ BOOLEAN InitOperatingSystemList(PCSTR **SectionNamesPointer, PCSTR **DisplayName
CHAR SettingValue[260]; CHAR SettingValue[260];
ULONG OperatingSystemCount; ULONG OperatingSystemCount;
ULONG_PTR SectionId; ULONG_PTR SectionId;
ULONG_PTR OperatingSystemSectionId;
ULONG SectionSettingCount; ULONG SectionSettingCount;
PCHAR *OperatingSystemSectionNames; PCHAR *OperatingSystemSectionNames;
PCHAR *OperatingSystemDisplayNames; PCHAR *OperatingSystemDisplayNames;
@ -60,17 +59,14 @@ BOOLEAN InitOperatingSystemList(PCSTR **SectionNamesPointer, PCSTR **DisplayName
{ {
IniReadSettingByNumber(SectionId, Idx, SettingName, sizeof(SettingName), SettingValue, sizeof(SettingValue)); 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 // Copy the display name
RemoveQuotes(SettingValue); RemoveQuotes(SettingValue);
strcpy(OperatingSystemDisplayNames[CurrentOperatingSystemIndex], SettingValue); strcpy(OperatingSystemDisplayNames[CurrentOperatingSystemIndex], SettingValue);
CurrentOperatingSystemIndex++; CurrentOperatingSystemIndex++;
}
} }
*OperatingSystemCountPointer = OperatingSystemCount; *OperatingSystemCountPointer = OperatingSystemCount;
@ -82,32 +78,7 @@ BOOLEAN InitOperatingSystemList(PCSTR **SectionNamesPointer, PCSTR **DisplayName
ULONG CountOperatingSystems(ULONG SectionId) ULONG CountOperatingSystems(ULONG SectionId)
{ {
ULONG Idx; return IniGetNumSectionItems(SectionId);
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;
} }
BOOLEAN AllocateListMemory(PCHAR **SectionNamesPointer, PCHAR **DisplayNamesPointer, ULONG OperatingSystemCount) BOOLEAN AllocateListMemory(PCHAR **SectionNamesPointer, PCHAR **DisplayNamesPointer, ULONG OperatingSystemCount)

View file

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