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

commit 3141668724e37d0dac6cee831db1fe4eda6bf84f
Author:     Jérôme Gardou <[email protected]>
AuthorDate: Fri Dec 11 18:53:32 2020 +0100
Commit:     Jérôme Gardou <[email protected]>
CommitDate: Wed Feb 3 09:41:22 2021 +0100

    [NTOS:MM] Various fixes.
    
    Fix MmFlushImageSection behaviour
    Remove an invalid ASSERT
---
 ntoskrnl/mm/section.c | 48 ++++++++++++++----------------------------------
 1 file changed, 14 insertions(+), 34 deletions(-)

diff --git a/ntoskrnl/mm/section.c b/ntoskrnl/mm/section.c
index 8e9669d9ab9..8acc368a884 100644
--- a/ntoskrnl/mm/section.c
+++ b/ntoskrnl/mm/section.c
@@ -4093,46 +4093,26 @@ CheckSectionPointer:
  */
 BOOLEAN NTAPI
 MmFlushImageSection (IN PSECTION_OBJECT_POINTERS SectionObjectPointer,
-                     IN MMFLUSH_TYPE   FlushType)
+                     IN MMFLUSH_TYPE FlushType)
 {
-    BOOLEAN Result = TRUE;
-#ifdef NEWCC
-    PMM_SECTION_SEGMENT Segment;
-#endif
-
     switch(FlushType)
     {
-    case MmFlushForDelete:
-        if (SectionObjectPointer->ImageSectionObject ||
-                SectionObjectPointer->DataSectionObject)
+        case MmFlushForDelete:
+        case MmFlushForWrite:
         {
-            return FALSE;
-        }
-#ifndef NEWCC
-        CcRosRemoveIfClosed(SectionObjectPointer);
-#endif
-        return TRUE;
-    case MmFlushForWrite:
-    {
-        DPRINT("MmFlushImageSection(%d)\n", FlushType);
-#ifdef NEWCC
-        Segment = (PMM_SECTION_SEGMENT)SectionObjectPointer->DataSectionObject;
-#endif
+            BOOLEAN Ret = TRUE;
+            KIRQL OldIrql = MiAcquirePfnLock();
 
-        if (SectionObjectPointer->ImageSectionObject)
-        {
-            DPRINT1("SectionObject has ImageSection\n");
-            return FALSE;
-        }
+            if (SectionObjectPointer->ImageSectionObject)
+            {
+                PMM_IMAGE_SECTION_OBJECT ImageSectionObject = 
SectionObjectPointer->ImageSectionObject;
+                if (!(ImageSectionObject->SegFlags & MM_SEGMENT_INDELETE))
+                    Ret = FALSE;
+            }
 
-#ifdef NEWCC
-        CcpLock();
-        Result = !SectionObjectPointer->SharedCacheMap || 
(Segment->ReferenceCount == 
CcpCountCacheSections((PNOCC_CACHE_MAP)SectionObjectPointer->SharedCacheMap));
-        CcpUnlock();
-        DPRINT("Result %d\n", Result);
-#endif
-        return Result;
-    }
+            MiReleasePfnLock(OldIrql);
+            return Ret;
+        }
     }
     return FALSE;
 }

Reply via email to