Jacek Caban : win32u: Move UnhookWindowsHook implementation from user32.
Alexandre Julliard
julliard at winehq.org
Wed Feb 16 15:30:25 CST 2022
Module: wine
Branch: master
Commit: 8714eb2fef7182a9c73b9963493935decca89fdc
URL: https://source.winehq.org/git/wine.git/?a=commit;h=8714eb2fef7182a9c73b9963493935decca89fdc
Author: Jacek Caban <jacek at codeweavers.com>
Date: Wed Feb 16 12:31:17 2022 +0100
win32u: Move UnhookWindowsHook implementation from user32.
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/user32/hook.c | 16 +---------------
dlls/win32u/hook.c | 28 +++++++++++++++++++++++++++-
dlls/win32u/sysparams.c | 2 ++
dlls/win32u/win32u_private.h | 3 +++
include/ntuser.h | 1 +
5 files changed, 34 insertions(+), 16 deletions(-)
diff --git a/dlls/user32/hook.c b/dlls/user32/hook.c
index 7a9cff63298..1ccd69f5a98 100644
--- a/dlls/user32/hook.c
+++ b/dlls/user32/hook.c
@@ -520,21 +520,7 @@ HHOOK WINAPI SetWindowsHookExW( INT id, HOOKPROC proc, HINSTANCE inst, DWORD tid
*/
BOOL WINAPI UnhookWindowsHook( INT id, HOOKPROC proc )
{
- BOOL ret;
-
- TRACE( "%s %p\n", hook_names[id-WH_MINHOOK], proc );
-
- SERVER_START_REQ( remove_hook )
- {
- req->handle = 0;
- req->id = id;
- req->proc = wine_server_client_ptr( proc );
- ret = !wine_server_call_err( req );
- if (ret) get_user_thread_info()->active_hooks = reply->active_hooks;
- }
- SERVER_END_REQ;
- if (!ret && GetLastError() == ERROR_INVALID_HANDLE) SetLastError( ERROR_INVALID_HOOK_HANDLE );
- return ret;
+ return NtUserCallTwoParam( id, (UINT_PTR)proc, NtUserUnhookWindowsHook );
}
diff --git a/dlls/win32u/hook.c b/dlls/win32u/hook.c
index b7630a14f16..b390676fc60 100644
--- a/dlls/win32u/hook.c
+++ b/dlls/win32u/hook.c
@@ -53,6 +53,12 @@ static const char * const hook_names[WH_WINEVENT - WH_MINHOOK + 1] =
"WH_WINEVENT"
};
+static const char *debugstr_hook_id( unsigned int id )
+{
+ if (id - WH_MINHOOK >= ARRAYSIZE(hook_names)) return wine_dbg_sprintf( "%u", id );
+ return hook_names[id - WH_MINHOOK];
+}
+
static BOOL is_hooked( INT id )
{
struct user_thread_info *thread_info = get_user_thread_info();
@@ -122,7 +128,7 @@ HHOOK WINAPI NtUserSetWindowsHookEx( HINSTANCE inst, UNICODE_STRING *module, DWO
}
SERVER_END_REQ;
- TRACE( "%s %p %x -> %p\n", hook_names[id - WH_MINHOOK], proc, tid, handle );
+ TRACE( "%s %p %x -> %p\n", debugstr_hook_id(id), proc, tid, handle );
return handle;
}
@@ -145,6 +151,26 @@ BOOL WINAPI NtUserUnhookWindowsHookEx( HHOOK handle )
return !status;
}
+/* see UnhookWindowsHook */
+BOOL unhook_windows_hook( INT id, HOOKPROC proc )
+{
+ NTSTATUS status;
+
+ TRACE( "%s %p\n", debugstr_hook_id(id), proc );
+
+ SERVER_START_REQ( remove_hook )
+ {
+ req->handle = 0;
+ req->id = id;
+ req->proc = wine_server_client_ptr( proc );
+ status = wine_server_call_err( req );
+ if (!status) get_user_thread_info()->active_hooks = reply->active_hooks;
+ }
+ SERVER_END_REQ;
+ if (status == STATUS_INVALID_HANDLE) SetLastError( ERROR_INVALID_HOOK_HANDLE );
+ return !status;
+}
+
/***********************************************************************
* NtUserSetWinEventHook (win32u.@)
*/
diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c
index 93fda23a31e..c9885f89d87 100644
--- a/dlls/win32u/sysparams.c
+++ b/dlls/win32u/sysparams.c
@@ -4565,6 +4565,8 @@ ULONG_PTR WINAPI NtUserCallTwoParam( ULONG_PTR arg1, ULONG_PTR arg2, ULONG code
return mirror_window_region( UlongToHandle(arg1), UlongToHandle(arg2) );
case NtUserMonitorFromRect:
return HandleToUlong( monitor_from_rect( (const RECT *)arg1, arg2, get_thread_dpi() ));
+ case NtUserUnhookWindowsHook:
+ return unhook_windows_hook( arg1, (HOOKPROC)arg2 );
/* temporary exports */
case NtUserRegisterWindowSurface:
register_window_surface( (struct window_surface *)arg1, (struct window_surface *)arg2 );
diff --git a/dlls/win32u/win32u_private.h b/dlls/win32u/win32u_private.h
index c099a8c8c4d..c3419d83858 100644
--- a/dlls/win32u/win32u_private.h
+++ b/dlls/win32u/win32u_private.h
@@ -248,6 +248,9 @@ struct unix_funcs
/* cursoricon.c */
extern BOOL get_clip_cursor( RECT *rect ) DECLSPEC_HIDDEN;
+/* hook.c */
+extern BOOL unhook_windows_hook( INT id, HOOKPROC proc ) DECLSPEC_HIDDEN;
+
/* input.c */
extern LONG global_key_state_counter DECLSPEC_HIDDEN;
extern BOOL get_cursor_pos( POINT *pt ) DECLSPEC_HIDDEN;
diff --git a/include/ntuser.h b/include/ntuser.h
index 14ff5d861d0..6e4183b1e14 100644
--- a/include/ntuser.h
+++ b/include/ntuser.h
@@ -94,6 +94,7 @@ enum
NtUserGetSystemMetricsForDpi,
NtUserMirrorRgn,
NtUserMonitorFromRect,
+ NtUserUnhookWindowsHook,
/* temporary exports */
NtUserRegisterWindowSurface,
};
More information about the wine-cvs
mailing list