<div dir="ltr">Thanks.<div><br></div><div>My question is now how to access that function from my Windows program as it does not seem to be directly available (i.e. in a importable header file). In any cae, is  it similar to _get_osfhandle()? I was considering using it (it is documented by Microsoft) but I also failed at including "msvcrt/io.h" (not found).</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Dec 22, 2019 at 8:12 AM Alexandre Julliard <<a href="mailto:julliard@winehq.org">julliard@winehq.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Zebediah Figura <<a href="mailto:z.figura12@gmail.com" target="_blank">z.figura12@gmail.com</a>> writes:<br>
<br>
> On 12/22/19 6:40 AM, Gabriel Ivăncescu wrote:<br>
>> On 12/21/19 5:34 PM, Bruno Albuquerque wrote:<br>
>>> Thanks. That led me to the init_user_process_params() where it seems <br>
>>> stdin/stdout/stderr are mapped to the running Windows program. I could <br>
>>> not find any code that would do anything with other inherited opened fds <br>
>>> and that led me to think that there is really no special handling and it <br>
>>> somehow just happens to work with a winelib program (most likely because <br>
>>> it has a bigger Linux surface to it).<br>
>>><br>
>>> Based on this, I guess what I really want to know is:<br>
>>><br>
>>> 1 - Does a non-winelib Windows program have access to opened fds <br>
>>> inherited during a fork/exec of Wine?<br>
>>> 2 - If so, is there a way to actually use those fds in the Windows program?<br>
>>><br>
>>><br>
>> <br>
>> Hi Bruno,<br>
>> <br>
>> I'm not sure if this is feasible to you, but keep in mind that "Windows <br>
>> programs" ran under Wine are technically still running on Linux. So you <br>
>> still have access to Linux syscalls (but not libraries, unless you load <br>
>> them manually, which is not worth it).<br>
>> <br>
>> One possible hack to do this in a "generic" way would be:<br>
>> <br>
>> 1) Use an exception handler in your app.<br>
>> <br>
>> 2) Call the 'uname' system call to make sure the returned sysname is <br>
>> 'Linux'. If the syscall results in an exception, then it's obviously not <br>
>> running on Linux (it could be running on Windows), so do the necessary <br>
>> thing there.<br>
><br>
> There's also wine_get_host_version(), exported from ntdll, which would<br>
> probably be easier.<br>
><br>
> In order to get access to file descriptors in the first place, you can<br>
> use the counterpart wine_server_handle_to_fd() [also exported from ntdll].<br>
<br>
Or use wine_server_fd_to_handle() and call Win32 APIs instead of direct<br>
syscalls, that's even easier...<br>
<br>
-- <br>
Alexandre Julliard<br>
<a href="mailto:julliard@winehq.org" target="_blank">julliard@winehq.org</a><br>
<br>
</blockquote></div>