Global memory (GlobalAlloc, etc...)
-
Hello, is the memory allocated by the GlobalAlloc function really global? Can different processes access the same memory block allocated by GlobalAlloc? Thanks -Dominik
-
Hello, is the memory allocated by the GlobalAlloc function really global? Can different processes access the same memory block allocated by GlobalAlloc? Thanks -Dominik
No. Memory allocated by GlobalAlloc is not visible to other process. If you want to share memory across process, i sugest that you use memory mapped files. Also, MSDN state that GlobalAlloc is not the preferred way to allocate memory. Try the heap memory function instead (HeapAlloc, HeapFree, ect,ect).
-
No. Memory allocated by GlobalAlloc is not visible to other process. If you want to share memory across process, i sugest that you use memory mapped files. Also, MSDN state that GlobalAlloc is not the preferred way to allocate memory. Try the heap memory function instead (HeapAlloc, HeapFree, ect,ect).
Ok, I will use memory mapped files. Thank you! -Dominik
-
Ok, I will use memory mapped files. Thank you! -Dominik
When you call
::CreateFileMapping
with(HANDLE) LongToHandle(-1)
as the first parameter, PAGE_READWRITE as the protection and a name, which is how other applications will access it by callingOpenFileMapping
. If the creator will be in one set of permissions (like a service logged in as an administrator) and the other application will have lower permissions, you'll need to create and use SECURITY_ATTRIBUTES (you can create a NULL security attribute which essentially grants global rights to the memory.)