Module: wine Branch: master Commit: 347e3927994834dec2472f6a13038bc92714cbfa URL: https://gitlab.winehq.org/wine/wine/-/commit/347e3927994834dec2472f6a13038bc...
Author: Jacek Caban jacek@codeweavers.com Date: Tue Jul 18 22:25:58 2023 +0200
win32u: Use user message packing for WM_NEXTMENU.
---
dlls/user32/winproc.c | 16 +--------------- dlls/win32u/message.c | 19 ++++++++++++++++--- dlls/win32u/tests/win32u.c | 7 +++++++ dlls/wow64win/user.c | 28 +++++++++++++++++++++++++++- 4 files changed, 51 insertions(+), 19 deletions(-)
diff --git a/dlls/user32/winproc.c b/dlls/user32/winproc.c index a8524c746b3..f10a8c0d49e 100644 --- a/dlls/user32/winproc.c +++ b/dlls/user32/winproc.c @@ -761,12 +761,6 @@ static inline void *unpack_ptr( ULONGLONG ptr64 ) return (void *)(ULONG_PTR)ptr64; }
-/* convert a server handle to a generic handle */ -static inline HANDLE unpack_handle( UINT handle ) -{ - return (HANDLE)(INT_PTR)(int)handle; -} - /* make sure that the buffer contains a valid null-terminated Unicode string */ static inline BOOL check_string( LPCWSTR str, size_t size ) { @@ -876,17 +870,8 @@ BOOL unpack_message( HWND hwnd, UINT message, WPARAM *wparam, LPARAM *lparam, case CB_GETLBTEXT: case LB_GETTEXT: case LB_GETSELITEMS: - break; case WM_NEXTMENU: - { - MDINEXTMENU mnm; - if (size < sizeof(ps->mnm)) return FALSE; - mnm.hmenuIn = unpack_handle( ps->mnm.hmenuIn ); - mnm.hmenuNext = unpack_handle( ps->mnm.hmenuNext ); - mnm.hwndNext = unpack_handle( ps->mnm.hwndNext ); - memcpy( *buffer, &mnm, sizeof(mnm) ); break; - } case WM_SIZING: case WM_MOVING: minsize = sizeof(RECT); @@ -1062,6 +1047,7 @@ BOOL WINAPI User32CallWindowProc( struct win_proc_params *params, ULONG size ) case CB_GETLBTEXT: case LB_GETTEXT: case LB_GETSELITEMS: + case WM_NEXTMENU: { LRESULT *result_ptr = (LRESULT *)buffer - 1; *result_ptr = result; diff --git a/dlls/win32u/message.c b/dlls/win32u/message.c index bb052ade359..a09aaa9022c 100644 --- a/dlls/win32u/message.c +++ b/dlls/win32u/message.c @@ -634,6 +634,16 @@ static BOOL unpack_message( HWND hwnd, UINT message, WPARAM *wparam, LPARAM *lpa case LB_GETSELITEMS: if (!get_buffer_space( buffer, *wparam * sizeof(UINT), size )) return FALSE; break; + case WM_NEXTMENU: + { + MDINEXTMENU mnm; + if (size < sizeof(ps->mnm)) return FALSE; + mnm.hmenuIn = wine_server_ptr_handle( ps->mnm.hmenuIn ); + mnm.hmenuNext = wine_server_ptr_handle( ps->mnm.hmenuNext ); + mnm.hwndNext = wine_server_ptr_handle( ps->mnm.hwndNext ); + memcpy( *buffer, &mnm, sizeof(mnm) ); + break; + } case WM_WINE_SETWINDOWPOS: { WINDOWPOS wp; @@ -1476,6 +1486,9 @@ size_t user_message_size( HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam, case LB_GETSELITEMS: size = wparam * sizeof(UINT); break; + case WM_NEXTMENU: + size = sizeof(MDINEXTMENU); + break; }
return size; @@ -1649,6 +1662,9 @@ static void copy_user_result( void *buffer, size_t size, LRESULT result, UINT me case LB_GETSELITEMS: copy_size = wparam * sizeof(UINT); break; + case WM_NEXTMENU: + copy_size = sizeof(MDINEXTMENU); + break; default: return; } @@ -1679,9 +1695,6 @@ static void copy_reply( LRESULT result, HWND hwnd, UINT message, WPARAM wparam, case WM_MDIGETACTIVE: if (lparam) copy_size = sizeof(BOOL); break; - case WM_NEXTMENU: - copy_size = sizeof(MDINEXTMENU); - break; case WM_MDICREATE: copy_size = sizeof(MDICREATESTRUCTW); break; diff --git a/dlls/win32u/tests/win32u.c b/dlls/win32u/tests/win32u.c index d0f79b5c124..0f176ea88f5 100644 --- a/dlls/win32u/tests/win32u.c +++ b/dlls/win32u/tests/win32u.c @@ -1682,6 +1682,8 @@ static void test_wndproc_hook(void) static const DWORD dw_in = 1, dw_out = 2; static const UINT32 tabstops_in[2] = { 3, 4 }; static const UINT32 items_out[2] = { 1, 2 }; + static const MDINEXTMENU nm_in = { .hmenuIn = (HMENU)0xdeadbeef }; + static const MDINEXTMENU nm_out = { .hmenuIn = (HMENU)1 };
static const struct lparam_hook_test lparam_hook_tests[] = { @@ -1897,6 +1899,11 @@ static void test_wndproc_hook(void) .wparam = ARRAYSIZE(items_out), .msg_result = ARRAYSIZE(items_out), .lparam_size = sizeof(items_out), .change_lparam = items_out, }, + { + "WM_NEXTMENU", WM_NEXTMENU, + .lparam_size = sizeof(nm_in), .lparam = &nm_in, .change_lparam = &nm_out, + .check_size = sizeof(nm_in) + }, /* messages that don't change lparam */ { "WM_USER", WM_USER }, { "WM_NOTIFY", WM_NOTIFY }, diff --git a/dlls/wow64win/user.c b/dlls/wow64win/user.c index 326c9256f1d..669506b5147 100644 --- a/dlls/wow64win/user.c +++ b/dlls/wow64win/user.c @@ -762,6 +762,17 @@ static size_t packed_message_64to32( UINT message, WPARAM wparam, case WM_GETDLGCODE: msg_64to32( params64, params32 ); return sizeof(MSG32); + + case WM_NEXTMENU: + { + MDINEXTMENU32 *next32 = params32; + const MDINEXTMENU *next64 = params64; + + next32->hmenuIn = HandleToLong( next64->hmenuIn ); + next32->hmenuNext = HandleToLong( next64->hmenuNext ); + next32->hwndNext = HandleToLong( next64->hwndNext ); + return sizeof(*next32); + } }
memmove( params32, params64, size ); @@ -828,6 +839,17 @@ static size_t packed_result_32to64( UINT message, WPARAM wparam, const void *par winpos_32to64( params64, params32 ); return sizeof(WINDOWPOS);
+ case WM_NEXTMENU: + { + const MDINEXTMENU32 *next32 = params32; + MDINEXTMENU *next64 = params64; + + next64->hmenuIn = LongToHandle( next32->hmenuIn ); + next64->hmenuNext = LongToHandle( next32->hmenuNext ); + next64->hwndNext = LongToHandle( next32->hwndNext ); + return sizeof(*next64); + } + case WM_GETTEXT: case WM_ASKCBFORMATNAME: case WM_GETMINMAXINFO: @@ -3357,7 +3379,11 @@ static LRESULT message_call_32to64( HWND hwnd, UINT msg, WPARAM wparam, LPARAM l next.hmenuIn = LongToHandle( next32->hmenuIn ); next.hmenuNext = LongToHandle( next32->hmenuNext ); next.hwndNext = LongToHandle( next32->hwndNext ); - return NtUserMessageCall( hwnd, msg, wparam, (LPARAM)&next, result_info, type, ansi ); + ret = NtUserMessageCall( hwnd, msg, wparam, (LPARAM)&next, result_info, type, ansi ); + next32->hmenuIn = HandleToLong( next.hmenuIn ); + next32->hmenuNext = HandleToLong( next.hmenuNext ); + next32->hwndNext = HandleToLong( next.hwndNext ); + return ret; }
case WM_PAINTCLIPBOARD: