mirror of
https://github.com/ApfelTeeSaft/reactos.git
synced 2026-08-30 19:26:05 +00:00
Fix PAGE_ROUND_DOWN, PAGE_ROUND_UP, and a user of them (correctness and speedup)
svn path=/trunk/; revision=29633
This commit is contained in:
@@ -30,11 +30,9 @@ Author:
|
||||
// Page-Rounding Macros
|
||||
//
|
||||
#define PAGE_ROUND_DOWN(x) \
|
||||
(((ULONG_PTR)x)&(~(PAGE_SIZE-1)))
|
||||
(((ULONG_PTR)(x))&(~(PAGE_SIZE-1)))
|
||||
#define PAGE_ROUND_UP(x) \
|
||||
( (((ULONG_PTR)x)%PAGE_SIZE) ? \
|
||||
((((ULONG_PTR)x)&(~(PAGE_SIZE-1)))+PAGE_SIZE) : \
|
||||
((ULONG_PTR)x) )
|
||||
( (((ULONG_PTR)(x)) + PAGE_SIZE-1) & (~(PAGE_SIZE-1)) )
|
||||
#ifdef NTOS_MODE_USER
|
||||
#define ROUND_TO_PAGES(Size) \
|
||||
(((ULONG_PTR)(Size) + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1))
|
||||
|
||||
@@ -20,11 +20,11 @@
|
||||
#endif
|
||||
|
||||
#ifndef PAGE_ROUND_DOWN
|
||||
#define PAGE_ROUND_DOWN(x) (((ULONG_PTR)x)&(~(PAGE_SIZE-1)))
|
||||
#define PAGE_ROUND_DOWN(x) (((ULONG_PTR)(x))&(~(PAGE_SIZE-1)))
|
||||
#endif
|
||||
|
||||
#ifndef PAGE_ROUND_UP
|
||||
#define PAGE_ROUND_UP(x) ( (((ULONG_PTR)x)%PAGE_SIZE) ? ((((ULONG_PTR)x)&(~(PAGE_SIZE-1)))+PAGE_SIZE) : ((ULONG_PTR)x) )
|
||||
#define PAGE_ROUND_UP(x) ( (((ULONG_PTR)(x)) + PAGE_SIZE-1) & (~(PAGE_SIZE-1)) )
|
||||
#endif
|
||||
|
||||
#define ABS_VALUE(V) (((V) < 0) ? -(V) : (V))
|
||||
|
||||
@@ -390,7 +390,7 @@ MiProtectVirtualMemory(IN PEPROCESS Process,
|
||||
NTSTATUS Status;
|
||||
|
||||
*NumberOfBytesToProtect =
|
||||
PAGE_ROUND_UP((*BaseAddress) + (*NumberOfBytesToProtect)) -
|
||||
PAGE_ROUND_UP((ULONG_PTR)(*BaseAddress) + (*NumberOfBytesToProtect)) -
|
||||
PAGE_ROUND_DOWN(*BaseAddress);
|
||||
*BaseAddress = (PVOID)PAGE_ROUND_DOWN(*BaseAddress);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user