Commit ad45d84a authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

win32u: Use user message packing for WM_MDIGETACTIVE.

parent 8561e8e9
......@@ -478,7 +478,7 @@ BOOL WINAPI User32CallWindowsHook( struct win_hook_params *params, ULONG size )
{
cbtc.hwndInsertAfter = HWND_TOP;
unpack_message( (HWND)params->wparam, WM_CREATE, NULL, (LPARAM *)&cbtc.lpcs,
&ret_ptr, ret_size, FALSE );
ret_ptr, ret_size, FALSE );
params->lparam = (LPARAM)&cbtc;
ret_size = sizeof(*cbtc.lpcs);
}
......@@ -488,10 +488,9 @@ BOOL WINAPI User32CallWindowsHook( struct win_hook_params *params, ULONG size )
{
CWPSTRUCT *cwp = (CWPSTRUCT *)params->lparam;
size_t offset = (lparam_offset + sizeof(*cwp) + 15) & ~15;
void *buffer = (char *)params + offset;
unpack_message( cwp->hwnd, cwp->message, &cwp->wParam, &cwp->lParam,
&buffer, size - offset, !params->prev_unicode );
(char *)params + offset, size - offset, !params->prev_unicode );
ret_size = 0;
break;
}
......@@ -500,10 +499,9 @@ BOOL WINAPI User32CallWindowsHook( struct win_hook_params *params, ULONG size )
{
CWPRETSTRUCT *cwpret = (CWPRETSTRUCT *)params->lparam;
size_t offset = (lparam_offset + sizeof(*cwpret) + 15) & ~15;
void *buffer = (char *)params + offset;
unpack_message( cwpret->hwnd, cwpret->message, &cwpret->wParam, &cwpret->lParam,
&buffer, size - offset, !params->prev_unicode );
(char *)params + offset, size - offset, !params->prev_unicode );
ret_size = 0;
break;
}
......
......@@ -52,7 +52,7 @@ extern BOOL unpack_dde_message( HWND hwnd, UINT message, WPARAM *wparam, LPARAM
extern void free_cached_data( UINT format, HANDLE handle ) DECLSPEC_HIDDEN;
extern HANDLE render_synthesized_format( UINT format, UINT from ) DECLSPEC_HIDDEN;
extern BOOL unpack_message( HWND hwnd, UINT message, WPARAM *wparam, LPARAM *lparam,
void **buffer, size_t size, BOOL ansi );
void *buffer, size_t size, BOOL ansi );
extern void CLIPBOARD_ReleaseOwner( HWND hwnd ) DECLSPEC_HIDDEN;
extern HDC get_display_dc(void) DECLSPEC_HIDDEN;
......
......@@ -730,14 +730,6 @@ LRESULT dispatch_win_proc_params( struct win_proc_params *params )
return result;
}
/* make sure that there is space for 'size' bytes in buffer, growing it if needed */
static inline void *get_buffer_space( void **buffer, size_t size, size_t prev_size )
{
if (prev_size < size)
*buffer = HeapAlloc( GetProcessHeap(), 0, size );
return *buffer;
}
static size_t string_size( const void *str, BOOL ansi )
{
return ansi ? strlen( str ) + 1 : (wcslen( str ) + 1) * sizeof(WCHAR);
......@@ -749,7 +741,7 @@ static size_t string_size( const void *str, BOOL ansi )
* Unpack a message received from another process.
*/
BOOL unpack_message( HWND hwnd, UINT message, WPARAM *wparam, LPARAM *lparam,
void **buffer, size_t size, BOOL ansi )
void *buffer, size_t size, BOOL ansi )
{
size_t minsize = 0;
......@@ -758,7 +750,7 @@ BOOL unpack_message( HWND hwnd, UINT message, WPARAM *wparam, LPARAM *lparam,
case WM_NCCREATE:
case WM_CREATE:
{
CREATESTRUCTA *cs = *buffer;
CREATESTRUCTA *cs = buffer;
char *str = (char *)(cs + 1);
if (!IS_INTRESOURCE(cs->lpszName))
......@@ -775,13 +767,13 @@ BOOL unpack_message( HWND hwnd, UINT message, WPARAM *wparam, LPARAM *lparam,
case WM_NCCALCSIZE:
if (*wparam)
{
NCCALCSIZE_PARAMS *ncp = *buffer;
NCCALCSIZE_PARAMS *ncp = buffer;
ncp->lppos = (WINDOWPOS *)((NCCALCSIZE_PARAMS *)ncp + 1);
}
break;
case WM_COPYDATA:
{
COPYDATASTRUCT *cds = *buffer;
COPYDATASTRUCT *cds = buffer;
if (cds->lpData) cds->lpData = cds + 1;
break;
}
......@@ -789,14 +781,14 @@ BOOL unpack_message( HWND hwnd, UINT message, WPARAM *wparam, LPARAM *lparam,
case SBM_GETRANGE:
case CB_GETEDITSEL:
{
DWORD *ptr = *buffer;
DWORD *ptr = buffer;
*wparam = (WPARAM)ptr++;
*lparam = (LPARAM)ptr;
return TRUE;
}
case WM_MDICREATE:
{
MDICREATESTRUCTA *mcs = *buffer;
MDICREATESTRUCTA *mcs = buffer;
char *str = (char *)(mcs + 1);
if (!IS_INTRESOURCE(mcs->szClass))
......@@ -858,10 +850,7 @@ BOOL unpack_message( HWND hwnd, UINT message, WPARAM *wparam, LPARAM *lparam,
case WM_SIZING:
case WM_MOVING:
case CB_GETCOMBOBOXINFO:
break;
case WM_MDIGETACTIVE:
if (!*lparam) return TRUE;
if (!get_buffer_space( buffer, sizeof(BOOL), size )) return FALSE;
break;
case WM_DEVICECHANGE:
if (!(*wparam & 0x8000)) return TRUE;
......@@ -916,7 +905,7 @@ BOOL unpack_message( HWND hwnd, UINT message, WPARAM *wparam, LPARAM *lparam,
/* default exit for most messages: check minsize and store buffer in lparam */
if (size < minsize) return FALSE;
*lparam = (LPARAM)*buffer;
*lparam = (LPARAM)buffer;
return TRUE;
}
......@@ -926,22 +915,13 @@ BOOL WINAPI User32CallWindowProc( struct win_proc_params *params, ULONG size )
if (params->needs_unpack)
{
char stack_buffer[128];
size_t msg_size = size - sizeof(*params);
void *buffer;
if (size > sizeof(*params))
{
size -= sizeof(*params);
buffer = params + 1;
}
else
{
size = sizeof(stack_buffer);
buffer = stack_buffer;
}
size -= sizeof(*params);
buffer = params + 1;
if (!unpack_message( params->hwnd, params->msg, &params->wparam,
&params->lparam, &buffer, size, params->ansi ))
&params->lparam, buffer, size, params->ansi ))
return 0;
result = dispatch_win_proc_params( params );
......@@ -1003,17 +983,16 @@ BOOL WINAPI User32CallWindowProc( struct win_proc_params *params, ULONG size )
case WM_MOVING:
case WM_MDICREATE:
case CB_GETCOMBOBOXINFO:
case WM_MDIGETACTIVE:
{
LRESULT *result_ptr = (LRESULT *)buffer - 1;
*result_ptr = result;
return NtCallbackReturn( result_ptr, sizeof(*result_ptr) + msg_size, TRUE );
return NtCallbackReturn( result_ptr, sizeof(*result_ptr) + size, TRUE );
}
}
NtUserMessageCall( params->hwnd, params->msg, params->wparam, params->lparam,
(void *)result, NtUserWinProcResult, FALSE );
if (buffer != stack_buffer && buffer != params + 1)
HeapFree( GetProcessHeap(), 0, buffer );
}
else
{
......
......@@ -874,6 +874,10 @@ static BOOL unpack_message( HWND hwnd, UINT message, WPARAM *wparam, LPARAM *lpa
memcpy( ps, &cbi, sizeof(cbi) );
break;
}
case WM_MDIGETACTIVE:
if (!*lparam) return TRUE;
if (!get_buffer_space( buffer, sizeof(BOOL), size )) return FALSE;
break;
default:
return TRUE; /* message doesn't need any unpacking */
}
......@@ -1699,6 +1703,9 @@ size_t user_message_size( HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam,
case CB_GETCOMBOBOXINFO:
size = sizeof(COMBOBOXINFO);
break;
case WM_MDIGETACTIVE:
if (lparam) size = sizeof(BOOL);
break;
}
return size;
......@@ -1908,26 +1915,6 @@ static void copy_user_result( void *buffer, size_t size, LRESULT result, UINT me
}
copy_size = sizeof(COMBOBOXINFO);
break;
default:
return;
}
if (copy_size > size) copy_size = size;
if (copy_size) memcpy( lparam_ptr, buffer, copy_size );
}
/***********************************************************************
* copy_reply
*
* Copy a message reply received from client.
*/
static void copy_reply( LRESULT result, HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam,
WPARAM wparam_src, LPARAM lparam_src )
{
size_t copy_size = 0;
switch(message)
{
case WM_MDIGETACTIVE:
if (lparam) copy_size = sizeof(BOOL);
break;
......@@ -1935,7 +1922,8 @@ static void copy_reply( LRESULT result, HWND hwnd, UINT message, WPARAM wparam,
return;
}
if (copy_size) memcpy( (void *)lparam, (void *)lparam_src, copy_size );
if (copy_size > size) copy_size = size;
if (copy_size) memcpy( lparam_ptr, buffer, copy_size );
}
/***********************************************************************
......@@ -2001,12 +1989,7 @@ static BOOL reply_winproc_result( LRESULT result, HWND hwnd, UINT message, WPARA
MSG msg;
if (!info) return FALSE;
if (info->type == MSG_CLIENT_MESSAGE)
{
copy_reply( result, hwnd, message, info->msg.wParam, info->msg.lParam, wparam, lparam );
return TRUE;
}
if (info->type == MSG_CLIENT_MESSAGE) return TRUE;
msg.hwnd = hwnd;
msg.message = message;
......
......@@ -1368,7 +1368,6 @@ struct lparam_hook_test
size_t check_size;
BOOL poison_lparam;
BOOL not_allowed;
BOOL todo;
};
static const struct lparam_hook_test *current_hook_test;
......@@ -1594,7 +1593,6 @@ static void test_msg_output( const struct lparam_hook_test *test, LRESULT result
(test->message == LB_GETTEXT && test->msg_result == 7))
ok( !memcmp( lparam_buffer, expected, test->lparam_size ), "unexpected lparam content\n" );
todo_wine_if(test->todo)
ok( wndproc_lparam != orig, "wndproc_lparam unmodified\n" );
if (!hooks_called)
return;
......@@ -1604,13 +1602,9 @@ static void test_msg_output( const struct lparam_hook_test *test, LRESULT result
ok( retwnd_hook_lparam, "retwnd_hook_lparam not called\n" );
ok( retwnd_hook_lparam2, "retwnd_hook_lparam2 not called\n" );
todo_wine_if(test->todo)
ok( orig != callwnd_hook_lparam, "callwnd_hook_lparam not modified\n" );
todo_wine_if(test->todo)
ok( orig != callwnd_hook_lparam2, "callwnd_hook_lparam2 not modified\n" );
todo_wine_if(test->todo)
ok( orig != retwnd_hook_lparam, "retwnd_hook_lparam not modified\n" );
todo_wine_if(test->todo)
ok( orig != retwnd_hook_lparam2, "retwnd_hook_lparam2 not modified\n" );
/*
......@@ -1788,7 +1782,6 @@ static void test_wndproc_hook(void)
{
"WM_MDIGETACTIVE", WM_MDIGETACTIVE, .no_wparam_check = TRUE,
.lparam_size = sizeof(BOOL), .change_lparam = &false_lparam,
.todo = TRUE
},
{
"WM_GETMINMAXINFO", WM_GETMINMAXINFO,
......
......@@ -917,6 +917,7 @@ static size_t packed_result_32to64( UINT message, WPARAM wparam, const void *par
case LB_GETSELITEMS:
case WM_SIZING:
case WM_MOVING:
case WM_MDIGETACTIVE:
break;
default:
......
Markdown is supported
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