<div dir="ltr">I am new to writing wine specific things so bear with me for a while. Is there a header file that I can include to get access to those ntdll functions (a cursory look only  resulted in me finding the associated c file)? If not, do I have to use LoadLibrary() or some other trick?<div><br></div><div>Thanks again for all your help so far. It is much appreciated.</div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Dec 22, 2019 at 8:04 AM Zebediah Figura <<a href="mailto:z.figura12@gmail.com">z.figura12@gmail.com</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"><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>
> <br>
> 3) If it's 'Linux' then mark it so and simply use Linux syscalls to use <br>
> the fd and read or write to it. You can use inline assembly for this <br>
> purpose.<br>
> <br>
> If your program is not intended to run on non-Linux environments then <br>
> you can skip the first two steps. I realize it's a hack but without <br>
> winelib I don't think there's much else you can do.<br>
> <br>
<br>
</blockquote></div>