7

Here is my problem: I have a closed-source third-party Win32 application, which acts as a server for other programs via named pipes, i.e. it expects its clients to do smth like this:

HANDLE h = CreateFile("\\\\.\\pipe\\$pipe_name$", GENERIC_READ | GENERIC_WRITE, etc...);
// ...
TransactNamedPipe(h, buf, etc...);
// ...
CloseHandle(h);

This app runs perfectly in WINE, except that I can't communicate with it. So here is my question:

What exactly does WINE do when it is requested to open a pipe? Does it, say, map it to some FIFO file in ~/.wine/ or wherever? Is there any way to communicate with such program from a Linux application? Google doesn't know anything about it.

Thank you.

ScumCoder
  • 690
  • 1
  • 8
  • 20

2 Answers2

4

Named Pipes in a wine official wiki

this article could help too: http://lkcl.net/namedpipes/namedpipes-emulation.txt

zed_0xff
  • 32,417
  • 7
  • 53
  • 72
4

Named pipes are hosted by the WINE server process. Requests are sent to this process by the WINE clients. For example, CreateNamedPipe uses a request like:

    SERVER_START_REQ( open_file_object )
    {
        req->access     = access;
        req->attributes = attr->Attributes;
        req->rootdir    = wine_server_obj_handle( attr->RootDirectory );
        req->sharing    = sharing;
        req->options    = options;
        wine_server_add_data( req, attr->ObjectName->Buffer, attr->ObjectName->Length );
        io->u.Status = wine_server_call( req );
        *handle = wine_server_ptr_handle( reply->handle );
    }

The server manages connecting the named pipe. Once a client and server have connected, the WINE server gets out of the way by sending an fd to the client. I think this fd is just an anonymous pipe created by the WINE server, one end being sent to the pipe server and one end to the pipe client.

Dark Falcon
  • 43,592
  • 5
  • 83
  • 98
  • Does that mean that it's only possible to communicate with Win app inside the Wine environment? I just don't understand how to "break the wall" between this environment and native Linux. – ScumCoder Dec 13 '11 at 20:40
  • Yes, you will have to talk to the WINE server in some way in order to gain access to the pipe. – Dark Falcon Dec 13 '11 at 21:08
  • Thank you, I'll see what I can do. – ScumCoder Dec 14 '11 at 08:18
  • It might be easiest to write your client as a Windows program and run it under WINE, or perhaps the Windows API from WINE can be easily linked to from a Linux program. These seem like the most straightforward approach, as you then have a documented interface to use. – Dark Falcon Dec 14 '11 at 13:18