From a38083f7d528111087949a0ba8e3970f091f2fc9 Mon Sep 17 00:00:00 2001 From: Amlal EL Mahrouss Date: Sun, 4 Aug 2024 14:16:39 +0200 Subject: [FIX] CG's text writer functions. Need to fix ProgramLoader class now for DLLs/LIBs. Signed-off-by: Amlal EL Mahrouss --- Boot/Sources/ProgramLoader.cxx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'Boot/Sources/ProgramLoader.cxx') 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 = §Ptr[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"); } -- cgit v1.2.3