Discussion:
[Wine] Shared Memory and Memory Mapped I/O
jluoni
2009-01-13 18:40:23 UTC
Permalink
I am running wine 1.1.12 on Solaris 10. I have a windows application running with wine that interfaces to other applications via "shared memory" or "memory mapped I/O" or what ever the official name for this is. In windows I would typically use something like
Code:
token.hFileMapping = OpenFileMapping(0xF001F, false, "test");
token.location = MapViewOfFile(token.hFileMapping, 0xF001F, 0, 0, 1000);


in windows to get the memory location to read or write to.

I want to access the shared memory created by the windows application running under wine with a linux application. Using something like "shmat".

Is this possible? Can someone point me in the right direction for this?

Thanks in advanced.
vitamin
2009-01-13 21:20:37 UTC
Permalink
Post by jluoni
I want to access the shared memory created by the windows application running under wine with a linux application.
It's possible however you'll have to take care of synchronization between the two processes.
Of course what happens behind the scene is much more complicated in Wine so you can't just use shmat. To get an idea of what all happens see server/mapping.c
jluoni
2009-01-14 17:53:49 UTC
Permalink
I guess its good that you are saying it is possible. I looked at the server/mapping.c file, but it didn't get me anywhere. I am new to this stuff and don't know much about linux. Is this something much more difficult than how it would be done in Windows?

Also, I cannot see or change the source for the windows application, but it seems like the app does no more than create the shared memory space and reads the data. The linux app would write to the shared memory location.

Maybe if someone has an example of doing this. I can't imagine that I am the first to want to do this.

Thanks
vitamin
2009-01-14 18:52:22 UTC
Permalink
Post by jluoni
I looked at the server/mapping.c file, but it didn't get me anywhere. I am new to this stuff and don't know much about linux.
Then don't use shared memory for IPC. Use the most simplistic (and most idiot-proof) IPC - nameless/named pipes. If you want to get more sophisticated - use sockets.

Shared memory is a huge PITA, especially mixing win32, Wine & POSIX implementations of it.
jluoni
2009-01-14 19:23:09 UTC
Permalink
This seems harder than I initially thought. I thought I would call a couple functions and have a pointer to my array of 32bit floats.
Then don't use shared memory for IPC. Use the most simplistic (and most idiot-proof) IPC - nameless/named pipes. If you want to get more sophisticated - use sockets or pipes.
Unfortunately the windows application that I need to access interfaces via shared memory and not through sockets or pipes. I have no control over that application. I wish I could change the applications, I am stuck with it and how it is implemented.
Shared memory is a huge PITA, especially mixing win32, Wine & POSIX implementations of it.
Since I am stuck, which of the following is going to be a bigger PITA.

-Figure this whole intermixing shared memory thing.(which seems like the way it should be done)
-Or write another windows app to be the middle man. Pipes or Sockets to Shared Memory type deal.
Loading...