mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 19:05:52 +00:00
[NTOSKRNL]
Make MmIsAddressValid portable by using _MI_PAGING_LEVELS macro. svn path=/trunk/; revision=48238
This commit is contained in:
parent
a28e798006
commit
0bbdcf4d8b
4 changed files with 27 additions and 27 deletions
|
@ -4,6 +4,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#define _MI_PAGING_LEVELS 4
|
||||
|
||||
/* Helper macros */
|
||||
#define PAGE_MASK(x) ((x)&(~0xfff))
|
||||
#define PAE_PAGE_MASK(x) ((x)&(~0xfffLL))
|
||||
|
|
|
@ -7,6 +7,12 @@
|
|||
struct _EPROCESS;
|
||||
PULONG MmGetPageDirectory(VOID);
|
||||
|
||||
#ifdef _PAE_
|
||||
#define _MI_PAGING_LEVELS 3
|
||||
#else
|
||||
#define _MI_PAGING_LEVELS 2
|
||||
#endif
|
||||
|
||||
#define PAGE_MASK(x) ((x)&(~0xfff))
|
||||
#define PAE_PAGE_MASK(x) ((x)&(~0xfffLL))
|
||||
|
||||
|
|
|
@ -64,22 +64,26 @@ BOOLEAN
|
|||
NTAPI
|
||||
MmIsAddressValid(IN PVOID VirtualAddress)
|
||||
{
|
||||
//
|
||||
// Just check the Valid bit in the Address' PDE and PTE
|
||||
//
|
||||
if ((MiAddressToPde(VirtualAddress)->u.Hard.Valid == 0) ||
|
||||
(MiAddressToPte(VirtualAddress)->u.Hard.Valid == 0))
|
||||
{
|
||||
//
|
||||
// Attempting to access this page is guranteed to result in a page fault
|
||||
//
|
||||
return FALSE;
|
||||
}
|
||||
#if _MI_PAGING_LEVELS >= 4
|
||||
/* Check if the PXE is valid */
|
||||
if (MiAddressToPxe(VirtualAddress)->u.Hard.Valid == 0) return FALSE;
|
||||
#endif
|
||||
|
||||
//
|
||||
// This address is valid now, but it will only stay so if the caller holds
|
||||
// the PFN lock
|
||||
//
|
||||
#if _MI_PAGING_LEVELS >= 3
|
||||
/* Check if the PPE is valid */
|
||||
if (MiAddressToPpe(VirtualAddress)->u.Hard.Valid == 0) return FALSE;
|
||||
#endif
|
||||
|
||||
#if _MI_PAGING_LEVELS >= 2
|
||||
/* Check if the PDE is valid */
|
||||
if (MiAddressToPde(VirtualAddress)->u.Hard.Valid == 0) return FALSE;
|
||||
#endif
|
||||
|
||||
/* Check if the PTE is valid */
|
||||
if (MiAddressToPte(VirtualAddress)->u.Hard.Valid == 0) return FALSE;
|
||||
|
||||
/* This address is valid now, but it will only stay so if the caller holds
|
||||
* the PFN lock */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -519,16 +519,4 @@ MmCreateProcessAddressSpace(IN ULONG MinWs,
|
|||
return 0;
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
NTAPI
|
||||
_MmIsAddressValid(IN PVOID VirtualAddress)
|
||||
{
|
||||
/* Check all four page table levels */
|
||||
return (MiAddressToPxe(VirtualAddress)->u.Hard.Valid != 0 &&
|
||||
MiAddressToPpe(VirtualAddress)->u.Hard.Valid != 0 &&
|
||||
MiAddressToPde(VirtualAddress)->u.Hard.Valid != 0 &&
|
||||
MiAddressToPte(VirtualAddress)->u.Hard.Valid != 0);
|
||||
}
|
||||
|
||||
|
||||
/* EOF */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue