What is the trick in pAddress & ~(PAGE_SIZE - 1) to get the page's start address

Posted by Dbger on Stack Overflow See other posts from Stack Overflow or by Dbger
Published on 2010-06-11T15:06:21Z Indexed on 2010/06/11 15:12 UTC
Read the original article Hit count: 151

Filed under:

Following function is used to get the page's start address of an address which in side this page:

void* GetPageAddress(void* pAddress)
{
    return (void*)((ULONG_PTR)pAddress & ~(PAGE_SIZE - 1));
}

But I couldn't quite get to it, what is the trick it plays here?

© Stack Overflow or respective owner

Related posts about bitwise