Skip to content

Commit

Permalink
user32: Remove hooks that time out.
Browse files Browse the repository at this point in the history
In accordance with Win7+ behaviour.
  • Loading branch information
zfigura authored and aeikum committed Oct 13, 2020
1 parent e93ae14 commit 5d0bdb1
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions dlls/user32/hook.c
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ void *get_hook_proc( void *proc, const WCHAR *module, HMODULE *free_module )
static LRESULT call_hook( struct hook_info *info, INT code, WPARAM wparam, LPARAM lparam )
{
DWORD_PTR ret = 0;
LRESULT lres;

if (info->tid)
{
Expand All @@ -395,20 +396,24 @@ static LRESULT call_hook( struct hook_info *info, INT code, WPARAM wparam, LPARA
switch(info->id)
{
case WH_KEYBOARD_LL:
MSG_SendInternalMessageTimeout( info->pid, info->tid, WM_WINE_KEYBOARD_LL_HOOK,
wparam, (LPARAM)&h_extra, SMTO_ABORTIFHUNG,
get_ll_hook_timeout(), &ret );
lres = MSG_SendInternalMessageTimeout( info->pid, info->tid, WM_WINE_KEYBOARD_LL_HOOK,
wparam, (LPARAM)&h_extra, SMTO_ABORTIFHUNG, get_ll_hook_timeout(), &ret );
break;
case WH_MOUSE_LL:
MSG_SendInternalMessageTimeout( info->pid, info->tid, WM_WINE_MOUSE_LL_HOOK,
wparam, (LPARAM)&h_extra, SMTO_ABORTIFHUNG,
get_ll_hook_timeout(), &ret );
lres = MSG_SendInternalMessageTimeout( info->pid, info->tid, WM_WINE_MOUSE_LL_HOOK,
wparam, (LPARAM)&h_extra, SMTO_ABORTIFHUNG, get_ll_hook_timeout(), &ret );
break;
default:
ERR("Unknown hook id %d\n", info->id);
assert(0);
break;
}

if (!lres && GetLastError() == ERROR_TIMEOUT)
{
TRACE("Hook %p timed out; removing it.\n", info->handle);
UnhookWindowsHookEx( info->handle );
}
}
else if (info->proc)
{
Expand Down

0 comments on commit 5d0bdb1

Please sign in to comment.