#pragma data_seg("SHARED")

looks like this is doing some serious IPC magic behing the scenes.

Check this out for some critters:��https://social.msdn.microsoft.com/Forums/vstudio/en-US/bc93445e-cec3-456d-9596-15528060dc94/sharing-data-between-processes-using-pragma-dataseg-and-windows-7?forum=vcgeneral

Phil

On Wed, Oct 12, 2016 at 9:34 AM, CodeDmitry <dimamakhnin@gmail.com> wrote:
Have you got my modified message? or have I been wasting my revisions all
along O.o? I'll repost.


O.o can you please elaborate?

I wrote a DLL a while ago that successfully shared the global state it
exported between the callers that without any shared memory explicitly being
created.

I'll recreate a test case to make sure that I am not just lying.

*Solution SharingDemo*:
*Project ShareMe*:
*ShareMe.cpp*:
#pragma data_seg("SHARED")
�� �� extern "C" {
�� �� �� �� __declspec(dllexport)
�� �� �� �� int sharedInteger = 0;
�� �� }
#pragma data_seg()

#pragma comment(linker, "/section:SHARED,RWS")

*Project Client1*:
*main.cpp*:
#include <Windows.h>
#include <stdio.h>

int main(int argc, char **argv)
{
�� �� HMODULE module_handle = LoadLibrary("ShareMe.dll");
�� �� int *shared_integer_handle = (int *)GetProcAddress(module_handle,
"sharedInteger");
�� �� printf("*(shared_integer_handle) = %d.\n", *shared_integer_handle);

�� �� *shared_integer_handle = 1337;

�� �� printf("*(shared_integer_handle) = %d.\n", *shared_integer_handle);

�� �� system("pause");
�� �� return 0;
}

*Project Client2*:
*main.cpp*:
#include <Windows.h>
#include <stdio.h>

int main(int argc, char **argv)
{
�� �� HMODULE module_handle = LoadLibrary("ShareMe.dll");
�� �� int *shared_integer_handle = (int *)GetProcAddress(module_handle,
"sharedInteger");
�� �� printf("*(shared_integer_handle) = %d.\n", *shared_integer_handle);

�� �� *shared_integer_handle = 0;

�� �� printf("*(shared_integer_handle) = %d.\n", *shared_integer_handle);

�� �� system("pause");
�� �� return 0;
}

now, debug client1, then debug client2. Client 2 should start with mutated
shared state(1337).




--
View this message in context: http://forum.world.st/Can-Pharo-VM-be-altered-to-act-like-GNUStep-as-well-tp4918693p4918720.html
Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.