Reputation: 1789
I have to access an object in .exe which is created and stored in .dll's address space. There's a lot of answers that mention IPC as a solution but I'm not sure how it can help. IMO, IPC is just a message "chat" between processes and can share primitives by recreating them on caller side (.exe). I can't recreate the object because it's being created by some thirdparty library on the .dll's side and if I share raw memory and just reinterpret_cast
it, it will likely be an invalid object. I can't also share a pointer to the object because it will share only the virtual memory address which will likely be garbage on the caller's side. I don't want to link my library statically. What should I do?
Upvotes: 0
Views: 313
Reputation: 67362
IPC is a broad umbrella term that covers all inter process communication, not just shared memory (which is nothing like a "chat", by the way).
Luckily you don't need any kind of IPC, since you don't have different processes. The dll and the exe share the same address space, so simply return the pointer to the constructed object and use it directly, no reinterpreting needed.
Upvotes: 2