forked from reactos/reactos-deprecated-gitsvn-dont-use
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FREELDR] Load Hardware IDs from txtsetup.sif ([HardwareIdsDatabase] …
…section) to allocated in memory Database. SetupBlock->HardwareIdDatabase point on Head it.
- Loading branch information
1 parent
b1be7a0
commit 2a1811e
Showing
1 changed file
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ | |
|
||
DBG_DEFAULT_CHANNEL(WINDOWS); | ||
#define TAG_BOOT_OPTIONS 'pOtB' | ||
#define TAG_HARDWARE_ID 'dIwH' | ||
|
||
void | ||
WinLdrSetupMachineDependent(PLOADER_PARAMETER_BLOCK LoaderBlock); | ||
|
@@ -133,6 +134,82 @@ SetupLdrScanBootDrivers(PLIST_ENTRY BootDriverListHead, HINF InfHandle, LPCSTR S | |
} while (InfFindNextLine(&InfContext, &InfContext)); | ||
} | ||
|
||
static VOID | ||
SetupLdrLoadHardwareIdsDatabase(PSETUP_LOADER_BLOCK SetupBlock, HINF InfHandle, LPCSTR SearchPath) | ||
{ | ||
INFCONTEXT InfContext; | ||
LPCSTR Id; | ||
LPCSTR DriverName; | ||
SIZE_T Size; | ||
PVOID Temp; | ||
PPNP_HARDWARE_ID HardwareId; | ||
PPNP_HARDWARE_ID HeadHardwareId; | ||
PPNP_HARDWARE_ID LastHardwareId = 0; | ||
|
||
/* | ||
typedef struct _PNP_HARDWARE_ID | ||
{ | ||
struct _PNP_HARDWARE_ID *Next; | ||
PCHAR Id; | ||
PCHAR DriverName; | ||
PCHAR ClassGuid; | ||
This comment has been minimized.
Sorry, something went wrong. |
||
} PNP_HARDWARE_ID, *PPNP_HARDWARE_ID; | ||
*/ | ||
|
||
/* Open inf section */ | ||
if (!InfFindFirstLine(InfHandle, "HardwareIdsDatabase", NULL, &InfContext)) | ||
return; | ||
This comment has been minimized.
Sorry, something went wrong. |
||
|
||
/* Load all HardwareIds */ | ||
do | ||
{ | ||
if (InfGetDataField(&InfContext, 0, &Id) && | ||
InfGetDataField(&InfContext, 1, &DriverName)) | ||
{ | ||
/* Allocate and initialize the new struct _PNP_HARDWARE_ID */ | ||
Size = sizeof(PNP_HARDWARE_ID); | ||
HardwareId = FrLdrHeapAlloc(Size, TAG_HARDWARE_ID); | ||
if (HardwareId == NULL) | ||
return; | ||
|
||
memset(HardwareId, 0, Size); | ||
|
||
/* For link field */ | ||
if(LastHardwareId) | ||
LastHardwareId->Next = (PPNP_HARDWARE_ID)((ULONG)HardwareId | 0x80000000); | ||
else | ||
HeadHardwareId = (PPNP_HARDWARE_ID)((ULONG)HardwareId | 0x80000000); //first record | ||
This comment has been minimized.
Sorry, something went wrong.
learn-more
|
||
|
||
/* DPRINT */ | ||
//ERR("SetupLdrLoadHardwareIdsDatabase: HardwareId - %p\n", HardwareId); | ||
|
||
LastHardwareId = HardwareId; | ||
|
||
/* Allocate and copy name Id */ | ||
Size = strlen(Id) + 1; | ||
Temp = FrLdrHeapAlloc(Size, TAG_HARDWARE_ID); | ||
if (Temp == NULL) | ||
return; | ||
|
||
memmove(Temp, Id, Size); | ||
|
||
HardwareId->Id = (PCHAR)((ULONG)Temp | 0x80000000); | ||
|
||
/* Allocate and copy driver name */ | ||
Size = strlen(DriverName) + 1; | ||
Temp = FrLdrHeapAlloc(Size, TAG_HARDWARE_ID); | ||
if (Temp == NULL) | ||
return; | ||
|
||
memmove(Temp, DriverName, Size); | ||
|
||
HardwareId->DriverName = (PCHAR)((ULONG)Temp | 0x80000000); | ||
} | ||
} while (InfFindNextLine(&InfContext, &InfContext)); | ||
|
||
SetupBlock->HardwareIdDatabase = (PPNP_HARDWARE_ID)((ULONG)HeadHardwareId | 0x80000000); | ||
} | ||
|
||
VOID | ||
LoadReactOSSetup(IN OperatingSystemItem* OperatingSystem, | ||
IN USHORT OperatingSystemVersion) | ||
|
@@ -328,6 +405,9 @@ LoadReactOSSetup(IN OperatingSystemItem* OperatingSystem, | |
/* Get a list of boot drivers */ | ||
SetupLdrScanBootDrivers(&LoaderBlock->BootDriverListHead, InfHandle, BootPath); | ||
|
||
/* Load HardwareIds Database */ | ||
SetupLdrLoadHardwareIdsDatabase(SetupBlock, InfHandle, BootPath); | ||
|
||
/* Close the inf file */ | ||
InfCloseFile(InfHandle); | ||
|
||
|
Should we also initialize ClassGuid?
(Atleast set it to NULL!)