mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 21:32:56 +00:00
- Fix a couple of bugs, and majorly refactor MmDeleteVirtualMapping to sync it to the x86 version somewhat more.
svn path=/trunk/; revision=34859
This commit is contained in:
parent
8054941a9f
commit
ac0487dfa5
1 changed files with 18 additions and 56 deletions
|
@ -569,80 +569,42 @@ MmDeleteVirtualMapping(IN PEPROCESS Process,
|
||||||
{
|
{
|
||||||
PMMPTE PointerPte;
|
PMMPTE PointerPte;
|
||||||
MMPTE Pte;
|
MMPTE Pte;
|
||||||
|
PFN_NUMBER Pfn = 0;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Get the PTE
|
// Get the PTE
|
||||||
//
|
//
|
||||||
PointerPte = MiGetPageTableForProcess(NULL, Address, FALSE);
|
PointerPte = MiGetPageTableForProcess(NULL, Address, FALSE);
|
||||||
if (!PointerPte)
|
if (PointerPte)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Invalid PDE
|
// Save and destroy the PTE
|
||||||
//
|
//
|
||||||
if (WasDirty) *WasDirty = FALSE;
|
Pte = *PointerPte;
|
||||||
if (Page) *Page = 0;
|
PointerPte->u.Hard.AsUlong = 0;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Save the PTE
|
|
||||||
//
|
|
||||||
Pte = *PointerPte;
|
|
||||||
if (PointerPte->u.Hard.L1.Fault.Type == FaultPte)
|
|
||||||
{
|
|
||||||
//
|
//
|
||||||
// Invalid PTE
|
// Flush the TLB
|
||||||
//
|
//
|
||||||
if (WasDirty) *WasDirty = FALSE;
|
MiFlushTlb(PointerPte, Address);
|
||||||
if (Page) *Page = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Destroy the PTE
|
|
||||||
//
|
|
||||||
PointerPte->u.Hard.AsUlong = 0;
|
|
||||||
ASSERT(PointerPte->u.Hard.L2.Fault.Type == FaultPte);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Flush the TLB
|
|
||||||
//
|
|
||||||
MiFlushTlb(PointerPte, Address);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Check if the PTE was valid
|
|
||||||
//
|
|
||||||
if (Pte.u.Hard.L2.Fault.Type != FaultPte)
|
|
||||||
{
|
|
||||||
//
|
//
|
||||||
// Mark the page as unmapped
|
// Unmap the PFN
|
||||||
//
|
//
|
||||||
MmMarkPageUnmapped(Pte.u.Hard.L2.Small.BaseAddress);
|
Pfn = Pte.u.Hard.L2.Small.BaseAddress;
|
||||||
}
|
if (Pfn) MmMarkPageUnmapped(Pfn);
|
||||||
else
|
|
||||||
{
|
|
||||||
//
|
//
|
||||||
// Make it sane
|
// Release the PFN if it was ours
|
||||||
//
|
//
|
||||||
Pte.u.Hard.L2.Small.BaseAddress = 0;
|
if ((FreePage) && (Pfn)) MmReleasePageMemoryConsumer(MC_NPPOOL, Pfn);
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Check if this was our page, and valid
|
|
||||||
//
|
|
||||||
if ((FreePage) && (Pte.u.Hard.L2.Fault.Type != FaultPte))
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Release it
|
|
||||||
//
|
|
||||||
MmReleasePageMemoryConsumer(MC_NPPOOL, Pte.u.Hard.L2.Small.BaseAddress);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Return if the page was dirty
|
// Return if the page was dirty
|
||||||
//
|
//
|
||||||
if (WasDirty) *WasDirty = TRUE; // LIE!!!
|
if (WasDirty) *WasDirty = FALSE; // LIE!!!
|
||||||
if (Page) *Page = Pte.u.Hard.L2.Small.BaseAddress;
|
if (Page) *Page = Pfn;
|
||||||
}
|
}
|
||||||
|
|
||||||
PVOID
|
PVOID
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue