Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- )
- func VAtoOffsets(va uint64) {
- phy_offset := va & 0xFFF
- pt_index := (va >> 12) & 0x1FF
- pde_index := (va >> (12 + 9)) & 0x1FF
- pdpt_index := (va >> (12 + 9 + 9)) & 0x1FF
- pml4_index := (va >> (12 + 9 + 9 + 9)) & 0x1FF
- fmt.Printf("PML4 Index: %03x\n", pml4_index)
- fmt.Printf("PDPT Index: %03x\n", pdpt_index)
- fmt.Printf("PDE Index: %03x\n", pde_index)
- fmt.Printf("PT Index: %03x\n", pt_index)
- fmt.Printf("Page offset: %03x\n", phy_offset)
- }
- func OffsetsToVA(phy_offset, pt_index, pde_index, pdpt_index, pml4_index uint64) {
- var va uint64
- va = pml4_index << (12 + 9 + 9 + 9)
- va = va | pdpt_index << (12 + 9 + 9)
- va = va | pde_index << (12 + 9)
- va = va | pt_index << 12
- va = va | phy_offset
- if ((va & 0x800000000000) == 0x800000000000) {
- va |= 0xFFFF000000000000
- }
- fmt.Printf("Virtual Address: %x\n", va)
- }
- func main() {
- VAtoOffsets(0xffff804020100000)
- OffsetsToVA(0, 0x100, 0x100, 0x100, 0x100)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement