View Single Post
Old 10-08-2006, 03:55 PM   #3 (permalink)
n0nsensical
It's Just A Game
 
n0nsensical's Avatar
 
Join Date: Sep 2003
Location: San Francisco
On any modern OS, with some exceptions like the embedded single-process variety, every application has its own virtual memory space and it's impossible to access any other application's space without help from the OS (well, technically you need help from the OS to access any memory at all since you never deal with hardware addresses directly, but you need extra-special help for this), which is referred to generally as interprocess communication (IPC).

On windows, you can use the APIs ReadProcessMemory and WriteProcessMemory. Here is a program that reads the first 10 bytes at memory location 0x00400000 of process with ID 666:
Code:
#include <windows.h>

int main()
{
	char c[10];
	void * p = (void*)0x00400000;
	HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, 666);
	ReadProcessMemory(hProcess, p, c, 10, NULL);
	CloseHandle(hProcess); // ok, its a little redundant
	return 0;
}
It's also possible to set up shared memory pages which both apps can access.
n0nsensical is online now   Reply With Quote