[NTOS]: At times, pages may be removed from the zero or free page list, but without being initialized as part of the PFN database, such that their PageLocation has not changed. However, we can detect these pages because their link pointers will be NULL, meaning they're not _really_ free or zeroed. Use this enhanced check when verifying if a page is in use or not, and additionally triple-check by making sure the reference count is zero. This now matches the Windows checks. We also consider Standby pages (not yet implemented) as usable, since we can always steal them.

svn path=/trunk/; revision=47148
This commit is contained in:
Sir Richard 2010-05-09 18:06:38 +00:00
parent b6b00740ca
commit a38d98d504

View file

@ -128,12 +128,23 @@ MmRemoveLRUUserPage(PFN_TYPE Page)
RtlClearBit(&MiUserPfnBitMap, Page);
}
BOOLEAN
NTAPI
MiIsPfnFree(IN PMMPFN Pfn1)
{
/* Must be a free or zero page, with no references, linked */
return ((Pfn1->u3.e1.PageLocation <= StandbyPageList) &&
(Pfn1->u1.Flink) &&
(Pfn1->u2.Blink) &&
!(Pfn1->u3.e2.ReferenceCount));
}
BOOLEAN
NTAPI
MiIsPfnInUse(IN PMMPFN Pfn1)
{
return ((Pfn1->u3.e1.PageLocation != FreePageList) &&
(Pfn1->u3.e1.PageLocation != ZeroedPageList));
/* Standby list or higher, unlinked, and with references */
return !MiIsPfnFree(Pfn1);
}
PFN_NUMBER