ASSERT(PointerPde->u.Hard.L1.Fault.Type == FaultPte);
//
- // Check if this is a kernel PDE
+ // Invalidate the TLB entry
//
- if ((PointerPde >= (PMMPTE)PTE_BASE) && (PointerPde < (PMMPTE)PTE_BASE + (1024 * 1024)))
+ KiFlushSingleTb(TRUE, Address);
+}
+
+PFN_TYPE
+NTAPI
+MmGetPfnForProcess(IN PEPROCESS Process,
+ IN PVOID Address)
+{
+ PMMPTE Pte;
+
+ //
+ // Check if this is for a different process
+ //
+ if ((Process) && (Process != PsGetCurrentProcess()))
{
//
- // Invalidate the TLB entry
+ // TODO
//
- KiFlushSingleTb(TRUE, Address);
+ UNIMPLEMENTED;
+ return 0;
}
- else
+
+ //
+ // Get the PDE
+ //
+ Pte = MiGetPdeAddress(Address);
+ if (Pte->u.Hard.L1.Fault.Type != FaultPte)
{
//
- // Process PDE, unmap it from hyperspace (will also invalidate TLB entry)
+ // Get the PTE
//
- MmDeleteHyperspaceMapping((PVOID)PAGE_ROUND_DOWN(PointerPde));
+ Pte = MiGetPteAddress(Address);
}
-}
-
-PFN_TYPE
-NTAPI
-MmGetPfnForProcess(IN PEPROCESS Process,
- IN PVOID Address)
-{
- PFN_TYPE Pfn = {0};
//
- // TODO
+ // If PTE is invalid, return 0
//
- UNIMPLEMENTED;
- return Pfn;
+ if (Pte->u.Hard.L2.Fault.Type == FaultPte) return 0;
+
+ //
+ // Return PFN
+ //
+ return Pte->u.Hard.L2.Small.BaseAddress;
}
VOID
// Return whether or not it's valid
//
return (Pte->u.Hard.L1.Fault.Type != FaultPte);
-
-
}
BOOLEAN
MmIsPageSwapEntry(IN PEPROCESS Process,
IN PVOID Address)
{
+ PMMPTE Pte;
+
//
- // TODO
+ // Check if this is for a different process
//
- UNIMPLEMENTED;
- return 0;
+ if ((Process) && (Process != PsGetCurrentProcess()))
+ {
+ //
+ // TODO
+ //
+ UNIMPLEMENTED;
+ return 0;
+ }
+
+ //
+ // Get the PDE
+ //
+ Pte = MiGetPdeAddress(Address);
+ if (Pte->u.Hard.L1.Fault.Type != FaultPte)
+ {
+ //
+ // Get the PTE
+ //
+ Pte = MiGetPteAddress(Address);
+ }
+
+ //
+ // Return whether or not it's valid
+ //
+ return ((Pte->u.Hard.L2.Fault.Type == FaultPte) && (Pte->u.Hard.AsUlong));
}
NTSTATUS
NTSTATUS Status;
PFN_NUMBER Pfn;
DPRINT1("[KMAP]: %p %d\n", Address, PageCount);
- ASSERT(Address >= MmSystemRangeStart);
+ //ASSERT(Address >= MmSystemRangeStart);
//
// Get our templates
//
// Are we only handling the kernel?
//
- if (!Process)
+ if (!(Process) || (Process == PsGetCurrentProcess()))
{
//
// Call the kernel version
//
KiFlushSingleTb(TRUE, Address);
return Pfn;
-
}
VOID