https://bugs.winehq.org/show_bug.cgi?id=52724
Bug ID: 52724 Summary: expose a stable interface to get the linux pid mapped to a wine pid Product: Wine Version: 7.4 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: -unknown Assignee: wine-bugs@winehq.org Reporter: redartofcode@gmail.com Distribution: ---
to get the x11 window id of a window handle inside wine, you can use `GetProp(win32_handle, "__wine_x11_whole_window");`.
but there is no equivalent function to get the linux pid of a wine process by using its wine pid. it is useful when a windows app and linux app need to interact with each other. to check that the wine application is still running, or monitor its resource usage etc.. the linux native app could use linux pid of the wine application.
Use Case: I run Guild Was 2 in wine. and Guild Wars 2 shares live data of the player via shared memory called MumbleLink. unfortunately, shared memory of windows is not exposed as shared memory of linux. so, i wrote a small app windows which runs inside the same prefix of Guild Wars 2, and copies that data to z:\dev\shm\gw2link file which is in the linux path of /dev/shm/gw2link.
on Windows, there are Overlays (officially allowed) which make use of this data to provide a wide variety of utilities to players. I am making a linux Overlay and to get the position / size of the Guild Wars 2 Window, i need the x11 window id. as mentioned above, I already use the "__wine_x11_whole_window" to get that and copy it to the /dev/shm/gw2link along with the other data. then, linux native Overlay uses that file to get the window id and uses x11 to take care of the rest.
But there are complex scenarios like multiple instances of gw2 running, and to make it easy, gw2 writes is pid along with player data in the shared memory. we use that pid to check if gw2 is running or other such things. and here's the issue, gw2 writes the windows (wine) pid in the shared memory. and i have no way of translating it to the mapped linux pid of that gw2 instance.
I am currently able to use _NET_WM_PID x11 property to get the pid of a gw2 window, but it is not actually required by the x11 spec, and its also not immediately set when the game starts. so, it is sort of unreliable at the moment.
so, I was hoping that wine could expose a function (or a property like __wine_x11_whole_window) so that i could translate the wine pid to linux pid, and provide that pid via /dev/shm/gw2link just like x11 window id.
https://bugs.winehq.org/show_bug.cgi?id=52724
--- Comment #1 from Hans Leidekker hans@meelstraat.net --- See bug 46272 for a related discussion.