June 29, 2023
2:58 p.m.
On Thu Jun 29 13:07:22 2023 +0000, Jinoh Kang wrote:
> > We could use something like `alloc_session_shared` from
> https://gitlab.winehq.org/jacek/wine/-/commit/fc899509484cb381ceb9dba1a788cc8f6d33cfe4
> (without the handle argument).
> This solution would be directly applicable if HDESK was a USER handle,
> but it is actually a KERNEL handle. This means:
> 1. We can't use `handle_to_entry( user_handle_t handle )`. The closest
> thing available for KERNEL handles is `get_cached_fd`, but it deals with
> file descriptors.
> 2. We can't extend `fd_cache_entry` to include `shared_offset`, since
> `fd_cache_entry` will exceed 8 bytes and we'll need to use
> `InterlockedCompareExchange128` to update it. `cmpxchg16` is not
> available on 32-bit. Besides, introducing all this complexity just for
> desktop handles doesn't seem worth it.
> 3. We can of course create our own `HDESK -> shared_{offset|address}`
> map, but this means dealing with handle aliases--two different HDESKs
> can point to the same desktop object. Not to mention that KERNEL handles
> can be freely duplicated and closed via other kernel32 functions as well
> as from other processes.
We could just pass a data offset as part of server requests that affect or query current desktop.
And yes, there is an argument to use a different mapping for more-or-less thread-specific data, but desktops are global objects.
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/3103#note_37337