From 523822a16928cbd75ef7c027fd51761dc5caac11 Mon Sep 17 00:00:00 2001 From: Alex Ionescu Date: Sat, 3 Mar 2007 05:41:14 +0000 Subject: [PATCH] - Copy the entire drivers in memory, not just their mappable sections, since WinDBG (and probably other things) use "SizeOfImage" in the header to figure out when the image ends, but we map considerably less, creating overlaps. svn path=/trunk/; revision=25966 --- .../boot/freeldr/freeldr/arch/i386/loader.c | 22 +++---------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/reactos/boot/freeldr/freeldr/arch/i386/loader.c b/reactos/boot/freeldr/freeldr/arch/i386/loader.c index b0f5be398bf..69d72593f3b 100644 --- a/reactos/boot/freeldr/freeldr/arch/i386/loader.c +++ b/reactos/boot/freeldr/freeldr/arch/i386/loader.c @@ -545,29 +545,13 @@ FrLdrReMapImage(IN PVOID Base, NtHeader = RtlImageNtHeader(Base); Section = IMAGE_FIRST_SECTION(NtHeader); - /* Determine the size of the module */ - for (i = 0; i < NtHeader->FileHeader.NumberOfSections; i++) - { - /* Skip this section if we're not supposed to load it */ - if (!(Section[i].Characteristics & IMAGE_SCN_TYPE_NOLOAD)) - { - /* Add the size of this section into the total size */ - Size = Section[i].VirtualAddress + Section[i].Misc.VirtualSize; - DriverSize = max(DriverSize, Size); - } - } - - /* Round up the driver size to section alignment */ - DriverSize = ROUND_UP(DriverSize, NtHeader->OptionalHeader.SectionAlignment); - /* Allocate memory for the driver */ + DriverSize = NtHeader->OptionalHeader.SizeOfImage; LoadBase = MmAllocateMemoryAtAddress(DriverSize, LoadBase); ASSERT(LoadBase); /* Copy headers over */ - RtlMoveMemory(LoadBase, - Base, - NtHeader->OptionalHeader.SizeOfHeaders); + RtlMoveMemory(LoadBase, Base, NtHeader->OptionalHeader.SizeOfHeaders); /* Copy image sections into virtual section */ for (i = 0; i < NtHeader->FileHeader.NumberOfSections; i++) @@ -644,7 +628,7 @@ FrLdrMapImage(IN FILE *Image, NextModuleBase = ROUND_UP(NextModuleBase + ImageSize, PAGE_SIZE); /* Successful load! */ - //DbgPrint("Image: %s loaded at: %p\n", Name, ImageBase); + DbgPrint("Image: %s loaded at: %p\n", Name, ImageBase); /* Load HAL if this is the kernel */ if (ImageType == 1) FrLdrLoadImage("hal.dll", 10, FALSE);