summaryrefslogtreecommitdiffhomepage
path: root/Boot/Sources/ProgramLoader.cxx
diff options
context:
space:
mode:
authorAmlal EL Mahrouss <amlalelmahrouss@icloud.com>2024-08-04 14:16:39 +0200
committerAmlal EL Mahrouss <amlalelmahrouss@icloud.com>2024-08-04 14:16:39 +0200
commita38083f7d528111087949a0ba8e3970f091f2fc9 (patch)
treec21cda9b4571758540564b562ea6858ddf89030b /Boot/Sources/ProgramLoader.cxx
parentcd400898f5a6ef04690231323c0be107ae330fb4 (diff)
[FIX] CG's text writer functions. Need to fix ProgramLoader class now
for DLLs/LIBs. Signed-off-by: Amlal EL Mahrouss <amlalelmahrouss@icloud.com>
Diffstat (limited to 'Boot/Sources/ProgramLoader.cxx')
-rw-r--r--Boot/Sources/ProgramLoader.cxx9
1 files changed, 7 insertions, 2 deletions
diff --git a/Boot/Sources/ProgramLoader.cxx b/Boot/Sources/ProgramLoader.cxx
index be2650dc..e4f61630 100644
--- a/Boot/Sources/ProgramLoader.cxx
+++ b/Boot/Sources/ProgramLoader.cxx
@@ -56,11 +56,16 @@ namespace Boot
writer.Write("newosldr: Major Subsystem Ver: ").Write(optHdr->mMajorSubsystemVersion).Write("\r");
writer.Write("newosldr: Minor Subsystem Ver: ").Write(optHdr->mMinorSubsystemVersion).Write("\r");
writer.Write("newosldr: Magic: ").Write(optHdr->mMagic).Write("\r");
+ writer.Write("newosldr: ImageBase: ").Write(optHdr->mImageBase).Write("\r");
- ExecSectionHeaderPtr sectPtr = (ExecSectionHeaderPtr)((UIntPtr)firstBytes + ((DosHeaderPtr)firstBytes)->eLfanew + hdrPtr->mSizeOfOptionalHeader + sizeof(ExecHeader) + sizeof(UInt32));
+ EfiPhysicalAddress base_img_addr = optHdr->mImageBase;
constexpr auto cMaxSectionsOfKernel = 10;
+ BS->AllocatePages(EfiAllocateType::AllocateAnyPages, EfiMemoryType::EfiLoaderCode, cMaxSectionsOfKernel, &base_img_addr);
+
+ ExecSectionHeaderPtr sectPtr = (ExecSectionHeaderPtr)((UIntPtr)firstBytes + ((DosHeaderPtr)firstBytes)->eLfanew + hdrPtr->mSizeOfOptionalHeader + sizeof(ExecHeader) + sizeof(UInt32));
+
for (SizeT sectIndex = 0; sectIndex < cMaxSectionsOfKernel; ++sectIndex)
{
ExecSectionHeaderPtr sect = &sectPtr[sectIndex];
@@ -72,7 +77,7 @@ namespace Boot
{
if (!fStartAddress)
{
- fStartAddress = (VoidPtr)((VoidPtr)((UIntPtr)fBlob + 184 + (sect->mVirtualAddress - optHdr->mAddressOfEntryPoint)));
+ fStartAddress = (VoidPtr)((VoidPtr)((UIntPtr)sect->mPointerToRawData + (sect->mVirtualAddress - optHdr->mAddressOfEntryPoint)));
writer.Write("newosldr: Start Address set: ").Write((UIntPtr)fStartAddress).Write("\r");
}