Access to the same memory adress through two parallel application in C
I have two applications.
First application:
int a = 42;
int *P = &a;
Second application:
int b = *P;
Is it possible to do that? Otherwise, is it possible to access the same memory through two applications (or multiple) that a开发者_运维技巧re executed in parallel?
For two separate applications, even the shared memory bit involves more than referencing through the same address, certainly on typical desktop systems. Each application sees a virtual address space - not the physical address space of the machine. The memory for other applications usually isn't even visible - let alone mapped to the same address.
There are (platform specific) APIs that can give you some access to another applications memory, aimed mainly at debuggers and similar tools, but also e.g. used by games "trainer" cheats - but this isn't a good way to communicate between apps.
On Windows...
http://msdn.microsoft.com/en-us/library/ms680553%28VS.85%29.aspx
精彩评论