[ros-diffs] [fireball] 51192: [NTOS/MM] - Remove IMG_SCN_TYPE_NOLOAD support which was firstly removed by Alex, then reenabled by Herve. Hopefully it works this time. - Return proper image size after successfu...

fireball at svn.reactos.org fireball at svn.reactos.org
Tue Mar 29 10:56:28 UTC 2011


Author: fireball
Date: Tue Mar 29 10:56:28 2011
New Revision: 51192

URL: http://svn.reactos.org/svn/reactos?rev=51192&view=rev
Log:
[NTOS/MM]
- Remove IMG_SCN_TYPE_NOLOAD support which was firstly removed by Alex, then reenabled by Herve. Hopefully it works this time.
- Return proper image size after successfully mapping an image section (previously, 0 was always returned). The change above is necessary for returning correct size.

Modified:
    trunk/reactos/ntoskrnl/mm/section.c

Modified: trunk/reactos/ntoskrnl/mm/section.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/section.c?rev=51192&r1=51191&r2=51192&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/mm/section.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/section.c [iso-8859-1] Tue Mar 29 10:56:28 2011
@@ -4326,14 +4326,11 @@
        * and calculate the image base address */
       for (i = 0; i < NrSegments; i++)
       {
-         if (!(SectionSegments[i].Characteristics & IMAGE_SCN_TYPE_NOLOAD))
-         {
-            if (Segment == &SectionSegments[i])
-            {
-               ImageBaseAddress = (char*)BaseAddress - (ULONG_PTR)SectionSegments[i].VirtualAddress;
-               break;
-            }
-         }
+          if (Segment == &SectionSegments[i])
+          {
+              ImageBaseAddress = (char*)BaseAddress - (ULONG_PTR)SectionSegments[i].VirtualAddress;
+              break;
+          }
       }
       if (i >= NrSegments)
       {
@@ -4342,13 +4339,10 @@
 
       for (i = 0; i < NrSegments; i++)
       {
-         if (!(SectionSegments[i].Characteristics & IMAGE_SCN_TYPE_NOLOAD))
-         {
-            PVOID SBaseAddress = (PVOID)
-                                 ((char*)ImageBaseAddress + (ULONG_PTR)SectionSegments[i].VirtualAddress);
-
-            Status = MmUnmapViewOfSegment(AddressSpace, SBaseAddress);
-         }
+          PVOID SBaseAddress = (PVOID)
+                               ((char*)ImageBaseAddress + (ULONG_PTR)SectionSegments[i].VirtualAddress);
+
+          Status = MmUnmapViewOfSegment(AddressSpace, SBaseAddress);
       }
    }
    else
@@ -4625,13 +4619,10 @@
       ImageSize = 0;
       for (i = 0; i < NrSegments; i++)
       {
-         if (!(SectionSegments[i].Characteristics & IMAGE_SCN_TYPE_NOLOAD))
-         {
-            ULONG_PTR MaxExtent;
-            MaxExtent = (ULONG_PTR)SectionSegments[i].VirtualAddress +
-                        SectionSegments[i].Length;
-            ImageSize = max(ImageSize, MaxExtent);
-         }
+          ULONG_PTR MaxExtent;
+          MaxExtent = (ULONG_PTR)SectionSegments[i].VirtualAddress +
+                      SectionSegments[i].Length;
+          ImageSize = max(ImageSize, MaxExtent);
       }
 
       ImageSectionObject->ImageSize = ImageSize;
@@ -4659,29 +4650,27 @@
 
       for (i = 0; i < NrSegments; i++)
       {
-         if (!(SectionSegments[i].Characteristics & IMAGE_SCN_TYPE_NOLOAD))
-         {
-            PVOID SBaseAddress = (PVOID)
-                                 ((char*)ImageBase + (ULONG_PTR)SectionSegments[i].VirtualAddress);
-            MmLockSectionSegment(&SectionSegments[i]);
-            Status = MmMapViewOfSegment(AddressSpace,
-                                        Section,
-                                        &SectionSegments[i],
-                                        &SBaseAddress,
-                                        SectionSegments[i].Length,
-                                        SectionSegments[i].Protection,
-                                        0,
-                                        0);
-            MmUnlockSectionSegment(&SectionSegments[i]);
-            if (!NT_SUCCESS(Status))
-            {
-               MmUnlockAddressSpace(AddressSpace);
-               return(Status);
-            }
-         }
+          PVOID SBaseAddress = (PVOID)
+                               ((char*)ImageBase + (ULONG_PTR)SectionSegments[i].VirtualAddress);
+          MmLockSectionSegment(&SectionSegments[i]);
+          Status = MmMapViewOfSegment(AddressSpace,
+                                      Section,
+                                      &SectionSegments[i],
+                                      &SBaseAddress,
+                                      SectionSegments[i].Length,
+                                      SectionSegments[i].Protection,
+                                      0,
+                                      0);
+          MmUnlockSectionSegment(&SectionSegments[i]);
+          if (!NT_SUCCESS(Status))
+          {
+              MmUnlockAddressSpace(AddressSpace);
+              return(Status);
+          }
       }
 
       *BaseAddress = (PVOID)ImageBase;
+      *ViewSize = ImageSize;
    }
    else
    {




More information about the Ros-diffs mailing list