clementgallet / libTAS

GNU/Linux software to (hopefully) give TAS tools to games
GNU General Public License v3.0
496 stars 57 forks source link

[Wine] CreateFileW opens a file by wineserver #250

Open clementgallet opened 5 years ago

clementgallet commented 5 years ago

CreateFileW is implemented by making a request to wineserver to open the file, and get the resulting file descriptor, so our fileio hooking functions don't catch the file opening. Moreover, file closing is done by client, resulting in unknown file descriptor when closing.

madewokherd commented 5 years ago

The functions that do this are in ntdll (https://source.winehq.org/git/wine.git/blob/wine-4.12.1:/dlls/ntdll/ntdll.spec#l1522), and it does some client-side caching: https://source.winehq.org/git/wine.git/blob/wine-4.12.1:/dlls/ntdll/server.c#l928

If you wanted to handle this at a syscall level, you could hook recvmsg. I think that would take care of the client-side cached fd's.

You would also have to take care of the server-side handles. Hooking the relevant functions in ntdll might be a possibility. It may also be possible to snoop on client/server communication, but that protocol changes often and is not in the public headers.