[NTOS:MM] Pass FaultCode to MiDispatchFault
authorTimo Kreuzer <timo.kreuzer@reactos.org>
Mon, 1 Jan 2018 21:40:43 +0000 (22:40 +0100)
committerTimo Kreuzer <timo.kreuzer@reactos.org>
Sat, 6 Jan 2018 17:20:24 +0000 (18:20 +0100)
ntoskrnl/mm/ARM3/pagfault.c
ntoskrnl/mm/i386/page.c

index 191ef21..c75c459 100644 (file)
@@ -1274,7 +1274,7 @@ MiResolveProtoPteFault(IN BOOLEAN StoreInstruction,
 
 NTSTATUS
 NTAPI
-MiDispatchFault(IN BOOLEAN StoreInstruction,
+MiDispatchFault(IN ULONG FaultCode,
                 IN PVOID Address,
                 IN PMMPTE PointerPte,
                 IN PMMPTE PointerProtoPte,
@@ -1333,7 +1333,7 @@ MiDispatchFault(IN BOOLEAN StoreInstruction,
             }
 
             /* Resolve the fault -- this will release the PFN lock */
-            Status = MiResolveProtoPteFault(StoreInstruction,
+            Status = MiResolveProtoPteFault(!MI_IS_NOT_PRESENT_FAULT(FaultCode),
                                             Address,
                                             PointerPte,
                                             PointerProtoPte,
@@ -1450,7 +1450,7 @@ MiDispatchFault(IN BOOLEAN StoreInstruction,
                 if (++ProcessedPtes == PteCount)
                 {
                     /* Complete the fault */
-                    MiCompleteProtoPteFault(StoreInstruction,
+                    MiCompleteProtoPteFault(!MI_IS_NOT_PRESENT_FAULT(FaultCode),
                                             Address,
                                             PointerPte,
                                             PointerProtoPte,
@@ -1489,7 +1489,7 @@ MiDispatchFault(IN BOOLEAN StoreInstruction,
             ASSERT(PointerPte->u.Hard.Valid == 0);
 
             /* Resolve the fault -- this will release the PFN lock */
-            Status = MiResolveProtoPteFault(StoreInstruction,
+            Status = MiResolveProtoPteFault(!MI_IS_NOT_PRESENT_FAULT(FaultCode),
                                             Address,
                                             PointerPte,
                                             PointerProtoPte,
@@ -1537,7 +1537,7 @@ MiDispatchFault(IN BOOLEAN StoreInstruction,
         LockIrql = MiAcquirePfnLock();
 
         /* Resolve */
-        Status = MiResolveTransitionFault(StoreInstruction, Address, PointerPte, Process, LockIrql, &InPageBlock);
+        Status = MiResolveTransitionFault(!MI_IS_NOT_PRESENT_FAULT(FaultCode), Address, PointerPte, Process, LockIrql, &InPageBlock);
 
         ASSERT(NT_SUCCESS(Status));
 
@@ -1576,7 +1576,7 @@ MiDispatchFault(IN BOOLEAN StoreInstruction,
         LockIrql = MiAcquirePfnLock();
 
         /* Resolve */
-        Status = MiResolvePageFileFault(StoreInstruction, Address, PointerPte, Process, &LockIrql);
+        Status = MiResolvePageFileFault(!MI_IS_NOT_PRESENT_FAULT(FaultCode), Address, PointerPte, Process, &LockIrql);
 
         /* And now release the lock and leave*/
         MiReleasePfnLock(LockIrql);
@@ -2028,7 +2028,7 @@ _WARN("Session space stuff is not implemented yet!")
         }
 
         /* Now do the real fault handling */
-        Status = MiDispatchFault(!MI_IS_NOT_PRESENT_FAULT(FaultCode),
+        Status = MiDispatchFault(FaultCode,
                                  Address,
                                  PointerPte,
                                  ProtoPte,
@@ -2480,7 +2480,7 @@ UserFault:
     }
 
     /* Dispatch the fault */
-    Status = MiDispatchFault(!MI_IS_NOT_PRESENT_FAULT(FaultCode),
+    Status = MiDispatchFault(FaultCode,
                              Address,
                              PointerPte,
                              ProtoPte,
index 4ed0ebc..1bc842d 100644 (file)
@@ -191,7 +191,7 @@ ProtectToPTE(ULONG flProtect)
 
 NTSTATUS
 NTAPI
-MiDispatchFault(IN BOOLEAN StoreInstruction,
+MiDispatchFault(IN ULONG FaultCode,
                 IN PVOID Address,
                 IN PMMPTE PointerPte,
                 IN PMMPTE PointerProtoPte,
@@ -262,7 +262,8 @@ MmGetPageTableForProcess(PEPROCESS Process, PVOID Address, BOOLEAN Create)
             ASSERT(PointerPde->u.Long == 0);
 
             MI_WRITE_INVALID_PTE(PointerPde, DemandZeroPde);
-            Status = MiDispatchFault(TRUE,
+            // Tiny HACK: Parameter 1 is the architecture specific FaultCode for an access violation (i.e. page is present)
+            Status = MiDispatchFault(0x1,
                                      Pt,
                                      PointerPde,
                                      NULL,