From 16e6da0e966d6125ba389857f3c7f6206b2ecca7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Sun, 3 Apr 2022 02:48:36 +0200 Subject: [PATCH] [FREELDR:SETUPLDR] Add the missing known platform-specific SourcePaths where TXTSETUP.SIF can be found And slightly improve the search loop. - Unconditionally look into the root directory as well, in order to cover all possible boot disk layouts in case someone customizes the ReactOS boot media layout. - Improve the `InfOpenFile()` call error handling, in order to show the erroneous line _iff_ the call failed because of a wrong syntax in TXTSETUP.SIF . Distinguish it from a failure because the file doesn't exist in the source path being tested (in which case, no error is shown). --- boot/freeldr/freeldr/ntldr/setupldr.c | 31 +++++++++++++++++++++------ 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/boot/freeldr/freeldr/ntldr/setupldr.c b/boot/freeldr/freeldr/ntldr/setupldr.c index 9c8272b6306..1f7f2cd0b54 100644 --- a/boot/freeldr/freeldr/ntldr/setupldr.c +++ b/boot/freeldr/freeldr/ntldr/setupldr.c @@ -514,16 +514,21 @@ LoadReactOSSetup( static PCSTR SourcePaths[] = { - "", /* Only for floppy boot */ + "", /* Keep first to optimize TXTSETUP.SIF search on floppy boot */ #if defined(_M_IX86) "I386\\", +#elif defined(_M_AMD64) + "AMD64\\", +#elif defined(_M_ARM) + "ARM\\", +#elif defined(_M_ARM64) + "ARM64\\", #elif defined(_M_MPPC) "PPC\\", #elif defined(_M_MRX000) "MIPS\\", #endif "reactos\\", - NULL }; /* Retrieve the (mandatory) boot type */ @@ -624,26 +629,38 @@ LoadReactOSSetup( } /* Check if we booted from floppy */ - BootFromFloppy = strstr(BootPath, "fdisk") != NULL; + BootFromFloppy = !!strstr(BootPath, ")fdisk("); + // FIXME: Use for implementing disk tag check when booting using multiple floppies. + DBG_UNREFERENCED_LOCAL_VARIABLE(BootFromFloppy); - /* Open 'txtsetup.sif' from any of the source paths */ + /* Open 'TXTSETUP.SIF' from any of the source paths */ FileName = BootPath + strlen(BootPath); - for (i = BootFromFloppy ? 0 : 1; ; i++) + for (i = 0;; ++i) { - SystemPath = SourcePaths[i]; - if (!SystemPath) + if (i >= RTL_NUMBER_OF(SourcePaths)) { UiMessageBox("Failed to open txtsetup.sif"); return ENOENT; } + SystemPath = SourcePaths[i]; + + /* Adjust the tentative BootPath */ FileNameLength = (ULONG)(sizeof(BootPath) - (FileName - BootPath)*sizeof(CHAR)); RtlStringCbCopyA(FileName, FileNameLength, SystemPath); + + /* Try to open TXTSETUP.SIF from this BootPath */ RtlStringCbCopyA(FilePath, sizeof(FilePath), BootPath); RtlStringCbCatA(FilePath, sizeof(FilePath), "txtsetup.sif"); if (InfOpenFile(&InfHandle, FilePath, &ErrorLine)) { + /* Found and opened: TXTSETUP.SIF is in the correct BootPath */ break; } + else + { + if (ErrorLine != -1) + UiMessageBox("Error in %s at line %lu", FilePath, ErrorLine); + } } TRACE("BootPath: '%s', SystemPath: '%s'\n", BootPath, SystemPath);