diff --git a/dlls/user32/winstation.c b/dlls/user32/winstation.c index 98afc499234..122d8486e1f 100644 --- a/dlls/user32/winstation.c +++ b/dlls/user32/winstation.c @@ -290,24 +290,13 @@ HDESK WINAPI OpenDesktopA( LPCSTR name, DWORD flags, BOOL inherit, ACCESS_MASK a HDESK open_winstation_desktop( HWINSTA hwinsta, LPCWSTR name, DWORD flags, BOOL inherit, ACCESS_MASK access ) { - HANDLE ret = 0; - DWORD len = name ? lstrlenW(name) : 0; - if (len >= MAX_PATH) - { - SetLastError( ERROR_FILENAME_EXCED_RANGE ); - return 0; - } - SERVER_START_REQ( open_desktop ) - { - req->winsta = wine_server_obj_handle( hwinsta ); - req->flags = flags; - req->access = access; - req->attributes = OBJ_CASE_INSENSITIVE | (inherit ? OBJ_INHERIT : 0); - wine_server_add_data( req, name, len * sizeof(WCHAR) ); - if (!wine_server_call_err( req )) ret = wine_server_ptr_handle( reply->handle ); - } - SERVER_END_REQ; - return ret; + OBJECT_ATTRIBUTES attr; + UNICODE_STRING str; + + RtlInitUnicodeString( &str, name ); + InitializeObjectAttributes( &attr, &str, OBJ_CASE_INSENSITIVE, hwinsta, NULL ); + if (inherit) attr.Attributes |= OBJ_INHERIT; + return NtUserOpenDesktop( &attr, flags, access ); } diff --git a/dlls/win32u/syscall.c b/dlls/win32u/syscall.c index b4d5d718bf5..12b895eff9a 100644 --- a/dlls/win32u/syscall.c +++ b/dlls/win32u/syscall.c @@ -101,6 +101,7 @@ static void * const syscalls[] = NtUserGetObjectInformation, NtUserGetProcessWindowStation, NtUserGetThreadDesktop, + NtUserOpenDesktop, NtUserOpenInputDesktop, NtUserOpenWindowStation, NtUserSetObjectInformation, diff --git a/dlls/win32u/win32u.spec b/dlls/win32u/win32u.spec index bb800830f3d..1c5a960e59c 100644 --- a/dlls/win32u/win32u.spec +++ b/dlls/win32u/win32u.spec @@ -1091,7 +1091,7 @@ @ stub NtUserNotifyProcessCreate @ stub NtUserNotifyWinEvent @ stub NtUserOpenClipboard -@ stub NtUserOpenDesktop +@ stdcall -syscall NtUserOpenDesktop(ptr long long) @ stdcall -syscall NtUserOpenInputDesktop(long long long) @ stub NtUserOpenThreadDesktop @ stdcall -syscall NtUserOpenWindowStation(ptr long) diff --git a/dlls/win32u/winstation.c b/dlls/win32u/winstation.c index 0d0eefcf629..aff16e2a873 100644 --- a/dlls/win32u/winstation.c +++ b/dlls/win32u/winstation.c @@ -159,6 +159,30 @@ HDESK WINAPI NtUserCreateDesktopEx( OBJECT_ATTRIBUTES *attr, UNICODE_STRING *dev return ret; } +/*********************************************************************** + * NtUserOpenDesktop (win32u.@) + */ +HDESK WINAPI NtUserOpenDesktop( OBJECT_ATTRIBUTES *attr, DWORD flags, ACCESS_MASK access ) +{ + HANDLE ret = 0; + if (attr->ObjectName->Length >= MAX_PATH * sizeof(WCHAR)) + { + SetLastError( ERROR_FILENAME_EXCED_RANGE ); + return 0; + } + SERVER_START_REQ( open_desktop ) + { + req->winsta = wine_server_obj_handle( attr->RootDirectory ); + req->flags = flags; + req->access = access; + req->attributes = attr->Attributes; + wine_server_add_data( req, attr->ObjectName->Buffer, attr->ObjectName->Length ); + if (!wine_server_call_err( req )) ret = wine_server_ptr_handle( reply->handle ); + } + SERVER_END_REQ; + return ret; + } + /*********************************************************************** * NtUserCloseDesktop (win32u.@) */ diff --git a/dlls/wow64win/syscall.h b/dlls/wow64win/syscall.h index a1dc08103d4..1d74d55e032 100644 --- a/dlls/wow64win/syscall.h +++ b/dlls/wow64win/syscall.h @@ -87,6 +87,7 @@ SYSCALL_ENTRY( NtUserCreateWindowStation ) \ SYSCALL_ENTRY( NtUserGetProcessWindowStation ) \ SYSCALL_ENTRY( NtUserGetThreadDesktop ) \ + SYSCALL_ENTRY( NtUserOpenDesktop ) \ SYSCALL_ENTRY( NtUserOpenInputDesktop ) \ SYSCALL_ENTRY( NtUserOpenWindowStation ) \ SYSCALL_ENTRY( NtUserSetObjectInformation ) \ diff --git a/dlls/wow64win/user.c b/dlls/wow64win/user.c index b20ff3f887b..b497b0edbdf 100644 --- a/dlls/wow64win/user.c +++ b/dlls/wow64win/user.c @@ -92,6 +92,19 @@ NTSTATUS WINAPI wow64_NtUserCreateDesktopEx( UINT *args ) return HandleToUlong( ret ); } +NTSTATUS WINAPI wow64_NtUserOpenDesktop( UINT *args ) +{ + OBJECT_ATTRIBUTES32 *attr32 = get_ptr( &args ); + DWORD flags = get_ulong( &args ); + ACCESS_MASK access = get_ulong( &args ); + + struct object_attr64 attr; + HANDLE ret; + + ret = NtUserOpenDesktop( objattr_32to64( &attr, attr32 ), flags, access ); + return HandleToUlong( ret ); +} + NTSTATUS WINAPI wow64_NtUserCloseDesktop( UINT *args ) { HDESK handle = get_handle( &args ); diff --git a/include/ntuser.h b/include/ntuser.h index 8687a6bbc59..daac994c84d 100644 --- a/include/ntuser.h +++ b/include/ntuser.h @@ -36,6 +36,7 @@ HWINSTA WINAPI NtUserGetProcessWindowStation(void); HDESK WINAPI NtUserGetThreadDesktop( DWORD thread ); HWINSTA WINAPI NtUserOpenWindowStation( OBJECT_ATTRIBUTES *attr, ACCESS_MASK access ); BOOL WINAPI NtUserSetObjectInformation( HANDLE handle, INT index, void *info, DWORD len ); +HDESK WINAPI NtUserOpenDesktop( OBJECT_ATTRIBUTES *attr, DWORD flags, ACCESS_MASK access ); HDESK WINAPI NtUserOpenInputDesktop( DWORD flags, BOOL inherit, ACCESS_MASK access ); BOOL WINAPI NtUserSetProcessWindowStation( HWINSTA handle ); BOOL WINAPI NtUserSetThreadDesktop( HDESK handle );