how can get address of PT form virtual address ?
this method is self-reference trick but i dont know what is behind it
i used google and read some article but cant find it
this code work in windows x64 but i cant know how it works
Code: Select all
UINT64 getPTfromVA(UINT64 vaddr)
{
vaddr >>= 9;
vaddr >>= 3;
vaddr <<= 3;
vaddr &= 0xfffff6ffffffffff;
vaddr |= 0xfffff68000000000;
return vaddr;
}
UINT64 getPDfromVA(UINT64 vaddr)
{
vaddr >>= 18;
vaddr >>= 3;
vaddr <<= 3;
vaddr &= 0xfffff6fb7fffffff;
vaddr |= 0xfffff6fb40000000;
return vaddr;
}
UINT64 getPDPTfromVA(UINT64 vaddr)
{
vaddr >>= 27;
vaddr >>= 3;
vaddr <<= 3;
vaddr &= 0xfffff6fb7dbfffff;
vaddr |= 0xfffff6fb7da00000;
return vaddr;
}
UINT64 getPML4fromVA(UINT64 vaddr)
{
vaddr >>= 36;
vaddr >>= 3;
vaddr <<= 3;
vaddr &= 0xfffff6fb7dbedfff;
vaddr |= 0xfffff6fb7dbed000;
return vaddr;
}