Module: wine Branch: master Commit: 9062314aedb940a00ce1e44317b73d6c498cafa3 URL: https://gitlab.winehq.org/wine/wine/-/commit/9062314aedb940a00ce1e44317b73d6...
Author: Rémi Bernon rbernon@codeweavers.com Date: Wed Oct 19 01:21:36 2022 +0200
winex11.drv: Use session BaseNamedObjects for display_device_init mutex.
The mutex is also used in user32, gdi32, and winevulkan, where it is opened through kernel32, which opens it from the session directory.
Note that this was also not even using the global BaseNamedObjects and was silently failing to open the mutex.
---
dlls/winex11.drv/x11drv_main.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/dlls/winex11.drv/x11drv_main.c b/dlls/winex11.drv/x11drv_main.c index 7f9ada291a0..497e270ee8a 100644 --- a/dlls/winex11.drv/x11drv_main.c +++ b/dlls/winex11.drv/x11drv_main.c @@ -1009,14 +1009,19 @@ NTSTATUS CDECL X11DRV_D3DKMTCheckVidPnExclusiveOwnership( const D3DKMT_CHECKVIDP
static HANDLE get_display_device_init_mutex(void) { - static const WCHAR init_mutexW[] = {'d','i','s','p','l','a','y','_','d','e','v','i','c','e','_','i','n','i','t'}; - UNICODE_STRING name = { sizeof(init_mutexW), sizeof(init_mutexW), (WCHAR *)init_mutexW }; + WCHAR bufferW[256]; + UNICODE_STRING name = {.Buffer = bufferW}; OBJECT_ATTRIBUTES attr; - HANDLE mutex = 0; + char buffer[256]; + HANDLE mutex; + + snprintf( buffer, ARRAY_SIZE(buffer), "\Sessions\%u\BaseNamedObjects\display_device_init", + NtCurrentTeb()->Peb->SessionId ); + name.Length = name.MaximumLength = asciiz_to_unicode( bufferW, buffer );
InitializeObjectAttributes( &attr, &name, OBJ_OPENIF, NULL, NULL ); - NtCreateMutant( &mutex, MUTEX_ALL_ACCESS, &attr, FALSE ); - if (mutex) NtWaitForSingleObject( mutex, FALSE, NULL ); + if (NtCreateMutant( &mutex, MUTEX_ALL_ACCESS, &attr, FALSE ) < 0) return 0; + NtWaitForSingleObject( mutex, FALSE, NULL ); return mutex; }