[FREELDR] Pass VA instead of PA to PeLdrAllocateDataTableEntry

This allows to create DTEs for loader modules.
This commit is contained in:
Timo Kreuzer 2024-10-03 10:12:29 +02:00
parent 8a5ef4c1cc
commit 6eac9b5891
3 changed files with 10 additions and 6 deletions

View file

@ -44,7 +44,7 @@ PeLdrAllocateDataTableEntry(
IN OUT PLIST_ENTRY ModuleListHead, IN OUT PLIST_ENTRY ModuleListHead,
IN PCCH BaseDllName, IN PCCH BaseDllName,
IN PCCH FullDllName, IN PCCH FullDllName,
IN PVOID BasePA, IN PVOID BaseVA,
OUT PLDR_DATA_TABLE_ENTRY *NewEntry); OUT PLDR_DATA_TABLE_ENTRY *NewEntry);
VOID VOID

View file

@ -418,7 +418,7 @@ PeLdrpLoadAndScanReferencedDll(
Success = PeLdrAllocateDataTableEntry(Parent ? Parent->Blink : ModuleListHead, Success = PeLdrAllocateDataTableEntry(Parent ? Parent->Blink : ModuleListHead,
ImportName, ImportName,
FullDllName, FullDllName,
BasePA, PaToVa(BasePA),
DataTableEntry); DataTableEntry);
if (!Success) if (!Success)
{ {
@ -682,10 +682,10 @@ PeLdrAllocateDataTableEntry(
IN OUT PLIST_ENTRY ModuleListHead, IN OUT PLIST_ENTRY ModuleListHead,
IN PCCH BaseDllName, IN PCCH BaseDllName,
IN PCCH FullDllName, IN PCCH FullDllName,
IN PVOID BasePA, IN PVOID BaseVA,
OUT PLDR_DATA_TABLE_ENTRY *NewEntry) OUT PLDR_DATA_TABLE_ENTRY *NewEntry)
{ {
PVOID BaseVA = PaToVa(BasePA); PVOID BasePA = VaToPa(BaseVA);
PWSTR BaseDllNameBuffer, Buffer; PWSTR BaseDllNameBuffer, Buffer;
PLDR_DATA_TABLE_ENTRY DataTableEntry; PLDR_DATA_TABLE_ENTRY DataTableEntry;
PIMAGE_NT_HEADERS NtHeaders; PIMAGE_NT_HEADERS NtHeaders;

View file

@ -342,7 +342,11 @@ WinLdrLoadDeviceDriver(PLIST_ENTRY LoadOrderListHead,
} }
// Allocate a DTE for it // Allocate a DTE for it
Success = PeLdrAllocateDataTableEntry(LoadOrderListHead, DllName, DllName, DriverBase, DriverDTE); Success = PeLdrAllocateDataTableEntry(LoadOrderListHead,
DllName,
DllName,
PaToVa(DriverBase),
DriverDTE);
if (!Success) if (!Success)
{ {
/* Cleanup and bail out */ /* Cleanup and bail out */
@ -542,7 +546,7 @@ LoadModule(
Success = PeLdrAllocateDataTableEntry(&LoaderBlock->LoadOrderListHead, Success = PeLdrAllocateDataTableEntry(&LoaderBlock->LoadOrderListHead,
ImportName, ImportName,
FullFileName, FullFileName,
BaseAddress, PaToVa(BaseAddress),
Dte); Dte);
if (!Success) if (!Success)
{ {