https://git.reactos.org/?p=reactos.git;a=commitdiff;h=c6a87f28bf4a0a3270adf6114ed2589e200c5b86

commit c6a87f28bf4a0a3270adf6114ed2589e200c5b86
Author:     Jérôme Gardou <[email protected]>
AuthorDate: Fri Oct 23 16:55:00 2020 +0200
Commit:     Jérôme Gardou <[email protected]>
CommitDate: Wed Feb 3 09:41:21 2021 +0100

    [NTOSKRNL] Get rid of MEMORY_AREA::Protect
    
    Use the VAD node instead
---
 ntoskrnl/include/internal/mm.h |  1 -
 ntoskrnl/mm/marea.c            | 10 +++++-----
 ntoskrnl/mm/section.c          | 10 +++++-----
 3 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/ntoskrnl/include/internal/mm.h b/ntoskrnl/include/internal/mm.h
index 4bb6d1a60ca..a7affb0a49c 100644
--- a/ntoskrnl/include/internal/mm.h
+++ b/ntoskrnl/include/internal/mm.h
@@ -212,7 +212,6 @@ typedef struct _MEMORY_AREA
     MMVAD VadNode;
 
     ULONG Type;
-    ULONG Protect;
     ULONG Flags;
     BOOLEAN DeleteInProgress;
     ULONG Magic;
diff --git a/ntoskrnl/mm/marea.c b/ntoskrnl/mm/marea.c
index 3736a5a36c8..cd7b9594f1d 100644
--- a/ntoskrnl/mm/marea.c
+++ b/ntoskrnl/mm/marea.c
@@ -165,12 +165,13 @@ MiMakeProtectionMask(
 static VOID
 MmInsertMemoryArea(
     PMMSUPPORT AddressSpace,
-    PMEMORY_AREA marea)
+    PMEMORY_AREA marea,
+    ULONG Protect)
 {
     PEPROCESS Process = MmGetAddressSpaceOwner(AddressSpace);
 
     marea->VadNode.u.VadFlags.Spare = 1;
-    marea->VadNode.u.VadFlags.Protection = 
MiMakeProtectionMask(marea->Protect);
+    marea->VadNode.u.VadFlags.Protection = MiMakeProtectionMask(Protect);
 
     /* Build a lame VAD if this is a user-space allocation */
     if (marea->VadNode.EndingVpn + 1 < (ULONG_PTR)MmSystemRangeStart >> 
PAGE_SHIFT)
@@ -457,7 +458,6 @@ MmCreateMemoryArea(PMMSUPPORT AddressSpace,
 
     RtlZeroMemory(MemoryArea, sizeof(MEMORY_AREA));
     MemoryArea->Type = Type & ~MEMORY_AREA_STATIC;
-    MemoryArea->Protect = Protect;
     MemoryArea->Flags = AllocationFlags;
     MemoryArea->Magic = 'erAM';
     MemoryArea->DeleteInProgress = FALSE;
@@ -478,7 +478,7 @@ MmCreateMemoryArea(PMMSUPPORT AddressSpace,
 
         MemoryArea->VadNode.StartingVpn = (ULONG_PTR)*BaseAddress >> 
PAGE_SHIFT;
         MemoryArea->VadNode.EndingVpn = ((ULONG_PTR)*BaseAddress + tmpLength - 
1) >> PAGE_SHIFT;
-        MmInsertMemoryArea(AddressSpace, MemoryArea);
+        MmInsertMemoryArea(AddressSpace, MemoryArea, Protect);
     }
     else
     {
@@ -516,7 +516,7 @@ MmCreateMemoryArea(PMMSUPPORT AddressSpace,
 
         MemoryArea->VadNode.StartingVpn = (ULONG_PTR)*BaseAddress >> 
PAGE_SHIFT;
         MemoryArea->VadNode.EndingVpn = ((ULONG_PTR)*BaseAddress + tmpLength - 
1) >> PAGE_SHIFT;
-        MmInsertMemoryArea(AddressSpace, MemoryArea);
+        MmInsertMemoryArea(AddressSpace, MemoryArea, Protect);
     }
 
     *Result = MemoryArea;
diff --git a/ntoskrnl/mm/section.c b/ntoskrnl/mm/section.c
index 91ef5133849..59b6a22ec36 100644
--- a/ntoskrnl/mm/section.c
+++ b/ntoskrnl/mm/section.c
@@ -2222,7 +2222,7 @@ MmPageOutSectionView(PMMSUPPORT AddressSpace,
             {
                 Status = MmCreateVirtualMapping(Process,
                                                 Address,
-                                                MemoryArea->Protect,
+                                                
MmProtectToValue[MemoryArea->VadNode.u.VadFlags.Protection],
                                                 &Page,
                                                 1);
                 MmSetDirtyPage(Process, Address);
@@ -2243,7 +2243,7 @@ MmPageOutSectionView(PMMSUPPORT AddressSpace,
                  */
                 Status = MmCreateVirtualMapping(Process,
                                                 Address,
-                                                MemoryArea->Protect,
+                                                
MmProtectToValue[MemoryArea->VadNode.u.VadFlags.Protection],
                                                 &Page,
                                                 1);
                 MmSetDirtyPage(Process, Address);
@@ -2280,7 +2280,7 @@ MmPageOutSectionView(PMMSUPPORT AddressSpace,
         {
             Status = MmCreateVirtualMapping(Process,
                                             Address,
-                                            MemoryArea->Protect,
+                                            
MmProtectToValue[MemoryArea->VadNode.u.VadFlags.Protection],
                                             &Page,
                                             1);
             MmSetDirtyPage(Process, Address);
@@ -2293,7 +2293,7 @@ MmPageOutSectionView(PMMSUPPORT AddressSpace,
             MmLockSectionSegment(Context.Segment);
             Status = MmCreateVirtualMapping(Process,
                                             Address,
-                                            MemoryArea->Protect,
+                                            
MmProtectToValue[MemoryArea->VadNode.u.VadFlags.Protection],
                                             &Page,
                                             1);
             MmSetDirtyPage(Process, Address);
@@ -2579,7 +2579,7 @@ MmQuerySectionView(PMEMORY_AREA MemoryArea,
         Info->Type = MEM_MAPPED;
     }
     Info->BaseAddress = RegionBaseAddress;
-    Info->AllocationProtect = MemoryArea->Protect;
+    Info->AllocationProtect = 
MmProtectToValue[MemoryArea->VadNode.u.VadFlags.Protection];
     Info->RegionSize = Region->Length;
     Info->State = MEM_COMMIT;
     Info->Protect = Region->Protect;

Reply via email to