[NTOS:MM] Fix-up call site of traced PFNs when serving a page fault

This commit is contained in:
Jérôme Gardou 2021-06-24 17:01:38 +02:00 committed by Jérôme Gardou
parent 146337cc50
commit 1c5ce8d11c

View file

@ -1286,6 +1286,14 @@ MiResolveProtoPteFault(IN BOOLEAN StoreInstruction,
(ULONG)TempPte.u.Soft.Protection, (ULONG)TempPte.u.Soft.Protection,
Process, Process,
OldIrql); OldIrql);
#if MI_TRACE_PFNS
/* Update debug info */
if (TrapInformation)
MiGetPfnEntry(PointerProtoPte->u.Hard.PageFrameNumber)->CallSite = (PVOID)((PKTRAP_FRAME)TrapInformation)->Eip;
else
MiGetPfnEntry(PointerProtoPte->u.Hard.PageFrameNumber)->CallSite = _ReturnAddress();
#endif
ASSERT(NT_SUCCESS(Status)); ASSERT(NT_SUCCESS(Status));
} }
@ -1637,6 +1645,14 @@ MiDispatchFault(IN ULONG FaultCode,
ASSERT(KeAreAllApcsDisabled() == TRUE); ASSERT(KeAreAllApcsDisabled() == TRUE);
if (NT_SUCCESS(Status)) if (NT_SUCCESS(Status))
{ {
#if MI_TRACE_PFNS
/* Update debug info */
if (TrapInformation)
MiGetPfnEntry(PointerPte->u.Hard.PageFrameNumber)->CallSite = (PVOID)((PKTRAP_FRAME)TrapInformation)->Eip;
else
MiGetPfnEntry(PointerPte->u.Hard.PageFrameNumber)->CallSite = _ReturnAddress();
#endif
// //
// Make sure we're returning in a sane state and pass the status down // Make sure we're returning in a sane state and pass the status down
// //
@ -2191,6 +2207,11 @@ UserFault:
#if MI_TRACE_PFNS #if MI_TRACE_PFNS
UserPdeFault = FALSE; UserPdeFault = FALSE;
/* Update debug info */
if (TrapInformation)
MiGetPfnEntry(PointerPde->u.Hard.PageFrameNumber)->CallSite = (PVOID)((PKTRAP_FRAME)TrapInformation)->Eip;
else
MiGetPfnEntry(PointerPde->u.Hard.PageFrameNumber)->CallSite = _ReturnAddress();
#endif #endif
/* We should come back with APCs enabled, and with a valid PDE */ /* We should come back with APCs enabled, and with a valid PDE */
ASSERT(KeAreAllApcsDisabled() == TRUE); ASSERT(KeAreAllApcsDisabled() == TRUE);
@ -2286,6 +2307,14 @@ UserFault:
CurrentProcess, CurrentProcess,
MM_NOIRQL); MM_NOIRQL);
#if MI_TRACE_PFNS
/* Update debug info */
if (TrapInformation)
MiGetPfnEntry(PointerPte->u.Hard.PageFrameNumber)->CallSite = (PVOID)((PKTRAP_FRAME)TrapInformation)->Eip;
else
MiGetPfnEntry(PointerPte->u.Hard.PageFrameNumber)->CallSite = _ReturnAddress();
#endif
/* Return the status */ /* Return the status */
MiUnlockProcessWorkingSet(CurrentProcess, CurrentThread); MiUnlockProcessWorkingSet(CurrentProcess, CurrentThread);
return STATUS_PAGE_FAULT_DEMAND_ZERO; return STATUS_PAGE_FAULT_DEMAND_ZERO;