Skip to content

Commit 9b7c788

Browse files
committed
[SETUPLDR] Add support for architecture-specific "SourceDisksNames" section (reactos#8249)
Will be used for installing specific drivers on x64 (e.g. the ACPI driver, see PR reactos#8238). Add also the ARM64 define in the SETUPLIB spapisup.h header.
1 parent a18a573 commit 9b7c788

File tree

2 files changed

+29
-10
lines changed

2 files changed

+29
-10
lines changed

base/setup/lib/spapisup/spapisup.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,17 @@
1313
#define _SETUPAPI_
1414
#endif
1515

16-
/* Architecture names to be used for architecture-specific INF sections */
17-
#ifdef _M_IX86
16+
/* Architecture name suffixes for architecture-specific INF sections */
17+
#if defined(_M_IX86)
1818
#define INF_ARCH L"x86"
1919
#elif defined(_M_AMD64)
2020
#define INF_ARCH L"amd64"
21-
#elif defined(_M_IA64)
22-
#define INF_ARCH L"ia64"
2321
#elif defined(_M_ARM)
2422
#define INF_ARCH L"arm"
23+
#elif defined(_M_ARM64)
24+
#define INF_ARCH L"arm64"
25+
#elif defined(_M_IA64)
26+
#define INF_ARCH L"ia64"
2527
#elif defined(_M_PPC)
2628
#define INF_ARCH L"ppc"
2729
#endif

boot/freeldr/freeldr/ntldr/setupldr.c

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,17 @@
1515
#include <debug.h>
1616
DBG_DEFAULT_CHANNEL(WINDOWS);
1717

18+
/* Architecture name suffixes for architecture-specific INF sections */
19+
#if defined(_M_IX86)
20+
#define INF_ARCH "x86"
21+
#elif defined(_M_AMD64)
22+
#define INF_ARCH "amd64"
23+
#elif defined(_M_ARM)
24+
#define INF_ARCH "arm"
25+
#elif defined(_M_ARM64)
26+
#define INF_ARCH "arm64"
27+
#endif
28+
1829
// TODO: Move to .h
1930
VOID
2031
AllocateAndInitLPB(
@@ -143,14 +154,20 @@ SetupLdrScanBootDrivers(
143154
INFCONTEXT InfContext, dirContext;
144155
PCSTR Media, DriverName, dirIndex, ImagePath;
145156
BOOLEAN Success;
157+
UINT8 Pass;
146158
WCHAR ImagePathW[MAX_PATH];
147159
WCHAR DriverNameW[256];
148160

149161
UNREFERENCED_PARAMETER(SearchPath);
150162

151-
/* Open INF section */
152-
if (!InfFindFirstLine(InfHandle, "SourceDisksFiles", NULL, &InfContext))
153-
goto Quit;
163+
/* Open the INF section, first the optional platform-specific one,
164+
* then the generic section */
165+
for (Pass = 0; Pass <= 1; ++Pass)
166+
{
167+
PCSTR pFilesSection[] = {"SourceDisksFiles." INF_ARCH, "SourceDisksFiles"};
168+
169+
if (!InfFindFirstLine(InfHandle, pFilesSection[Pass], NULL, &InfContext))
170+
continue;
154171

155172
/* Load all listed boot drivers */
156173
do
@@ -159,15 +176,15 @@ SetupLdrScanBootDrivers(
159176
InfGetDataField(&InfContext, 0, &DriverName) &&
160177
InfGetDataField(&InfContext, 13, &dirIndex))
161178
{
162-
if ((strcmp(Media, "x") == 0) &&
179+
if ((strcmp(Media, "x") == 0) && // HACK: ReactOS-specific
163180
InfFindFirstLine(InfHandle, "Directories", dirIndex, &dirContext) &&
164181
InfGetDataField(&dirContext, 1, &ImagePath))
165182
{
166183
/* Prepare image path */
167184
RtlStringCbPrintfW(ImagePathW, sizeof(ImagePathW),
168185
L"%S\\%S", ImagePath, DriverName);
169186

170-
/* Convert name to unicode and remove .sys extension */
187+
/* Convert name to Unicode and remove .sys extension */
171188
RtlStringCbPrintfW(DriverNameW, sizeof(DriverNameW),
172189
L"%S", DriverName);
173190
DriverNameW[wcslen(DriverNameW) - 4] = UNICODE_NULL;
@@ -188,8 +205,8 @@ SetupLdrScanBootDrivers(
188205
}
189206
}
190207
} while (InfFindNextLine(&InfContext, &InfContext));
208+
} // for (Pass...)
191209

192-
Quit:
193210
/* Finally, add the boot filesystem driver to the list */
194211
if (BootFileSystem)
195212
{

0 commit comments

Comments
 (0)