Commit 11657aab authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard
Browse files

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.
parent 059c70d7
...@@ -153,13 +153,7 @@ void WIN_ReleasePtr( WND *ptr ) ...@@ -153,13 +153,7 @@ void WIN_ReleasePtr( WND *ptr )
*/ */
HWND WIN_IsCurrentProcess( HWND hwnd ) HWND WIN_IsCurrentProcess( HWND hwnd )
{ {
WND *ptr; return UlongToHandle( NtUserCallHwnd( hwnd, NtUserIsCurrehtProcessWindow ));
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;
} }
...@@ -170,13 +164,7 @@ HWND WIN_IsCurrentProcess( HWND hwnd ) ...@@ -170,13 +164,7 @@ HWND WIN_IsCurrentProcess( HWND hwnd )
*/ */
HWND WIN_IsCurrentThread( HWND hwnd ) HWND WIN_IsCurrentThread( HWND hwnd )
{ {
WND *ptr; return UlongToHandle( NtUserCallHwnd( hwnd, NtUserIsCurrehtThreadWindow ));
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;
} }
...@@ -205,36 +193,7 @@ UINT win_set_flags( HWND hwnd, UINT set_mask, UINT clear_mask ) ...@@ -205,36 +193,7 @@ UINT win_set_flags( HWND hwnd, UINT set_mask, UINT clear_mask )
*/ */
HWND WIN_GetFullHandle( HWND hwnd ) HWND WIN_GetFullHandle( HWND hwnd )
{ {
WND *ptr; return UlongToHandle( NtUserCallHwnd( hwnd, NtUserGetFullWindowHandle ));
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;
} }
......
...@@ -5408,6 +5408,16 @@ ULONG_PTR WINAPI NtUserCallHwnd( HWND hwnd, DWORD code ) ...@@ -5408,6 +5408,16 @@ ULONG_PTR WINAPI NtUserCallHwnd( HWND hwnd, DWORD code )
case NtUserCallHwnd_SetForegroundWindow: case NtUserCallHwnd_SetForegroundWindow:
return set_foreground_window( hwnd, FALSE ); 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: default:
FIXME( "invalid code %u\n", code ); FIXME( "invalid code %u\n", code );
return 0; return 0;
......
...@@ -1112,6 +1112,10 @@ enum ...@@ -1112,6 +1112,10 @@ enum
NtUserCallHwnd_IsWindowUnicode, NtUserCallHwnd_IsWindowUnicode,
NtUserCallHwnd_IsWindowVisible, NtUserCallHwnd_IsWindowVisible,
NtUserCallHwnd_SetForegroundWindow, NtUserCallHwnd_SetForegroundWindow,
/* temporary exports */
NtUserGetFullWindowHandle,
NtUserIsCurrehtProcessWindow,
NtUserIsCurrehtThreadWindow,
}; };
static inline UINT NtUserArrangeIconicWindows( HWND parent ) static inline UINT NtUserArrangeIconicWindows( HWND parent )
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment