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.
This commit is contained in:
Rémi Bernon 2022-10-19 01:21:36 +02:00 committed by Alexandre Julliard
parent 94ece19f8e
commit 9062314aed

View file

@ -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;
}