I could just try it, but now I figure asking is alot quicker.
Can you pass pointers to other programs? (not handles or anything, I mean pointers made with new or malloc.)
I could just try it, but now I figure asking is alot quicker.
Can you pass pointers to other programs? (not handles or anything, I mean pointers made with new or malloc.)
You can pass them, sure - they're just numbers. But you can't use them there, because the other program uses a different address space, so the pointer would be meaningless.
The exception are function pointers to functions in DLLs, which may point to the same function, provided that the DLL is present in both apps and mapped to the same base address.
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
If you allocate data in shared memory, multiple processes should be able to access it.
I could add that it is possible to share memory between processes using some type of shared memory such as memory mapped files, but it's not possible to pass a pointer directly and expect the other process to be able to use the memory in another process. It doesn't work that way due to virtual memory.
Of course, you could also read other processes' memory using special API, but I don't think it's really recommended for purpose such as this.
Okay, now I know.
Do you know of an easy way to create shared memory?
or in UNIX there's a bunch of functions that start with "shm", like shmat(), shmdt(), shmget(), shmctl()...
The file-based shared memory do not allow any specification of the base-address of the mapping, it will be allocated as the OS sees fit. So pointers in the first process are not pointing to the same thing in the second process.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
There's also Boost.Interprocess. It will be part of the upcoming 1.35 release. Aside from raw shared memory and memory-mapped files, Interprocess also provides special containers that can reside in such memory.
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law