Shared Memory Objects Across Modules
<p>How can I share Objects across DLL's? </p>

<p>Example:</p>

<p>DLLA is loaded by Process A. DLL A collects data (Intercepts calls from process A).</p>

<p>DLLB is loaded by a Pascal program and wants to use the data that DLLA collected.</p>

<p>I've created a mapping with DLLA like so:</p>

<pre><code>GL_EXTERN bool __stdcall CreateSharedMemory()
{
    if ((hMapFile = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, MapSize, SharedMemoryName.c_str())) == NULL)
    {
        return false;
    }

    if ((pData = MapViewOfFile(hMapFile, FILE_MAP_ALL_ACCESS, 0, 0, MapSize)) == NULL)
    {
        CloseHandle(hMapFile);
        return false;
    }
    return true;
}
</code></pre>

<p>And DLLB just opens it and maps it.</p>

<p>They can share commands. So DLL B can give DLLA commands and retrieve data but I cannot seem to figure out how to share objects/classes/vectors across the memory.</p>

<p>I've tried using a pointer but realized that this is invalid and gives access violation errors. Also it seems to share integers fine but it doesn't seem to be able to share floats :S How can I accomplish these tasks?</p>

<p>EDIT: To communicate I do:</p>

<pre><code>int* Foo = static_cast&lt;int*&gt;(pData); where pData is the map pointer.
//Then I do:

Foo[0] = X; Foo[1] = Y;
</code></pre>

<p>And have the processes read and write from the corresponding values.</p>

<p>Info:</p>

<p>This is the files for DLLA: <a href="http://pastebin.com/MFkqwxJe" rel="nofollow">http://pastebin.com/MFkqwxJe</a>  and <a href="http://pastebin.com/MDeWprkb" rel="nofollow">http://pastebin.com/MDeWprkb</a></p>

<p>This is the files for DLLB: <a href="http://pastebin.com/Uj3dijc4" rel="nofollow">http://pastebin.com/Uj3dijc4</a>  and <a href="http://pastebin.com/vkDdPp7e" rel="nofollow">http://pastebin.com/vkDdPp7e</a></p>

<p>EDIT: Narrowed it down to: <a href="http://pastebin.com/hNF6Cu2L" rel="nofollow">http://pastebin.com/hNF6Cu2L</a> as requested.</p>
