Say I send a pointer as an argument to another program:
program.exe -mypointer
and try to use it in that program, it won’t work. After some research (i.e asking at Lounge C++ ) I found that since Windows 95, you can’t access the address space of another program. In older versions of Windows it was allowed. My question is, why did Microsoft disallow it? What were the problems or disadvantages of doing this?
P.S Is it still possible through some work-around to do this in new versions of Windows?
Because being able to access the address space of other processes means that you can crash them by, for example, changing their memory contents randomly.
The whole point of protected mode is to protect processes from each other. See the memory protection Wikipedia page for some more details. In the bad old days before protection, it was a lot easier to write code that fiddled with other processes.
The downside of that is that it was a lot easier for some a bug in MS Word to not just crash MS Word but also Excel, Borland C, your PI digit calculator that had been running for the last six weeks, and even the operating system itself.
You still can get access to another process address space but you basically have to run at higher privileges to do this. For example, this is how debuggers allow you to run a process and access all its memory for debugging purposes.
The calls
ReadProcessMemoryandWriteProcessMemoryallow you to do this, along with many other debugging functions.