I want to use one Shared Memory in both directions. Samples in the internet are poor.
In the server, I wrote:
rc := DosAllocSharedMem(SharedMem, NULL, 4096/*smaller has no effect*/, PAG_WRITE | PAG_READ | PAG_COMMIT | OBJ_GETTABLE);
SharedMem is an untyped pointer.
I transfer the pointer value via commandline parameter to the client.
The pointer value is hold in ulong4.
In the client, I wrote:
SharedMem = (VOID*) ulong4;
SharedMem2 = (VOID*) (ulong4+8);
rc = DosGetSharedMem(SharedMem, PAG_READ | PAG_WRITE);
PSharedULONG = (PULONG) SharedMem;
PSharedULONG2 = (PULONG) SharedMem2;
I can write the values in the server and read the values in the client, but not reverse (crash). I wrote in the client:
*PSharedULONG2 = 2;
//Now it crashes. PSharedULONG also crashes.
Where is my mistake?