[NTOSKRNL]
[reactos.git] / reactos / ntoskrnl / mm / section.c
index 5dad201..596be8a 100644 (file)
@@ -45,6 +45,9 @@
 /* INCLUDES *****************************************************************/
 
 #include <ntoskrnl.h>
+#ifdef NEWCC
+#include "../cache/section/newmm.h"
+#endif
 #define NDEBUG
 #include <debug.h>
 #include <reactos/exeformat.h>
@@ -84,7 +87,7 @@ MmMapViewOfArm3Section(IN PVOID SectionObject,
                        IN SECTION_INHERIT InheritDisposition,
                        IN ULONG AllocationType,
                        IN ULONG Protect);
-                       
+
 //
 // PeFmtCreateSection depends on the following:
 //
@@ -121,8 +124,6 @@ MM_SECTION_PAGEOUT_CONTEXT;
 
 POBJECT_TYPE MmSectionObjectType = NULL;
 
-SIZE_T MmAllocationFragment;
-
 ULONG_PTR MmSubsectionBase;
 
 static ULONG SectionCharacteristicsToProtect[16] =
@@ -160,9 +161,9 @@ static GENERIC_MAPPING MmpSectionMapping = {
 #define SHARE_COUNT_FROM_SSE(E)  (((E) & 0x00000FFE) >> 1)
 #define IS_SWAP_FROM_SSE(E)      ((E) & 0x00000001)
 #define MAX_SHARE_COUNT          0x7FF
-#define MAKE_SSE(P, C)           ((P) | ((C) << 1))
+#define MAKE_SSE(P, C)           ((ULONG)(P) | ((C) << 1))
 #define SWAPENTRY_FROM_SSE(E)    ((E) >> 1)
-#define MAKE_SWAP_SSE(S)         (((S) << 1) | 0x1)
+#define MAKE_SWAP_SSE(S)         (((ULONG)(S) << 1) | 0x1)
 
 static const INFORMATION_CLASS_INFO ExSectionInfoClass[] =
 {
@@ -202,7 +203,7 @@ NTSTATUS NTAPI PeFmtCreateSection(IN CONST VOID * FileHeader,
     PMM_SECTION_SEGMENT pssSegments;
     LARGE_INTEGER lnOffset;
     PVOID pBuffer;
-    ULONG nPrevVirtualEndOfSegment = 0;
+    SIZE_T nPrevVirtualEndOfSegment = 0;
     ULONG nFileSizeOfHeaders = 0;
     ULONG i;
 
@@ -428,7 +429,7 @@ l_ReadHeaderFromFile:
                if(pioh64OptHeader->SizeOfStackReserve > MAXULONG_PTR)
                    DIE(("SizeOfStackReserve exceeds the address space\n"));
 
-               ImageSectionObject->StackReserve = pioh64OptHeader->SizeOfStackReserve;
+               ImageSectionObject->StackReserve = (ULONG_PTR)pioh64OptHeader->SizeOfStackReserve;
            }
 
            if(RTL_CONTAINS_FIELD(pioh64OptHeader, cbOptHeaderSize, SizeOfStackCommit))
@@ -436,7 +437,7 @@ l_ReadHeaderFromFile:
                if(pioh64OptHeader->SizeOfStackCommit > MAXULONG_PTR)
                    DIE(("SizeOfStackCommit exceeds the address space\n"));
 
-               ImageSectionObject->StackCommit = pioh64OptHeader->SizeOfStackCommit;
+               ImageSectionObject->StackCommit = (ULONG_PTR)pioh64OptHeader->SizeOfStackCommit;
            }
 
            break;
@@ -581,7 +582,7 @@ l_ReadHeaderFromFile:
     ImageSectionObject->Segments = AllocateSegmentsCb(ImageSectionObject->NrSegments);
 
     if(ImageSectionObject->Segments == NULL)
-       DIE(("AllocateSegments failed\n"));
+        DIE(("AllocateSegments failed\n"));
 
     /* initialize the headers segment */
        pssSegments = ImageSectionObject->Segments;
@@ -589,10 +590,11 @@ l_ReadHeaderFromFile:
 //  ASSERT(IsAligned(cbHeadersSize, nFileAlignment));
 
     if(!AlignUp(&nFileSizeOfHeaders, cbHeadersSize, nFileAlignment))
-       DIE(("Cannot align the size of the section headers\n"));
+        DIE(("Cannot align the size of the section headers\n"));
 
-    if(!AlignUp(&nPrevVirtualEndOfSegment, cbHeadersSize, nSectionAlignment))
-       DIE(("Cannot align the size of the section headers\n"));
+    nPrevVirtualEndOfSegment = ALIGN_UP_BY(cbHeadersSize, nSectionAlignment);
+    if (nPrevVirtualEndOfSegment < cbHeadersSize)
+        DIE(("Cannot align the size of the section headers\n"));
 
     pssSegments[0].FileOffset = 0;
     pssSegments[0].Protection = PAGE_READONLY;
@@ -671,11 +673,10 @@ l_ReadHeaderFromFile:
        else
            pssSegments[i].Length = pishSectionHeaders[i].Misc.VirtualSize;
 
-       if(!AlignUp(&pssSegments[i].Length, pssSegments[i].Length, nSectionAlignment))
+    pssSegments[i].Length = ALIGN_UP_BY(pssSegments[i].Length, nSectionAlignment);
+    if (pssSegments[i].Length < pssSegments[i].Length)
            DIE(("Cannot align the virtual size of section %u\n", i));
 
-       ASSERT(IsAligned(pssSegments[i].Length, nSectionAlignment));
-
        if(pssSegments[i].Length == 0)
            DIE(("Virtual size of section %u is null\n", i));
 
@@ -683,13 +684,11 @@ l_ReadHeaderFromFile:
        pssSegments[i].Characteristics = pishSectionHeaders[i].Characteristics;
 
        /* ensure the memory image is no larger than 4GB */
-       if(!Intsafe_AddULong32(&nPrevVirtualEndOfSegment, pssSegments[i].VirtualAddress, pssSegments[i].Length))
-           DIE(("The image is larger than 4GB\n"));
+       nPrevVirtualEndOfSegment = pssSegments[i].VirtualAddress + pssSegments[i].Length;
+       if (nPrevVirtualEndOfSegment < pssSegments[i].VirtualAddress)
+           DIE(("The image is too large\n"));
     }
 
-    /* spare our caller some work in validating the segments */
-    *Flags = EXEFMT_LOAD_ASSUME_SEGMENTS_SORTED | EXEFMT_LOAD_ASSUME_SEGMENTS_NO_OVERLAP;
-
     if(nSectionAlignment >= PAGE_SIZE)
        *Flags |= EXEFMT_LOAD_ASSUME_SEGMENTS_PAGE_ALIGNED;
 
@@ -745,7 +744,7 @@ MmspCompleteAndReleasePageOp(PMM_PAGEOP PageOp)
  * ARGUMENTS: PFILE_OBJECT to wait for.
  * RETURNS:   Status of the wait.
  */
-static NTSTATUS
+NTSTATUS
 MmspWaitForFileLock(PFILE_OBJECT File)
 {
     return STATUS_SUCCESS;
@@ -832,12 +831,12 @@ MmUnlockSectionSegment(PMM_SECTION_SEGMENT Segment)
 VOID
 NTAPI
 MmSetPageEntrySectionSegment(PMM_SECTION_SEGMENT Segment,
-                             ULONG Offset,
-                             ULONG Entry)
+                             ULONG_PTR Offset,
+                             ULONG_PTR Entry)
 {
    PSECTION_PAGE_TABLE Table;
-   ULONG DirectoryOffset;
-   ULONG TableOffset;
+   ULONG_PTR DirectoryOffset;
+   ULONG_PTR TableOffset;
 
    if (Segment->Length <= NR_SECTION_PAGE_TABLES * PAGE_SIZE)
    {
@@ -862,19 +861,19 @@ MmSetPageEntrySectionSegment(PMM_SECTION_SEGMENT Segment,
       }
    }
    TableOffset = PAGE_TO_SECTION_PAGE_TABLE_OFFSET(Offset);
-   Table->Entry[TableOffset] = Entry;
+   Table->Entry[TableOffset] = (ULONG)Entry;
 }
 
 
 ULONG
 NTAPI
 MmGetPageEntrySectionSegment(PMM_SECTION_SEGMENT Segment,
-                             ULONG Offset)
+                             ULONG_PTR Offset)
 {
    PSECTION_PAGE_TABLE Table;
    ULONG Entry;
-   ULONG DirectoryOffset;
-   ULONG TableOffset;
+   ULONG_PTR DirectoryOffset;
+   ULONG_PTR TableOffset;
 
    DPRINT("MmGetPageEntrySection(Segment %x, Offset %x)\n", Segment, Offset);
 
@@ -900,7 +899,7 @@ MmGetPageEntrySectionSegment(PMM_SECTION_SEGMENT Segment,
 VOID
 NTAPI
 MmSharePageEntrySectionSegment(PMM_SECTION_SEGMENT Segment,
-                               ULONG Offset)
+                               ULONG_PTR Offset)
 {
    ULONG Entry;
 
@@ -979,7 +978,11 @@ MmUnsharePageEntrySectionSegment(PROS_SECTION_OBJECT Section,
             NTSTATUS Status;
             Bcb = FileObject->SectionObjectPointer->SharedCacheMap;
             IsDirectMapped = TRUE;
+#ifndef NEWCC
             Status = CcRosUnmapCacheSegment(Bcb, FileOffset, Dirty);
+#else
+                       Status = STATUS_SUCCESS;
+#endif
             if (!NT_SUCCESS(Status))
             {
                DPRINT1("CcRosUnmapCacheSegment failed, status = %x\n", Status);
@@ -1057,6 +1060,7 @@ MmUnsharePageEntrySectionSegment(PROS_SECTION_OBJECT Section,
 BOOLEAN MiIsPageFromCache(PMEMORY_AREA MemoryArea,
                        ULONG SegOffset)
 {
+#ifndef NEWCC
    if (!(MemoryArea->Data.SectionData.Segment->Characteristics & IMAGE_SCN_MEM_SHARED))
    {
       PBCB Bcb;
@@ -1069,6 +1073,7 @@ BOOLEAN MiIsPageFromCache(PMEMORY_AREA MemoryArea,
          return TRUE;
       }
    }
+#endif
    return FALSE;
 }
 
@@ -1079,7 +1084,7 @@ MiCopyFromUserPage(PFN_NUMBER DestPage, PVOID SourceAddress)
     PEPROCESS Process;
     KIRQL Irql;
     PVOID TempAddress;
-    
+
     Process = PsGetCurrentProcess();
     TempAddress = MiMapPageInHyperSpace(Process, DestPage, &Irql);
     if (TempAddress == NULL)
@@ -1091,10 +1096,11 @@ MiCopyFromUserPage(PFN_NUMBER DestPage, PVOID SourceAddress)
     return(STATUS_SUCCESS);
 }
 
+#ifndef NEWCC
 NTSTATUS
 NTAPI
 MiReadPage(PMEMORY_AREA MemoryArea,
-           ULONG SegOffset,
+           ULONG_PTR SegOffset,
            PPFN_NUMBER Page)
 /*
  * FUNCTION: Read a page for a section backed memory area.
@@ -1105,16 +1111,16 @@ MiReadPage(PMEMORY_AREA MemoryArea,
  */
 {
    ULONG BaseOffset;
-   ULONG FileOffset;
+   ULONG_PTR FileOffset;
    PVOID BaseAddress;
    BOOLEAN UptoDate;
    PCACHE_SEGMENT CacheSeg;
    PFILE_OBJECT FileObject;
    NTSTATUS Status;
-   ULONG RawLength;
+   ULONG_PTR RawLength;
    PBCB Bcb;
    BOOLEAN IsImageSection;
-   ULONG Length;
+   ULONG_PTR Length;
 
    FileObject = MemoryArea->Data.SectionData.Section->FileObject;
    Bcb = FileObject->SectionObjectPointer->SharedCacheMap;
@@ -1142,7 +1148,7 @@ MiReadPage(PMEMORY_AREA MemoryArea,
        * alignment less than the file system block size.
        */
       Status = CcRosGetCacheSegment(Bcb,
-                                    FileOffset,
+                                    (ULONG)FileOffset,
                                     &BaseOffset,
                                     &BaseAddress,
                                     &UptoDate,
@@ -1177,19 +1183,21 @@ MiReadPage(PMEMORY_AREA MemoryArea,
       PEPROCESS Process;
       KIRQL Irql;
       PVOID PageAddr;
-      ULONG CacheSegOffset;
+      ULONG_PTR CacheSegOffset;
 
       /*
        * Allocate a page, this is rather complicated by the possibility
        * we might have to move other things out of memory
        */
+      MI_SET_USAGE(MI_USAGE_SECTION);
+      MI_SET_PROCESS2(PsGetCurrentProcess()->ImageFileName);
       Status = MmRequestPageMemoryConsumer(MC_USER, TRUE, Page);
       if (!NT_SUCCESS(Status))
       {
          return(Status);
       }
       Status = CcRosGetCacheSegment(Bcb,
-                                    FileOffset,
+                                    (ULONG)FileOffset,
                                     &BaseOffset,
                                     &BaseAddress,
                                     &UptoDate,
@@ -1230,7 +1238,7 @@ MiReadPage(PMEMORY_AREA MemoryArea,
          MiUnmapPageInHyperSpace(Process, PageAddr, Irql);
          CcRosReleaseCacheSegment(Bcb, CacheSeg, TRUE, FALSE, FALSE);
          Status = CcRosGetCacheSegment(Bcb,
-                                       FileOffset + CacheSegOffset,
+                                       (ULONG)(FileOffset + CacheSegOffset),
                                        &BaseOffset,
                                        &BaseAddress,
                                        &UptoDate,
@@ -1267,28 +1275,55 @@ MiReadPage(PMEMORY_AREA MemoryArea,
    }
    return(STATUS_SUCCESS);
 }
+#else
+NTSTATUS
+NTAPI
+MiReadPage(PMEMORY_AREA MemoryArea,
+           ULONG SegOffset,
+           PPFN_NUMBER Page)
+/*
+ * FUNCTION: Read a page for a section backed memory area.
+ * PARAMETERS:
+ *       MemoryArea - Memory area to read the page for.
+ *       Offset - Offset of the page to read.
+ *       Page - Variable that receives a page contains the read data.
+ */
+{
+   MM_REQUIRED_RESOURCES Resources = { };
+
+   Resources.Context = MemoryArea->Data.SectionData.Section->FileObject;
+   Resources.FileOffset.QuadPart = SegOffset +
+          MemoryArea->Data.SectionData.Segment->FileOffset;
+   Resources.Consumer = MC_USER;
+   Resources.Amount = PAGE_SIZE;
+
+   DPRINT1("%S, offset %x, len %d, page %x\n", ((PFILE_OBJECT)Resources.Context)->FileName.Buffer, Resources.FileOffset.LowPart, Resources.Amount, Resources.Page[0]);
+
+   NTSTATUS Status = MiReadFilePage(NULL, NULL, &Resources);
+   *Page = Resources.Page[0];
+   return Status;
+}
+#endif
 
 NTSTATUS
 NTAPI
 MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace,
                              MEMORY_AREA* MemoryArea,
-                             PVOID Address,
-                             BOOLEAN Locked)
+                             PVOID Address)
 {
    ULONG Offset;
    PFN_NUMBER Page;
    NTSTATUS Status;
-   PVOID PAddress;
    PROS_SECTION_OBJECT Section;
    PMM_SECTION_SEGMENT Segment;
-   ULONG Entry;
-   ULONG Entry1;
+   ULONG_PTR Entry;
+   ULONG_PTR Entry1;
    ULONG Attributes;
    PMM_PAGEOP PageOp;
    PMM_REGION Region;
    BOOLEAN HasSwapEntry;
    PEPROCESS Process = MmGetAddressSpaceOwner(AddressSpace);
-    
+
    /*
     * There is a window between taking the page fault and locking the
     * address space when another thread could load the page so we check
@@ -1298,10 +1333,18 @@ MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace,
    {
       return(STATUS_SUCCESS);
    }
+   
+   /*
+    * Check for the virtual memory area being deleted.
+    */
+   if (MemoryArea->DeleteInProgress)
+   {
+      return(STATUS_UNSUCCESSFUL);
+   }
 
-   PAddress = MM_ROUND_DOWN(Address, PAGE_SIZE);
-   Offset = (ULONG_PTR)PAddress - (ULONG_PTR)MemoryArea->StartingAddress
-            + MemoryArea->Data.SectionData.ViewOffset;
+   Address = MM_ROUND_DOWN(Address, PAGE_SIZE);
+   Offset = (ULONG)((ULONG_PTR)Address - (ULONG_PTR)MemoryArea->StartingAddress
+            + MemoryArea->Data.SectionData.ViewOffset);
 
    Segment = MemoryArea->Data.SectionData.Segment;
    Section = MemoryArea->Data.SectionData.Section;
@@ -1388,7 +1431,7 @@ MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace,
       if (!MmIsPagePresent(Process, Address))
       {
          Entry = MmGetPageEntrySectionSegment(Segment, Offset);
-         HasSwapEntry = MmIsPageSwapEntry(Process, (PVOID)PAddress);
+         HasSwapEntry = MmIsPageSwapEntry(Process, (PVOID)Address);
 
          if (PAGE_FROM_SSE(Entry) == 0 || HasSwapEntry)
          {
@@ -1417,7 +1460,7 @@ MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace,
             DPRINT1("Unable to create virtual mapping\n");
             KeBugCheck(MEMORY_MANAGEMENT);
          }
-         MmInsertRmap(Page, Process, (PVOID)PAddress);
+         MmInsertRmap(Page, Process, Address);
       }
       MmUnlockSectionSegment(Segment);
       PageOp->Status = STATUS_SUCCESS;
@@ -1426,7 +1469,7 @@ MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace,
       return(STATUS_SUCCESS);
    }
 
-   HasSwapEntry = MmIsPageSwapEntry(Process, (PVOID)PAddress);
+   HasSwapEntry = MmIsPageSwapEntry(Process, Address);
    if (HasSwapEntry)
    {
       /*
@@ -1444,9 +1487,12 @@ MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace,
       }
 
       MmUnlockSectionSegment(Segment);
-      MmDeletePageFileMapping(Process, (PVOID)PAddress, &SwapEntry);
+      MmDeletePageFileMapping(Process, Address, &SwapEntry);
 
       MmUnlockAddressSpace(AddressSpace);
+      MI_SET_USAGE(MI_USAGE_SECTION);
+      if (Process) MI_SET_PROCESS2(Process->ImageFileName);
+      if (!Process) MI_SET_PROCESS2("Kernel Section");
       Status = MmRequestPageMemoryConsumer(MC_USER, TRUE, &Page);
       if (!NT_SUCCESS(Status))
       {
@@ -1480,8 +1526,7 @@ MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace,
       /*
        * Add the page to the process's working set
        */
-      MmInsertRmap(Page, Process, (PVOID)PAddress);
-
+      MmInsertRmap(Page, Process, Address);
       /*
        * Finish the operation
        */
@@ -1528,6 +1573,9 @@ MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace,
    if (Segment->Characteristics & IMAGE_SCN_CNT_UNINITIALIZED_DATA)
    {
       MmUnlockSectionSegment(Segment);
+      MI_SET_USAGE(MI_USAGE_SECTION);
+      if (Process) MI_SET_PROCESS2(Process->ImageFileName);
+      if (!Process) MI_SET_PROCESS2("Kernel Section");
       Status = MmRequestPageMemoryConsumer(MC_USER, FALSE, &Page);
       if (!NT_SUCCESS(Status))
       {
@@ -1550,7 +1598,7 @@ MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace,
           KeBugCheck(MEMORY_MANAGEMENT);
          return(Status);
       }
-      MmInsertRmap(Page, Process, (PVOID)PAddress);
+      MmInsertRmap(Page, Process, Address);
 
       /*
        * Cleanup and release locks
@@ -1582,11 +1630,15 @@ MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace,
       if ((Segment->Flags & MM_PAGEFILE_SEGMENT) ||
           (Offset >= PAGE_ROUND_UP(Segment->RawLength) && Section->AllocationAttributes & SEC_IMAGE))
       {
+         MI_SET_USAGE(MI_USAGE_SECTION);
+         if (Process) MI_SET_PROCESS2(Process->ImageFileName);
+         if (!Process) MI_SET_PROCESS2("Kernel Section");
          Status = MmRequestPageMemoryConsumer(MC_USER, TRUE, &Page);
          if (!NT_SUCCESS(Status))
          {
             DPRINT1("MmRequestPageMemoryConsumer failed (Status %x)\n", Status);
          }
+
       }
       else
       {
@@ -1624,7 +1676,7 @@ MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace,
       if (Entry != Entry1)
       {
          DPRINT1("Someone changed ppte entry while we slept\n");
-          KeBugCheck(MEMORY_MANAGEMENT);
+                KeBugCheck(MEMORY_MANAGEMENT);
       }
 
       /*
@@ -1645,7 +1697,7 @@ MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace,
          DPRINT1("Unable to create virtual mapping\n");
           KeBugCheck(MEMORY_MANAGEMENT);
       }
-      MmInsertRmap(Page, Process, (PVOID)PAddress);
+      MmInsertRmap(Page, Process, Address);
 
       PageOp->Status = STATUS_SUCCESS;
       MmspCompleteAndReleasePageOp(PageOp);
@@ -1664,7 +1716,9 @@ MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace,
       MmUnlockSectionSegment(Segment);
 
       MmUnlockAddressSpace(AddressSpace);
-
+      MI_SET_USAGE(MI_USAGE_SECTION);
+      if (Process) MI_SET_PROCESS2(Process->ImageFileName);
+      if (!Process) MI_SET_PROCESS2("Kernel Section");
       Status = MmRequestPageMemoryConsumer(MC_USER, TRUE, &Page);
       if (!NT_SUCCESS(Status))
       {
@@ -1716,7 +1770,7 @@ MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace,
          DPRINT1("Unable to create virtual mapping\n");
           KeBugCheck(MEMORY_MANAGEMENT);
       }
-      MmInsertRmap(Page, Process, (PVOID)PAddress);
+      MmInsertRmap(Page, Process, Address);
       PageOp->Status = STATUS_SUCCESS;
       MmspCompleteAndReleasePageOp(PageOp);
       DPRINT("Address 0x%.8X\n", Address);
@@ -1744,7 +1798,7 @@ MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace,
          DPRINT1("Unable to create virtual mapping\n");
           KeBugCheck(MEMORY_MANAGEMENT);
       }
-      MmInsertRmap(Page, Process, (PVOID)PAddress);
+      MmInsertRmap(Page, Process, Address);
       PageOp->Status = STATUS_SUCCESS;
       MmspCompleteAndReleasePageOp(PageOp);
       DPRINT("Address 0x%.8X\n", Address);
@@ -1756,28 +1810,25 @@ NTSTATUS
 NTAPI
 MmAccessFaultSectionView(PMMSUPPORT AddressSpace,
                          MEMORY_AREA* MemoryArea,
-                         PVOID Address,
-                         BOOLEAN Locked)
+                         PVOID Address)
 {
    PMM_SECTION_SEGMENT Segment;
    PROS_SECTION_OBJECT Section;
    PFN_NUMBER OldPage;
    PFN_NUMBER NewPage;
    NTSTATUS Status;
-   PVOID PAddress;
    ULONG Offset;
    PMM_PAGEOP PageOp;
    PMM_REGION Region;
    ULONG Entry;
    PEPROCESS Process = MmGetAddressSpaceOwner(AddressSpace);
-    
-   DPRINT("MmAccessFaultSectionView(%x, %x, %x, %x)\n", AddressSpace, MemoryArea, Address, Locked);
+
+   DPRINT("MmAccessFaultSectionView(%x, %x, %x, %x)\n", AddressSpace, MemoryArea, Address);
 
    /*
-    * Check if the page has been paged out or has already been set readwrite
+    * Check if the page has already been set readwrite
     */
-   if (!MmIsPagePresent(Process, Address) ||
-         MmGetPageProtect(Process, Address) & PAGE_READWRITE)
+   if (MmGetPageProtect(Process, Address) & PAGE_READWRITE)
    {
       DPRINT("Address 0x%.8X\n", Address);
       return(STATUS_SUCCESS);
@@ -1786,9 +1837,9 @@ MmAccessFaultSectionView(PMMSUPPORT AddressSpace,
    /*
     * Find the offset of the page
     */
-   PAddress = MM_ROUND_DOWN(Address, PAGE_SIZE);
-   Offset = (ULONG_PTR)PAddress - (ULONG_PTR)MemoryArea->StartingAddress
-            + MemoryArea->Data.SectionData.ViewOffset;
+   Address = MM_ROUND_DOWN(Address, PAGE_SIZE);
+   Offset = (ULONG)((ULONG_PTR)Address - (ULONG_PTR)MemoryArea->StartingAddress
+            + MemoryArea->Data.SectionData.ViewOffset);
 
    Segment = MemoryArea->Data.SectionData.Segment;
    Section = MemoryArea->Data.SectionData.Section;
@@ -1800,7 +1851,7 @@ MmAccessFaultSectionView(PMMSUPPORT AddressSpace,
     */
    MmLockSectionSegment(Segment);
 
-   OldPage = MmGetPfnForProcess(NULL, Address);
+   OldPage = MmGetPfnForProcess(Process, Address);
    Entry = MmGetPageEntrySectionSegment(Segment, Offset);
 
    MmUnlockSectionSegment(Segment);
@@ -1820,7 +1871,7 @@ MmAccessFaultSectionView(PMMSUPPORT AddressSpace,
        PFN_FROM_SSE(Entry) != OldPage)
    {
       /* This is a private page. We must only change the page protection. */
-      MmSetPageProtect(Process, PAddress, Region->Protect);
+      MmSetPageProtect(Process, Address, Region->Protect);
       return(STATUS_SUCCESS);
    }
 
@@ -1872,6 +1923,9 @@ MmAccessFaultSectionView(PMMSUPPORT AddressSpace,
    /*
     * Allocate a page
     */
+   MI_SET_USAGE(MI_USAGE_SECTION);
+   if (Process) MI_SET_PROCESS2(Process->ImageFileName);
+   if (!Process) MI_SET_PROCESS2("Kernel Section");
    Status = MmRequestPageMemoryConsumer(MC_USER, TRUE, &NewPage);
    if (!NT_SUCCESS(Status))
    {
@@ -1881,7 +1935,7 @@ MmAccessFaultSectionView(PMMSUPPORT AddressSpace,
    /*
     * Copy the old page
     */
-   MiCopyFromUserPage(NewPage, PAddress);
+   MiCopyFromUserPage(NewPage, Address);
 
    MmLockAddressSpace(AddressSpace);
    /*
@@ -1912,8 +1966,8 @@ MmAccessFaultSectionView(PMMSUPPORT AddressSpace,
    /*
     * Unshare the old page.
     */
-   MmDeleteRmap(OldPage, Process, PAddress);
-   MmInsertRmap(NewPage, Process, PAddress);
+   MmDeleteRmap(OldPage, Process, Address);
+   MmInsertRmap(NewPage, Process, Address);
    MmLockSectionSegment(Segment);
    MmUnsharePageEntrySectionSegment(Section, Segment, Offset, FALSE, FALSE);
    MmUnlockSectionSegment(Segment);
@@ -1983,12 +2037,14 @@ MmPageOutSectionView(PMMSUPPORT AddressSpace,
    ULONG FileOffset;
    NTSTATUS Status;
    PFILE_OBJECT FileObject;
+#ifndef NEWCC
    PBCB Bcb = NULL;
+#endif
    BOOLEAN DirectMapped;
    BOOLEAN IsImageSection;
    PEPROCESS Process = MmGetAddressSpaceOwner(AddressSpace);
    KIRQL OldIrql;
-    
+
    Address = (PVOID)PAGE_ROUND_DOWN(Address);
 
    /*
@@ -1997,14 +2053,15 @@ MmPageOutSectionView(PMMSUPPORT AddressSpace,
    Context.Segment = MemoryArea->Data.SectionData.Segment;
    Context.Section = MemoryArea->Data.SectionData.Section;
 
-   Context.Offset = (ULONG_PTR)Address - (ULONG_PTR)MemoryArea->StartingAddress
-                    + MemoryArea->Data.SectionData.ViewOffset;
+   Context.Offset = (ULONG)((ULONG_PTR)Address - (ULONG_PTR)MemoryArea->StartingAddress
+                    + MemoryArea->Data.SectionData.ViewOffset);
    FileOffset = Context.Offset + Context.Segment->FileOffset;
 
    IsImageSection = Context.Section->AllocationAttributes & SEC_IMAGE ? TRUE : FALSE;
 
    FileObject = Context.Section->FileObject;
    DirectMapped = FALSE;
+#ifndef NEWCC
    if (FileObject != NULL &&
        !(Context.Segment->Characteristics & IMAGE_SCN_MEM_SHARED))
    {
@@ -2021,6 +2078,7 @@ MmPageOutSectionView(PMMSUPPORT AddressSpace,
          DirectMapped = TRUE;
       }
    }
+#endif
 
 
    /*
@@ -2048,6 +2106,18 @@ MmPageOutSectionView(PMMSUPPORT AddressSpace,
    Page = MmGetPfnForProcess(Process, Address);
    SwapEntry = MmGetSavedSwapEntryPage(Page);
 
+   /*
+    * Check the reference count to ensure this page can be paged out
+    */
+   if (MmGetReferenceCountPage(Page) != 1)
+   {
+       DPRINT1("Cannot page out locked section page: 0x%p (RefCount: %d)\n",
+               Page, MmGetReferenceCountPage(Page));
+       PageOp->Status = STATUS_UNSUCCESSFUL;
+       MmspCompleteAndReleasePageOp(PageOp);
+       return STATUS_UNSUCCESSFUL;
+   }
+
    /*
     * Prepare the context structure for the rmap delete call.
     */
@@ -2151,7 +2221,11 @@ MmPageOutSectionView(PMMSUPPORT AddressSpace,
                  Address);
          KeBugCheck(MEMORY_MANAGEMENT);
       }
+#ifndef NEWCC
       Status = CcRosUnmapCacheSegment(Bcb, FileOffset, FALSE);
+#else
+         Status = STATUS_SUCCESS;
+#endif
       if (!NT_SUCCESS(Status))
       {
          DPRINT1("CCRosUnmapCacheSegment failed, status = %x\n", Status);
@@ -2333,7 +2407,7 @@ MmWritePageSectionView(PMMSUPPORT AddressSpace,
                        PVOID Address,
                        PMM_PAGEOP PageOp)
 {
-   ULONG Offset;
+   ULONG_PTR Offset;
    PROS_SECTION_OBJECT Section;
    PMM_SECTION_SEGMENT Segment;
    PFN_NUMBER Page;
@@ -2429,7 +2503,9 @@ MmWritePageSectionView(PMMSUPPORT AddressSpace,
    if (DirectMapped && !Private)
    {
       ASSERT(SwapEntry == 0);
-      CcRosMarkDirtyCacheSegment(Bcb, Offset + Segment->FileOffset);
+#ifndef NEWCC
+      CcRosMarkDirtyCacheSegment(Bcb, (ULONG)Offset + Segment->FileOffset);
+#endif
       PageOp->Status = STATUS_SUCCESS;
       MmspCompleteAndReleasePageOp(PageOp);
       return(STATUS_SUCCESS);
@@ -2477,7 +2553,7 @@ MmWritePageSectionView(PMMSUPPORT AddressSpace,
 static VOID
 MmAlterViewAttributes(PMMSUPPORT AddressSpace,
                       PVOID BaseAddress,
-                      ULONG RegionSize,
+                      SIZE_T RegionSize,
                       ULONG OldType,
                       ULONG OldProtect,
                       ULONG NewType,
@@ -2490,6 +2566,7 @@ MmAlterViewAttributes(PMMSUPPORT AddressSpace,
    PEPROCESS Process = MmGetAddressSpaceOwner(AddressSpace);
 
    MemoryArea = MmLocateMemoryAreaByAddress(AddressSpace, BaseAddress);
+   ASSERT(MemoryArea);
    Segment = MemoryArea->Data.SectionData.Segment;
 
    if ((Segment->WriteCopy) &&
@@ -2511,7 +2588,7 @@ MmAlterViewAttributes(PMMSUPPORT AddressSpace,
           */
          if (DoCOW && MmIsPagePresent(Process, Address))
          {
-            ULONG Offset;
+            ULONG_PTR Offset;
             ULONG Entry;
             PFN_NUMBER Page;
 
@@ -2543,7 +2620,7 @@ NTAPI
 MmProtectSectionView(PMMSUPPORT AddressSpace,
                      PMEMORY_AREA MemoryArea,
                      PVOID BaseAddress,
-                     ULONG Length,
+                     SIZE_T Length,
                      ULONG Protect,
                      PULONG OldProtect)
 {
@@ -2553,7 +2630,7 @@ MmProtectSectionView(PMMSUPPORT AddressSpace,
 
    MaxLength = (ULONG_PTR)MemoryArea->EndingAddress - (ULONG_PTR)BaseAddress;
    if (Length > MaxLength)
-      Length = MaxLength;
+      Length = (ULONG)MaxLength;
 
    Region = MmFindRegion(MemoryArea->StartingAddress,
                          &MemoryArea->Data.SectionData.RegionListHead,
@@ -2621,7 +2698,7 @@ MmpFreePageFileSegment(PMM_SECTION_SEGMENT Segment)
    ULONG Length;
    ULONG Offset;
    ULONG Entry;
-   ULONG SavedSwapEntry;
+   SWAPENTRY SavedSwapEntry;
    PFN_NUMBER Page;
 
    Page = 0;
@@ -2717,7 +2794,9 @@ MmpDeleteSection(PVOID ObjectBody)
    }
    if (Section->FileObject != NULL)
    {
+#ifndef NEWCC
       CcRosDereferenceCache(Section->FileObject);
+#endif
       ObDereferenceObject(Section->FileObject);
       Section->FileObject = NULL;
    }
@@ -2807,7 +2886,7 @@ MmInitSectionImplementation(VOID)
    ObjectTypeInitializer.CloseProcedure = MmpCloseSection;
    ObjectTypeInitializer.ValidAccessMask = SECTION_ALL_ACCESS;
    ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, &MmSectionObjectType);
-    
+
    MmCreatePhysicalMemorySection();
 
    return(STATUS_SUCCESS);
@@ -3122,7 +3201,9 @@ MmCreateDataFileSection(PROS_SECTION_OBJECT *SectionObject,
    MmUnlockSectionSegment(Segment);
    Section->FileObject = FileObject;
    Section->MaximumSize = MaximumSize;
+#ifndef NEWCC
    CcRosReferenceCache(FileObject);
+#endif
    //KeSetEvent((PVOID)&FileObject->Lock, IO_NO_INCREMENT, FALSE);
    *SectionObject = Section;
    return(STATUS_SUCCESS);
@@ -3272,7 +3353,7 @@ ExeFmtpReadFile(IN PVOID File,
 
       if(NT_SUCCESS(Status))
       {
-         UsedSize = Iosb.Information;
+         UsedSize = (ULONG)Iosb.Information;
       }
    }
 #endif
@@ -3484,13 +3565,13 @@ MmspPageAlignSegments
          EffectiveSegment->VirtualAddress = PAGE_ROUND_DOWN(VirtualAddress);
 
          /* Round up the virtual size to the nearest page */
-         EffectiveSegment->Length = PAGE_ROUND_UP(VirtualAddress + EffectiveSegment->Length) -
-                                    EffectiveSegment->VirtualAddress;
+         EffectiveSegment->Length = (ULONG)(PAGE_ROUND_UP(VirtualAddress + EffectiveSegment->Length) -
+                                    EffectiveSegment->VirtualAddress);
 
          /* Adjust the raw address and size */
          VirtualOffset = VirtualAddress - EffectiveSegment->VirtualAddress;
 
-         if (EffectiveSegment->FileOffset < VirtualOffset)
+         if (EffectiveSegment->FileOffset < (LONG_PTR)VirtualOffset)
          {
             return FALSE;
          }
@@ -3500,8 +3581,8 @@ MmspPageAlignSegments
           * offset point in curious and odd places, but that's what we were
           * asked for
           */
-         EffectiveSegment->FileOffset -= VirtualOffset;
-         EffectiveSegment->RawLength += VirtualOffset;
+         EffectiveSegment->FileOffset -= (ULONG)VirtualOffset;
+         EffectiveSegment->RawLength += (ULONG)VirtualOffset;
       }
       else
       {
@@ -3585,8 +3666,8 @@ MmspPageAlignSegments
              */
             ASSERT(PAGE_ROUND_UP(Segment->VirtualAddress + Segment->Length) >= EndOfEffectiveSegment);
 
-            EffectiveSegment->Length = PAGE_ROUND_UP(Segment->VirtualAddress + Segment->Length) -
-                                       EffectiveSegment->VirtualAddress;
+            EffectiveSegment->Length = (ULONG)(PAGE_ROUND_UP(Segment->VirtualAddress + Segment->Length) -
+                                       EffectiveSegment->VirtualAddress);
 
             /*
              * Merge the protection
@@ -3853,11 +3934,15 @@ MmCreateImageSection(PROS_SECTION_OBJECT *SectionObject,
    Section->SectionPageProtection = SectionPageProtection;
    Section->AllocationAttributes = AllocationAttributes;
 
+#ifndef NEWCC
    /*
     * Initialized caching for this file object if previously caching
     * was initialized for the same on disk file
     */
    Status = CcTryToInitializeFileCache(FileObject);
+#else
+   Status = STATUS_SUCCESS;
+#endif
 
    if (!NT_SUCCESS(Status) || FileObject->SectionObjectPointer->ImageSectionObject == NULL)
    {
@@ -3950,7 +4035,9 @@ MmCreateImageSection(PROS_SECTION_OBJECT *SectionObject,
       Status = STATUS_SUCCESS;
    }
    Section->FileObject = FileObject;
+#ifndef NEWCC
    CcRosReferenceCache(FileObject);
+#endif
    //KeSetEvent((PVOID)&FileObject->Lock, IO_NO_INCREMENT, FALSE);
    *SectionObject = Section;
    return(Status);
@@ -4024,8 +4111,8 @@ MmFreeSectionPage(PVOID Context, MEMORY_AREA* MemoryArea, PVOID Address,
 
    Address = (PVOID)PAGE_ROUND_DOWN(Address);
 
-   Offset = ((ULONG_PTR)Address - (ULONG_PTR)MemoryArea->StartingAddress) +
-            MemoryArea->Data.SectionData.ViewOffset;
+   Offset = (ULONG)(((ULONG_PTR)Address - (ULONG_PTR)MemoryArea->StartingAddress) +
+            MemoryArea->Data.SectionData.ViewOffset);
 
    Section = MemoryArea->Data.SectionData.Section;
    Segment = MemoryArea->Data.SectionData.Segment;
@@ -4062,7 +4149,9 @@ MmFreeSectionPage(PVOID Context, MEMORY_AREA* MemoryArea, PVOID Address,
       {
          FileObject = MemoryArea->Data.SectionData.Section->FileObject;
          Bcb = FileObject->SectionObjectPointer->SharedCacheMap;
+#ifndef NEWCC
          CcRosMarkDirtyCacheSegment(Bcb, Offset + Segment->FileOffset);
+#endif
          ASSERT(SwapEntry == 0);
       }
    }
@@ -4208,7 +4297,7 @@ MmUnmapViewOfSection(PEPROCESS Process,
          Offset -= PAGE_SIZE;
          PageOp = MmCheckForPageOp(MemoryArea, NULL, NULL,
                                    MemoryArea->Data.SectionData.Segment,
-                                   Offset + MemoryArea->Data.SectionData.ViewOffset);
+                                   (ULONG)Offset + MemoryArea->Data.SectionData.ViewOffset);
          if (PageOp)
          {
             MmUnlockAddressSpace(AddressSpace);
@@ -4251,14 +4340,11 @@ MmUnmapViewOfSection(PEPROCESS Process,
        * 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)
       {
@@ -4267,13 +4353,10 @@ MmUnmapViewOfSection(PEPROCESS Process,
 
       for (i = 0; i < NrSegments; i++)
       {
-         if (!(SectionSegments[i].Characteristics & IMAGE_SCN_TYPE_NOLOAD))
-         {
-            PVOID SBaseAddress = (PVOID)
-                                 ((char*)ImageBaseAddress + (ULONG_PTR)SectionSegments[i].VirtualAddress);
+          PVOID SBaseAddress = (PVOID)
+                               ((char*)ImageBaseAddress + (ULONG_PTR)SectionSegments[i].VirtualAddress);
 
-            Status = MmUnmapViewOfSegment(AddressSpace, SBaseAddress);
-         }
+          Status = MmUnmapViewOfSegment(AddressSpace, SBaseAddress);
       }
    }
    else
@@ -4332,7 +4415,7 @@ NtQuerySection(IN HANDLE SectionHandle,
                                         ExSectionInfoClass,
                                         sizeof(ExSectionInfoClass) / sizeof(ExSectionInfoClass[0]),
                                         SectionInformation,
-                                        SectionInformationLength,
+                                        (ULONG)SectionInformationLength,
                                         NULL,
                                         ResultLength,
                                         PreviousMode);
@@ -4430,7 +4513,7 @@ NtQuerySection(IN HANDLE SectionHandle,
 
    return(Status);
 }
-                       
+
 /**********************************************************************
  * NAME       EXPORTED
  * MmMapViewOfSection
@@ -4496,6 +4579,7 @@ MmMapViewOfSection(IN PVOID SectionObject,
    PMMSUPPORT AddressSpace;
    ULONG ViewOffset;
    NTSTATUS Status = STATUS_SUCCESS;
+   BOOLEAN NotAtBase = FALSE;
 
    if ((ULONG_PTR)SectionObject & 1)
    {
@@ -4510,7 +4594,7 @@ MmMapViewOfSection(IN PVOID SectionObject,
                                      AllocationType,
                                      Protect);
    }
-   
+
    ASSERT(Process);
 
    if (!Protect || Protect & ~PAGE_FLAGS_VALID_FOR_SECTION)
@@ -4531,7 +4615,7 @@ MmMapViewOfSection(IN PVOID SectionObject,
       ULONG i;
       ULONG NrSegments;
       ULONG_PTR ImageBase;
-      ULONG ImageSize;
+      SIZE_T ImageSize;
       PMM_IMAGE_SECTION_OBJECT ImageSectionObject;
       PMM_SECTION_SEGMENT SectionSegments;
 
@@ -4549,16 +4633,19 @@ MmMapViewOfSection(IN PVOID SectionObject,
       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;
+      ImageSectionObject->ImageSize = (ULONG)ImageSize;
+
+      /* Check for an illegal base address */
+      if ((ImageBase + ImageSize) > (ULONG_PTR)MmHighestUserAddress)
+      {
+          ImageBase = PAGE_ROUND_DOWN((ULONG_PTR)MmHighestUserAddress - ImageSize);
+      }
 
       /* Check there is enough space to map the section at that point. */
       if (MmLocateMemoryAreaByRegion(AddressSpace, (PVOID)ImageBase,
@@ -4577,33 +4664,33 @@ MmMapViewOfSection(IN PVOID SectionObject,
             MmUnlockAddressSpace(AddressSpace);
             return(STATUS_UNSUCCESSFUL);
          }
+         /* Remember that we loaded image at a different base address */
+         NotAtBase = TRUE;
       }
 
       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
    {
@@ -4681,7 +4768,12 @@ MmMapViewOfSection(IN PVOID SectionObject,
 
    MmUnlockAddressSpace(AddressSpace);
 
-   return(STATUS_SUCCESS);
+   if (NotAtBase)
+       Status = STATUS_IMAGE_NOT_AT_BASE;
+   else
+       Status = STATUS_SUCCESS;
+
+   return Status;
 }
 
 /*
@@ -4720,7 +4812,7 @@ MmCanFileBeTruncated (IN PSECTION_OBJECT_POINTERS SectionObjectPointer,
       else
       {
          /* Something must gone wrong
-          * how can we have a Section but no 
+          * how can we have a Section but no
           * reference? */
          DPRINT("ERROR: DataSectionObject without reference!\n");
       }
@@ -4749,7 +4841,9 @@ MmFlushImageSection (IN PSECTION_OBJECT_POINTERS SectionObjectPointer,
          {
             return FALSE;
          }
+#ifndef NEWCC
          CcRosSetRemoveOnClose(SectionObjectPointer);
+#endif
          return TRUE;
       case MmFlushForWrite:
          break;
@@ -4769,7 +4863,7 @@ MmMapViewInSystemSpace (IN PVOID SectionObject,
    PMMSUPPORT AddressSpace;
    NTSTATUS Status;
    PAGED_CODE();
-        
+
     if ((ULONG_PTR)SectionObject & 1)
     {
         extern PVOID MmSession;
@@ -4826,8 +4920,12 @@ MmUnmapViewInSystemSpace (IN PVOID MappedBase)
    DPRINT("MmUnmapViewInSystemSpace() called\n");
 
    AddressSpace = MmGetKernelAddressSpace();
+   
+   MmLockAddressSpace(AddressSpace);
 
    Status = MmUnmapViewOfSegment(AddressSpace, MappedBase);
+   
+   MmUnlockAddressSpace(AddressSpace);
 
    return Status;
 }
@@ -4900,7 +4998,7 @@ MmCreateSection (OUT PVOID  * Section,
 {
    ULONG Protection;
    PROS_SECTION_OBJECT *SectionObject = (PROS_SECTION_OBJECT *)Section;
-   
+
     /* Check if an ARM3 section is being created instead */
     if (AllocationAttributes & 1)
     {