Unix FD to Windows File Handles mapping.

Bruno Albuquerque bga at gmail.com
Sat Dec 21 09:34:25 CST 2019

Thanks. That led me to the init_user_process_params() where it seems
stdin/stdout/stderr are mapped to the running Windows program. I could not
find any code that would do anything with other inherited opened fds and
that led me to think that there is really no special handling and it
somehow just happens to work with a winelib program (most likely because it
has a bigger Linux surface to it).

Based on this, I guess what I really want to know is:

1 - Does a non-winelib Windows program have access to opened fds inherited
during a fork/exec of Wine?
2 - If so, is there a way to actually use those fds in the Windows program?

On Fri, Dec 20, 2019 at 7:49 PM Damjan Jovanovic <damjan.jov at gmail.com>

> Try wine_server_fd_to_handle()
> Once you register a fd with Wine that way, it lives inside wineserver, and
> during API calls, you just get back temporary copies of it, usually with
> different fd numbers.
> On Sat, Dec 21, 2019 at 1:57 AM Bruno Albuquerque <bga at gmail.com> wrote:
>> Is the way that wine maps file handles from Unix (Linux, more
>> specifically) to Windows predictable?
>> I have this Linux program that forks Wine to run a Windows program. The
>> Windows program can easily access stdin/stdout/stderr the way one would
>> expect in a forked Unix program but I am trying to pass one extra file
>> descriptor to the windows program but I am not sure how to do that.
>> In the Unix program, the FD will be, say, 3. As I am forking then
>> exec'ing Wine, wine itself will have access to this FD and, from Wine's
>> point of view, it should also be 3. The problem is that it seems file
>> handles in Windows are not like in Unix (for example, stdin is not 0,
>> stdout is not 1 and stderr is not 2) so I am assuming that to make this FD
>> available to the WIndows program, it is somehow mapped to a file handle
>> with a different number too. I need to know which one it si to be able to
>> use it. Any pointers on how to do that?
>> If I compile a C program with winegcc/winelib and fork/exec it, it looks
>> like file handles and file descriptors match so one option is to use it.
>> But I prefer to create the program in a different language so winelib is
>> not ideal.
>> Any help would be much appreciated.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.winehq.org/pipermail/wine-devel/attachments/20191221/983828bb/attachment.htm>

More information about the wine-devel mailing list