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

win32u: Use a client copy of windows hook lparam when calling hook procs.

Instead of leaking kernel pointers.
parent f48f5155
...@@ -439,18 +439,52 @@ BOOL WINAPI User32CallWinEventHook( const struct win_event_hook_params *params, ...@@ -439,18 +439,52 @@ BOOL WINAPI User32CallWinEventHook( const struct win_event_hook_params *params,
return TRUE; return TRUE;
} }
BOOL WINAPI User32CallWindowsHook( const struct win_hook_params *params, ULONG size ) BOOL WINAPI User32CallWindowsHook( struct win_hook_params *params, ULONG size )
{ {
HOOKPROC proc = params->proc; HOOKPROC proc = params->proc;
const WCHAR *module = NULL;
HMODULE free_module = 0; HMODULE free_module = 0;
void *ret_lparam = NULL;
CBT_CREATEWNDW cbtc;
UINT ret_lparam_size = 0;
LRESULT ret; LRESULT ret;
if (params->module[0] && !(proc = get_hook_proc( proc, params->module, &free_module ))) return FALSE; if (size > sizeof(*params) + params->lparam_size)
module = (const WCHAR *)((const char *)(params + 1) + params->lparam_size);
if (params->lparam_size)
{
ret_lparam = (void *)params->lparam;
ret_lparam_size = params->lparam_size;
params->lparam = (LPARAM)(params + 1);
if (params->id == WH_CBT && params->code == HCBT_CREATEWND)
{
CREATESTRUCTW *cs = (CREATESTRUCTW *)params->lparam;
const WCHAR *ptr = (const WCHAR *)(cs + 1);
if (!IS_INTRESOURCE(cs->lpszName))
{
cs->lpszName = ptr;
ptr += wcslen( ptr ) + 1;
}
if (!IS_INTRESOURCE(cs->lpszClass))
cs->lpszClass = ptr;
cbtc.hwndInsertAfter = HWND_TOP;
cbtc.lpcs = cs;
params->lparam = (LPARAM)&cbtc;
ret_lparam_size = sizeof(*cs);
}
}
if (module && !(proc = get_hook_proc( proc, module, &free_module ))) return FALSE;
ret = call_hook_proc( proc, params->id, params->code, params->wparam, params->lparam, ret = call_hook_proc( proc, params->id, params->code, params->wparam, params->lparam,
params->prev_unicode, params->next_unicode ); params->prev_unicode, params->next_unicode );
if (free_module) FreeLibrary( free_module ); if (free_module) FreeLibrary( free_module );
if (ret_lparam) memcpy( ret_lparam, params + 1, ret_lparam_size );
else if (ret_lparam_size) NtCallbackReturn( params + 1, ret_lparam_size, ret );
return ret; return ret;
} }
......
...@@ -83,7 +83,7 @@ BOOL WINAPI User32CallEnumDisplayMonitor( struct enum_display_monitor_params *pa ...@@ -83,7 +83,7 @@ BOOL WINAPI User32CallEnumDisplayMonitor( struct enum_display_monitor_params *pa
BOOL WINAPI User32CallSendAsyncCallback( const struct send_async_params *params, ULONG size ); BOOL WINAPI User32CallSendAsyncCallback( const struct send_async_params *params, ULONG size );
BOOL WINAPI User32CallWinEventHook( const struct win_event_hook_params *params, ULONG size ); BOOL WINAPI User32CallWinEventHook( const struct win_event_hook_params *params, ULONG size );
BOOL WINAPI User32CallWindowProc( struct win_proc_params *params, ULONG size ); BOOL WINAPI User32CallWindowProc( struct win_proc_params *params, ULONG size );
BOOL WINAPI User32CallWindowsHook( const struct win_hook_params *params, ULONG size ); BOOL WINAPI User32CallWindowsHook( struct win_hook_params *params, ULONG size );
BOOL WINAPI User32InitBuiltinClasses( const struct win_hook_params *params, ULONG size ); BOOL WINAPI User32InitBuiltinClasses( const struct win_hook_params *params, ULONG size );
/* message spy definitions */ /* message spy definitions */
......
...@@ -883,7 +883,7 @@ static void sys_command_size_move( HWND hwnd, WPARAM wparam ) ...@@ -883,7 +883,7 @@ static void sys_command_size_move( HWND hwnd, WPARAM wparam )
NtUserReleaseDC( parent, hdc ); NtUserReleaseDC( parent, hdc );
if (parent) map_window_points( 0, parent, (POINT *)&sizing_rect, 2, get_thread_dpi() ); if (parent) map_window_points( 0, parent, (POINT *)&sizing_rect, 2, get_thread_dpi() );
if (call_hooks( WH_CBT, HCBT_MOVESIZE, (WPARAM)hwnd, (LPARAM)&sizing_rect )) if (call_hooks( WH_CBT, HCBT_MOVESIZE, (WPARAM)hwnd, (LPARAM)&sizing_rect, sizeof(sizing_rect) ))
moved = FALSE; moved = FALSE;
send_message( hwnd, WM_EXITSIZEMOVE, 0, 0 ); send_message( hwnd, WM_EXITSIZEMOVE, 0, 0 );
...@@ -950,7 +950,7 @@ static LRESULT handle_sys_command( HWND hwnd, WPARAM wparam, LPARAM lparam ) ...@@ -950,7 +950,7 @@ static LRESULT handle_sys_command( HWND hwnd, WPARAM wparam, LPARAM lparam )
if (!is_window_enabled( hwnd )) return 0; if (!is_window_enabled( hwnd )) return 0;
if (call_hooks( WH_CBT, HCBT_SYSCOMMAND, wparam, lparam )) if (call_hooks( WH_CBT, HCBT_SYSCOMMAND, wparam, lparam, 0 ))
return 0; return 0;
if (!user_driver->pSysCommand( hwnd, wparam, lparam )) if (!user_driver->pSysCommand( hwnd, wparam, lparam ))
...@@ -2811,7 +2811,7 @@ LRESULT default_window_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, ...@@ -2811,7 +2811,7 @@ LRESULT default_window_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam,
{ {
HWND parent = get_parent( hwnd ); HWND parent = get_parent( hwnd );
if (!parent) if (!parent)
call_hooks( WH_SHELL, HSHELL_APPCOMMAND, wparam, lparam ); call_hooks( WH_SHELL, HSHELL_APPCOMMAND, wparam, lparam, 0 );
else else
send_message( parent, msg, wparam, lparam ); send_message( parent, msg, wparam, lparam );
break; break;
......
...@@ -179,8 +179,8 @@ BOOL WINAPI NtUserCallMsgFilter( MSG *msg, INT code ) ...@@ -179,8 +179,8 @@ BOOL WINAPI NtUserCallMsgFilter( MSG *msg, INT code )
{ {
/* FIXME: We should use NtCallbackReturn instead of passing (potentially kernel) pointer /* FIXME: We should use NtCallbackReturn instead of passing (potentially kernel) pointer
* like that, but we need to consequently use syscall thunks first for that to work. */ * like that, but we need to consequently use syscall thunks first for that to work. */
if (call_hooks( WH_SYSMSGFILTER, code, 0, (LPARAM)msg )) return TRUE; if (call_hooks( WH_SYSMSGFILTER, code, 0, (LPARAM)msg, sizeof(*msg) )) return TRUE;
return call_hooks( WH_MSGFILTER, code, 0, (LPARAM)msg ); return call_hooks( WH_MSGFILTER, code, 0, (LPARAM)msg, sizeof(*msg) );
} }
static UINT get_ll_hook_timeout(void) static UINT get_ll_hook_timeout(void)
...@@ -195,7 +195,7 @@ static UINT get_ll_hook_timeout(void) ...@@ -195,7 +195,7 @@ static UINT get_ll_hook_timeout(void)
* Call hook either in current thread or send message to the destination * Call hook either in current thread or send message to the destination
* thread. * thread.
*/ */
static LRESULT call_hook( struct win_hook_params *info ) static LRESULT call_hook( struct win_hook_params *info, const WCHAR *module )
{ {
DWORD_PTR ret = 0; DWORD_PTR ret = 0;
...@@ -231,10 +231,70 @@ static LRESULT call_hook( struct win_hook_params *info ) ...@@ -231,10 +231,70 @@ static LRESULT call_hook( struct win_hook_params *info )
struct user_thread_info *thread_info = get_user_thread_info(); struct user_thread_info *thread_info = get_user_thread_info();
HHOOK prev = thread_info->hook; HHOOK prev = thread_info->hook;
BOOL prev_unicode = thread_info->hook_unicode; BOOL prev_unicode = thread_info->hook_unicode;
size_t len = lstrlenW( info->module ); struct win_hook_params *params = info;
ULONG size = sizeof(*params);
ULONG lparam_ret_size = params->lparam_size;
CREATESTRUCTW *cs = NULL;
void *ret_ptr; void *ret_ptr;
ULONG ret_len; ULONG ret_len;
if (params->lparam_size)
{
lparam_ret_size = params->lparam_size;
if (params->id == WH_CBT && params->code == HCBT_CREATEWND)
{
cs = ((CBT_CREATEWNDW *)params->lparam)->lpcs;
params->lparam = 0;
lparam_ret_size = 0;
params->lparam_size = sizeof(*cs);
if (!IS_INTRESOURCE( cs->lpszName ))
params->lparam_size += (wcslen( cs->lpszName ) + 1) * sizeof(WCHAR);
if (!IS_INTRESOURCE( cs->lpszClass ))
params->lparam_size += (wcslen( cs->lpszClass ) + 1) * sizeof(WCHAR);
}
size += params->lparam_size;
}
if (module && module[0]) size += (lstrlenW( module ) + 1) * sizeof(WCHAR);
if (size != sizeof(*params))
{
if (!(params = malloc( size ))) return 0;
*params = *info;
}
if (params->lparam_size)
{
if (cs)
{
CREATESTRUCTW *params_cs = (CREATESTRUCTW *)(params + 1);
WCHAR *ptr = (WCHAR *)(params_cs + 1);
const void *inline_ptr = (void *)0xffffffff;
*params_cs = *cs;
if (!IS_INTRESOURCE( cs->lpszName ))
{
UINT len = wcslen( cs->lpszName ) + 1;
memcpy( ptr, cs->lpszName, len * sizeof(WCHAR) );
ptr += len;
params_cs->lpszName = inline_ptr;
}
if (!IS_INTRESOURCE( cs->lpszClass ))
{
wcscpy( ptr, cs->lpszClass );
params_cs->lpszClass = inline_ptr;
}
}
else
{
memcpy( params + 1, (const void *)params->lparam, params->lparam_size );
}
}
if (module && module[0])
wcscpy( (WCHAR *)((char *)(params + 1) + params->lparam_size), module );
/* /*
* Windows protects from stack overflow in recursive hook calls. Different Windows * Windows protects from stack overflow in recursive hook calls. Different Windows
* allow different depths. * allow different depths.
...@@ -246,18 +306,20 @@ static LRESULT call_hook( struct win_hook_params *info ) ...@@ -246,18 +306,20 @@ static LRESULT call_hook( struct win_hook_params *info )
} }
TRACE( "calling hook %p %s code %x wp %lx lp %lx module %s\n", TRACE( "calling hook %p %s code %x wp %lx lp %lx module %s\n",
info->proc, hook_names[info->id-WH_MINHOOK], info->code, info->wparam, params->proc, hook_names[params->id-WH_MINHOOK], params->code, params->wparam,
info->lparam, debugstr_w(info->module) ); params->lparam, debugstr_w(module) );
thread_info->hook = info->handle; thread_info->hook = params->handle;
thread_info->hook_unicode = info->next_unicode; thread_info->hook_unicode = params->next_unicode;
thread_info->hook_call_depth++; thread_info->hook_call_depth++;
ret = KeUserModeCallback( NtUserCallWindowsHook, info, ret = KeUserModeCallback( NtUserCallWindowsHook, params, size, &ret_ptr, &ret_len );
FIELD_OFFSET( struct win_hook_params, module[len + 1] ), if (ret_len && ret_len == lparam_ret_size)
&ret_ptr, &ret_len ); memcpy( (void *)params->lparam, ret_ptr, lparam_ret_size );
thread_info->hook = prev; thread_info->hook = prev;
thread_info->hook_unicode = prev_unicode; thread_info->hook_unicode = prev_unicode;
thread_info->hook_call_depth--; thread_info->hook_call_depth--;
if (params != info) free( params );
} }
if (info->id == WH_KEYBOARD_LL || info->id == WH_MOUSE_LL) if (info->id == WH_KEYBOARD_LL || info->id == WH_MOUSE_LL)
...@@ -272,18 +334,19 @@ LRESULT WINAPI NtUserCallNextHookEx( HHOOK hhook, INT code, WPARAM wparam, LPARA ...@@ -272,18 +334,19 @@ LRESULT WINAPI NtUserCallNextHookEx( HHOOK hhook, INT code, WPARAM wparam, LPARA
{ {
struct user_thread_info *thread_info = get_user_thread_info(); struct user_thread_info *thread_info = get_user_thread_info();
struct win_hook_params info; struct win_hook_params info;
WCHAR module[MAX_PATH];
memset( &info, 0, sizeof(info) - sizeof(info.module) ); memset( &info, 0, sizeof(info) );
SERVER_START_REQ( get_hook_info ) SERVER_START_REQ( get_hook_info )
{ {
req->handle = wine_server_user_handle( thread_info->hook ); req->handle = wine_server_user_handle( thread_info->hook );
req->get_next = 1; req->get_next = 1;
req->event = EVENT_MIN; req->event = EVENT_MIN;
wine_server_set_reply( req, info.module, sizeof(info.module)-sizeof(WCHAR) ); wine_server_set_reply( req, module, sizeof(module) - sizeof(WCHAR) );
if (!wine_server_call_err( req )) if (!wine_server_call_err( req ))
{ {
info.module[wine_server_reply_size(req) / sizeof(WCHAR)] = 0; module[wine_server_reply_size(req) / sizeof(WCHAR)] = 0;
info.handle = wine_server_ptr_handle( reply->handle ); info.handle = wine_server_ptr_handle( reply->handle );
info.id = reply->id; info.id = reply->id;
info.pid = reply->pid; info.pid = reply->pid;
...@@ -298,24 +361,25 @@ LRESULT WINAPI NtUserCallNextHookEx( HHOOK hhook, INT code, WPARAM wparam, LPARA ...@@ -298,24 +361,25 @@ LRESULT WINAPI NtUserCallNextHookEx( HHOOK hhook, INT code, WPARAM wparam, LPARA
info.wparam = wparam; info.wparam = wparam;
info.lparam = lparam; info.lparam = lparam;
info.prev_unicode = thread_info->hook_unicode; info.prev_unicode = thread_info->hook_unicode;
return call_hook( &info ); return call_hook( &info, module );
} }
LRESULT call_current_hook( HHOOK hhook, INT code, WPARAM wparam, LPARAM lparam ) LRESULT call_current_hook( HHOOK hhook, INT code, WPARAM wparam, LPARAM lparam )
{ {
struct win_hook_params info; struct win_hook_params info;
WCHAR module[MAX_PATH];
memset( &info, 0, sizeof(info) - sizeof(info.module) ); memset( &info, 0, sizeof(info) );
SERVER_START_REQ( get_hook_info ) SERVER_START_REQ( get_hook_info )
{ {
req->handle = wine_server_user_handle( hhook ); req->handle = wine_server_user_handle( hhook );
req->get_next = 0; req->get_next = 0;
req->event = EVENT_MIN; req->event = EVENT_MIN;
wine_server_set_reply( req, info.module, sizeof(info.module)-sizeof(WCHAR) ); wine_server_set_reply( req, module, sizeof(module) );
if (!wine_server_call_err( req )) if (!wine_server_call_err( req ))
{ {
info.module[wine_server_reply_size(req) / sizeof(WCHAR)] = 0; module[wine_server_reply_size(req) / sizeof(WCHAR)] = 0;
info.handle = wine_server_ptr_handle( reply->handle ); info.handle = wine_server_ptr_handle( reply->handle );
info.id = reply->id; info.id = reply->id;
info.pid = reply->pid; info.pid = reply->pid;
...@@ -330,13 +394,14 @@ LRESULT call_current_hook( HHOOK hhook, INT code, WPARAM wparam, LPARAM lparam ) ...@@ -330,13 +394,14 @@ LRESULT call_current_hook( HHOOK hhook, INT code, WPARAM wparam, LPARAM lparam )
info.wparam = wparam; info.wparam = wparam;
info.lparam = lparam; info.lparam = lparam;
info.prev_unicode = TRUE; /* assume Unicode for this function */ info.prev_unicode = TRUE; /* assume Unicode for this function */
return call_hook( &info ); return call_hook( &info, module );
} }
LRESULT call_hooks( INT id, INT code, WPARAM wparam, LPARAM lparam ) LRESULT call_hooks( INT id, INT code, WPARAM wparam, LPARAM lparam, size_t lparam_size )
{ {
struct user_thread_info *thread_info = get_user_thread_info(); struct user_thread_info *thread_info = get_user_thread_info();
struct win_hook_params info; struct win_hook_params info;
WCHAR module[MAX_PATH];
DWORD_PTR ret; DWORD_PTR ret;
user_check_not_lock(); user_check_not_lock();
...@@ -347,7 +412,7 @@ LRESULT call_hooks( INT id, INT code, WPARAM wparam, LPARAM lparam ) ...@@ -347,7 +412,7 @@ LRESULT call_hooks( INT id, INT code, WPARAM wparam, LPARAM lparam )
return 0; return 0;
} }
memset( &info, 0, sizeof(info) - sizeof(info.module) ); memset( &info, 0, sizeof(info) );
info.prev_unicode = TRUE; info.prev_unicode = TRUE;
info.id = id; info.id = id;
...@@ -355,10 +420,10 @@ LRESULT call_hooks( INT id, INT code, WPARAM wparam, LPARAM lparam ) ...@@ -355,10 +420,10 @@ LRESULT call_hooks( INT id, INT code, WPARAM wparam, LPARAM lparam )
{ {
req->id = info.id; req->id = info.id;
req->event = EVENT_MIN; req->event = EVENT_MIN;
wine_server_set_reply( req, info.module, sizeof(info.module)-sizeof(WCHAR) ); wine_server_set_reply( req, module, sizeof(module)-sizeof(WCHAR) );
if (!wine_server_call( req )) if (!wine_server_call( req ))
{ {
info.module[wine_server_reply_size(req) / sizeof(WCHAR)] = 0; module[wine_server_reply_size(req) / sizeof(WCHAR)] = 0;
info.handle = wine_server_ptr_handle( reply->handle ); info.handle = wine_server_ptr_handle( reply->handle );
info.pid = reply->pid; info.pid = reply->pid;
info.tid = reply->tid; info.tid = reply->tid;
...@@ -373,7 +438,8 @@ LRESULT call_hooks( INT id, INT code, WPARAM wparam, LPARAM lparam ) ...@@ -373,7 +438,8 @@ LRESULT call_hooks( INT id, INT code, WPARAM wparam, LPARAM lparam )
info.code = code; info.code = code;
info.wparam = wparam; info.wparam = wparam;
info.lparam = lparam; info.lparam = lparam;
ret = call_hook( &info ); info.lparam_size = lparam_size;
ret = call_hook( &info, module );
SERVER_START_REQ( finish_hook_chain ) SERVER_START_REQ( finish_hook_chain )
{ {
...@@ -514,7 +580,7 @@ void WINAPI NtUserNotifyWinEvent( DWORD event, HWND hwnd, LONG object_id, LONG c ...@@ -514,7 +580,7 @@ void WINAPI NtUserNotifyWinEvent( DWORD event, HWND hwnd, LONG object_id, LONG c
info.time = NtGetTickCount(); info.time = NtGetTickCount();
KeUserModeCallback( NtUserCallWinEventHook, &info, KeUserModeCallback( NtUserCallWinEventHook, &info,
FIELD_OFFSET( struct win_hook_params, module[lstrlenW(info.module) + 1] ), FIELD_OFFSET( struct win_event_hook_params, module[lstrlenW(info.module) + 1] ),
&ret_ptr, &ret_len ); &ret_ptr, &ret_len );
SERVER_START_REQ( get_hook_info ) SERVER_START_REQ( get_hook_info )
......
...@@ -1611,7 +1611,7 @@ static BOOL set_active_window( HWND hwnd, HWND *prev, BOOL mouse, BOOL focus ) ...@@ -1611,7 +1611,7 @@ static BOOL set_active_window( HWND hwnd, HWND *prev, BOOL mouse, BOOL focus )
/* call CBT hook chain */ /* call CBT hook chain */
cbt.fMouse = mouse; cbt.fMouse = mouse;
cbt.hWndActive = previous; cbt.hWndActive = previous;
if (call_hooks( WH_CBT, HCBT_ACTIVATE, (WPARAM)hwnd, (LPARAM)&cbt )) return FALSE; if (call_hooks( WH_CBT, HCBT_ACTIVATE, (WPARAM)hwnd, (LPARAM)&cbt, sizeof(cbt) )) return FALSE;
if (is_window( previous )) if (is_window( previous ))
{ {
...@@ -1763,7 +1763,7 @@ HWND WINAPI NtUserSetFocus( HWND hwnd ) ...@@ -1763,7 +1763,7 @@ HWND WINAPI NtUserSetFocus( HWND hwnd )
} }
/* call hooks */ /* call hooks */
if (call_hooks( WH_CBT, HCBT_SETFOCUS, (WPARAM)hwnd, (LPARAM)previous )) return 0; if (call_hooks( WH_CBT, HCBT_SETFOCUS, (WPARAM)hwnd, (LPARAM)previous, 0 )) return 0;
/* activate hwndTop if needed. */ /* activate hwndTop if needed. */
if (hwndTop != get_active_window()) if (hwndTop != get_active_window())
...@@ -1778,7 +1778,7 @@ HWND WINAPI NtUserSetFocus( HWND hwnd ) ...@@ -1778,7 +1778,7 @@ HWND WINAPI NtUserSetFocus( HWND hwnd )
else /* NULL hwnd passed in */ else /* NULL hwnd passed in */
{ {
if (!previous) return 0; /* nothing to do */ if (!previous) return 0; /* nothing to do */
if (call_hooks( WH_CBT, HCBT_SETFOCUS, 0, (LPARAM)previous )) return 0; if (call_hooks( WH_CBT, HCBT_SETFOCUS, 0, (LPARAM)previous, 0 )) return 0;
} }
/* change focus and send messages */ /* change focus and send messages */
......
...@@ -1365,7 +1365,7 @@ static LRESULT call_window_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpar ...@@ -1365,7 +1365,7 @@ static LRESULT call_window_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpar
cwp.wParam = wparam; cwp.wParam = wparam;
cwp.message = msg; cwp.message = msg;
cwp.hwnd = params->hwnd; cwp.hwnd = params->hwnd;
call_hooks( WH_CALLWNDPROC, HC_ACTION, same_thread, (LPARAM)&cwp ); call_hooks( WH_CALLWNDPROC, HC_ACTION, same_thread, (LPARAM)&cwp, sizeof(cwp) );
dispatch_win_proc_params( params, sizeof(*params) + size ); dispatch_win_proc_params( params, sizeof(*params) + size );
if (params != &p) free( params ); if (params != &p) free( params );
...@@ -1376,7 +1376,7 @@ static LRESULT call_window_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpar ...@@ -1376,7 +1376,7 @@ static LRESULT call_window_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpar
cwpret.wParam = wparam; cwpret.wParam = wparam;
cwpret.message = msg; cwpret.message = msg;
cwpret.hwnd = params->hwnd; cwpret.hwnd = params->hwnd;
call_hooks( WH_CALLWNDPROCRET, HC_ACTION, same_thread, (LPARAM)&cwpret ); call_hooks( WH_CALLWNDPROCRET, HC_ACTION, same_thread, (LPARAM)&cwpret, sizeof(cwpret) );
return result; return result;
} }
...@@ -1483,7 +1483,7 @@ static BOOL process_keyboard_message( MSG *msg, UINT hw_id, HWND hwnd_filter, ...@@ -1483,7 +1483,7 @@ static BOOL process_keyboard_message( MSG *msg, UINT hw_id, HWND hwnd_filter,
event.paramL = (msg->wParam & 0xFF) | (HIWORD(msg->lParam) << 8); event.paramL = (msg->wParam & 0xFF) | (HIWORD(msg->lParam) << 8);
event.paramH = msg->lParam & 0x7FFF; event.paramH = msg->lParam & 0x7FFF;
if (HIWORD(msg->lParam) & 0x0100) event.paramH |= 0x8000; /* special_key - bit */ if (HIWORD(msg->lParam) & 0x0100) event.paramH |= 0x8000; /* special_key - bit */
call_hooks( WH_JOURNALRECORD, HC_ACTION, 0, (LPARAM)&event ); call_hooks( WH_JOURNALRECORD, HC_ACTION, 0, (LPARAM)&event, sizeof(event) );
/* check message filters */ /* check message filters */
if (msg->message < first || msg->message > last) return FALSE; if (msg->message < first || msg->message > last) return FALSE;
...@@ -1516,10 +1516,10 @@ static BOOL process_keyboard_message( MSG *msg, UINT hw_id, HWND hwnd_filter, ...@@ -1516,10 +1516,10 @@ static BOOL process_keyboard_message( MSG *msg, UINT hw_id, HWND hwnd_filter,
} }
if (call_hooks( WH_KEYBOARD, remove ? HC_ACTION : HC_NOREMOVE, if (call_hooks( WH_KEYBOARD, remove ? HC_ACTION : HC_NOREMOVE,
LOWORD(msg->wParam), msg->lParam )) LOWORD(msg->wParam), msg->lParam, 0 ))
{ {
/* skip this message */ /* skip this message */
call_hooks( WH_CBT, HCBT_KEYSKIPPED, LOWORD(msg->wParam), msg->lParam ); call_hooks( WH_CBT, HCBT_KEYSKIPPED, LOWORD(msg->wParam), msg->lParam, 0 );
accept_hardware_message( hw_id ); accept_hardware_message( hw_id );
return FALSE; return FALSE;
} }
...@@ -1591,7 +1591,7 @@ static BOOL process_mouse_message( MSG *msg, UINT hw_id, ULONG_PTR extra_info, H ...@@ -1591,7 +1591,7 @@ static BOOL process_mouse_message( MSG *msg, UINT hw_id, ULONG_PTR extra_info, H
event.hwnd = msg->hwnd; event.hwnd = msg->hwnd;
event.paramL = msg->pt.x; event.paramL = msg->pt.x;
event.paramH = msg->pt.y; event.paramH = msg->pt.y;
call_hooks( WH_JOURNALRECORD, HC_ACTION, 0, (LPARAM)&event ); call_hooks( WH_JOURNALRECORD, HC_ACTION, 0, (LPARAM)&event, sizeof(event) );
if (!check_hwnd_filter( msg, hwnd_filter )) return FALSE; if (!check_hwnd_filter( msg, hwnd_filter )) return FALSE;
...@@ -1665,14 +1665,14 @@ static BOOL process_mouse_message( MSG *msg, UINT hw_id, ULONG_PTR extra_info, H ...@@ -1665,14 +1665,14 @@ static BOOL process_mouse_message( MSG *msg, UINT hw_id, ULONG_PTR extra_info, H
hook.wHitTestCode = hittest; hook.wHitTestCode = hittest;
hook.dwExtraInfo = extra_info; hook.dwExtraInfo = extra_info;
hook.mouseData = msg->wParam; hook.mouseData = msg->wParam;
if (call_hooks( WH_MOUSE, remove ? HC_ACTION : HC_NOREMOVE, message, (LPARAM)&hook )) if (call_hooks( WH_MOUSE, remove ? HC_ACTION : HC_NOREMOVE, message, (LPARAM)&hook, sizeof(hook) ))
{ {
hook.pt = msg->pt; hook.pt = msg->pt;
hook.hwnd = msg->hwnd; hook.hwnd = msg->hwnd;
hook.wHitTestCode = hittest; hook.wHitTestCode = hittest;
hook.dwExtraInfo = extra_info; hook.dwExtraInfo = extra_info;
hook.mouseData = msg->wParam; hook.mouseData = msg->wParam;
call_hooks( WH_CBT, HCBT_CLICKSKIPPED, message, (LPARAM)&hook ); call_hooks( WH_CBT, HCBT_CLICKSKIPPED, message, (LPARAM)&hook, sizeof(hook) );
accept_hardware_message( hw_id ); accept_hardware_message( hw_id );
return FALSE; return FALSE;
} }
...@@ -1896,7 +1896,7 @@ static int peek_message( MSG *msg, HWND hwnd, UINT first, UINT last, UINT flags, ...@@ -1896,7 +1896,7 @@ static int peek_message( MSG *msg, HWND hwnd, UINT first, UINT last, UINT flags,
memcpy( params.module, &msg_data->winevent + 1, size ); memcpy( params.module, &msg_data->winevent + 1, size );
} }
params.module[size / sizeof(WCHAR)] = 0; params.module[size / sizeof(WCHAR)] = 0;
size = FIELD_OFFSET( struct win_hook_params, module[size / sizeof(WCHAR) + 1] ); size = FIELD_OFFSET( struct win_event_hook_params, module[size / sizeof(WCHAR) + 1] );
params.handle = wine_server_ptr_handle( msg_data->winevent.hook ); params.handle = wine_server_ptr_handle( msg_data->winevent.hook );
params.event = info.msg.message; params.event = info.msg.message;
...@@ -1923,7 +1923,8 @@ static int peek_message( MSG *msg, HWND hwnd, UINT first, UINT last, UINT flags, ...@@ -1923,7 +1923,8 @@ static int peek_message( MSG *msg, HWND hwnd, UINT first, UINT last, UINT flags,
hook.dwExtraInfo = msg_data->hardware.info; hook.dwExtraInfo = msg_data->hardware.info;
TRACE( "calling keyboard LL hook vk %x scan %x flags %x time %u info %lx\n", TRACE( "calling keyboard LL hook vk %x scan %x flags %x time %u info %lx\n",
hook.vkCode, hook.scanCode, hook.flags, hook.time, hook.dwExtraInfo ); hook.vkCode, hook.scanCode, hook.flags, hook.time, hook.dwExtraInfo );
result = call_hooks( WH_KEYBOARD_LL, HC_ACTION, info.msg.wParam, (LPARAM)&hook ); result = call_hooks( WH_KEYBOARD_LL, HC_ACTION, info.msg.wParam,
(LPARAM)&hook, sizeof(hook) );
} }
else if (info.msg.message == WH_MOUSE_LL && size >= sizeof(msg_data->hardware)) else if (info.msg.message == WH_MOUSE_LL && size >= sizeof(msg_data->hardware))
{ {
...@@ -1936,7 +1937,8 @@ static int peek_message( MSG *msg, HWND hwnd, UINT first, UINT last, UINT flags, ...@@ -1936,7 +1937,8 @@ static int peek_message( MSG *msg, HWND hwnd, UINT first, UINT last, UINT flags,
hook.dwExtraInfo = msg_data->hardware.info; hook.dwExtraInfo = msg_data->hardware.info;
TRACE( "calling mouse LL hook pos %d,%d data %x flags %x time %u info %lx\n", TRACE( "calling mouse LL hook pos %d,%d data %x flags %x time %u info %lx\n",
hook.pt.x, hook.pt.y, hook.mouseData, hook.flags, hook.time, hook.dwExtraInfo ); hook.pt.x, hook.pt.y, hook.mouseData, hook.flags, hook.time, hook.dwExtraInfo );
result = call_hooks( WH_MOUSE_LL, HC_ACTION, info.msg.wParam, (LPARAM)&hook ); result = call_hooks( WH_MOUSE_LL, HC_ACTION, info.msg.wParam,
(LPARAM)&hook, sizeof(hook) );
} }
reply_message( &info, result, &info.msg ); reply_message( &info, result, &info.msg );
continue; continue;
...@@ -1966,7 +1968,7 @@ static int peek_message( MSG *msg, HWND hwnd, UINT first, UINT last, UINT flags, ...@@ -1966,7 +1968,7 @@ static int peek_message( MSG *msg, HWND hwnd, UINT first, UINT last, UINT flags,
thread_info->client_info.message_time = info.msg.time; thread_info->client_info.message_time = info.msg.time;
thread_info->client_info.message_extra = msg_data->hardware.info; thread_info->client_info.message_extra = msg_data->hardware.info;
free( buffer ); free( buffer );
call_hooks( WH_GETMESSAGE, HC_ACTION, flags & PM_REMOVE, (LPARAM)msg ); call_hooks( WH_GETMESSAGE, HC_ACTION, flags & PM_REMOVE, (LPARAM)msg, sizeof(*msg) );
return 1; return 1;
} }
continue; continue;
...@@ -2019,7 +2021,7 @@ static int peek_message( MSG *msg, HWND hwnd, UINT first, UINT last, UINT flags, ...@@ -2019,7 +2021,7 @@ static int peek_message( MSG *msg, HWND hwnd, UINT first, UINT last, UINT flags,
thread_info->client_info.message_extra = 0; thread_info->client_info.message_extra = 0;
thread_info->client_info.msg_source = msg_source_unavailable; thread_info->client_info.msg_source = msg_source_unavailable;
free( buffer ); free( buffer );
call_hooks( WH_GETMESSAGE, HC_ACTION, flags & PM_REMOVE, (LPARAM)msg ); call_hooks( WH_GETMESSAGE, HC_ACTION, flags & PM_REMOVE, (LPARAM)msg, sizeof(*msg) );
return 1; return 1;
} }
......
...@@ -618,7 +618,6 @@ static void test_message_filter(void) ...@@ -618,7 +618,6 @@ static void test_message_filter(void)
msg.lParam = 20; msg.lParam = 20;
ret = NtUserCallMsgFilter( &msg, 100 ); ret = NtUserCallMsgFilter( &msg, 100 );
ok( !ret, "CallMsgFilterW returned: %x\n", ret ); ok( !ret, "CallMsgFilterW returned: %x\n", ret );
todo_wine
ok( msg_ptr != &msg, "our ptr was passed directly to hook\n" ); ok( msg_ptr != &msg, "our ptr was passed directly to hook\n" );
if (sizeof(void *) == 8) /* on some Windows versions, msg is not modified on wow64 */ if (sizeof(void *) == 8) /* on some Windows versions, msg is not modified on wow64 */
......
...@@ -251,7 +251,8 @@ extern LRESULT handle_nc_hit_test( HWND hwnd, POINT pt ) DECLSPEC_HIDDEN; ...@@ -251,7 +251,8 @@ extern LRESULT handle_nc_hit_test( HWND hwnd, POINT pt ) DECLSPEC_HIDDEN;
/* hook.c */ /* hook.c */
extern LRESULT call_current_hook( HHOOK hhook, INT code, WPARAM wparam, LPARAM lparam ) DECLSPEC_HIDDEN; extern LRESULT call_current_hook( HHOOK hhook, INT code, WPARAM wparam, LPARAM lparam ) DECLSPEC_HIDDEN;
extern LRESULT call_hooks( INT id, INT code, WPARAM wparam, LPARAM lparam ) DECLSPEC_HIDDEN; extern LRESULT call_hooks( INT id, INT code, WPARAM wparam, LPARAM lparam,
size_t lparam_size ) DECLSPEC_HIDDEN;
extern BOOL is_hooked( INT id ) DECLSPEC_HIDDEN; extern BOOL is_hooked( INT id ) DECLSPEC_HIDDEN;
extern BOOL unhook_windows_hook( INT id, HOOKPROC proc ) DECLSPEC_HIDDEN; extern BOOL unhook_windows_hook( INT id, HOOKPROC proc ) DECLSPEC_HIDDEN;
......
...@@ -4040,7 +4040,7 @@ static UINT window_min_maximize( HWND hwnd, UINT cmd, RECT *rect ) ...@@ -4040,7 +4040,7 @@ static UINT window_min_maximize( HWND hwnd, UINT cmd, RECT *rect )
wpl.length = sizeof(wpl); wpl.length = sizeof(wpl);
NtUserGetWindowPlacement( hwnd, &wpl ); NtUserGetWindowPlacement( hwnd, &wpl );
if (call_hooks( WH_CBT, HCBT_MINMAX, (WPARAM)hwnd, cmd )) if (call_hooks( WH_CBT, HCBT_MINMAX, (WPARAM)hwnd, cmd, 0 ))
return SWP_NOSIZE | SWP_NOMOVE; return SWP_NOSIZE | SWP_NOMOVE;
if (is_iconic( hwnd )) if (is_iconic( hwnd ))
...@@ -4752,7 +4752,7 @@ BOOL WINAPI NtUserDestroyWindow( HWND hwnd ) ...@@ -4752,7 +4752,7 @@ BOOL WINAPI NtUserDestroyWindow( HWND hwnd )
TRACE( "(%p)\n", hwnd ); TRACE( "(%p)\n", hwnd );
if (call_hooks( WH_CBT, HCBT_DESTROYWND, (WPARAM)hwnd, 0 )) return FALSE; if (call_hooks( WH_CBT, HCBT_DESTROYWND, (WPARAM)hwnd, 0, 0 )) return FALSE;
if (is_menu_active() == hwnd) NtUserEndMenu(); if (is_menu_active() == hwnd) NtUserEndMenu();
...@@ -4765,7 +4765,7 @@ BOOL WINAPI NtUserDestroyWindow( HWND hwnd ) ...@@ -4765,7 +4765,7 @@ BOOL WINAPI NtUserDestroyWindow( HWND hwnd )
} }
else if (!get_window_relative( hwnd, GW_OWNER )) else if (!get_window_relative( hwnd, GW_OWNER ))
{ {
call_hooks( WH_SHELL, HSHELL_WINDOWDESTROYED, (WPARAM)hwnd, 0 ); call_hooks( WH_SHELL, HSHELL_WINDOWDESTROYED, (WPARAM)hwnd, 0, 0 );
/* FIXME: clean up palette - see "Internals" p.352 */ /* FIXME: clean up palette - see "Internals" p.352 */
} }
...@@ -5154,7 +5154,7 @@ HWND WINAPI NtUserCreateWindowEx( DWORD ex_style, UNICODE_STRING *class_name, ...@@ -5154,7 +5154,7 @@ HWND WINAPI NtUserCreateWindowEx( DWORD ex_style, UNICODE_STRING *class_name,
release_win_ptr( win ); release_win_ptr( win );
cbtc.hwndInsertAfter = HWND_TOP; cbtc.hwndInsertAfter = HWND_TOP;
cbtc.lpcs = &cs; cbtc.lpcs = &cs;
if (call_hooks( WH_CBT, HCBT_CREATEWND, (WPARAM)hwnd, (LPARAM)&cbtc )) if (call_hooks( WH_CBT, HCBT_CREATEWND, (WPARAM)hwnd, (LPARAM)&cbtc, sizeof(cbtc) ))
{ {
free_window_handle( hwnd ); free_window_handle( hwnd );
return 0; return 0;
...@@ -5334,7 +5334,7 @@ HWND WINAPI NtUserCreateWindowEx( DWORD ex_style, UNICODE_STRING *class_name, ...@@ -5334,7 +5334,7 @@ HWND WINAPI NtUserCreateWindowEx( DWORD ex_style, UNICODE_STRING *class_name,
/* Call WH_SHELL hook */ /* Call WH_SHELL hook */
if (!(get_window_long( hwnd, GWL_STYLE ) & WS_CHILD) && !get_window_relative( hwnd, GW_OWNER )) if (!(get_window_long( hwnd, GWL_STYLE ) & WS_CHILD) && !get_window_relative( hwnd, GW_OWNER ))
call_hooks( WH_SHELL, HSHELL_WINDOWCREATED, (WPARAM)hwnd, 0 ); call_hooks( WH_SHELL, HSHELL_WINDOWCREATED, (WPARAM)hwnd, 0, 0 );
TRACE( "created window %p\n", hwnd ); TRACE( "created window %p\n", hwnd );
SetThreadDpiAwarenessContext( context ); SetThreadDpiAwarenessContext( context );
......
...@@ -164,9 +164,9 @@ struct win_hook_params ...@@ -164,9 +164,9 @@ struct win_hook_params
int code; int code;
WPARAM wparam; WPARAM wparam;
LPARAM lparam; LPARAM lparam;
UINT lparam_size;
BOOL prev_unicode; BOOL prev_unicode;
BOOL next_unicode; BOOL next_unicode;
WCHAR module[MAX_PATH];
}; };
/* NtUserCopyImage params */ /* NtUserCopyImage params */
......
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