One would expect that a function called "MmIsUsablePage" would return whether a not a page is usable. In other words, we are making sure that the page is free/available, so that we may make use of it. Apparently not so -- MmIsUsable page returned if a page was NOT usable, but was instead "already used". The caller's wish was to ensure he was correctly using a used page, not to check if he could start using a usable page. This would just be an annoying gramatical/logic error (but makes "sense" in the way it's used), if it weren't for the fact that MmIsUsablePage also returned TRUE for BIOS pages (which meant, "yes, you are correctly using/overwriting memory we spent time ensuring to mark as reserved/BIOS").

Renamed the function to MmIsPageInUse, and only return TRUE if the page is in use. Like the name says.

svn path=/trunk/; revision=32364
This commit is contained in:
ReactOS Portable Systems Group 2008-02-14 20:30:31 +00:00
parent bf3c65f8a3
commit 93c66fb50d
3 changed files with 8 additions and 22 deletions

View file

@ -1145,7 +1145,7 @@ MmGetReferenceCountPage(PFN_TYPE Page);
BOOLEAN
NTAPI
MmIsUsablePage(PFN_TYPE Page);
MmIsPageInUse(PFN_TYPE Page);
VOID
NTAPI

View file

@ -640,23 +640,17 @@ MmGetReferenceCountPage(PFN_TYPE Pfn)
BOOLEAN
NTAPI
MmIsUsablePage(PFN_TYPE Pfn)
MmIsPageInUse(PFN_TYPE Pfn)
{
DPRINT("MmIsUsablePage(PhysicalAddress %x)\n", Pfn << PAGE_SHIFT);
DPRINT("MmIsPageInUse(PhysicalAddress %x)\n", Pfn << PAGE_SHIFT);
if (Pfn == 0 || Pfn >= MmPageArraySize)
{
KEBUGCHECK(0);
}
if (MmPageArray[Pfn].Flags.Type != MM_PHYSICAL_PAGE_USED &&
MmPageArray[Pfn].Flags.Type != MM_PHYSICAL_PAGE_BIOS)
{
return(FALSE);
}
return(TRUE);
return (MmPageArray[Pfn].Flags.Type == MM_PHYSICAL_PAGE_USED);
}
VOID

View file

@ -1941,18 +1941,10 @@ MmCreateVirtualMapping(PEPROCESS Process,
for (i = 0; i < PageCount; i++)
{
if (!MmIsUsablePage(Pages[i]))
if (!MmIsPageInUse(Pages[i]))
{
/* Is this an attempt to map KUSER_SHARED_DATA? */
if ((Address == (PVOID)0x7FFE0000) && (PageCount == 1) && (Pages[0] == 2))
{
// allow
}
else
{
DPRINT1("Page at address %x not usable\n", PFN_TO_PTE(Pages[i]));
KEBUGCHECK(0);
}
DPRINT1("Page at address %x not in use\n", PFN_TO_PTE(Pages[i]));
KEBUGCHECK(0);
}
}