user32: Avoid using WIN_GetPtr for window handle validation.

We will eventually want to make GetWindowThreadProcessId fast (probably based on shared handle table) instead of calling win32u.
This commit is contained in:
Jacek Caban 2022-07-26 16:08:55 +02:00 committed by Alexandre Julliard
parent 059c70d736
commit 11657aab27
3 changed files with 17 additions and 44 deletions

View file

@ -153,13 +153,7 @@ void WIN_ReleasePtr( WND *ptr )
*/
HWND WIN_IsCurrentProcess( HWND hwnd )
{
WND *ptr;
HWND ret;
if (!(ptr = WIN_GetPtr( hwnd )) || ptr == WND_OTHER_PROCESS || ptr == WND_DESKTOP) return 0;
ret = ptr->obj.handle;
WIN_ReleasePtr( ptr );
return ret;
return UlongToHandle( NtUserCallHwnd( hwnd, NtUserIsCurrehtProcessWindow ));
}
@ -170,13 +164,7 @@ HWND WIN_IsCurrentProcess( HWND hwnd )
*/
HWND WIN_IsCurrentThread( HWND hwnd )
{
WND *ptr;
HWND ret = 0;
if (!(ptr = WIN_GetPtr( hwnd )) || ptr == WND_OTHER_PROCESS || ptr == WND_DESKTOP) return 0;
if (ptr->tid == GetCurrentThreadId()) ret = ptr->obj.handle;
WIN_ReleasePtr( ptr );
return ret;
return UlongToHandle( NtUserCallHwnd( hwnd, NtUserIsCurrehtThreadWindow ));
}
@ -205,36 +193,7 @@ UINT win_set_flags( HWND hwnd, UINT set_mask, UINT clear_mask )
*/
HWND WIN_GetFullHandle( HWND hwnd )
{
WND *ptr;
if (!hwnd || (ULONG_PTR)hwnd >> 16) return hwnd;
if (LOWORD(hwnd) <= 1 || LOWORD(hwnd) == 0xffff) return hwnd;
/* do sign extension for -2 and -3 */
if (LOWORD(hwnd) >= (WORD)-3) return (HWND)(LONG_PTR)(INT16)LOWORD(hwnd);
if (!(ptr = WIN_GetPtr( hwnd ))) return hwnd;
if (ptr == WND_DESKTOP)
{
if (LOWORD(hwnd) == LOWORD(GetDesktopWindow())) return GetDesktopWindow();
else return get_hwnd_message_parent();
}
if (ptr != WND_OTHER_PROCESS)
{
hwnd = ptr->obj.handle;
WIN_ReleasePtr( ptr );
}
else /* may belong to another process */
{
SERVER_START_REQ( get_window_info )
{
req->handle = wine_server_user_handle( hwnd );
if (!wine_server_call_err( req )) hwnd = wine_server_ptr_handle( reply->full_handle );
}
SERVER_END_REQ;
}
return hwnd;
return UlongToHandle( NtUserCallHwnd( hwnd, NtUserGetFullWindowHandle ));
}

View file

@ -5408,6 +5408,16 @@ ULONG_PTR WINAPI NtUserCallHwnd( HWND hwnd, DWORD code )
case NtUserCallHwnd_SetForegroundWindow:
return set_foreground_window( hwnd, FALSE );
/* temporary exports */
case NtUserGetFullWindowHandle:
return HandleToUlong( get_full_window_handle( hwnd ));
case NtUserIsCurrehtProcessWindow:
return HandleToUlong( is_current_process_window( hwnd ));
case NtUserIsCurrehtThreadWindow:
return HandleToUlong( is_current_thread_window( hwnd ));
default:
FIXME( "invalid code %u\n", code );
return 0;

View file

@ -1112,6 +1112,10 @@ enum
NtUserCallHwnd_IsWindowUnicode,
NtUserCallHwnd_IsWindowVisible,
NtUserCallHwnd_SetForegroundWindow,
/* temporary exports */
NtUserGetFullWindowHandle,
NtUserIsCurrehtProcessWindow,
NtUserIsCurrehtThreadWindow,
};
static inline UINT NtUserArrangeIconicWindows( HWND parent )