mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-01 07:53:38 +00:00
win32u: Use user message packing for messages passing string.
This commit is contained in:
parent
78a4bad8c5
commit
4777bd62ae
|
@ -833,17 +833,13 @@ BOOL unpack_message( HWND hwnd, UINT message, WPARAM *wparam, LPARAM *lparam,
|
||||||
break;
|
break;
|
||||||
case WM_GETTEXT:
|
case WM_GETTEXT:
|
||||||
case WM_ASKCBFORMATNAME:
|
case WM_ASKCBFORMATNAME:
|
||||||
break;
|
|
||||||
case WM_WININICHANGE:
|
case WM_WININICHANGE:
|
||||||
if (!*lparam) return TRUE;
|
|
||||||
/* fall through */
|
|
||||||
case WM_SETTEXT:
|
case WM_SETTEXT:
|
||||||
case WM_DEVMODECHANGE:
|
case WM_DEVMODECHANGE:
|
||||||
case CB_DIR:
|
case CB_DIR:
|
||||||
case LB_DIR:
|
case LB_DIR:
|
||||||
case LB_ADDFILE:
|
case LB_ADDFILE:
|
||||||
case EM_REPLACESEL:
|
case EM_REPLACESEL:
|
||||||
if (!check_string( *buffer, size )) return FALSE;
|
|
||||||
break;
|
break;
|
||||||
case WM_GETMINMAXINFO:
|
case WM_GETMINMAXINFO:
|
||||||
minsize = sizeof(MINMAXINFO);
|
minsize = sizeof(MINMAXINFO);
|
||||||
|
@ -1184,6 +1180,13 @@ BOOL WINAPI User32CallWindowProc( struct win_proc_params *params, ULONG size )
|
||||||
case WM_NCCALCSIZE:
|
case WM_NCCALCSIZE:
|
||||||
case WM_GETTEXT:
|
case WM_GETTEXT:
|
||||||
case WM_ASKCBFORMATNAME:
|
case WM_ASKCBFORMATNAME:
|
||||||
|
case WM_WININICHANGE:
|
||||||
|
case WM_SETTEXT:
|
||||||
|
case WM_DEVMODECHANGE:
|
||||||
|
case CB_DIR:
|
||||||
|
case LB_DIR:
|
||||||
|
case LB_ADDFILE:
|
||||||
|
case EM_REPLACESEL:
|
||||||
{
|
{
|
||||||
LRESULT *result_ptr = (LRESULT *)buffer - 1;
|
LRESULT *result_ptr = (LRESULT *)buffer - 1;
|
||||||
*result_ptr = result;
|
*result_ptr = result;
|
||||||
|
|
|
@ -246,7 +246,7 @@ static LRESULT call_hook( struct win_hook_params *info, const WCHAR *module, siz
|
||||||
if (params->id == WH_CBT && params->code == HCBT_CREATEWND)
|
if (params->id == WH_CBT && params->code == HCBT_CREATEWND)
|
||||||
{
|
{
|
||||||
CBT_CREATEWNDW *cbtc = (CBT_CREATEWNDW *)params->lparam;
|
CBT_CREATEWNDW *cbtc = (CBT_CREATEWNDW *)params->lparam;
|
||||||
message_size = user_message_size( WM_NCCREATE, 0, (LPARAM)cbtc->lpcs, FALSE );
|
message_size = user_message_size( WM_NCCREATE, 0, (LPARAM)cbtc->lpcs, TRUE, FALSE );
|
||||||
lparam_size = lparam_ret_size = 0;
|
lparam_size = lparam_ret_size = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -420,6 +420,16 @@ static BOOL unpack_message( HWND hwnd, UINT message, WPARAM *wparam, LPARAM *lpa
|
||||||
case WM_ASKCBFORMATNAME:
|
case WM_ASKCBFORMATNAME:
|
||||||
if (!get_buffer_space( buffer, (*wparam * sizeof(WCHAR)), size )) return FALSE;
|
if (!get_buffer_space( buffer, (*wparam * sizeof(WCHAR)), size )) return FALSE;
|
||||||
break;
|
break;
|
||||||
|
case WM_WININICHANGE:
|
||||||
|
if (!*lparam) return TRUE;
|
||||||
|
/* fall through */
|
||||||
|
case WM_SETTEXT:
|
||||||
|
case WM_DEVMODECHANGE:
|
||||||
|
case CB_DIR:
|
||||||
|
case LB_DIR:
|
||||||
|
case LB_ADDFILE:
|
||||||
|
case EM_REPLACESEL:
|
||||||
|
break;
|
||||||
case WM_WINE_SETWINDOWPOS:
|
case WM_WINE_SETWINDOWPOS:
|
||||||
{
|
{
|
||||||
WINDOWPOS wp;
|
WINDOWPOS wp;
|
||||||
|
@ -1172,7 +1182,7 @@ static size_t copy_string( void *ptr, const void *str, BOOL ansi )
|
||||||
*
|
*
|
||||||
* Calculate size of packed message buffer.
|
* Calculate size of packed message buffer.
|
||||||
*/
|
*/
|
||||||
size_t user_message_size( UINT message, WPARAM wparam, LPARAM lparam, BOOL ansi )
|
size_t user_message_size( UINT message, WPARAM wparam, LPARAM lparam, BOOL other_process, BOOL ansi )
|
||||||
{
|
{
|
||||||
const void *lparam_ptr = (const void *)lparam;
|
const void *lparam_ptr = (const void *)lparam;
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
|
@ -1195,6 +1205,15 @@ size_t user_message_size( UINT message, WPARAM wparam, LPARAM lparam, BOOL ansi
|
||||||
case WM_ASKCBFORMATNAME:
|
case WM_ASKCBFORMATNAME:
|
||||||
size = wparam * char_size( ansi );
|
size = wparam * char_size( ansi );
|
||||||
break;
|
break;
|
||||||
|
case WM_WININICHANGE:
|
||||||
|
case WM_SETTEXT:
|
||||||
|
case WM_DEVMODECHANGE:
|
||||||
|
case CB_DIR:
|
||||||
|
case LB_DIR:
|
||||||
|
case LB_ADDFILE:
|
||||||
|
case EM_REPLACESEL:
|
||||||
|
if (other_process && lparam) size = string_size( lparam_ptr, ansi );
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
|
@ -1590,7 +1609,7 @@ static LRESULT call_window_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpar
|
||||||
if (!needs_unpack) size = 0;
|
if (!needs_unpack) size = 0;
|
||||||
if (!is_current_thread_window( hwnd )) return 0;
|
if (!is_current_thread_window( hwnd )) return 0;
|
||||||
|
|
||||||
packed_size = user_message_size( msg, wparam, lparam, ansi );
|
packed_size = user_message_size( msg, wparam, lparam, needs_unpack, ansi );
|
||||||
if (packed_size) size = packed_size;
|
if (packed_size) size = packed_size;
|
||||||
|
|
||||||
/* first the WH_CALLWNDPROC hook */
|
/* first the WH_CALLWNDPROC hook */
|
||||||
|
|
|
@ -1362,6 +1362,7 @@ struct lparam_hook_test
|
||||||
const void *change_lparam;
|
const void *change_lparam;
|
||||||
const void *check_lparam;
|
const void *check_lparam;
|
||||||
size_t lparam_size;
|
size_t lparam_size;
|
||||||
|
size_t lparam_init_size;
|
||||||
size_t check_size;
|
size_t check_size;
|
||||||
BOOL poison_lparam;
|
BOOL poison_lparam;
|
||||||
BOOL todo;
|
BOOL todo;
|
||||||
|
@ -1582,7 +1583,9 @@ static void init_hook_test( const struct lparam_hook_test *test )
|
||||||
|
|
||||||
if (test->lparam_size)
|
if (test->lparam_size)
|
||||||
{
|
{
|
||||||
if (test->lparam)
|
if (test->lparam_init_size)
|
||||||
|
memcpy( lparam_buffer, test->lparam, test->lparam_init_size );
|
||||||
|
else if (test->lparam)
|
||||||
memcpy( lparam_buffer, test->lparam, test->lparam_size );
|
memcpy( lparam_buffer, test->lparam, test->lparam_size );
|
||||||
else
|
else
|
||||||
memset( lparam_buffer, 0xcc, test->lparam_size );
|
memset( lparam_buffer, 0xcc, test->lparam_size );
|
||||||
|
@ -1689,8 +1692,16 @@ static void test_wndproc_hook(void)
|
||||||
.lparam_size = sizeof(BOOL), .change_lparam = &false_lparam,
|
.lparam_size = sizeof(BOOL), .change_lparam = &false_lparam,
|
||||||
.todo = TRUE
|
.todo = TRUE
|
||||||
},
|
},
|
||||||
|
/* messages that don't change lparam */
|
||||||
{ "WM_USER", WM_USER },
|
{ "WM_USER", WM_USER },
|
||||||
{ "WM_NOTIFY", WM_NOTIFY },
|
{ "WM_NOTIFY", WM_NOTIFY },
|
||||||
|
{ "WM_SETTEXT", WM_SETTEXT, .lparam = strbufW, .lparam_init_size = sizeof(strbufW) },
|
||||||
|
{ "WM_DEVMODECHANGE", WM_DEVMODECHANGE, .lparam = strbufW, .lparam_init_size = sizeof(strbufW) },
|
||||||
|
{ "CB_DIR", CB_DIR, .lparam = strbufW, .lparam_init_size = sizeof(strbufW) },
|
||||||
|
{ "LB_DIR", LB_DIR, .lparam = strbufW, .lparam_init_size = sizeof(strbufW) },
|
||||||
|
{ "LB_ADDFILE", LB_ADDFILE, .lparam = strbufW, .lparam_init_size = sizeof(strbufW) },
|
||||||
|
{ "EM_REPLACESEL", EM_REPLACESEL, .lparam = strbufW, .lparam_init_size = sizeof(strbufW) },
|
||||||
|
{ "WM_WININICHANGE", WM_WININICHANGE, .lparam = strbufW, .lparam_init_size = sizeof(strbufW) },
|
||||||
};
|
};
|
||||||
|
|
||||||
cls.lpfnWndProc = lparam_test_proc;
|
cls.lpfnWndProc = lparam_test_proc;
|
||||||
|
|
|
@ -140,7 +140,8 @@ extern LRESULT send_message( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
|
||||||
extern BOOL send_notify_message( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, BOOL ansi ) DECLSPEC_HIDDEN;
|
extern BOOL send_notify_message( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, BOOL ansi ) DECLSPEC_HIDDEN;
|
||||||
extern LRESULT send_message_timeout( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam,
|
extern LRESULT send_message_timeout( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam,
|
||||||
UINT flags, UINT timeout, BOOL ansi ) DECLSPEC_HIDDEN;
|
UINT flags, UINT timeout, BOOL ansi ) DECLSPEC_HIDDEN;
|
||||||
extern size_t user_message_size( UINT message, WPARAM wparam, LPARAM lparam, BOOL ansi ) DECLSPEC_HIDDEN;
|
extern size_t user_message_size( UINT message, WPARAM wparam, LPARAM lparam,
|
||||||
|
BOOL other_process, BOOL ansi ) DECLSPEC_HIDDEN;
|
||||||
extern void pack_user_message( void *buffer, size_t size, UINT message,
|
extern void pack_user_message( void *buffer, size_t size, UINT message,
|
||||||
WPARAM wparam, LPARAM lparam, BOOL ansi ) DECLSPEC_HIDDEN;
|
WPARAM wparam, LPARAM lparam, BOOL ansi ) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue