Indeed that pragma looks like a shared memory macro to me

Actually one thing I found out is that DLLs and Shared Libraries are
implemented via shared memory mapped files without giving access to shared
memory.

CodeDmitry I did get your message as you can see by the quote of my last
reply. You are basically using Shared Memory IPC , its just an ungly
Windows hack via a pragma and from the thread that Phil linked it looks
like its also bug prone.

This is also confirmed by Mircrosoft itself here ->
https://msdn.microsoft.com/en-us/library/h90dkhs0(v=vs.90).aspx

Summary: Use shared memory mapped files, far safer and far more cross
platform

On Wed, Oct 12, 2016 at 11:12 AM p...@highoctane.be <p...@highoctane.be>
wrote:

> #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 <dimamakh...@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.
>
>
>

Reply via email to