Author: sir_richard
Date: Sun May 9 20:06:38 2010
New Revision: 47148
URL:
http://svn.reactos.org/svn/reactos?rev=47148&view=rev
Log:
[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.
Modified:
trunk/reactos/ntoskrnl/mm/freelist.c
Modified: trunk/reactos/ntoskrnl/mm/freelist.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/freelist.c?rev…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/freelist.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/freelist.c [iso-8859-1] Sun May 9 20:06:38 2010
@@ -130,10 +130,21 @@
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