From 7fdadbb377ac35b265e731eaec42c07d07160a3b Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Mon, 8 Dec 2008 16:58:20 +0100 Subject: [PATCH] server: Add functions for conversions between server user handles and pointer-style handles. --- dlls/kernel32/console.c | 2 +- dlls/user32/caret.c | 20 ++--- dlls/user32/class.c | 8 +- dlls/user32/clipboard.c | 76 +++++-------------- dlls/user32/defwnd.c | 4 +- dlls/user32/focus.c | 36 +++++---- dlls/user32/hook.c | 28 +++---- dlls/user32/input.c | 8 +- dlls/user32/message.c | 40 +++++----- dlls/user32/painting.c | 18 ++--- dlls/user32/property.c | 8 +- dlls/user32/win.c | 115 +++++++++++++++-------------- dlls/user32/winpos.c | 23 +++--- dlls/winex11.drv/clipboard.c | 6 +- dlls/winex11.drv/event.c | 2 +- dlls/winex11.drv/mouse.c | 4 +- dlls/winex11.drv/window.c | 4 +- dlls/ws2_32/socket.c | 2 +- include/wine/server.h | 6 ++ programs/wineconsole/wineconsole.c | 2 +- 20 files changed, 197 insertions(+), 215 deletions(-) diff --git a/dlls/kernel32/console.c b/dlls/kernel32/console.c index 5666c87f6a..878452fa3c 100644 --- a/dlls/kernel32/console.c +++ b/dlls/kernel32/console.c @@ -142,7 +142,7 @@ HWND WINAPI GetConsoleWindow(VOID) SERVER_START_REQ(get_console_input_info) { req->handle = 0; - if (!wine_server_call_err(req)) hWnd = reply->win; + if (!wine_server_call_err(req)) hWnd = wine_server_ptr_handle( reply->win ); } SERVER_END_REQ; diff --git a/dlls/user32/caret.c b/dlls/user32/caret.c index 8ff8da27b3..953a0815d5 100644 --- a/dlls/user32/caret.c +++ b/dlls/user32/caret.c @@ -82,14 +82,14 @@ static void CALLBACK CARET_Callback( HWND hwnd, UINT msg, UINT_PTR id, DWORD cti SERVER_START_REQ( set_caret_info ) { req->flags = SET_CARET_STATE; - req->handle = hwnd; + req->handle = wine_server_user_handle( hwnd ); req->x = 0; req->y = 0; req->hide = 0; req->state = -1; /* toggle current state */ if ((ret = !wine_server_call( req ))) { - hwnd = reply->full_handle; + hwnd = wine_server_ptr_handle( reply->full_handle ); r.left = reply->old_rect.left; r.top = reply->old_rect.top; r.right = reply->old_rect.right; @@ -166,12 +166,12 @@ BOOL WINAPI CreateCaret( HWND hwnd, HBITMAP bitmap, INT width, INT height ) SERVER_START_REQ( set_caret_window ) { - req->handle = hwnd; + req->handle = wine_server_user_handle( hwnd ); req->width = width; req->height = height; if ((ret = !wine_server_call_err( req ))) { - prev = reply->previous; + prev = wine_server_ptr_handle( reply->previous ); r.left = reply->old_rect.left; r.top = reply->old_rect.top; r.right = reply->old_rect.right; @@ -215,7 +215,7 @@ BOOL WINAPI DestroyCaret(void) req->height = 0; if ((ret = !wine_server_call_err( req ))) { - prev = reply->previous; + prev = wine_server_ptr_handle( reply->previous ); r.left = reply->old_rect.left; r.top = reply->old_rect.top; r.right = reply->old_rect.right; @@ -259,7 +259,7 @@ BOOL WINAPI SetCaretPos( INT x, INT y ) req->state = 1; if ((ret = !wine_server_call_err( req ))) { - hwnd = reply->full_handle; + hwnd = wine_server_ptr_handle( reply->full_handle ); r.left = reply->old_rect.left; r.top = reply->old_rect.top; r.right = reply->old_rect.right; @@ -296,14 +296,14 @@ BOOL WINAPI HideCaret( HWND hwnd ) SERVER_START_REQ( set_caret_info ) { req->flags = SET_CARET_HIDE|SET_CARET_STATE; - req->handle = hwnd; + req->handle = wine_server_user_handle( hwnd ); req->x = 0; req->y = 0; req->hide = 1; req->state = 0; if ((ret = !wine_server_call_err( req ))) { - hwnd = reply->full_handle; + hwnd = wine_server_ptr_handle( reply->full_handle ); r.left = reply->old_rect.left; r.top = reply->old_rect.top; r.right = reply->old_rect.right; @@ -335,14 +335,14 @@ BOOL WINAPI ShowCaret( HWND hwnd ) SERVER_START_REQ( set_caret_info ) { req->flags = SET_CARET_HIDE|SET_CARET_STATE; - req->handle = hwnd; + req->handle = wine_server_user_handle( hwnd ); req->x = 0; req->y = 0; req->hide = -1; req->state = 1; if ((ret = !wine_server_call_err( req ))) { - hwnd = reply->full_handle; + hwnd = wine_server_ptr_handle( reply->full_handle ); r.left = reply->old_rect.left; r.top = reply->old_rect.top; r.right = reply->old_rect.right; diff --git a/dlls/user32/class.c b/dlls/user32/class.c index 1f4b7b5028..418c86e652 100644 --- a/dlls/user32/class.c +++ b/dlls/user32/class.c @@ -129,7 +129,7 @@ static BOOL set_server_info( HWND hwnd, INT offset, LONG_PTR newval, UINT size ) SERVER_START_REQ( set_class_info ) { - req->window = hwnd; + req->window = wine_server_user_handle( hwnd ); req->extra_offset = -1; switch(offset) { @@ -653,7 +653,7 @@ WORD WINAPI GetClassWord( HWND hwnd, INT offset ) { SERVER_START_REQ( set_class_info ) { - req->window = hwnd; + req->window = wine_server_user_handle( hwnd ); req->flags = 0; req->extra_offset = offset; req->extra_size = sizeof(retvalue); @@ -690,7 +690,7 @@ static ULONG_PTR CLASS_GetClassLong( HWND hwnd, INT offset, UINT size, { SERVER_START_REQ( set_class_info ) { - req->window = hwnd; + req->window = wine_server_user_handle( hwnd ); req->flags = 0; req->extra_offset = (offset >= 0) ? offset : -1; req->extra_size = (offset >= 0) ? size : 0; @@ -845,7 +845,7 @@ WORD WINAPI SetClassWord( HWND hwnd, INT offset, WORD newval ) SERVER_START_REQ( set_class_info ) { - req->window = hwnd; + req->window = wine_server_user_handle( hwnd ); req->flags = SET_CLASS_EXTRA; req->extra_offset = offset; req->extra_size = sizeof(newval); diff --git a/dlls/user32/clipboard.c b/dlls/user32/clipboard.c index 137ace9bfa..b0ff10d496 100644 --- a/dlls/user32/clipboard.c +++ b/dlls/user32/clipboard.c @@ -81,23 +81,15 @@ static BOOL bCBHasChanged = FALSE; */ static BOOL CLIPBOARD_SetClipboardOwner(HWND hWnd) { - BOOL bRet = FALSE; + BOOL bRet; TRACE(" hWnd(%p)\n", hWnd); SERVER_START_REQ( set_clipboard_info ) { req->flags = SET_CB_OWNER; - req->owner = WIN_GetFullHandle( hWnd ); - - if (wine_server_call_err( req )) - { - ERR("Failed to set clipboard owner to %p\n", hWnd); - } - else - { - bRet = TRUE; - } + req->owner = wine_server_user_handle( hWnd ); + bRet = !wine_server_call_err( req ); } SERVER_END_REQ; @@ -110,25 +102,19 @@ static BOOL CLIPBOARD_SetClipboardOwner(HWND hWnd) */ static BOOL CLIPBOARD_GetClipboardInfo(LPCLIPBOARDINFO cbInfo) { - BOOL bRet = FALSE; + BOOL bRet; SERVER_START_REQ( set_clipboard_info ) { req->flags = 0; - if (wine_server_call_err( req )) - { - ERR("Failed to get clipboard info\n"); - } - else + if (((bRet = !wine_server_call_err( req )))) { - cbInfo->hWndOpen = reply->old_clipboard; - cbInfo->hWndOwner = reply->old_owner; - cbInfo->hWndViewer = reply->old_viewer; + cbInfo->hWndOpen = wine_server_ptr_handle( reply->old_clipboard ); + cbInfo->hWndOwner = wine_server_ptr_handle( reply->old_owner ); + cbInfo->hWndViewer = wine_server_ptr_handle( reply->old_viewer ); cbInfo->seqno = reply->seqno; cbInfo->flags = reply->flags; - - bRet = TRUE; } } SERVER_END_REQ; @@ -168,15 +154,13 @@ BOOL CLIPBOARD_ReleaseOwner(void) */ static BOOL CLIPBOARD_OpenClipboard(HWND hWnd) { - BOOL bRet = FALSE; + BOOL bRet; SERVER_START_REQ( set_clipboard_info ) { req->flags = SET_CB_OPEN; - req->clipboard = WIN_GetFullHandle( hWnd ); - - if (!wine_server_call( req )) - bRet = TRUE; + req->clipboard = wine_server_user_handle( hWnd ); + bRet = !wine_server_call( req ); } SERVER_END_REQ; @@ -189,28 +173,15 @@ static BOOL CLIPBOARD_OpenClipboard(HWND hWnd) */ static BOOL CLIPBOARD_CloseClipboard(void) { - BOOL bRet = FALSE; + BOOL bRet; TRACE(" Changed=%d\n", bCBHasChanged); SERVER_START_REQ( set_clipboard_info ) { req->flags = SET_CB_CLOSE; - - if (bCBHasChanged) - { - req->flags |= SET_CB_SEQNO; - TRACE("Clipboard data changed\n"); - } - - if (wine_server_call_err( req )) - { - ERR("Failed to set clipboard.\n"); - } - else - { - bRet = TRUE; - } + if (bCBHasChanged) req->flags |= SET_CB_SEQNO; + bRet = !wine_server_call_err( req ); } SERVER_END_REQ; @@ -384,7 +355,7 @@ HWND WINAPI GetClipboardOwner(void) SERVER_START_REQ( set_clipboard_info ) { req->flags = 0; - if (!wine_server_call_err( req )) hWndOwner = reply->old_owner; + if (!wine_server_call_err( req )) hWndOwner = wine_server_ptr_handle( reply->old_owner ); } SERVER_END_REQ; @@ -404,7 +375,7 @@ HWND WINAPI GetOpenClipboardWindow(void) SERVER_START_REQ( set_clipboard_info ) { req->flags = 0; - if (!wine_server_call_err( req )) hWndOpen = reply->old_clipboard; + if (!wine_server_call_err( req )) hWndOpen = wine_server_ptr_handle( reply->old_clipboard ); } SERVER_END_REQ; @@ -424,16 +395,9 @@ HWND WINAPI SetClipboardViewer( HWND hWnd ) SERVER_START_REQ( set_clipboard_info ) { req->flags = SET_CB_VIEWER; - req->viewer = WIN_GetFullHandle(hWnd); - - if (wine_server_call_err( req )) - { - ERR("Failed to set clipboard.\n"); - } - else - { - hwndPrev = reply->old_viewer; - } + req->viewer = wine_server_user_handle( hWnd ); + if (!wine_server_call_err( req )) + hwndPrev = wine_server_ptr_handle( reply->old_viewer ); } SERVER_END_REQ; @@ -453,7 +417,7 @@ HWND WINAPI GetClipboardViewer(void) SERVER_START_REQ( set_clipboard_info ) { req->flags = 0; - if (!wine_server_call_err( req )) hWndViewer = reply->old_viewer; + if (!wine_server_call_err( req )) hWndViewer = wine_server_ptr_handle( reply->old_viewer ); } SERVER_END_REQ; diff --git a/dlls/user32/defwnd.c b/dlls/user32/defwnd.c index c31956c841..e878adb1ab 100644 --- a/dlls/user32/defwnd.c +++ b/dlls/user32/defwnd.c @@ -97,7 +97,7 @@ static void DEFWND_SetTextA( HWND hwnd, LPCSTR text ) MultiByteToWideChar( CP_ACP, 0, text, -1, textW, count ); SERVER_START_REQ( set_window_text ) { - req->handle = hwnd; + req->handle = wine_server_user_handle( hwnd ); wine_server_add_data( req, textW, (count-1) * sizeof(WCHAR) ); wine_server_call( req ); } @@ -131,7 +131,7 @@ static void DEFWND_SetTextW( HWND hwnd, LPCWSTR text ) strcpyW( wndPtr->text, text ); SERVER_START_REQ( set_window_text ) { - req->handle = hwnd; + req->handle = wine_server_user_handle( hwnd ); wine_server_add_data( req, wndPtr->text, (count-1) * sizeof(WCHAR) ); wine_server_call( req ); } diff --git a/dlls/user32/focus.c b/dlls/user32/focus.c index 36f44f3697..210af36362 100644 --- a/dlls/user32/focus.c +++ b/dlls/user32/focus.c @@ -48,8 +48,9 @@ static HWND set_focus_window( HWND hwnd ) SERVER_START_REQ( set_focus_window ) { - req->handle = hwnd; - if ((ret = !wine_server_call_err( req ))) previous = reply->previous; + req->handle = wine_server_user_handle( hwnd ); + if ((ret = !wine_server_call_err( req ))) + previous = wine_server_ptr_handle( reply->previous ); } SERVER_END_REQ; if (!ret) return 0; @@ -99,8 +100,9 @@ static BOOL set_active_window( HWND hwnd, HWND *prev, BOOL mouse, BOOL focus ) SERVER_START_REQ( set_active_window ) { - req->handle = hwnd; - if ((ret = !wine_server_call_err( req ))) previous = reply->previous; + req->handle = wine_server_user_handle( hwnd ); + if ((ret = !wine_server_call_err( req ))) + previous = wine_server_ptr_handle( reply->previous ); } SERVER_END_REQ; if (!ret) return FALSE; @@ -181,10 +183,10 @@ static BOOL set_foreground_window( HWND hwnd, BOOL mouse ) SERVER_START_REQ( set_foreground_window ) { - req->handle = hwnd; + req->handle = wine_server_user_handle( hwnd ); if ((ret = !wine_server_call_err( req ))) { - previous = reply->previous; + previous = wine_server_ptr_handle( reply->previous ); send_msg_old = reply->send_msg_old; send_msg_new = reply->send_msg_new; } @@ -314,7 +316,7 @@ HWND WINAPI GetActiveWindow(void) SERVER_START_REQ( get_thread_input ) { req->tid = GetCurrentThreadId(); - if (!wine_server_call_err( req )) ret = reply->active; + if (!wine_server_call_err( req )) ret = wine_server_ptr_handle( reply->active ); } SERVER_END_REQ; return ret; @@ -331,7 +333,7 @@ HWND WINAPI GetFocus(void) SERVER_START_REQ( get_thread_input ) { req->tid = GetCurrentThreadId(); - if (!wine_server_call_err( req )) ret = reply->focus; + if (!wine_server_call_err( req )) ret = wine_server_ptr_handle( reply->focus ); } SERVER_END_REQ; return ret; @@ -348,7 +350,7 @@ HWND WINAPI GetForegroundWindow(void) SERVER_START_REQ( get_thread_input ) { req->tid = 0; - if (!wine_server_call_err( req )) ret = reply->foreground; + if (!wine_server_call_err( req )) ret = wine_server_ptr_handle( reply->foreground ); } SERVER_END_REQ; return ret; @@ -388,8 +390,8 @@ BOOL WINAPI SetShellWindowEx(HWND hwndShell, HWND hwndListView) SERVER_START_REQ(set_global_windows) { req->flags = SET_GLOBAL_SHELL_WINDOWS; - req->shell_window = hwndShell; - req->shell_listview = hwndListView; + req->shell_window = wine_server_user_handle( hwndShell ); + req->shell_listview = wine_server_user_handle( hwndListView ); ret = !wine_server_call_err(req); } SERVER_END_REQ; @@ -418,7 +420,7 @@ HWND WINAPI GetShellWindow(void) { req->flags = 0; if (!wine_server_call_err(req)) - hwndShell = reply->old_shell_window; + hwndShell = wine_server_ptr_handle( reply->old_shell_window ); } SERVER_END_REQ; @@ -434,7 +436,7 @@ HWND WINAPI SetProgmanWindow ( HWND hwnd ) SERVER_START_REQ(set_global_windows) { req->flags = SET_GLOBAL_PROGMAN_WINDOW; - req->progman_window = hwnd; + req->progman_window = wine_server_user_handle( hwnd ); if (wine_server_call_err( req )) hwnd = 0; } SERVER_END_REQ; @@ -452,7 +454,8 @@ HWND WINAPI GetProgmanWindow(void) SERVER_START_REQ(set_global_windows) { req->flags = 0; - if (!wine_server_call_err(req)) ret = reply->old_progman_window; + if (!wine_server_call_err(req)) + ret = wine_server_ptr_handle( reply->old_progman_window ); } SERVER_END_REQ; return ret; @@ -470,7 +473,7 @@ HWND WINAPI SetTaskmanWindow ( HWND hwnd ) SERVER_START_REQ(set_global_windows) { req->flags = SET_GLOBAL_TASKMAN_WINDOW; - req->taskman_window = hwnd; + req->taskman_window = wine_server_user_handle( hwnd ); if (wine_server_call_err( req )) hwnd = 0; } SERVER_END_REQ; @@ -487,7 +490,8 @@ HWND WINAPI GetTaskmanWindow(void) SERVER_START_REQ(set_global_windows) { req->flags = 0; - if (!wine_server_call_err(req)) ret = reply->old_taskman_window; + if (!wine_server_call_err(req)) + ret = wine_server_ptr_handle( reply->old_taskman_window ); } SERVER_END_REQ; return ret; diff --git a/dlls/user32/hook.c b/dlls/user32/hook.c index 4354e055e2..c70af45f92 100644 --- a/dlls/user32/hook.c +++ b/dlls/user32/hook.c @@ -191,7 +191,7 @@ static HHOOK set_windows_hook( INT id, HOOKPROC proc, HINSTANCE inst, DWORD tid, if (!wine_server_call_err( req )) { - handle = reply->handle; + handle = wine_server_ptr_handle( reply->handle ); get_user_thread_info()->active_hooks = reply->active_hooks; } } @@ -417,7 +417,7 @@ LRESULT HOOK_CallHooks( INT id, INT code, WPARAM wparam, LPARAM lparam, BOOL uni if (!wine_server_call( req )) { info.module[wine_server_reply_size(req) / sizeof(WCHAR)] = 0; - info.handle = reply->handle; + info.handle = wine_server_ptr_handle( reply->handle ); info.pid = reply->pid; info.tid = reply->tid; info.proc = reply->proc; @@ -520,7 +520,7 @@ BOOL WINAPI UnhookWindowsHookEx( HHOOK hhook ) SERVER_START_REQ( remove_hook ) { - req->handle = hhook; + req->handle = wine_server_user_handle( hhook ); req->id = 0; ret = !wine_server_call_err( req ); if (ret) get_user_thread_info()->active_hooks = reply->active_hooks; @@ -543,14 +543,14 @@ LRESULT WINAPI CallNextHookEx( HHOOK hhook, INT code, WPARAM wparam, LPARAM lpar SERVER_START_REQ( get_hook_info ) { - req->handle = thread_info->hook; + req->handle = wine_server_user_handle( thread_info->hook ); req->get_next = 1; req->event = EVENT_MIN; wine_server_set_reply( req, info.module, sizeof(info.module)-sizeof(WCHAR) ); if (!wine_server_call_err( req )) { info.module[wine_server_reply_size(req) / sizeof(WCHAR)] = 0; - info.handle = reply->handle; + info.handle = wine_server_ptr_handle( reply->handle ); info.id = reply->id; info.pid = reply->pid; info.tid = reply->tid; @@ -573,14 +573,14 @@ LRESULT call_current_hook( HHOOK hhook, INT code, WPARAM wparam, LPARAM lparam ) SERVER_START_REQ( get_hook_info ) { - req->handle = hhook; + req->handle = wine_server_user_handle( hhook ); req->get_next = 0; req->event = EVENT_MIN; wine_server_set_reply( req, info.module, sizeof(info.module)-sizeof(WCHAR) ); if (!wine_server_call_err( req )) { info.module[wine_server_reply_size(req) / sizeof(WCHAR)] = 0; - info.handle = reply->handle; + info.handle = wine_server_ptr_handle( reply->handle ); info.id = reply->id; info.pid = reply->pid; info.tid = reply->tid; @@ -683,7 +683,7 @@ HWINEVENTHOOK WINAPI SetWinEventHook(DWORD event_min, DWORD event_max, if (!wine_server_call_err( req )) { - handle = reply->handle; + handle = wine_server_ptr_handle( reply->handle ); get_user_thread_info()->active_hooks = reply->active_hooks; } } @@ -712,7 +712,7 @@ BOOL WINAPI UnhookWinEvent(HWINEVENTHOOK hEventHook) SERVER_START_REQ( remove_hook ) { - req->handle = hEventHook; + req->handle = wine_server_user_handle( hEventHook ); req->id = WH_WINEVENT; ret = !wine_server_call_err( req ); if (ret) get_user_thread_info()->active_hooks = reply->active_hooks; @@ -737,7 +737,7 @@ static inline BOOL find_first_hook(DWORD id, DWORD event, HWND hwnd, LONG object { req->id = id; req->event = event; - req->window = hwnd; + req->window = wine_server_user_handle( hwnd ); req->object_id = object_id; req->child_id = child_id; wine_server_set_reply( req, info->module, sizeof(info->module)-sizeof(WCHAR) ); @@ -745,7 +745,7 @@ static inline BOOL find_first_hook(DWORD id, DWORD event, HWND hwnd, LONG object if (ret) { info->module[wine_server_reply_size(req) / sizeof(WCHAR)] = 0; - info->handle = reply->handle; + info->handle = wine_server_ptr_handle( reply->handle ); info->proc = reply->proc; info->tid = reply->tid; thread_info->active_hooks = reply->active_hooks; @@ -762,10 +762,10 @@ static inline BOOL find_next_hook(DWORD event, HWND hwnd, LONG object_id, SERVER_START_REQ( get_hook_info ) { - req->handle = info->handle; + req->handle = wine_server_user_handle( info->handle ); req->get_next = 1; req->event = event; - req->window = hwnd; + req->window = wine_server_user_handle( hwnd ); req->object_id = object_id; req->child_id = child_id; wine_server_set_reply( req, info->module, sizeof(info->module)-sizeof(WCHAR) ); @@ -773,7 +773,7 @@ static inline BOOL find_next_hook(DWORD event, HWND hwnd, LONG object_id, if (ret) { info->module[wine_server_reply_size(req) / sizeof(WCHAR)] = 0; - info->handle = reply->handle; + info->handle = wine_server_ptr_handle( reply->handle ); info->proc = reply->proc; info->tid = reply->tid; } diff --git a/dlls/user32/input.c b/dlls/user32/input.c index dce50b51ee..69bf2e8c0a 100644 --- a/dlls/user32/input.c +++ b/dlls/user32/input.c @@ -90,12 +90,12 @@ BOOL set_capture_window( HWND hwnd, UINT gui_flags, HWND *prev_ret ) SERVER_START_REQ( set_capture_window ) { - req->handle = hwnd; + req->handle = wine_server_user_handle( hwnd ); req->flags = flags; if ((ret = !wine_server_call_err( req ))) { - previous = reply->previous; - hwnd = reply->full_handle; + previous = wine_server_ptr_handle( reply->previous ); + hwnd = wine_server_ptr_handle( reply->full_handle ); } } SERVER_END_REQ; @@ -256,7 +256,7 @@ HWND WINAPI GetCapture(void) SERVER_START_REQ( get_thread_input ) { req->tid = GetCurrentThreadId(); - if (!wine_server_call_err( req )) ret = reply->capture; + if (!wine_server_call_err( req )) ret = wine_server_ptr_handle( reply->capture ); } SERVER_END_REQ; return ret; diff --git a/dlls/user32/message.c b/dlls/user32/message.c index 7db48d8c53..d973462913 100644 --- a/dlls/user32/message.c +++ b/dlls/user32/message.c @@ -1495,7 +1495,7 @@ static BOOL post_dde_message( struct packed_message *data, const struct send_mes req->id = info->dest_tid; req->type = info->type; req->flags = 0; - req->win = info->hwnd; + req->win = wine_server_user_handle( info->hwnd ); req->msg = info->msg; req->wparam = info->wparam; req->lparam = lp; @@ -1683,7 +1683,7 @@ static void accept_hardware_message( UINT hw_id, BOOL remove, HWND new_hwnd ) { req->hw_id = hw_id; req->remove = remove; - req->new_win = new_hwnd; + req->new_win = wine_server_user_handle( new_hwnd ); if (wine_server_call( req )) FIXME("Failed to reply to MSG_HARDWARE message. Message may not be removed from queue.\n"); } @@ -2043,7 +2043,7 @@ static BOOL peek_message( MSG *msg, HWND hwnd, UINT first, UINT last, UINT flags SERVER_START_REQ( get_message ) { req->flags = flags; - req->get_win = hwnd; + req->get_win = wine_server_user_handle( hwnd ); req->get_first = first; req->get_last = last; req->hw_id = hw_id; @@ -2054,7 +2054,7 @@ static BOOL peek_message( MSG *msg, HWND hwnd, UINT first, UINT last, UINT flags { size = wine_server_reply_size( reply ); info.type = reply->type; - info.msg.hwnd = reply->win; + info.msg.hwnd = wine_server_ptr_handle( reply->win ); info.msg.message = reply->msg; info.msg.wParam = reply->wparam; info.msg.lParam = reply->lparam; @@ -2125,16 +2125,16 @@ static BOOL peek_message( MSG *msg, HWND hwnd, UINT first, UINT last, UINT flags } if (TRACE_ON(relay)) - DPRINTF( "%04x:Call winevent proc %p (hook=%p,event=%x,hwnd=%p,object_id=%lx,child_id=%lx,tid=%04x,time=%x)\n", + DPRINTF( "%04x:Call winevent proc %p (hook=%04x,event=%x,hwnd=%p,object_id=%lx,child_id=%lx,tid=%04x,time=%x)\n", GetCurrentThreadId(), hook_proc, data->hook, info.msg.message, info.msg.hwnd, info.msg.wParam, info.msg.lParam, data->tid, info.msg.time); - hook_proc( data->hook, info.msg.message, info.msg.hwnd, info.msg.wParam, - info.msg.lParam, data->tid, info.msg.time ); + hook_proc( wine_server_ptr_handle( data->hook ), info.msg.message, + info.msg.hwnd, info.msg.wParam, info.msg.lParam, data->tid, info.msg.time ); if (TRACE_ON(relay)) - DPRINTF( "%04x:Ret winevent proc %p (hook=%p,event=%x,hwnd=%p,object_id=%lx,child_id=%lx,tid=%04x,time=%x)\n", + DPRINTF( "%04x:Ret winevent proc %p (hook=%04x,event=%x,hwnd=%p,object_id=%lx,child_id=%lx,tid=%04x,time=%x)\n", GetCurrentThreadId(), hook_proc, data->hook, info.msg.message, info.msg.hwnd, info.msg.wParam, info.msg.lParam, data->tid, info.msg.time); @@ -2339,7 +2339,7 @@ static BOOL put_message_in_queue( const struct send_message_info *info, size_t * req->id = info->dest_tid; req->type = info->type; req->flags = 0; - req->win = info->hwnd; + req->win = wine_server_user_handle( info->hwnd ); req->msg = info->msg; req->wparam = info->wparam; req->lparam = info->lparam; @@ -3569,7 +3569,7 @@ UINT_PTR WINAPI SetTimer( HWND hwnd, UINT_PTR id, UINT timeout, TIMERPROC proc ) SERVER_START_REQ( set_win_timer ) { - req->win = hwnd; + req->win = wine_server_user_handle( hwnd ); req->msg = WM_TIMER; req->id = id; req->rate = max( timeout, SYS_TIMER_RATE ); @@ -3600,7 +3600,7 @@ UINT_PTR WINAPI SetSystemTimer( HWND hwnd, UINT_PTR id, UINT timeout, TIMERPROC SERVER_START_REQ( set_win_timer ) { - req->win = hwnd; + req->win = wine_server_user_handle( hwnd ); req->msg = WM_SYSTIMER; req->id = id; req->rate = max( timeout, SYS_TIMER_RATE ); @@ -3628,7 +3628,7 @@ BOOL WINAPI KillTimer( HWND hwnd, UINT_PTR id ) SERVER_START_REQ( kill_win_timer ) { - req->win = hwnd; + req->win = wine_server_user_handle( hwnd ); req->msg = WM_TIMER; req->id = id; ret = !wine_server_call_err( req ); @@ -3647,7 +3647,7 @@ BOOL WINAPI KillSystemTimer( HWND hwnd, UINT_PTR id ) SERVER_START_REQ( kill_win_timer ) { - req->win = hwnd; + req->win = wine_server_user_handle( hwnd ); req->msg = WM_SYSTIMER; req->id = id; ret = !wine_server_call_err( req ); @@ -3670,12 +3670,12 @@ BOOL WINAPI GetGUIThreadInfo( DWORD id, GUITHREADINFO *info ) if ((ret = !wine_server_call_err( req ))) { info->flags = 0; - info->hwndActive = reply->active; - info->hwndFocus = reply->focus; - info->hwndCapture = reply->capture; - info->hwndMenuOwner = reply->menu_owner; - info->hwndMoveSize = reply->move_size; - info->hwndCaret = reply->caret; + info->hwndActive = wine_server_ptr_handle( reply->active ); + info->hwndFocus = wine_server_ptr_handle( reply->focus ); + info->hwndCapture = wine_server_ptr_handle( reply->capture ); + info->hwndMenuOwner = wine_server_ptr_handle( reply->menu_owner ); + info->hwndMoveSize = wine_server_ptr_handle( reply->move_size ); + info->hwndCaret = wine_server_ptr_handle( reply->caret ); info->rcCaret.left = reply->rect.left; info->rcCaret.top = reply->rect.top; info->rcCaret.right = reply->rect.right; @@ -3700,7 +3700,7 @@ BOOL WINAPI IsHungAppWindow( HWND hWnd ) SERVER_START_REQ( is_window_hung ) { - req->win = hWnd; + req->win = wine_server_user_handle( hWnd ); ret = !wine_server_call_err( req ) && reply->is_hung; } SERVER_END_REQ; diff --git a/dlls/user32/painting.c b/dlls/user32/painting.c index 65f708e638..6c15ec6e22 100644 --- a/dlls/user32/painting.c +++ b/dlls/user32/painting.c @@ -125,7 +125,7 @@ static void update_visible_region( struct dce *dce ) SERVER_START_REQ( get_visible_region ) { - req->window = dce->hwnd; + req->window = wine_server_user_handle( dce->hwnd ); req->flags = flags; wine_server_set_reply( req, data->Buffer, size ); if (!(status = wine_server_call( req ))) @@ -137,7 +137,7 @@ static void update_visible_region( struct dce *dce ) data->rdh.nRgnSize = reply_size; vis_rgn = ExtCreateRegion( NULL, size, data ); - top_win = reply->top_win; + top_win = wine_server_ptr_handle( reply->top_win ); win_rect.left = reply->win_rect.left; win_rect.top = reply->win_rect.top; win_rect.right = reply->win_rect.right; @@ -535,8 +535,8 @@ static HRGN get_update_region( HWND hwnd, UINT *flags, HWND *child ) SERVER_START_REQ( get_update_region ) { - req->window = hwnd; - req->from_child = child ? *child : 0; + req->window = wine_server_user_handle( hwnd ); + req->from_child = wine_server_user_handle( child ? *child : 0 ); req->flags = *flags; wine_server_set_reply( req, data->Buffer, size ); if (!(status = wine_server_call( req ))) @@ -547,7 +547,7 @@ static HRGN get_update_region( HWND hwnd, UINT *flags, HWND *child ) data->rdh.nCount = reply_size / sizeof(RECT); data->rdh.nRgnSize = reply_size; hrgn = ExtCreateRegion( NULL, size, data ); - if (child) *child = reply->child; + if (child) *child = wine_server_ptr_handle( reply->child ); *flags = reply->flags; } else size = reply->total_size; @@ -572,12 +572,12 @@ static BOOL get_update_flags( HWND hwnd, HWND *child, UINT *flags ) SERVER_START_REQ( get_update_region ) { - req->window = hwnd; - req->from_child = child ? *child : 0; + req->window = wine_server_user_handle( hwnd ); + req->from_child = wine_server_user_handle( child ? *child : 0 ); req->flags = *flags | UPDATE_NOREGION; if ((ret = !wine_server_call_err( req ))) { - if (child) *child = reply->child; + if (child) *child = wine_server_ptr_handle( reply->child ); *flags = reply->flags; } } @@ -600,7 +600,7 @@ static BOOL redraw_window_rects( HWND hwnd, UINT flags, const RECT *rects, UINT SERVER_START_REQ( redraw_window ) { - req->window = hwnd; + req->window = wine_server_user_handle( hwnd ); req->flags = flags; wine_server_add_data( req, rects, count * sizeof(RECT) ); ret = !wine_server_call_err( req ); diff --git a/dlls/user32/property.c b/dlls/user32/property.c index 964a423820..c6da0ab385 100644 --- a/dlls/user32/property.c +++ b/dlls/user32/property.c @@ -53,7 +53,7 @@ static property_data_t *get_properties( HWND hwnd, int *count ) *count = 0; SERVER_START_REQ( get_window_properties ) { - req->window = hwnd; + req->window = wine_server_user_handle( hwnd ); wine_server_set_reply( req, data, total * sizeof(*data) ); if (!wine_server_call( req )) res = reply->total; } @@ -134,7 +134,7 @@ HANDLE WINAPI GetPropW( HWND hwnd, LPCWSTR str ) SERVER_START_REQ( get_window_property ) { - req->window = hwnd; + req->window = wine_server_user_handle( hwnd ); if (!HIWORD(str)) req->atom = LOWORD(str); else wine_server_add_data( req, str, strlenW(str) * sizeof(WCHAR) ); if (!wine_server_call_err( req )) ret = wine_server_ptr_handle( reply->handle ); @@ -166,7 +166,7 @@ BOOL WINAPI SetPropW( HWND hwnd, LPCWSTR str, HANDLE handle ) SERVER_START_REQ( set_window_property ) { - req->window = hwnd; + req->window = wine_server_user_handle( hwnd ); req->handle = wine_server_obj_handle( handle ); if (!HIWORD(str)) req->atom = LOWORD(str); else wine_server_add_data( req, str, strlenW(str) * sizeof(WCHAR) ); @@ -199,7 +199,7 @@ HANDLE WINAPI RemovePropW( HWND hwnd, LPCWSTR str ) SERVER_START_REQ( remove_window_property ) { - req->window = hwnd; + req->window = wine_server_user_handle( hwnd ); if (!HIWORD(str)) req->atom = LOWORD(str); else wine_server_add_data( req, str, strlenW(str) * sizeof(WCHAR) ); if (!wine_server_call_err( req )) ret = wine_server_ptr_handle( reply->handle ); diff --git a/dlls/user32/win.c b/dlls/user32/win.c index 13372612e8..34491fe319 100644 --- a/dlls/user32/win.c +++ b/dlls/user32/win.c @@ -100,9 +100,8 @@ static WND *create_window_handle( HWND parent, HWND owner, LPCWSTR name, { WORD index; WND *win; - HWND full_parent = 0, full_owner = 0; + HWND handle = 0, full_parent = 0, full_owner = 0; struct tagCLASS *class = NULL; - user_handle_t handle = 0; int extra_bytes = 0; /* if 16-bit instance, map to module handle */ @@ -111,16 +110,16 @@ static WND *create_window_handle( HWND parent, HWND owner, LPCWSTR name, SERVER_START_REQ( create_window ) { - req->parent = parent; - req->owner = owner; + req->parent = wine_server_user_handle( parent ); + req->owner = wine_server_user_handle( owner ); req->instance = instance; if (!(req->atom = get_int_atom_value( name )) && name) wine_server_add_data( req, name, strlenW(name)*sizeof(WCHAR) ); if (!wine_server_call_err( req )) { - handle = reply->handle; - full_parent = reply->parent; - full_owner = reply->owner; + handle = wine_server_ptr_handle( reply->handle ); + full_parent = wine_server_ptr_handle( reply->parent ); + full_owner = wine_server_ptr_handle( reply->owner ); extra_bytes = reply->extra; class = reply->class_ptr; } @@ -138,7 +137,7 @@ static WND *create_window_handle( HWND parent, HWND owner, LPCWSTR name, { SERVER_START_REQ( destroy_window ) { - req->handle = handle; + req->handle = wine_server_user_handle( handle ); wine_server_call( req ); } SERVER_END_REQ; @@ -196,7 +195,7 @@ static WND *free_window_handle( HWND hwnd ) { SERVER_START_REQ( destroy_window ) { - req->handle = hwnd; + req->handle = wine_server_user_handle( hwnd ); if (!wine_server_call_err( req )) { user_handles[index] = NULL; @@ -222,7 +221,7 @@ static WND *free_window_handle( HWND hwnd ) static HWND *list_window_children( HDESK desktop, HWND hwnd, LPCWSTR class, DWORD tid ) { HWND *list; - int size = 128; + int i, size = 128; ATOM atom = get_int_atom_value( class ); /* empty class is not the same as NULL class */ @@ -237,16 +236,19 @@ static HWND *list_window_children( HDESK desktop, HWND hwnd, LPCWSTR class, DWOR SERVER_START_REQ( get_window_children ) { req->desktop = wine_server_obj_handle( desktop ); - req->parent = hwnd; + req->parent = wine_server_user_handle( hwnd ); req->tid = tid; req->atom = atom; if (!atom && class) wine_server_add_data( req, class, strlenW(class)*sizeof(WCHAR) ); - wine_server_set_reply( req, list, (size-1) * sizeof(HWND) ); + wine_server_set_reply( req, list, (size-1) * sizeof(user_handle_t) ); if (!wine_server_call( req )) count = reply->count; } SERVER_END_REQ; if (count && count < size) { + /* start from the end since HWND is potentially larger than user_handle_t */ + for (i = count - 1; i >= 0; i--) + list[i] = wine_server_ptr_handle( ((user_handle_t *)list)[i] ); list[count] = 0; return list; } @@ -268,7 +270,7 @@ static HWND *list_window_parents( HWND hwnd ) { WND *win; HWND current, *list; - int pos = 0, size = 16, count = 0; + int i, pos = 0, size = 16, count = 0; if (!(list = HeapAlloc( GetProcessHeap(), 0, size * sizeof(HWND) ))) return NULL; @@ -303,14 +305,17 @@ static HWND *list_window_parents( HWND hwnd ) count = 0; SERVER_START_REQ( get_window_parents ) { - req->handle = hwnd; - wine_server_set_reply( req, list, (size-1) * sizeof(HWND) ); + req->handle = wine_server_user_handle( hwnd ); + wine_server_set_reply( req, list, (size-1) * sizeof(user_handle_t) ); if (!wine_server_call( req )) count = reply->count; } SERVER_END_REQ; if (!count) goto empty; if (size > count) { + /* start from the end since HWND is potentially larger than user_handle_t */ + for (i = count - 1; i >= 0; i--) + list[i] = wine_server_ptr_handle( ((user_handle_t *)list)[i] ); list[count] = 0; return list; } @@ -352,7 +357,7 @@ static void get_server_window_text( HWND hwnd, LPWSTR text, INT count ) SERVER_START_REQ( get_window_text ) { - req->handle = hwnd; + req->handle = wine_server_user_handle( hwnd ); wine_server_set_reply( req, text, (count - 1) * sizeof(WCHAR) ); if (!wine_server_call_err( req )) len = wine_server_reply_size(reply); } @@ -491,8 +496,8 @@ HWND WIN_Handle32( HWND16 hwnd16 ) { SERVER_START_REQ( get_window_info ) { - req->handle = hwnd; - if (!wine_server_call_err( req )) hwnd = reply->full_handle; + req->handle = wine_server_user_handle( hwnd ); + if (!wine_server_call_err( req )) hwnd = wine_server_ptr_handle( reply->full_handle ); } SERVER_END_REQ; } @@ -518,12 +523,12 @@ HWND WIN_SetOwner( HWND hwnd, HWND owner ) } SERVER_START_REQ( set_window_owner ) { - req->handle = hwnd; - req->owner = owner; + req->handle = wine_server_user_handle( hwnd ); + req->owner = wine_server_user_handle( owner ); if (!wine_server_call( req )) { - win->owner = reply->full_owner; - ret = reply->prev_owner; + win->owner = wine_server_ptr_handle( reply->full_owner ); + ret = wine_server_ptr_handle( reply->prev_owner ); } } SERVER_END_REQ; @@ -560,7 +565,7 @@ ULONG WIN_SetStyle( HWND hwnd, ULONG set_bits, ULONG clear_bits ) } SERVER_START_REQ( set_window_info ) { - req->handle = hwnd; + req->handle = wine_server_user_handle( hwnd ); req->flags = SET_WIN_STYLE; req->style = style.styleNew; req->extra_offset = -1; @@ -613,7 +618,7 @@ BOOL WIN_GetRectangles( HWND hwnd, RECT *rectWindow, RECT *rectClient ) { SERVER_START_REQ( get_window_rectangles ) { - req->handle = hwnd; + req->handle = wine_server_user_handle( hwnd ); if ((ret = !wine_server_call( req ))) { if (rectWindow) @@ -673,7 +678,7 @@ LRESULT WIN_DestroyWindow( HWND hwnd ) /* Unlink now so we won't bother with the children later on */ SERVER_START_REQ( set_parent ) { - req->handle = hwnd; + req->handle = wine_server_user_handle( hwnd ); req->parent = 0; wine_server_call( req ); } @@ -1110,7 +1115,7 @@ static HWND WIN_CreateWindowEx( CREATESTRUCTA *cs, LPCWSTR className, UINT flags SERVER_START_REQ( set_window_info ) { - req->handle = hwnd; + req->handle = wine_server_user_handle( hwnd ); req->flags = SET_WIN_STYLE | SET_WIN_EXSTYLE | SET_WIN_INSTANCE | SET_WIN_UNICODE; req->style = wndPtr->dwStyle; req->ex_style = wndPtr->dwExStyle; @@ -1692,8 +1697,8 @@ HWND WINAPI GetDesktopWindow(void) req->force = 0; if (!wine_server_call( req )) { - thread_info->top_window = reply->top_window; - thread_info->msg_window = reply->msg_window; + thread_info->top_window = wine_server_ptr_handle( reply->top_window ); + thread_info->msg_window = wine_server_ptr_handle( reply->msg_window ); } } SERVER_END_REQ; @@ -1735,8 +1740,8 @@ HWND WINAPI GetDesktopWindow(void) req->force = 1; if (!wine_server_call( req )) { - thread_info->top_window = reply->top_window; - thread_info->msg_window = reply->msg_window; + thread_info->top_window = wine_server_ptr_handle( reply->top_window ); + thread_info->msg_window = wine_server_ptr_handle( reply->msg_window ); } } SERVER_END_REQ; @@ -1828,7 +1833,7 @@ BOOL WINAPI IsWindowUnicode( HWND hwnd ) { SERVER_START_REQ( get_window_info ) { - req->handle = hwnd; + req->handle = wine_server_user_handle( hwnd ); if (!wine_server_call_err( req )) retvalue = reply->is_unicode; } SERVER_END_REQ; @@ -1869,7 +1874,7 @@ static LONG_PTR WIN_GetWindowLong( HWND hwnd, INT offset, UINT size, BOOL unicod } SERVER_START_REQ( set_window_info ) { - req->handle = hwnd; + req->handle = wine_server_user_handle( hwnd ); req->flags = 0; /* don't set anything, just retrieve */ req->extra_offset = (offset >= 0) ? offset : -1; req->extra_size = (offset >= 0) ? size : 0; @@ -2066,7 +2071,7 @@ LONG_PTR WIN_SetWindowLong( HWND hwnd, INT offset, UINT size, LONG_PTR newval, B SERVER_START_REQ( set_window_info ) { - req->handle = hwnd; + req->handle = wine_server_user_handle( hwnd ); req->extra_offset = -1; switch(offset) { @@ -2520,7 +2525,7 @@ BOOL WINAPI IsWindow( HWND hwnd ) /* check other processes */ SERVER_START_REQ( get_window_info ) { - req->handle = hwnd; + req->handle = wine_server_user_handle( hwnd ); ret = !wine_server_call_err( req ); } SERVER_END_REQ; @@ -2554,7 +2559,7 @@ DWORD WINAPI GetWindowThreadProcessId( HWND hwnd, LPDWORD process ) /* check other processes */ SERVER_START_REQ( get_window_info ) { - req->handle = hwnd; + req->handle = wine_server_user_handle( hwnd ); if (!wine_server_call_err( req )) { tid = (DWORD)reply->tid; @@ -2587,11 +2592,11 @@ HWND WINAPI GetParent( HWND hwnd ) { SERVER_START_REQ( get_window_tree ) { - req->handle = hwnd; + req->handle = wine_server_user_handle( hwnd ); if (!wine_server_call_err( req )) { - if (style & WS_POPUP) retvalue = reply->owner; - else if (style & WS_CHILD) retvalue = reply->parent; + if (style & WS_POPUP) retvalue = wine_server_ptr_handle( reply->owner ); + else if (style & WS_CHILD) retvalue = wine_server_ptr_handle( reply->parent ); } } SERVER_END_REQ; @@ -2633,8 +2638,8 @@ HWND WINAPI GetAncestor( HWND hwnd, UINT type ) { SERVER_START_REQ( get_window_tree ) { - req->handle = hwnd; - if (!wine_server_call_err( req )) ret = reply->parent; + req->handle = wine_server_user_handle( hwnd ); + if (!wine_server_call_err( req )) ret = wine_server_ptr_handle( reply->parent ); } SERVER_END_REQ; } @@ -2714,12 +2719,12 @@ HWND WINAPI SetParent( HWND hwnd, HWND parent ) SERVER_START_REQ( set_parent ) { - req->handle = hwnd; - req->parent = parent; + req->handle = wine_server_user_handle( hwnd ); + req->parent = wine_server_user_handle( parent ); if ((ret = !wine_server_call( req ))) { - old_parent = reply->old_parent; - wndPtr->parent = parent = reply->full_parent; + old_parent = wine_server_ptr_handle( reply->old_parent ); + wndPtr->parent = parent = wine_server_ptr_handle( reply->full_parent ); } } @@ -2849,28 +2854,28 @@ HWND WINAPI GetWindow( HWND hwnd, UINT rel ) SERVER_START_REQ( get_window_tree ) { - req->handle = hwnd; + req->handle = wine_server_user_handle( hwnd ); if (!wine_server_call_err( req )) { switch(rel) { case GW_HWNDFIRST: - retval = reply->first_sibling; + retval = wine_server_ptr_handle( reply->first_sibling ); break; case GW_HWNDLAST: - retval = reply->last_sibling; + retval = wine_server_ptr_handle( reply->last_sibling ); break; case GW_HWNDNEXT: - retval = reply->next_sibling; + retval = wine_server_ptr_handle( reply->next_sibling ); break; case GW_HWNDPREV: - retval = reply->prev_sibling; + retval = wine_server_ptr_handle( reply->prev_sibling ); break; case GW_OWNER: - retval = reply->owner; + retval = wine_server_ptr_handle( reply->owner ); break; case GW_CHILD: - retval = reply->first_child; + retval = wine_server_ptr_handle( reply->first_child ); break; } } @@ -2939,8 +2944,8 @@ HWND WINAPI GetLastActivePopup( HWND hwnd ) SERVER_START_REQ( get_window_info ) { - req->handle = hwnd; - if (!wine_server_call_err( req )) retval = reply->last_active; + req->handle = wine_server_user_handle( hwnd ); + if (!wine_server_call_err( req )) retval = wine_server_ptr_handle( reply->last_active ); } SERVER_END_REQ; return retval; @@ -3337,7 +3342,7 @@ BOOL WINAPI SetLayeredWindowAttributes( HWND hwnd, COLORREF key, BYTE alpha, DWO SERVER_START_REQ( set_window_layered_info ) { - req->handle = hwnd; + req->handle = wine_server_user_handle( hwnd ); req->color_key = key; req->alpha = alpha; req->flags = flags; @@ -3360,7 +3365,7 @@ BOOL WINAPI GetLayeredWindowAttributes( HWND hwnd, COLORREF *key, BYTE *alpha, D SERVER_START_REQ( get_window_layered_info ) { - req->handle = hwnd; + req->handle = wine_server_user_handle( hwnd ); if ((ret = !wine_server_call_err( req ))) { if (key) *key = reply->color_key; diff --git a/dlls/user32/winpos.c b/dlls/user32/winpos.c index 4f5005cf32..d680cc177a 100644 --- a/dlls/user32/winpos.c +++ b/dlls/user32/winpos.c @@ -126,7 +126,7 @@ int WINAPI GetWindowRgn ( HWND hwnd, HRGN hrgn ) } SERVER_START_REQ( get_window_region ) { - req->window = hwnd; + req->window = wine_server_user_handle( hwnd ); wine_server_set_reply( req, data->Buffer, size ); if (!(status = wine_server_call( req ))) { @@ -178,7 +178,7 @@ int WINAPI SetWindowRgn( HWND hwnd, HRGN hrgn, BOOL bRedraw ) } SERVER_START_REQ( set_window_region ) { - req->window = hwnd; + req->window = wine_server_user_handle( hwnd ); req->redraw = (bRedraw != 0); if (data->rdh.nCount) wine_server_add_data( req, data->Buffer, data->rdh.nCount * sizeof(RECT) ); @@ -192,7 +192,7 @@ int WINAPI SetWindowRgn( HWND hwnd, HRGN hrgn, BOOL bRedraw ) { SERVER_START_REQ( set_window_region ) { - req->window = hwnd; + req->window = wine_server_user_handle( hwnd ); req->redraw = (bRedraw != 0); ret = !wine_server_call_err( req ); } @@ -259,7 +259,7 @@ BOOL WINAPI ScreenToClient( HWND hwnd, LPPOINT lppnt ) static HWND *list_children_from_point( HWND hwnd, POINT pt ) { HWND *list; - int size = 128; + int i, size = 128; for (;;) { @@ -269,15 +269,18 @@ static HWND *list_children_from_point( HWND hwnd, POINT pt ) SERVER_START_REQ( get_window_children_from_point ) { - req->parent = hwnd; + req->parent = wine_server_user_handle( hwnd ); req->x = pt.x; req->y = pt.y; - wine_server_set_reply( req, list, (size-1) * sizeof(HWND) ); + wine_server_set_reply( req, list, (size-1) * sizeof(user_handle_t) ); if (!wine_server_call( req )) count = reply->count; } SERVER_END_REQ; if (count && count < size) { + /* start from the end since HWND is potentially larger than user_handle_t */ + for (i = count - 1; i >= 0; i--) + list[i] = wine_server_ptr_handle( ((user_handle_t *)list)[i] ); list[count] = 0; return list; } @@ -473,8 +476,8 @@ static void WINPOS_GetWinOffset( HWND hwndFrom, HWND hwndTo, POINT *offset ) offset->x = offset->y = 0; SERVER_START_REQ( get_windows_offset ) { - req->from = hwndFrom; - req->to = hwndTo; + req->from = wine_server_user_handle( hwndFrom ); + req->to = wine_server_user_handle( hwndTo ); if (!wine_server_call( req )) { offset->x = reply->x; @@ -1894,8 +1897,8 @@ BOOL set_window_pos( HWND hwnd, HWND insert_after, UINT swp_flags, old_window_rect = win->rectWindow; SERVER_START_REQ( set_window_pos ) { - req->handle = hwnd; - req->previous = insert_after; + req->handle = wine_server_user_handle( hwnd ); + req->previous = wine_server_user_handle( insert_after ); req->flags = swp_flags; req->window.left = window_rect->left; req->window.top = window_rect->top; diff --git a/dlls/winex11.drv/clipboard.c b/dlls/winex11.drv/clipboard.c index 5577867cd6..36b26a7dc8 100644 --- a/dlls/winex11.drv/clipboard.c +++ b/dlls/winex11.drv/clipboard.c @@ -563,9 +563,9 @@ static BOOL X11DRV_CLIPBOARD_GetClipboardInfo(LPCLIPBOARDINFO cbInfo) } else { - cbInfo->hWndOpen = reply->old_clipboard; - cbInfo->hWndOwner = reply->old_owner; - cbInfo->hWndViewer = reply->old_viewer; + cbInfo->hWndOpen = wine_server_ptr_handle( reply->old_clipboard ); + cbInfo->hWndOwner = wine_server_ptr_handle( reply->old_owner ); + cbInfo->hWndViewer = wine_server_ptr_handle( reply->old_viewer ); cbInfo->seqno = reply->seqno; cbInfo->flags = reply->flags; diff --git a/dlls/winex11.drv/event.c b/dlls/winex11.drv/event.c index 5f7ebef243..f0aea44ecf 100644 --- a/dlls/winex11.drv/event.c +++ b/dlls/winex11.drv/event.c @@ -724,7 +724,7 @@ static void X11DRV_Expose( HWND hwnd, XEvent *xev ) { SERVER_START_REQ( update_window_zorder ) { - req->window = hwnd; + req->window = wine_server_user_handle( hwnd ); req->rect.left = rect.left; req->rect.top = rect.top; req->rect.right = rect.right; diff --git a/dlls/winex11.drv/mouse.c b/dlls/winex11.drv/mouse.c index 5df71a789d..bcae0c64de 100644 --- a/dlls/winex11.drv/mouse.c +++ b/dlls/winex11.drv/mouse.c @@ -196,7 +196,7 @@ static void update_mouse_state( HWND hwnd, Window window, int x, int y, unsigned { SERVER_START_REQ( update_window_zorder ) { - req->window = hwnd; + req->window = wine_server_user_handle( hwnd ); req->rect.left = pt->x; req->rect.top = pt->y; req->rect.right = pt->x + 1; @@ -255,7 +255,7 @@ static void queue_raw_mouse_message( UINT message, HWND hwnd, DWORD x, DWORD y, SERVER_START_REQ( send_hardware_message ) { req->id = (injected_flags & LLMHF_INJECTED) ? 0 : GetCurrentThreadId(); - req->win = hwnd; + req->win = wine_server_user_handle( hwnd ); req->msg = message; req->wparam = MAKEWPARAM( get_key_state(), data ); req->lparam = 0; diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c index 0ca0836de0..1f456248fe 100644 --- a/dlls/winex11.drv/window.c +++ b/dlls/winex11.drv/window.c @@ -1636,7 +1636,7 @@ BOOL X11DRV_CreateDesktopWindow( HWND hwnd ) /* retrieve the real size of the desktop */ SERVER_START_REQ( get_window_rectangles ) { - req->handle = hwnd; + req->handle = wine_server_user_handle( hwnd ); wine_server_call( req ); width = reply->window.right - reply->window.left; height = reply->window.bottom - reply->window.top; @@ -1647,7 +1647,7 @@ BOOL X11DRV_CreateDesktopWindow( HWND hwnd ) { SERVER_START_REQ( set_window_pos ) { - req->handle = hwnd; + req->handle = wine_server_user_handle( hwnd ); req->previous = 0; req->flags = SWP_NOZORDER; req->window.left = virtual_screen_rect.left; diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c index a14f3d63e6..da46b4afde 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c @@ -3720,7 +3720,7 @@ INT WINAPI WSAAsyncSelect(SOCKET s, HWND hWnd, UINT uMsg, LONG lEvent) req->handle = wine_server_obj_handle( SOCKET2HANDLE(s) ); req->mask = lEvent; req->event = 0; - req->window = hWnd; + req->window = wine_server_user_handle( hWnd ); req->msg = uMsg; ret = wine_server_call( req ); } diff --git a/include/wine/server.h b/include/wine/server.h index 238bd703d8..014885d2f1 100644 --- a/include/wine/server.h +++ b/include/wine/server.h @@ -96,6 +96,12 @@ static inline obj_handle_t wine_server_obj_handle( HANDLE handle ) return (INT_PTR)handle; } +/* convert a user handle to a server handle */ +static inline user_handle_t wine_server_user_handle( HANDLE handle ) +{ + return (UINT_PTR)handle; +} + /* convert a server handle to a generic handle */ static inline HANDLE wine_server_ptr_handle( obj_handle_t handle ) { diff --git a/programs/wineconsole/wineconsole.c b/programs/wineconsole/wineconsole.c index 0896ec8888..7d10783ab9 100644 --- a/programs/wineconsole/wineconsole.c +++ b/programs/wineconsole/wineconsole.c @@ -681,7 +681,7 @@ static struct inner_data* WINECON_Init(HINSTANCE hInst, DWORD pid, LPCWSTR appna SERVER_START_REQ( set_console_input_info ) { req->handle = wine_server_obj_handle( data->hConIn ); - req->win = data->hWnd; + req->win = wine_server_user_handle( data->hWnd ); req->mask = SET_CONSOLE_INPUT_INFO_TITLE | SET_CONSOLE_INPUT_INFO_WIN; wine_server_add_data( req, appname, lstrlenW(appname) * sizeof(WCHAR) ); -- 2.33.8