
pheres wrote:
-Allocate the memory range as the first call in main() using OS-specific functions like VirtualAlloc()
This is what I do. It's not 100% reliable (because at some point, you're going to have to VirtualFree the slice so the shared memory lib can use it), but it's better than most alternatives. If *you're* writing the code that uses the shared memory block, I would *strongly* encourage you to attempt to re-write it so that you don't need to have it loaded into the same address location in all processes. The only reason I researched and use the "first in main" trick is that I'm using a vendor-supplied library that really really really wants a certain location. Needless to say, I've been on their case to fix that, since it's brittle, at best, and completely unworkable in certain cases (like, where I'm writing a lib, and using their lib, but I didn't write "main").