Code Monkey home page Code Monkey logo

anyvtop's Introduction

anyvtop

x64 Windows implementation of virtual-address to physical-address translation

Windows Memory Management

Modern x64 Windows uses PML4 Page Map Level 4 as paging mode. careful that interpretation of the mode is a bit different with long/legacy mode on AMD64 and Intel64.
This repository is an implementation of virtual address a.k.a linear address to physical address translation, that usually done by the CPU's MMU Memory Management Unit.

This implementation is similar to MmGetPhysicalAddress.

DTB

DTB is a Directory Table Base which represents the base physical address of paging table.
Can be found at nt!_EPROCESS.Pcb.DirectoryTableBase, PCB means Processor Control Block.

dt nt!_KPROCESS DirectoryTableBase
  +0x028 DirectoryTableBase : Uint8B

If the virtual address is KVA Kernel Virtual Address, we could use system process's DTB.
The system process's DTB represents exact same value contained in CR3 because it is a part of the kernels.

Also if it is user's virtual address, ofcourse the DTB is different with the every single processes, so we have to lookup from the structure.

Paging

There's 4 things we first understand,

  • PML4 Page Map Level 4
  • PDP Page Directory Pointer
  • PD Page Directory
  • PT Page Table

Steps

  1. Lookup DTB
  2. Lookup PDP entry using DTB entry's PFN and VA's pml4_index
  3. Lookup PD entry using PDP entry's PFN and VA's pd_index
  4. Lookup PT entry using PD entry's PFN and VA's pt_index
  5. Translate to the physical address using PT entry's PFN and VA's offset, the first 12-bits value of virtual address.

Extra: PML5

Some of you may know that there is PML5 Page Map Level 5 is available on Linux. (some versions)
The PML5 is expanded physical address to the 56-bits allowing use of 4PiB of physical address ranges and 128PiB of virtual address ranges.

Do you think that Windows should have PML5?

License

MIT copyright Kento Oki <[email protected]>

anyvtop's People

Contributors

kkent030315 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.