How would one go about printing out the contents of the memory to the screen (the raw data)? Would the OS stop your program if you were attempting to read the memory from other programs running on the system?
How would one go about printing out the contents of the memory to the screen (the raw data)? Would the OS stop your program if you were attempting to read the memory from other programs running on the system?
You could set up a loop to start at address 0, attempt to print the character to the screen, and then advance your pointer one byte, and repeat that sequence until the end of memory.
However, you would have to set your program up to be able to handle signals, (via signal handlers), because you would certainly get seg faults and access errors and who knows what other errors. All these signals would have to be handled, and you would have to be able to recover from them and continue in your loop.
Mainframe assembler programmer by trade. C coder when I can.
Your looking to read other programs memory?
Well, you could alway make a .dll and inject it into the program. Then finally, read the memory of this single program.
On what OS?
You can probably do it with DOS pretty easily, but Windows & UNIX both use virtual memory, so I'm sure it would be a lot harder.
"I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008
"the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010
Swarvy, it's platform dependant as to how and if it is even possible.
You can't even address memory directly in a user mode program in Windows. Every app is given its own seperate address space. The same address in difference programs points to different data!
I'm not going to tell you about APIs that allow you to read memory from other programs because if you don't know how it should probably stay that way, in my opinion. There are very few valid reasons to ever do it.
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"