From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/window.c | 33 +++++++-------------------------- server/protocol.def | 2 -- server/window.c | 5 ----- 3 files changed, 7 insertions(+), 33 deletions(-)
diff --git a/dlls/win32u/window.c b/dlls/win32u/window.c index 3461093ec1f..8bd6e7b9aa1 100644 --- a/dlls/win32u/window.c +++ b/dlls/win32u/window.c @@ -325,36 +325,17 @@ BOOL is_window( HWND hwnd ) /* see GetWindowThreadProcessId */ DWORD get_window_thread( HWND hwnd, DWORD *process ) { - WND *ptr; - DWORD tid = 0; + struct user_entry entry; + HANDLE handle;
- if (!(ptr = get_win_ptr( hwnd ))) + if (!get_user_entry( hwnd, NTUSER_OBJ_WINDOW, &entry, &handle )) { - RtlSetLastWin32Error( ERROR_INVALID_WINDOW_HANDLE); + RtlSetLastWin32Error( ERROR_INVALID_WINDOW_HANDLE ); return 0; }
- if (ptr != WND_OTHER_PROCESS && ptr != WND_DESKTOP) - { - /* got a valid window */ - tid = ptr->tid; - if (process) *process = GetCurrentProcessId(); - release_win_ptr( ptr ); - return tid; - } - - /* check other processes */ - SERVER_START_REQ( get_window_info ) - { - req->handle = wine_server_user_handle( hwnd ); - if (!wine_server_call_err( req )) - { - tid = (DWORD)reply->tid; - if (process) *process = (DWORD)reply->pid; - } - } - SERVER_END_REQ; - return tid; + if (process) *process = entry.pid; + return entry.tid; }
/* see GetParent */ @@ -6078,7 +6059,7 @@ HANDLE WINAPI NtUserQueryWindow( HWND hwnd, WINDOWINFOCLASS cls ) { case WindowProcess: case WindowProcess2: - get_window_thread( hwnd, &pid ); + if (!get_window_thread( hwnd, &pid )) return NULL; return UlongToHandle( pid );
case WindowThread: diff --git a/server/protocol.def b/server/protocol.def index 516dc1a7a95..26c411d0c62 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -2583,8 +2583,6 @@ enum message_type user_handle_t handle; /* handle to the window */ @REPLY user_handle_t last_active; /* last active popup */ - process_id_t pid; /* process owning the window */ - thread_id_t tid; /* thread owning the window */ int is_unicode; /* ANSI or unicode */ unsigned int dpi_context; /* window DPI context */ @END diff --git a/server/window.c b/server/window.c index 8cbe55077bf..914d376a44a 100644 --- a/server/window.c +++ b/server/window.c @@ -2326,11 +2326,6 @@ DECL_HANDLER(get_window_info) reply->dpi_context = win->dpi_context;
if (get_user_object( win->last_active, NTUSER_OBJ_WINDOW )) reply->last_active = win->last_active; - if (win->thread) - { - reply->tid = get_thread_id( win->thread ); - reply->pid = get_process_id( win->thread->process ); - } }