[FREELDR] Make it more compatible with w2k3 ini file

This commit is contained in:
Daniel Victor 2024-11-22 11:16:17 -03:00 committed by Timo Kreuzer
parent e897a5654d
commit 34e76ade03
2 changed files with 37 additions and 7 deletions

View file

@ -38,9 +38,16 @@ BOOLEAN IniFileInitialize(VOID)
if (Status != ESUCCESS)
{
ERR("Error while opening freeldr.ini, Status: %d\n", Status);
UiMessageBoxCritical("Error opening freeldr.ini or file not found.\nYou need to re-install FreeLoader.");
/* Try to open boot.ini */
Status = FsOpenFile("boot.ini", FrLdrBootPath, OpenReadOnly, &FileId);
if (Status != ESUCCESS)
{
ERR("Error while opening boot.ini, Status: %d\n", Status);
UiMessageBoxCritical("Error opening freeldr.ini/boot.ini or file not found.\nYou need to re-install FreeLoader.");
return FALSE;
}
}
/* Get the file size */
Status = ArcGetFileInformation(FileId, &FileInformation);

View file

@ -126,13 +126,36 @@ LoadSettings(
return;
}
/* Open the [FreeLoader] section and load the settings */
if ((BootMgrInfo.FrLdrSection == 0) &&
!IniOpenSection("FreeLoader", &BootMgrInfo.FrLdrSection))
BOOLEAN FoundLoaderSection = FALSE;
PCSTR LoaderSections[] = {
"FreeLoader",
"Boot Loader",
"FlexBoot",
"MultiBoot",
};
/* Search for the first section in LoaderSections and load the settings,
* prioritizing the order in the file.
* If a section is already loaded, skip further checks. */
if (!BootMgrInfo.FrLdrSection)
{
UiMessageBoxCritical("Section [FreeLoader] not found in freeldr.ini");
for (ULONG i = 0; i < sizeof(LoaderSections) / sizeof(LoaderSections[0]); i++)
{
PCSTR Section = LoaderSections[i];
if (IniOpenSection(Section, &BootMgrInfo.FrLdrSection))
{
FoundLoaderSection = TRUE;
break;
}
}
if (!FoundLoaderSection)
{
UiMessageBoxCritical("Bootloader Section not found in freeldr.ini");
return;
}
}
/* Get the debug string. Always override it with the one from freeldr.ini */
if (IniReadSettingByName(BootMgrInfo.FrLdrSection, "Debug",