mirror of
https://github.com/reactos/reactos.git
synced 2025-08-04 23:55:41 +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
|
#pragma once
|
||||||
|
|
||||||
|
#define _MI_PAGING_LEVELS 4
|
||||||
|
|
||||||
/* Helper macros */
|
/* Helper macros */
|
||||||
#define PAGE_MASK(x) ((x)&(~0xfff))
|
#define PAGE_MASK(x) ((x)&(~0xfff))
|
||||||
#define PAE_PAGE_MASK(x) ((x)&(~0xfffLL))
|
#define PAE_PAGE_MASK(x) ((x)&(~0xfffLL))
|
||||||
|
|
|
@ -7,6 +7,12 @@
|
||||||
struct _EPROCESS;
|
struct _EPROCESS;
|
||||||
PULONG MmGetPageDirectory(VOID);
|
PULONG MmGetPageDirectory(VOID);
|
||||||
|
|
||||||
|
#ifdef _PAE_
|
||||||
|
#define _MI_PAGING_LEVELS 3
|
||||||
|
#else
|
||||||
|
#define _MI_PAGING_LEVELS 2
|
||||||
|
#endif
|
||||||
|
|
||||||
#define PAGE_MASK(x) ((x)&(~0xfff))
|
#define PAGE_MASK(x) ((x)&(~0xfff))
|
||||||
#define PAE_PAGE_MASK(x) ((x)&(~0xfffLL))
|
#define PAE_PAGE_MASK(x) ((x)&(~0xfffLL))
|
||||||
|
|
||||||
|
|
|
@ -64,22 +64,26 @@ BOOLEAN
|
||||||
NTAPI
|
NTAPI
|
||||||
MmIsAddressValid(IN PVOID VirtualAddress)
|
MmIsAddressValid(IN PVOID VirtualAddress)
|
||||||
{
|
{
|
||||||
//
|
#if _MI_PAGING_LEVELS >= 4
|
||||||
// Just check the Valid bit in the Address' PDE and PTE
|
/* Check if the PXE is valid */
|
||||||
//
|
if (MiAddressToPxe(VirtualAddress)->u.Hard.Valid == 0) return FALSE;
|
||||||
if ((MiAddressToPde(VirtualAddress)->u.Hard.Valid == 0) ||
|
#endif
|
||||||
(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 >= 3
|
||||||
// This address is valid now, but it will only stay so if the caller holds
|
/* Check if the PPE is valid */
|
||||||
// the PFN lock
|
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;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -519,16 +519,4 @@ MmCreateProcessAddressSpace(IN ULONG MinWs,
|
||||||
return 0;
|
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 */
|
/* EOF */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue