-- v3: server: Remove now unnecessary active_hooks from replies. win32u: Remove now unnecessary thread info active_hooks cache. win32u: Read the active hooks count from the shared memory. server: Update the active hooks bitmaps when hooks are added / removed. server: Move hooks struct initialization within add_hook. server: Keep a reference on the desktop the hook are registered for. server: Create a thread message queue shared mapping.
From: Rémi Bernon rbernon@codeweavers.com
--- server/protocol.def | 6 ++++++ server/queue.c | 8 ++++++++ 2 files changed, 14 insertions(+)
diff --git a/server/protocol.def b/server/protocol.def index 11539654dc3..97b4805c552 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -913,9 +913,15 @@ typedef volatile struct unsigned char keystate[256]; /* asynchronous key state */ } desktop_shm_t;
+typedef volatile struct +{ + int placeholder; +} queue_shm_t; + typedef volatile union { desktop_shm_t desktop; + queue_shm_t queue; } object_shm_t;
typedef volatile struct diff --git a/server/queue.c b/server/queue.c index a7814c83737..5f4e5fa33c2 100644 --- a/server/queue.c +++ b/server/queue.c @@ -146,6 +146,7 @@ struct msg_queue struct hook_table *hooks; /* hook table */ timeout_t last_get_msg; /* time of last get message call */ int keystate_lock; /* owns an input keystate lock */ + const queue_shm_t *shared; /* queue in session shared memory */ };
struct hotkey @@ -321,6 +322,12 @@ static struct msg_queue *create_msg_queue( struct thread *thread, struct thread_ list_init( &queue->expired_timers ); for (i = 0; i < NB_MSG_KINDS; i++) list_init( &queue->msg_list[i] );
+ if (!(queue->shared = alloc_shared_object())) + { + release_object( queue ); + return NULL; + } + thread->queue = queue; } if (new_input) release_object( new_input ); @@ -1210,6 +1217,7 @@ static void msg_queue_destroy( struct object *obj ) release_object( queue->input ); if (queue->hooks) release_object( queue->hooks ); if (queue->fd) release_object( queue->fd ); + if (queue->shared) free_shared_object( queue->shared ); }
static void msg_queue_poll_event( struct fd *fd, int event )
From: Rémi Bernon rbernon@codeweavers.com
--- server/hook.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/server/hook.c b/server/hook.c index c22e3748b8b..140f2ba5a90 100644 --- a/server/hook.c +++ b/server/hook.c @@ -43,6 +43,7 @@ struct hook { struct list chain; /* hook chain entry */ user_handle_t handle; /* user handle for this hook */ + struct desktop *desktop; /* desktop the hook is registered for */ struct process *process; /* process the hook is set to */ struct thread *thread; /* thread the hook is set to */ struct thread *owner; /* owner of the out of context hook */ @@ -145,6 +146,7 @@ static struct hook *add_hook( struct desktop *desktop, struct thread *thread, in free( hook ); return NULL; } + hook->desktop = (struct desktop *)grab_object( desktop ); hook->thread = thread ? (struct thread *)grab_object( thread ) : NULL; hook->table = table; hook->index = index; @@ -165,6 +167,7 @@ static void free_hook( struct hook *hook ) release_object( hook->thread ); } if (hook->process) release_object( hook->process ); + release_object( hook->desktop ); release_object( hook->owner ); list_remove( &hook->chain ); free( hook ); @@ -500,6 +503,7 @@ DECL_HANDLER(remove_hook) return; } } + remove_hook( hook ); reply->active_hooks = get_active_hooks(); }
From: Rémi Bernon rbernon@codeweavers.com
And some run_hook_in_current_thread logic in a separate helper. --- server/hook.c | 48 +++++++++++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 19 deletions(-)
diff --git a/server/hook.c b/server/hook.c index 140f2ba5a90..ed5ab7f5938 100644 --- a/server/hook.c +++ b/server/hook.c @@ -127,8 +127,20 @@ static struct hook_table *get_global_hooks( struct thread *thread ) return table; }
+/* check if a given hook should run in the given thread */ +static int run_hook_in_thread( struct hook *hook, struct thread *thread ) +{ + if (hook->process && hook->process != thread->process) return 0; + if ((hook->flags & WINEVENT_SKIPOWNPROCESS) && hook->process == thread->process) return 0; + if (hook->thread && hook->thread != thread) return 0; + if ((hook->flags & WINEVENT_SKIPOWNTHREAD) && hook->thread == thread) return 0; + return 1; +} + /* create a new hook and add it to the specified table */ -static struct hook *add_hook( struct desktop *desktop, struct thread *thread, int index, int global ) +static struct hook *add_hook( struct desktop *desktop, struct process *process, struct thread *thread, int index, int global, + int event_min, int event_max, int flags, client_ptr_t proc, int unicode, + WCHAR *module, data_size_t module_size ) { struct hook *hook; struct hook_table *table = global ? desktop->global_hooks : get_queue_hooks(thread); @@ -146,10 +158,19 @@ static struct hook *add_hook( struct desktop *desktop, struct thread *thread, in free( hook ); return NULL; } - hook->desktop = (struct desktop *)grab_object( desktop ); - hook->thread = thread ? (struct thread *)grab_object( thread ) : NULL; - hook->table = table; - hook->index = index; + hook->owner = (struct thread *)grab_object( current ); + hook->desktop = (struct desktop *)grab_object( desktop ); + hook->process = process ? (struct process *)grab_object( process ) : NULL; + hook->thread = thread ? (struct thread *)grab_object( thread ) : NULL; + hook->table = table; + hook->index = index; + hook->event_min = event_min; + hook->event_max = event_max; + hook->flags = flags; + hook->proc = proc; + hook->unicode = unicode; + hook->module = module; + hook->module_size = module_size; list_add_head( &table->hooks[index], &hook->chain ); if (thread) thread->desktop_users++; return hook; @@ -209,10 +230,7 @@ static inline int run_hook_in_owner_thread( struct hook *hook ) /* check if a given hook should run in the current thread */ static inline int run_hook_in_current_thread( struct hook *hook ) { - if (hook->process && hook->process != current->process) return 0; - if ((hook->flags & WINEVENT_SKIPOWNPROCESS) && hook->process == current->process) return 0; - if (hook->thread && hook->thread != current) return 0; - if ((hook->flags & WINEVENT_SKIPOWNTHREAD) && hook->thread == current) return 0; + if (!run_hook_in_thread( hook, current )) return 0; /* don't run low-level hooks in processes suspended for debugging */ if (run_hook_in_owner_thread( hook ) && hook->owner->process->suspend) return 0; return 1; @@ -454,17 +472,9 @@ DECL_HANDLER(set_hook) global = 0; }
- if ((hook = add_hook( desktop, thread, req->id - WH_MINHOOK, global ))) + if ((hook = add_hook( desktop, process, thread, req->id - WH_MINHOOK, global, req->event_min, req->event_max, + req->flags, req->proc, req->unicode, module, module_size ))) { - hook->owner = (struct thread *)grab_object( current ); - hook->process = process ? (struct process *)grab_object( process ) : NULL; - hook->event_min = req->event_min; - hook->event_max = req->event_max; - hook->flags = req->flags; - hook->proc = req->proc; - hook->unicode = req->unicode; - hook->module = module; - hook->module_size = module_size; reply->handle = hook->handle; reply->active_hooks = get_active_hooks(); }
From: Rémi Bernon rbernon@codeweavers.com
--- server/hook.c | 70 ++++++++++++++++++++++++++------------------- server/protocol.def | 2 +- server/queue.c | 42 +++++++++++++++++++++++++++ server/user.h | 2 ++ server/winstation.c | 2 ++ 5 files changed, 87 insertions(+), 31 deletions(-)
diff --git a/server/hook.c b/server/hook.c index ed5ab7f5938..3047f52492d 100644 --- a/server/hook.c +++ b/server/hook.c @@ -173,6 +173,15 @@ static struct hook *add_hook( struct desktop *desktop, struct process *process, hook->module_size = module_size; list_add_head( &table->hooks[index], &hook->chain ); if (thread) thread->desktop_users++; + + if (!global) + add_queue_hook_count( hook->thread, index, 1 ); + else LIST_FOR_EACH_ENTRY( thread, &desktop->threads, struct thread, desktop_entry ) + { + if (!run_hook_in_thread( hook, thread )) continue; + add_queue_hook_count( thread, index, 1 ); + } + return hook; }
@@ -315,12 +324,43 @@ static void hook_table_destroy( struct object *obj ) /* remove a hook, freeing it if the chain is not in use */ static void remove_hook( struct hook *hook ) { + struct desktop *desktop = hook->desktop; + int global = hook->table == desktop->global_hooks; + struct thread *thread; + + if (!global) + add_queue_hook_count( hook->thread, hook->index, -1 ); + else LIST_FOR_EACH_ENTRY( thread, &desktop->threads, struct thread, desktop_entry ) + { + if (!run_hook_in_thread( hook, thread )) continue; + add_queue_hook_count( thread, hook->index, -1 ); + } + if (hook->table->counts[hook->index]) hook->proc = 0; /* chain is in use, just mark it and return */ else free_hook( hook ); }
+/* update the thread message queue hooks counters from the desktop global hooks */ +void add_desktop_hook_count( struct desktop *desktop, struct thread *thread, int count ) +{ + struct hook_table *table; + struct hook *hook; + int index; + + if (!(table = desktop->global_hooks)) return; + + for (index = 0; index < ARRAY_SIZE(table->hooks); index++) + { + LIST_FOR_EACH_ENTRY( hook, &table->hooks[index], struct hook, chain ) + { + if (!run_hook_in_thread( hook, thread )) continue; + add_queue_hook_count( thread, hook->index, count ); + } + } +} + /* release a hook chain, removing deleted hooks if the use count drops to 0 */ static void release_hook_chain( struct hook_table *table, int index ) { @@ -362,36 +402,6 @@ void remove_thread_hooks( struct thread *thread ) } }
-/* get a bitmap of active hooks in a hook table */ -static int is_hook_active( struct hook_table *table, int index ) -{ - struct hook *hook = get_first_hook( table, index ); - - while (hook) - { - if (hook->proc && run_hook_in_current_thread( hook )) return 1; - hook = HOOK_ENTRY( list_next( &table->hooks[index], &hook->chain ) ); - } - return 0; -} - -/* get a bitmap of all active hooks for the current thread */ -unsigned int get_active_hooks(void) -{ - struct hook_table *table = get_queue_hooks( current ); - struct hook_table *global_hooks = get_global_hooks( current ); - unsigned int ret = 1u << 31; /* set high bit to indicate that the bitmap is valid */ - int id; - - for (id = WH_MINHOOK; id <= WH_WINEVENT; id++) - { - if ((table && is_hook_active( table, id - WH_MINHOOK )) || - (global_hooks && is_hook_active( global_hooks, id - WH_MINHOOK ))) - ret |= 1 << (id - WH_MINHOOK); - } - return ret; -} - /* return the thread that owns the first global hook */ struct thread *get_first_global_hook( struct desktop *desktop, int id ) { diff --git a/server/protocol.def b/server/protocol.def index 97b4805c552..12c27a8e3e1 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -915,7 +915,7 @@ typedef volatile struct
typedef volatile struct { - int placeholder; + int hooks_count[WH_MAX - WH_MIN + 2]; /* active hooks count */ } queue_shm_t;
typedef volatile union diff --git a/server/queue.c b/server/queue.c index 5f4e5fa33c2..6d9c9f20a5f 100644 --- a/server/queue.c +++ b/server/queue.c @@ -290,6 +290,7 @@ static struct msg_queue *create_msg_queue( struct thread *thread, struct thread_ { struct thread_input *new_input = NULL; struct msg_queue *queue; + struct desktop *desktop; int i;
if (!input) @@ -328,7 +329,19 @@ static struct msg_queue *create_msg_queue( struct thread *thread, struct thread_ return NULL; }
+ SHARED_WRITE_BEGIN( queue->shared, queue_shm_t ) + { + memset( (void *)shared->hooks_count, 0, sizeof(shared->hooks_count) ); + } + SHARED_WRITE_END; + thread->queue = queue; + + if ((desktop = get_thread_desktop( thread, 0 ))) + { + add_desktop_hook_count( desktop, thread, 1 ); + release_object( desktop ); + } } if (new_input) release_object( new_input ); return queue; @@ -612,6 +625,35 @@ void set_queue_hooks( struct thread *thread, struct hook_table *hooks ) queue->hooks = hooks; }
+/* get the thread message queue active hooks bitmap */ +unsigned int get_active_hooks(void) +{ + unsigned int ret = 1u << 31; /* set high bit to indicate that the bitmap is valid */ + struct msg_queue *queue; + int bit; + + if (!(queue = current->queue)) return ret; + + for (bit = 0; bit < ARRAY_SIZE(queue->shared->hooks_count); bit++) + if (queue->shared->hooks_count[bit]) ret |= 1 << bit; + + return ret; +} + +/* update the thread message queue hooks counters */ +void add_queue_hook_count( struct thread *thread, unsigned int index, int count ) +{ + if (!thread->queue) return; + + SHARED_WRITE_BEGIN( thread->queue->shared, queue_shm_t ) + { + shared->hooks_count[index] += count; + } + SHARED_WRITE_END; + + assert( thread->queue->shared->hooks_count[index] >= 0 ); +} + /* check the queue status */ static inline int is_signaled( struct msg_queue *queue ) { diff --git a/server/user.h b/server/user.h index 99491293a7c..4633c7dae7f 100644 --- a/server/user.h +++ b/server/user.h @@ -108,12 +108,14 @@ extern void cleanup_clipboard_thread( struct thread *thread ); extern void remove_thread_hooks( struct thread *thread ); extern unsigned int get_active_hooks(void); extern struct thread *get_first_global_hook( struct desktop *desktop, int id ); +extern void add_desktop_hook_count( struct desktop *desktop, struct thread *thread, int count );
/* queue functions */
extern void free_msg_queue( struct thread *thread ); extern struct hook_table *get_queue_hooks( struct thread *thread ); extern void set_queue_hooks( struct thread *thread, struct hook_table *hooks ); +extern void add_queue_hook_count( struct thread *thread, unsigned int index, int count ); extern void inc_queue_paint_count( struct thread *thread, int incr ); extern void queue_cleanup_window( struct thread *thread, user_handle_t win ); extern int init_thread_queue( struct thread *thread ); diff --git a/server/winstation.c b/server/winstation.c index 45c7defa1f7..75b604ae1c3 100644 --- a/server/winstation.c +++ b/server/winstation.c @@ -410,6 +410,7 @@ static void close_desktop_timeout( void *private ) static void add_desktop_thread( struct desktop *desktop, struct thread *thread ) { list_add_tail( &desktop->threads, &thread->desktop_entry ); + add_desktop_hook_count( desktop, thread, 1 );
if (!thread->process->is_system) { @@ -441,6 +442,7 @@ static void remove_desktop_user( struct desktop *desktop, struct thread *thread /* remove a thread from the list of threads attached to a desktop */ static void remove_desktop_thread( struct desktop *desktop, struct thread *thread ) { + add_desktop_hook_count( desktop, thread, -1 ); list_remove( &thread->desktop_entry );
if (!thread->process->is_system) remove_desktop_user( desktop, thread );
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/hook.c | 16 +++++++++++----- dlls/win32u/message.c | 2 +- dlls/win32u/win32u_private.h | 1 + dlls/win32u/winstation.c | 35 +++++++++++++++++++++++++++++++++++ server/protocol.def | 9 ++++++++- server/queue.c | 12 ++++++++++-- 6 files changed, 66 insertions(+), 9 deletions(-)
diff --git a/dlls/win32u/hook.c b/dlls/win32u/hook.c index eca9e7d6ce9..3e2798b8c75 100644 --- a/dlls/win32u/hook.c +++ b/dlls/win32u/hook.c @@ -62,10 +62,16 @@ static const char *debugstr_hook_id( unsigned int id )
BOOL is_hooked( INT id ) { - struct user_thread_info *thread_info = get_user_thread_info(); + struct object_lock lock = OBJECT_LOCK_INIT; + const queue_shm_t *queue_shm; + BOOL ret = TRUE; + UINT status; + + while ((status = get_shared_queue( &lock, &queue_shm )) == STATUS_PENDING) + ret = queue_shm->hooks_count[id - WH_MINHOOK] > 0;
- if (!thread_info->active_hooks) return TRUE; - return (thread_info->active_hooks & (1 << (id - WH_MINHOOK))) != 0; + if (status) return TRUE; + return ret; }
/*********************************************************************** @@ -430,7 +436,7 @@ LRESULT call_message_hooks( INT id, INT code, WPARAM wparam, LPARAM lparam, size
if (!is_hooked( id )) { - TRACE( "skipping hook %s mask %x\n", hook_names[id-WH_MINHOOK], thread_info->active_hooks ); + TRACE( "skipping hook %s\n", hook_names[id - WH_MINHOOK] ); return 0; }
@@ -569,7 +575,7 @@ void WINAPI NtUserNotifyWinEvent( DWORD event, HWND hwnd, LONG object_id, LONG c
if (!is_hooked( WH_WINEVENT )) { - TRACE( "skipping hook mask %x\n", thread_info->active_hooks ); + TRACE( "skipping hook\n" ); return; }
diff --git a/dlls/win32u/message.c b/dlls/win32u/message.c index b7062414658..941af31701f 100644 --- a/dlls/win32u/message.c +++ b/dlls/win32u/message.c @@ -2945,7 +2945,7 @@ static HANDLE get_server_queue_handle(void)
if (!(ret = thread_info->server_queue)) { - SERVER_START_REQ( get_msg_queue ) + SERVER_START_REQ( get_msg_queue_handle ) { wine_server_call( req ); ret = wine_server_ptr_handle( reply->handle ); diff --git a/dlls/win32u/win32u_private.h b/dlls/win32u/win32u_private.h index e2e35d6c40d..cd64751e95b 100644 --- a/dlls/win32u/win32u_private.h +++ b/dlls/win32u/win32u_private.h @@ -219,6 +219,7 @@ struct object_lock * on it, within the loop, or after, unless the function has returned STATUS_SUCCESS. */ extern NTSTATUS get_shared_desktop( struct object_lock *lock, const desktop_shm_t **desktop_shm ); +extern NTSTATUS get_shared_queue( struct object_lock *lock, const queue_shm_t **queue_shm );
extern BOOL is_virtual_desktop(void);
diff --git a/dlls/win32u/winstation.c b/dlls/win32u/winstation.c index 1676539c69c..1a1b37f6eda 100644 --- a/dlls/win32u/winstation.c +++ b/dlls/win32u/winstation.c @@ -48,6 +48,7 @@ WINE_DECLARE_DEBUG_CHANNEL(win); struct session_thread_data { const shared_object_t *shared_desktop; /* thread desktop shared session cached object */ + const shared_object_t *shared_queue; /* thread message queue shared session cached object */ };
struct session_block @@ -219,6 +220,40 @@ NTSTATUS get_shared_desktop( struct object_lock *lock, const desktop_shm_t **des return STATUS_SUCCESS; }
+NTSTATUS get_shared_queue( struct object_lock *lock, const queue_shm_t **queue_shm ) +{ + struct session_thread_data *data = get_session_thread_data(); + const shared_object_t *object; + + TRACE( "lock %p, queue_shm %p\n", lock, queue_shm ); + + if (!(object = data->shared_queue)) + { + obj_locator_t locator; + + SERVER_START_REQ( get_msg_queue ) + { + wine_server_call( req ); + locator = reply->locator; + } + SERVER_END_REQ; + + data->shared_queue = find_shared_session_object( locator ); + if (!(object = data->shared_queue)) return STATUS_INVALID_HANDLE; + memset( lock, 0, sizeof(*lock) ); + } + + if (!lock->id || !shared_object_release_seqlock( object, lock->seq )) + { + shared_object_acquire_seqlock( object, &lock->seq ); + *queue_shm = &object->shm.queue; + lock->id = object->id; + return STATUS_PENDING; + } + + return STATUS_SUCCESS; +} + BOOL is_virtual_desktop(void) { HANDLE desktop = NtUserGetThreadDesktop( GetCurrentThreadId() ); diff --git a/server/protocol.def b/server/protocol.def index 12c27a8e3e1..128aab3a812 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -2115,10 +2115,17 @@ struct process_info @END
+/* Get a handle for the current thread message queue */ +@REQ(get_msg_queue_handle) +@REPLY + obj_handle_t handle; /* handle to the queue */ +@END + + /* Get the message queue of the current thread */ @REQ(get_msg_queue) @REPLY - obj_handle_t handle; /* handle to the queue */ + obj_locator_t locator; /* locator for the shared session object */ @END
diff --git a/server/queue.c b/server/queue.c index 6d9c9f20a5f..f73beb3ce4c 100644 --- a/server/queue.c +++ b/server/queue.c @@ -2902,8 +2902,8 @@ DECL_HANDLER(is_window_hung) }
-/* get the message queue of the current thread */ -DECL_HANDLER(get_msg_queue) +/* get a handle for the current thread message queue */ +DECL_HANDLER(get_msg_queue_handle) { struct msg_queue *queue = get_current_queue();
@@ -2912,6 +2912,14 @@ DECL_HANDLER(get_msg_queue) }
+/* get the message queue of the current thread */ +DECL_HANDLER(get_msg_queue) +{ + struct msg_queue *queue = get_current_queue(); + if (queue) reply->locator = get_shared_object_locator( queue->shared ); +} + + /* set the file descriptor associated to the current thread queue */ DECL_HANDLER(set_queue_fd) {
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/hook.c | 9 --------- dlls/win32u/message.c | 1 - dlls/win32u/ntuser_private.h | 1 - 3 files changed, 11 deletions(-)
diff --git a/dlls/win32u/hook.c b/dlls/win32u/hook.c index 3e2798b8c75..d47aed4c6d6 100644 --- a/dlls/win32u/hook.c +++ b/dlls/win32u/hook.c @@ -135,7 +135,6 @@ HHOOK WINAPI NtUserSetWindowsHookEx( HINSTANCE inst, UNICODE_STRING *module, DWO if (!wine_server_call_err( req )) { handle = wine_server_ptr_handle( reply->handle ); - get_user_thread_info()->active_hooks = reply->active_hooks; } } SERVER_END_REQ; @@ -156,7 +155,6 @@ BOOL WINAPI NtUserUnhookWindowsHookEx( HHOOK handle ) req->handle = wine_server_user_handle( handle ); req->id = 0; 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) RtlSetLastWin32Error( ERROR_INVALID_HOOK_HANDLE ); @@ -176,7 +174,6 @@ BOOL unhook_windows_hook( INT id, HOOKPROC proc ) 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) RtlSetLastWin32Error( ERROR_INVALID_HOOK_HANDLE ); @@ -427,7 +424,6 @@ LRESULT call_current_hook( HHOOK hhook, INT code, WPARAM wparam, LPARAM lparam ) LRESULT call_message_hooks( INT id, INT code, WPARAM wparam, LPARAM lparam, size_t lparam_size, size_t message_size, BOOL ansi ) { - struct user_thread_info *thread_info = get_user_thread_info(); struct win_hook_params info; WCHAR module[MAX_PATH]; DWORD_PTR ret; @@ -457,7 +453,6 @@ LRESULT call_message_hooks( INT id, INT code, WPARAM wparam, LPARAM lparam, size info.tid = reply->tid; info.proc = wine_server_get_ptr( reply->proc ); info.next_unicode = reply->unicode; - thread_info->active_hooks = reply->active_hooks; } } SERVER_END_REQ; @@ -525,7 +520,6 @@ HWINEVENTHOOK WINAPI NtUserSetWinEventHook( DWORD event_min, DWORD event_max, HM if (!wine_server_call_err( req )) { handle = wine_server_ptr_handle( reply->handle ); - get_user_thread_info()->active_hooks = reply->active_hooks; } } SERVER_END_REQ; @@ -546,7 +540,6 @@ BOOL WINAPI NtUserUnhookWinEvent( HWINEVENTHOOK handle ) req->handle = wine_server_user_handle( handle ); req->id = WH_WINEVENT; ret = !wine_server_call_err( req ); - if (ret) get_user_thread_info()->active_hooks = reply->active_hooks; } SERVER_END_REQ; return ret; @@ -557,7 +550,6 @@ BOOL WINAPI NtUserUnhookWinEvent( HWINEVENTHOOK handle ) */ void WINAPI NtUserNotifyWinEvent( DWORD event, HWND hwnd, LONG object_id, LONG child_id ) { - struct user_thread_info *thread_info = get_user_thread_info(); struct win_event_hook_params info; void *ret_ptr; ULONG ret_len; @@ -599,7 +591,6 @@ void WINAPI NtUserNotifyWinEvent( DWORD event, HWND hwnd, LONG object_id, LONG c info.module[wine_server_reply_size(req) / sizeof(WCHAR)] = 0; info.handle = wine_server_ptr_handle( reply->handle ); info.proc = wine_server_get_ptr( reply->proc ); - thread_info->active_hooks = reply->active_hooks; } } SERVER_END_REQ; diff --git a/dlls/win32u/message.c b/dlls/win32u/message.c index 941af31701f..3099f5a6660 100644 --- a/dlls/win32u/message.c +++ b/dlls/win32u/message.c @@ -2698,7 +2698,6 @@ int peek_message( MSG *msg, const struct peek_message_filter *filter ) info.msg.pt.x = reply->x; info.msg.pt.y = reply->y; hw_id = 0; - thread_info->active_hooks = reply->active_hooks; } else buffer_size = reply->total; } diff --git a/dlls/win32u/ntuser_private.h b/dlls/win32u/ntuser_private.h index d95ea03d45f..44edadad8f8 100644 --- a/dlls/win32u/ntuser_private.h +++ b/dlls/win32u/ntuser_private.h @@ -114,7 +114,6 @@ struct user_thread_info WORD hook_call_depth; /* Number of recursively called hook procs */ WORD hook_unicode; /* Is current hook unicode? */ HHOOK hook; /* Current hook */ - UINT active_hooks; /* Bitmap of active hooks */ struct received_message_info *receive_info; /* Message being currently received */ struct imm_thread_data *imm_thread_data; /* IMM thread data */ HKL kbd_layout; /* Current keyboard layout */
From: Rémi Bernon rbernon@codeweavers.com
--- server/hook.c | 4 ---- server/protocol.def | 4 ---- server/queue.c | 17 ----------------- 3 files changed, 25 deletions(-)
diff --git a/server/hook.c b/server/hook.c index 3047f52492d..c2d2823cd61 100644 --- a/server/hook.c +++ b/server/hook.c @@ -486,7 +486,6 @@ DECL_HANDLER(set_hook) req->flags, req->proc, req->unicode, module, module_size ))) { reply->handle = hook->handle; - reply->active_hooks = get_active_hooks(); } else free( module );
@@ -525,7 +524,6 @@ DECL_HANDLER(remove_hook) }
remove_hook( hook ); - reply->active_hooks = get_active_hooks(); }
@@ -542,8 +540,6 @@ DECL_HANDLER(start_hook_chain) return; }
- reply->active_hooks = get_active_hooks(); - if (!table || !(hook = get_first_valid_hook( table, req->id - WH_MINHOOK, req->event, req->window, req->object_id, req->child_id ))) { diff --git a/server/protocol.def b/server/protocol.def index 128aab3a812..33fd7a96e03 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -2231,7 +2231,6 @@ enum message_type int x; /* message x position */ int y; /* message y position */ unsigned int time; /* message time */ - unsigned int active_hooks; /* active hooks bitmap */ data_size_t total; /* total size of extra data */ VARARG(data,message_data); /* message data for sent messages */ @END @@ -3035,7 +3034,6 @@ enum caret_state VARARG(module,unicode_str); /* module name */ @REPLY user_handle_t handle; /* handle to the hook */ - unsigned int active_hooks; /* active hooks bitmap */ @END
@@ -3045,7 +3043,6 @@ enum caret_state client_ptr_t proc; /* hook procedure if handle is 0 */ int id; /* id of the hook if handle is 0 */ @REPLY - unsigned int active_hooks; /* active hooks bitmap */ @END
@@ -3062,7 +3059,6 @@ enum caret_state thread_id_t tid; /* thread id for low-level keyboard/mouse hooks */ int unicode; /* is it a unicode hook? */ client_ptr_t proc; /* hook procedure */ - unsigned int active_hooks; /* active hooks bitmap */ VARARG(module,unicode_str); /* module name */ @END
diff --git a/server/queue.c b/server/queue.c index f73beb3ce4c..53306f46793 100644 --- a/server/queue.c +++ b/server/queue.c @@ -625,21 +625,6 @@ void set_queue_hooks( struct thread *thread, struct hook_table *hooks ) queue->hooks = hooks; }
-/* get the thread message queue active hooks bitmap */ -unsigned int get_active_hooks(void) -{ - unsigned int ret = 1u << 31; /* set high bit to indicate that the bitmap is valid */ - struct msg_queue *queue; - int bit; - - if (!(queue = current->queue)) return ret; - - for (bit = 0; bit < ARRAY_SIZE(queue->shared->hooks_count); bit++) - if (queue->shared->hooks_count[bit]) ret |= 1 << bit; - - return ret; -} - /* update the thread message queue hooks counters */ void add_queue_hook_count( struct thread *thread, unsigned int index, int count ) { @@ -3125,8 +3110,6 @@ DECL_HANDLER(get_message) user_handle_t get_win = get_user_full_handle( req->get_win ); unsigned int filter = req->flags >> 16;
- reply->active_hooks = get_active_hooks(); - if (get_win && get_win != 1 && get_win != -1 && !get_user_object( get_win, USER_WINDOW )) { set_win32_error( ERROR_INVALID_WINDOW_HANDLE );
v3: Kept the queue handle separate, with a new request to get it vs getting the shared object locator.