[FREELDR] Initialize a global module list head for freeldr

This commit is contained in:
Timo Kreuzer 2024-10-05 12:14:59 +02:00
parent 6eac9b5891
commit f9849f7cc4
3 changed files with 35 additions and 0 deletions

View file

@ -64,6 +64,13 @@ VOID __cdecl BootMain(IN PCCH CmdLine)
/* Initialize I/O subsystem */
FsInit();
/* Initialize the module list */
if (!PeLdrInitializeModuleList())
{
UiMessageBoxCritical("Unable to initialize module list.");
goto Quit;
}
RunLoader();
Quit:

View file

@ -26,6 +26,9 @@ typedef VOID
extern PELDR_IMPORTDLL_LOAD_CALLBACK PeLdrImportDllLoadCallback;
BOOLEAN
PeLdrInitializeModuleList(VOID);
BOOLEAN
PeLdrLoadImage(
_In_ PCSTR FilePath,

View file

@ -25,6 +25,8 @@ DBG_DEFAULT_CHANNEL(PELOADER);
/* GLOBALS *******************************************************************/
LIST_ENTRY FrLdrModuleList;
PELDR_IMPORTDLL_LOAD_CALLBACK PeLdrImportDllLoadCallback = NULL;
#ifdef _WIN64
@ -518,6 +520,29 @@ PeLdrpScanImportAddressTable(
/* FUNCTIONS *****************************************************************/
BOOLEAN
PeLdrInitializeModuleList(VOID)
{
PLDR_DATA_TABLE_ENTRY FreeldrDTE;
InitializeListHead(&FrLdrModuleList);
/* Allocate a data table entry for freeldr.sys.
The base name is scsiport.sys for imports from ntbootdd.sys */
if (!PeLdrAllocateDataTableEntry(&FrLdrModuleList,
"scsiport.sys",
"freeldr.sys",
&__ImageBase,
&FreeldrDTE))
{
/* Cleanup and bail out */
ERR("Failed to allocate DTE for freeldr\n");
return FALSE;
}
return TRUE;
}
PVOID
PeLdrInitSecurityCookie(PLDR_DATA_TABLE_ENTRY LdrEntry)
{