https://git.reactos.org/?p=reactos.git;a=commitdiff;h=8a5ef4c1cc40d4649cbdc…
commit 8a5ef4c1cc40d4649cbdc77b4e9b394b3ff111c9
Author: Timo Kreuzer <timo.kreuzer(a)reactos.org>
AuthorDate: Sun Jan 14 09:32:05 2024 +0100
Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org>
CommitDate: Sat Nov 2 17:31:57 2024 +0200
[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
---
boot/freeldr/freeldr/include/peloader.h | 7 +++++++
boot/freeldr/freeldr/lib/peloader.c | 16 +++++++++++++---
2 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/boot/freeldr/freeldr/include/peloader.h
b/boot/freeldr/freeldr/include/peloader.h
index 00a387ef7a0..05214be9621 100644
--- a/boot/freeldr/freeldr/include/peloader.h
+++ b/boot/freeldr/freeldr/include/peloader.h
@@ -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,
diff --git a/boot/freeldr/freeldr/lib/peloader.c b/boot/freeldr/freeldr/lib/peloader.c
index 857dba43258..13b6895f38b 100644
--- a/boot/freeldr/freeldr/lib/peloader.c
+++ b/boot/freeldr/freeldr/lib/peloader.c
@@ -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);
+}