Author: ion
Date: Sat Mar 3 08:41:14 2007
New Revision: 25966
URL:
http://svn.reactos.org/svn/reactos?rev=25966&view=rev
Log:
- 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.
Modified:
trunk/reactos/boot/freeldr/freeldr/arch/i386/loader.c
Modified: trunk/reactos/boot/freeldr/freeldr/arch/i386/loader.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/arch/i386/loader.c (original)
+++ trunk/reactos/boot/freeldr/freeldr/arch/i386/loader.c Sat Mar 3 08:41:14 2007
@@ -545,29 +545,13 @@
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 @@
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);