[FREELDR] Implement PeLdrLoadImageEx

This allows to load an image as freeldr extension code.
TODO:
- Add global bootloader DTE list
- Add wrapper function that also processes imports
- Use this for scsiport
This commit is contained in:
Timo Kreuzer 2024-01-14 09:32:05 +01:00
parent bee8e81d5a
commit 8a5ef4c1cc
2 changed files with 20 additions and 3 deletions

View file

@ -32,6 +32,13 @@ PeLdrLoadImage(
_In_ TYPE_OF_MEMORY MemoryType,
_Out_ PVOID* ImageBasePA);
BOOLEAN
PeLdrLoadImageEx(
_In_ PCSTR FilePath,
_In_ TYPE_OF_MEMORY MemoryType,
_Out_ PVOID* ImageBasePA,
_In_ BOOLEAN KernelMapping);
BOOLEAN
PeLdrAllocateDataTableEntry(
IN OUT PLIST_ENTRY ModuleListHead,

View file

@ -820,10 +820,11 @@ PeLdrFreeDataTableEntry(
* Addressing mode: physical.
**/
BOOLEAN
PeLdrLoadImage(
PeLdrLoadImageEx(
_In_ PCSTR FilePath,
_In_ TYPE_OF_MEMORY MemoryType,
_Out_ PVOID* ImageBasePA)
_Out_ PVOID* ImageBasePA,
_In_ BOOLEAN KernelMapping)
{
ULONG FileId;
PVOID PhysicalBase;
@ -895,7 +896,7 @@ PeLdrLoadImage(
}
/* This is the real image base, in form of a virtual address */
VirtualBase = PaToVa(PhysicalBase);
VirtualBase = KernelMapping ? PaToVa(PhysicalBase) : PhysicalBase;
TRACE("Base PA: 0x%p, VA: 0x%p\n", PhysicalBase, VirtualBase);
@ -1009,3 +1010,12 @@ Failure:
MmFreeMemory(PhysicalBase);
return FALSE;
}
BOOLEAN
PeLdrLoadImage(
_In_ PCSTR FilePath,
_In_ TYPE_OF_MEMORY MemoryType,
_Out_ PVOID* ImageBasePA)
{
return PeLdrLoadImageEx(FilePath, MemoryType, ImageBasePA, TRUE);
}