Physical to virtual memory

Programming, for all ages and all languages.
Locked
Hercules
Posts: 15
Joined: Sun Dec 01, 2013 6:08 am

Physical to virtual memory

Post by Hercules »

How to convert physical memory into virtual memory using CR3 if my program is a PE file and that's why can't read physical address of page directory at CR3 register?
User avatar
iansjack
Member
Member
Posts: 4685
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Physical to virtual memory

Post by iansjack »

You access physical memory by mapping a logical address to a physical page and then accessing the memory through that address. You are pretty free to choose whatever address you like to represent the physical page.
Hercules
Posts: 15
Joined: Sun Dec 01, 2013 6:08 am

Re: Physical to virtual memory

Post by Hercules »

How to read the physical address of Page Directory in a PE file?
User avatar
thepowersgang
Member
Member
Posts: 734
Joined: Tue Dec 25, 2007 6:03 am
Libera.chat IRC: thePowersGang
Location: Perth, Western Australia
Contact:

Re: Physical to virtual memory

Post by thepowersgang »

You seem to have missed some concepts.

The physical address of a process's PD (i.e. the value that gets written to CR3) is decided by the OS's low level memory manager (usually, it just grabs the first free page and uses that). It is not stored in the executable file, nor should the executing process care about it (in fact, processes rarely need to care that the addresses they're using are not actually physical addresses) as it is a kernel-level detail.
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
User avatar
BMW
Member
Member
Posts: 286
Joined: Mon Nov 05, 2012 8:31 pm
Location: New Zealand

Re: Physical to virtual memory

Post by BMW »

This should be in OS Development, not General Programming.
Currently developing Lithium OS (LiOS).

Recursive paging saves lives.
"I want to change the world, but they won't give me the source code."
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Physical to virtual memory

Post by Combuster »

And that should go under report post. Although I think autodelete or the moderator archives is a much better place with this OP considering his consistent bad questions and complete lack of followup, as if he does not want to be helped.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Hercules
Posts: 15
Joined: Sun Dec 01, 2013 6:08 am

Re: Physical to virtual memory

Post by Hercules »

What is teh virtual address of page directory in CR3?
Locked