[NTOSKRNL:CC] Add CalculatePageCount Template
Added CalculatePageCount Template function to calculate total pagecount from file offset and length
This commit is contained in:
parent
2bc93fca07
commit
0e2abe7eb5
@ -144,3 +144,16 @@ private:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
ULONG CalculatePageCount(T Length, LARGE_INTEGER FileOffset) {
|
||||||
|
constexpr ULONG PAGE_OFFSET = 0xFFF; // 4095 (mask for the lower 12 bits)
|
||||||
|
constexpr ULONG PAGE_SHIFT = 12; // Shift by 12 bits for 4KB pages
|
||||||
|
|
||||||
|
// Calculate the page count
|
||||||
|
ULONG pageCount = (Length >> PAGE_SHIFT) +
|
||||||
|
((FileOffset.LowPart & PAGE_OFFSET) + 4095 + (Length & PAGE_OFFSET)) >> PAGE_SHIFT;
|
||||||
|
|
||||||
|
return pageCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user