Author: fireball
Date: Thu Sep 18 06:19:29 2008
New Revision: 36300
URL:
http://svn.reactos.org/svn/reactos?rev=36300&view=rev
Log:
- Save SizeOfImage field from the image header during PE loading.
Modified:
trunk/reactos/ntoskrnl/mm/pe.c
Modified: trunk/reactos/ntoskrnl/mm/pe.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/pe.c?rev=36300…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/pe.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/pe.c [iso-8859-1] Thu Sep 18 06:19:29 2008
@@ -362,6 +362,9 @@
if(RTL_CONTAINS_FIELD(piohOptHeader, cbOptHeaderSize, ImageBase))
ImageSectionObject->ImageBase = piohOptHeader->ImageBase;
+ if(RTL_CONTAINS_FIELD(piohOptHeader, cbOptHeaderSize, SizeOfImage))
+ ImageSectionObject->ImageSize = piohOptHeader->SizeOfImage;
+
if(RTL_CONTAINS_FIELD(piohOptHeader, cbOptHeaderSize, SizeOfStackReserve))
ImageSectionObject->StackReserve = piohOptHeader->SizeOfStackReserve;
@@ -384,6 +387,14 @@
DIE(("ImageBase exceeds the address space\n"));
ImageSectionObject->ImageBase = pioh64OptHeader->ImageBase;
+ }
+
+ if(RTL_CONTAINS_FIELD(pioh64OptHeader, cbOptHeaderSize, SizeOfImage))
+ {
+ if(pioh64OptHeader->SizeOfImage > MAXULONG_PTR)
+ DIE(("SizeOfImage exceeds the address space\n"));
+
+ ImageSectionObject->ImageSize = pioh64OptHeader->SizeOfImage;
}
if(RTL_CONTAINS_FIELD(pioh64OptHeader, cbOptHeaderSize, SizeOfStackReserve))