Shared Memory and Memory Mapped I/O

Open forum for end-user questions about Wine. Before asking questions, check out the Wiki as a first step.
Forum Rules
Locked
jluoni
Newbie
Newbie
Posts: 4
Joined: Tue Jan 13, 2009 1:25 pm

Shared Memory and Memory Mapped I/O

Post by jluoni »

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: Select all

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
Moderator
Moderator
Posts: 6605
Joined: Sat Feb 23, 2008 2:29 pm

Re: Shared Memory and Memory Mapped I/O

Post by vitamin »

jluoni wrote: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
Newbie
Newbie
Posts: 4
Joined: Tue Jan 13, 2009 1:25 pm

Post by jluoni »

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
Moderator
Moderator
Posts: 6605
Joined: Sat Feb 23, 2008 2:29 pm

Post by vitamin »

jluoni wrote: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
Newbie
Newbie
Posts: 4
Joined: Tue Jan 13, 2009 1:25 pm

Post by jluoni »

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.
vitamin wrote: 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.
vitamin wrote: 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.
Locked