[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,8 +38,15 @@ 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.");
return FALSE;
/* 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 */

View file

@ -126,12 +126,35 @@ 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");
return;
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 */