diff --git a/ntoskrnl/include/internal/mm.h b/ntoskrnl/include/internal/mm.h index 91bf7599df236..1c3870d6370a6 100644 --- a/ntoskrnl/include/internal/mm.h +++ b/ntoskrnl/include/internal/mm.h @@ -131,6 +131,13 @@ typedef ULONG_PTR SWAPENTRY; #define MM_ROUND_DOWN(x,s) \ ((PVOID)(((ULONG_PTR)(x)) & ~((ULONG_PTR)(s)-1))) +/* PAGE_ROUND_UP and PAGE_ROUND_DOWN equivalent, with support for 64-bit-only data types */ +#define PAGE_ROUND_UP_64(x) \ + (((x) + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1)) + +#define PAGE_ROUND_DOWN_64(x) \ + ((x) & ~(PAGE_SIZE - 1)) + #define PAGE_FLAGS_VALID_FOR_SECTION \ (PAGE_READONLY | \ PAGE_READWRITE | \ diff --git a/ntoskrnl/mm/section.c b/ntoskrnl/mm/section.c index 73b414315fe38..d570dbc3cec0f 100644 --- a/ntoskrnl/mm/section.c +++ b/ntoskrnl/mm/section.c @@ -4876,7 +4876,7 @@ MmPurgeSegment( } /* Find byte offset of the page to start */ - PurgeStart.QuadPart = PAGE_ROUND_DOWN(PurgeStart.QuadPart); + PurgeStart.QuadPart = PAGE_ROUND_DOWN_64(PurgeStart.QuadPart); while (PurgeStart.QuadPart < PurgeEnd.QuadPart) { @@ -4947,7 +4947,7 @@ MmIsDataSectionResident( return FALSE; /* Find byte offset of the page to start */ - RangeStart.QuadPart = PAGE_ROUND_DOWN(RangeStart.QuadPart); + RangeStart.QuadPart = PAGE_ROUND_DOWN_64(RangeStart.QuadPart); MmLockSectionSegment(Segment); @@ -5010,7 +5010,7 @@ MmMakeSegmentDirty( return STATUS_NOT_MAPPED_VIEW; /* Find byte offset of the page to start */ - RangeStart.QuadPart = PAGE_ROUND_DOWN(RangeStart.QuadPart); + RangeStart.QuadPart = PAGE_ROUND_DOWN_64(RangeStart.QuadPart); MmLockSectionSegment(Segment); @@ -5098,7 +5098,7 @@ MmFlushSegment( } /* Find byte offset of the page to start */ - FlushStart.QuadPart = PAGE_ROUND_DOWN(FlushStart.QuadPart); + FlushStart.QuadPart = PAGE_ROUND_DOWN_64(FlushStart.QuadPart); while (FlushStart.QuadPart < FlushEnd.QuadPart) {