win32u: Use user message packing for WM_NEXTMENU.

This commit is contained in:
Jacek Caban 2023-07-18 22:25:58 +02:00 committed by Alexandre Julliard
parent c66984d174
commit 347e392799
4 changed files with 51 additions and 19 deletions

View file

@ -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;

View file

@ -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;

View file

@ -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 },

View file

@ -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: