win32u: Use the correct length for kernel object names in object attributes.

This commit is contained in:
Alexandre Julliard 2023-09-12 10:00:24 +02:00
parent a5463c88e2
commit d76f5b4ab9
3 changed files with 6 additions and 3 deletions

View file

@ -450,7 +450,8 @@ static HANDLE get_display_device_init_mutex( void )
snprintf( buffer, ARRAY_SIZE(buffer), "\\Sessions\\%u\\BaseNamedObjects\\display_device_init",
(int)NtCurrentTeb()->Peb->SessionId );
name.Length = name.MaximumLength = asciiz_to_unicode( bufferW, buffer );
name.MaximumLength = asciiz_to_unicode( bufferW, buffer );
name.Length = name.MaximumLength - sizeof(WCHAR);
InitializeObjectAttributes( &attr, &name, OBJ_OPENIF, NULL, NULL );
if (NtCreateMutant( &mutex, MUTEX_ALL_ACCESS, &attr, FALSE ) < 0) return 0;

View file

@ -554,7 +554,8 @@ static HANDLE get_winstations_dir_handle(void)
sprintf( bufferA, "\\Sessions\\%u\\Windows\\WindowStations", (int)NtCurrentTeb()->Peb->SessionId );
str.Buffer = buffer;
str.Length = str.MaximumLength = asciiz_to_unicode( buffer, bufferA ) - sizeof(WCHAR);
str.MaximumLength = asciiz_to_unicode( buffer, bufferA );
str.Length = str.MaximumLength - sizeof(WCHAR);
InitializeObjectAttributes( &attr, &str, 0, 0, NULL );
status = NtOpenDirectoryObject( &dir, DIRECTORY_CREATE_OBJECT | DIRECTORY_TRAVERSE, &attr );
return status ? 0 : dir;

View file

@ -1008,7 +1008,8 @@ static HANDLE get_display_device_init_mutex(void)
snprintf( buffer, ARRAY_SIZE(buffer), "\\Sessions\\%u\\BaseNamedObjects\\display_device_init",
(int)NtCurrentTeb()->Peb->SessionId );
name.Length = name.MaximumLength = asciiz_to_unicode( bufferW, buffer );
name.MaximumLength = asciiz_to_unicode( bufferW, buffer );
name.Length = name.MaximumLength - sizeof(WCHAR);
InitializeObjectAttributes( &attr, &name, OBJ_OPENIF, NULL, NULL );
if (NtCreateMutant( &mutex, MUTEX_ALL_ACCESS, &attr, FALSE ) < 0) return 0;