// #define SetupFindNextLine InfFindNextLine BOOL WINAPI SetupFindNextLine( IN PINFCONTEXT ContextIn, OUT PINFCONTEXT ContextOut) { return !!InfFindNextLine(ContextIn, ContextOut); }
static VOID SetupLdrScanBootDrivers(PLIST_ENTRY BootDriverListHead, HINF InfHandle, LPCSTR SearchPath) { INFCONTEXT InfContext, dirContext; BOOLEAN Status; LPCSTR Media, DriverName, dirIndex, ImagePath; WCHAR ServiceName[256]; WCHAR ImagePathW[256]; /* Open inf section */ if (!InfFindFirstLine(InfHandle, "SourceDisksFiles", NULL, &InfContext)) return; /* Load all listed boot drivers */ do { if (InfGetDataField(&InfContext, 7, &Media) && InfGetDataField(&InfContext, 0, &DriverName) && InfGetDataField(&InfContext, 13, &dirIndex)) { if ((strcmp(Media, "x") == 0) && InfFindFirstLine(InfHandle, "Directories", dirIndex, &dirContext) && InfGetDataField(&dirContext, 1, &ImagePath)) { /* Convert name to widechar */ swprintf(ServiceName, L"%S", DriverName); /* Prepare image path */ swprintf(ImagePathW, L"%S", ImagePath); wcscat(ImagePathW, L"\\"); wcscat(ImagePathW, ServiceName); /* Remove .sys extension */ ServiceName[wcslen(ServiceName) - 4] = 0; /* Add it to the list */ Status = WinLdrAddDriverToList(BootDriverListHead, L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\", ImagePathW, ServiceName); if (!Status) { ERR("could not add boot driver %s, %s\n", SearchPath, DriverName); return; } } } } while (InfFindNextLine(&InfContext, &InfContext)); }