|
-
September 10th, 2009, 10:58 PM
#1
Sharing DLL functions between processes
Hi gurus,
The real-time application I'm developing consists of the main program ("master") which starts child processes ("tasks"). The master process creates shared memory block which is used by the task processes to exchange data and to interact with each other. There's a type library (implemented as DLLs) which contains class member functions of the objects that reside in shared memory.
The question is how to load the DLL into the shared memory block (created by CreateFileMapping(..., PAGE_EXECUTABLE,...)?
Loading DLLs with LoadLibrary() places the executable into the virtual address space of master process, so the loaded modules are not accessible from other processes.
Loading DLLs separately in virtual address space of every process is not suitable because the pointers to the DLL functions are to be stored in shared objects (pointers to Virtual Function Table)
There's some quite low-level way to solve the problem: loading the DLL with LoadLibrary() call, locating the module in local memory with its handle and then copying the module contents into the shared memory block. But in this case a new problem arises. After moving the executable to some other place in memory the absolute (not relative to the value of stack register) addresses which are referenced by the executable should be adjusted by the value of memory shift.
Is there any way to solve the problem above? There may be some undocumented calls to the kernel.dll functions, are there? What were the reasons of Microsoft to specify the shared memory tag PAGE_EXECUTABLE ? How to place any executable into this space (except as with memcpy())?
Sorry for big amount of questions.
Julian Drachevsky aka Hobbiton
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|