Alexandre Julliard | 0286135 | 2002-10-29 00:41:42 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Server-side window hooks support |
| 3 | * |
| 4 | * Copyright (C) 2002 Alexandre Julliard |
| 5 | * |
| 6 | * This library is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU Lesser General Public |
| 8 | * License as published by the Free Software Foundation; either |
| 9 | * version 2.1 of the License, or (at your option) any later version. |
| 10 | * |
| 11 | * This library is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | * Lesser General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU Lesser General Public |
| 17 | * License along with this library; if not, write to the Free Software |
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 19 | */ |
| 20 | |
| 21 | #include "config.h" |
| 22 | #include "wine/port.h" |
| 23 | |
| 24 | #include <assert.h> |
Alexandre Julliard | e37c6e1 | 2003-09-05 23:08:26 +0000 | [diff] [blame] | 25 | #include <stdarg.h> |
Alexandre Julliard | 0286135 | 2002-10-29 00:41:42 +0000 | [diff] [blame] | 26 | #include <stdio.h> |
| 27 | |
Alexandre Julliard | e37c6e1 | 2003-09-05 23:08:26 +0000 | [diff] [blame] | 28 | #include "windef.h" |
Alexandre Julliard | 0286135 | 2002-10-29 00:41:42 +0000 | [diff] [blame] | 29 | #include "winbase.h" |
| 30 | #include "winuser.h" |
| 31 | |
| 32 | #include "object.h" |
Alexandre Julliard | ca3ac8f | 2003-07-11 21:55:58 +0000 | [diff] [blame] | 33 | #include "process.h" |
Alexandre Julliard | 0286135 | 2002-10-29 00:41:42 +0000 | [diff] [blame] | 34 | #include "request.h" |
| 35 | #include "user.h" |
| 36 | |
| 37 | struct hook_table; |
| 38 | |
| 39 | struct hook |
| 40 | { |
| 41 | struct list chain; /* hook chain entry */ |
| 42 | user_handle_t handle; /* user handle for this hook */ |
| 43 | struct thread *thread; /* thread owning the hook */ |
| 44 | int index; /* hook table index */ |
| 45 | void *proc; /* hook function */ |
| 46 | int unicode; /* is it a unicode hook? */ |
Alexandre Julliard | 14e68ba | 2002-11-20 19:54:32 +0000 | [diff] [blame] | 47 | WCHAR *module; /* module name for global hooks */ |
| 48 | size_t module_size; |
Alexandre Julliard | 0286135 | 2002-10-29 00:41:42 +0000 | [diff] [blame] | 49 | }; |
| 50 | |
| 51 | #define NB_HOOKS (WH_MAXHOOK-WH_MINHOOK+1) |
| 52 | #define HOOK_ENTRY(p) LIST_ENTRY( (p), struct hook, chain ) |
| 53 | |
| 54 | struct hook_table |
| 55 | { |
| 56 | struct object obj; /* object header */ |
| 57 | struct list hooks[NB_HOOKS]; /* array of hook chains */ |
| 58 | int counts[NB_HOOKS]; /* use counts for each hook chain */ |
| 59 | }; |
| 60 | |
| 61 | static void hook_table_dump( struct object *obj, int verbose ); |
| 62 | static void hook_table_destroy( struct object *obj ); |
| 63 | |
| 64 | static const struct object_ops hook_table_ops = |
| 65 | { |
| 66 | sizeof(struct hook_table), /* size */ |
| 67 | hook_table_dump, /* dump */ |
| 68 | no_add_queue, /* add_queue */ |
| 69 | NULL, /* remove_queue */ |
| 70 | NULL, /* signaled */ |
| 71 | NULL, /* satisfied */ |
Alexandre Julliard | 0286135 | 2002-10-29 00:41:42 +0000 | [diff] [blame] | 72 | no_get_fd, /* get_fd */ |
Alexandre Julliard | 0286135 | 2002-10-29 00:41:42 +0000 | [diff] [blame] | 73 | hook_table_destroy /* destroy */ |
| 74 | }; |
| 75 | |
| 76 | |
Alexandre Julliard | 14e68ba | 2002-11-20 19:54:32 +0000 | [diff] [blame] | 77 | static struct hook_table *global_hooks; |
| 78 | |
Alexandre Julliard | 0286135 | 2002-10-29 00:41:42 +0000 | [diff] [blame] | 79 | /* create a new hook table */ |
| 80 | static struct hook_table *alloc_hook_table(void) |
| 81 | { |
| 82 | struct hook_table *table; |
| 83 | int i; |
| 84 | |
Alexandre Julliard | e66207e | 2003-02-19 00:33:32 +0000 | [diff] [blame] | 85 | if ((table = alloc_object( &hook_table_ops ))) |
Alexandre Julliard | 0286135 | 2002-10-29 00:41:42 +0000 | [diff] [blame] | 86 | { |
| 87 | for (i = 0; i < NB_HOOKS; i++) |
| 88 | { |
| 89 | list_init( &table->hooks[i] ); |
| 90 | table->counts[i] = 0; |
| 91 | } |
| 92 | } |
| 93 | return table; |
| 94 | } |
| 95 | |
| 96 | /* create a new hook and add it to the specified table */ |
Alexandre Julliard | ca3ac8f | 2003-07-11 21:55:58 +0000 | [diff] [blame] | 97 | static struct hook *add_hook( struct thread *thread, int index, int global ) |
Alexandre Julliard | 0286135 | 2002-10-29 00:41:42 +0000 | [diff] [blame] | 98 | { |
| 99 | struct hook *hook; |
Alexandre Julliard | ca3ac8f | 2003-07-11 21:55:58 +0000 | [diff] [blame] | 100 | struct hook_table *table = global ? global_hooks : get_queue_hooks(thread); |
Alexandre Julliard | 0286135 | 2002-10-29 00:41:42 +0000 | [diff] [blame] | 101 | |
| 102 | if (!table) |
| 103 | { |
| 104 | if (!(table = alloc_hook_table())) return NULL; |
Alexandre Julliard | ca3ac8f | 2003-07-11 21:55:58 +0000 | [diff] [blame] | 105 | if (global) global_hooks = table; |
| 106 | else set_queue_hooks( thread, table ); |
Alexandre Julliard | 0286135 | 2002-10-29 00:41:42 +0000 | [diff] [blame] | 107 | } |
| 108 | if (!(hook = mem_alloc( sizeof(*hook) ))) return NULL; |
| 109 | |
| 110 | if (!(hook->handle = alloc_user_handle( hook, USER_HOOK ))) |
| 111 | { |
| 112 | free( hook ); |
| 113 | return NULL; |
| 114 | } |
| 115 | hook->thread = thread ? (struct thread *)grab_object( thread ) : NULL; |
| 116 | hook->index = index; |
| 117 | list_add_head( &table->hooks[index], &hook->chain ); |
| 118 | return hook; |
| 119 | } |
| 120 | |
| 121 | /* free a hook, removing it from its chain */ |
| 122 | static void free_hook( struct hook *hook ) |
| 123 | { |
| 124 | free_user_handle( hook->handle ); |
Alexandre Julliard | 14e68ba | 2002-11-20 19:54:32 +0000 | [diff] [blame] | 125 | if (hook->module) free( hook->module ); |
Alexandre Julliard | 0286135 | 2002-10-29 00:41:42 +0000 | [diff] [blame] | 126 | if (hook->thread) release_object( hook->thread ); |
| 127 | list_remove( &hook->chain ); |
| 128 | free( hook ); |
| 129 | } |
| 130 | |
| 131 | /* find a hook from its index and proc */ |
| 132 | static struct hook *find_hook( struct thread *thread, int index, void *proc ) |
| 133 | { |
| 134 | struct list *p; |
Alexandre Julliard | d55e7f1 | 2003-07-03 18:16:48 +0000 | [diff] [blame] | 135 | struct hook_table *table = get_queue_hooks( thread ); |
Alexandre Julliard | 0286135 | 2002-10-29 00:41:42 +0000 | [diff] [blame] | 136 | |
| 137 | if (table) |
| 138 | { |
| 139 | LIST_FOR_EACH( p, &table->hooks[index] ) |
| 140 | { |
| 141 | struct hook *hook = HOOK_ENTRY( p ); |
| 142 | if (hook->proc == proc) return hook; |
| 143 | } |
| 144 | } |
| 145 | return NULL; |
| 146 | } |
| 147 | |
| 148 | /* get the hook table that a given hook belongs to */ |
| 149 | inline static struct hook_table *get_table( struct hook *hook ) |
| 150 | { |
Alexandre Julliard | ca3ac8f | 2003-07-11 21:55:58 +0000 | [diff] [blame] | 151 | if (!hook->thread) return global_hooks; |
| 152 | if (hook->index + WH_MINHOOK == WH_KEYBOARD_LL) return global_hooks; |
| 153 | if (hook->index + WH_MINHOOK == WH_MOUSE_LL) return global_hooks; |
| 154 | return get_queue_hooks(hook->thread); |
Alexandre Julliard | 0286135 | 2002-10-29 00:41:42 +0000 | [diff] [blame] | 155 | } |
| 156 | |
| 157 | /* get the first hook in the chain */ |
| 158 | inline static struct hook *get_first_hook( struct hook_table *table, int index ) |
| 159 | { |
| 160 | struct list *elem = list_head( &table->hooks[index] ); |
| 161 | return elem ? HOOK_ENTRY( elem ) : NULL; |
| 162 | } |
| 163 | |
Alexandre Julliard | 14e68ba | 2002-11-20 19:54:32 +0000 | [diff] [blame] | 164 | /* find the first non-deleted hook in the chain */ |
| 165 | inline static struct hook *get_first_valid_hook( struct hook_table *table, int index ) |
| 166 | { |
| 167 | struct hook *hook = get_first_hook( table, index ); |
| 168 | while (hook && !hook->proc) |
| 169 | hook = HOOK_ENTRY( list_next( &table->hooks[index], &hook->chain ) ); |
| 170 | return hook; |
| 171 | } |
| 172 | |
Alexandre Julliard | 0286135 | 2002-10-29 00:41:42 +0000 | [diff] [blame] | 173 | /* find the next hook in the chain, skipping the deleted ones */ |
| 174 | static struct hook *get_next_hook( struct hook *hook ) |
| 175 | { |
| 176 | struct hook_table *table = get_table( hook ); |
Alexandre Julliard | 14e68ba | 2002-11-20 19:54:32 +0000 | [diff] [blame] | 177 | int index = hook->index; |
Alexandre Julliard | 0286135 | 2002-10-29 00:41:42 +0000 | [diff] [blame] | 178 | |
Alexandre Julliard | 14e68ba | 2002-11-20 19:54:32 +0000 | [diff] [blame] | 179 | while ((hook = HOOK_ENTRY( list_next( &table->hooks[index], &hook->chain ) ))) |
Alexandre Julliard | 0286135 | 2002-10-29 00:41:42 +0000 | [diff] [blame] | 180 | { |
Alexandre Julliard | 14e68ba | 2002-11-20 19:54:32 +0000 | [diff] [blame] | 181 | if (hook->proc) return hook; |
Alexandre Julliard | 0286135 | 2002-10-29 00:41:42 +0000 | [diff] [blame] | 182 | } |
Alexandre Julliard | 14e68ba | 2002-11-20 19:54:32 +0000 | [diff] [blame] | 183 | if (global_hooks && table != global_hooks) /* now search through the global table */ |
| 184 | { |
| 185 | hook = get_first_valid_hook( global_hooks, index ); |
| 186 | } |
| 187 | return hook; |
Alexandre Julliard | 0286135 | 2002-10-29 00:41:42 +0000 | [diff] [blame] | 188 | } |
| 189 | |
| 190 | static void hook_table_dump( struct object *obj, int verbose ) |
| 191 | { |
Alexandre Julliard | 14e68ba | 2002-11-20 19:54:32 +0000 | [diff] [blame] | 192 | struct hook_table *table = (struct hook_table *)obj; |
| 193 | if (table == global_hooks) fprintf( stderr, "Global hook table\n" ); |
| 194 | else fprintf( stderr, "Hook table\n" ); |
Alexandre Julliard | 0286135 | 2002-10-29 00:41:42 +0000 | [diff] [blame] | 195 | } |
| 196 | |
| 197 | static void hook_table_destroy( struct object *obj ) |
| 198 | { |
| 199 | int i; |
| 200 | struct hook *hook; |
| 201 | struct hook_table *table = (struct hook_table *)obj; |
| 202 | |
| 203 | for (i = 0; i < NB_HOOKS; i++) |
| 204 | { |
| 205 | while ((hook = get_first_hook( table, i )) != NULL) free_hook( hook ); |
| 206 | } |
| 207 | } |
| 208 | |
Alexandre Julliard | 14e68ba | 2002-11-20 19:54:32 +0000 | [diff] [blame] | 209 | /* free the global hooks table */ |
| 210 | void close_global_hooks(void) |
| 211 | { |
| 212 | if (global_hooks) release_object( global_hooks ); |
| 213 | } |
| 214 | |
Alexandre Julliard | 0286135 | 2002-10-29 00:41:42 +0000 | [diff] [blame] | 215 | /* remove a hook, freeing it if the chain is not in use */ |
| 216 | static void remove_hook( struct hook *hook ) |
| 217 | { |
| 218 | struct hook_table *table = get_table( hook ); |
| 219 | if (table->counts[hook->index]) |
| 220 | hook->proc = NULL; /* chain is in use, just mark it and return */ |
| 221 | else |
| 222 | free_hook( hook ); |
| 223 | } |
| 224 | |
| 225 | /* release a hook chain, removing deleted hooks if the use count drops to 0 */ |
| 226 | static void release_hook_chain( struct hook_table *table, int index ) |
| 227 | { |
| 228 | if (!table->counts[index]) /* use count shouldn't already be 0 */ |
| 229 | { |
| 230 | set_error( STATUS_INVALID_PARAMETER ); |
| 231 | return; |
| 232 | } |
| 233 | if (!--table->counts[index]) |
| 234 | { |
| 235 | struct hook *hook = get_first_hook( table, index ); |
| 236 | while (hook) |
| 237 | { |
| 238 | struct hook *next = HOOK_ENTRY( list_next( &table->hooks[hook->index], &hook->chain ) ); |
| 239 | if (!hook->proc) free_hook( hook ); |
| 240 | hook = next; |
| 241 | } |
| 242 | } |
| 243 | } |
| 244 | |
Alexandre Julliard | ca3ac8f | 2003-07-11 21:55:58 +0000 | [diff] [blame] | 245 | /* remove all global hooks owned by a given thread */ |
| 246 | void remove_thread_hooks( struct thread *thread ) |
| 247 | { |
| 248 | int index; |
| 249 | |
| 250 | if (!global_hooks) return; |
| 251 | |
| 252 | /* only low-level keyboard/mouse global hooks can be owned by a thread */ |
| 253 | for (index = WH_KEYBOARD_LL - WH_MINHOOK; index <= WH_MOUSE_LL - WH_MINHOOK; index++) |
| 254 | { |
| 255 | struct hook *hook = get_first_hook( global_hooks, index ); |
| 256 | while (hook) |
| 257 | { |
| 258 | struct hook *next = HOOK_ENTRY( list_next( &global_hooks->hooks[index], &hook->chain ) ); |
| 259 | if (hook->thread == thread) remove_hook( hook ); |
| 260 | hook = next; |
| 261 | } |
| 262 | } |
| 263 | } |
Alexandre Julliard | 0286135 | 2002-10-29 00:41:42 +0000 | [diff] [blame] | 264 | |
| 265 | /* set a window hook */ |
| 266 | DECL_HANDLER(set_hook) |
| 267 | { |
| 268 | struct thread *thread; |
| 269 | struct hook *hook; |
Alexandre Julliard | 14e68ba | 2002-11-20 19:54:32 +0000 | [diff] [blame] | 270 | WCHAR *module; |
Alexandre Julliard | ca3ac8f | 2003-07-11 21:55:58 +0000 | [diff] [blame] | 271 | int global; |
Alexandre Julliard | 14e68ba | 2002-11-20 19:54:32 +0000 | [diff] [blame] | 272 | size_t module_size = get_req_data_size(); |
Alexandre Julliard | 0286135 | 2002-10-29 00:41:42 +0000 | [diff] [blame] | 273 | |
| 274 | if (!req->proc || req->id < WH_MINHOOK || req->id > WH_MAXHOOK) |
| 275 | { |
| 276 | set_error( STATUS_INVALID_PARAMETER ); |
| 277 | return; |
| 278 | } |
Alexandre Julliard | ca3ac8f | 2003-07-11 21:55:58 +0000 | [diff] [blame] | 279 | if (req->id == WH_KEYBOARD_LL || req->id == WH_MOUSE_LL) |
| 280 | { |
| 281 | /* low-level hardware hooks are special: always global, but without a module */ |
| 282 | thread = (struct thread *)grab_object( current ); |
| 283 | module = NULL; |
| 284 | global = 1; |
| 285 | } |
| 286 | else if (!req->tid) |
Alexandre Julliard | 14e68ba | 2002-11-20 19:54:32 +0000 | [diff] [blame] | 287 | { |
| 288 | if (!module_size) |
| 289 | { |
| 290 | set_error( STATUS_INVALID_PARAMETER ); |
| 291 | return; |
| 292 | } |
| 293 | if (!(module = memdup( get_req_data(), module_size ))) return; |
| 294 | thread = NULL; |
Alexandre Julliard | ca3ac8f | 2003-07-11 21:55:58 +0000 | [diff] [blame] | 295 | global = 1; |
Alexandre Julliard | 14e68ba | 2002-11-20 19:54:32 +0000 | [diff] [blame] | 296 | } |
| 297 | else |
| 298 | { |
| 299 | module = NULL; |
Alexandre Julliard | ca3ac8f | 2003-07-11 21:55:58 +0000 | [diff] [blame] | 300 | global = 0; |
Alexandre Julliard | 14e68ba | 2002-11-20 19:54:32 +0000 | [diff] [blame] | 301 | if (!(thread = get_thread_from_id( req->tid ))) return; |
| 302 | } |
Alexandre Julliard | 0286135 | 2002-10-29 00:41:42 +0000 | [diff] [blame] | 303 | |
Alexandre Julliard | ca3ac8f | 2003-07-11 21:55:58 +0000 | [diff] [blame] | 304 | if ((hook = add_hook( thread, req->id - WH_MINHOOK, global ))) |
Alexandre Julliard | 0286135 | 2002-10-29 00:41:42 +0000 | [diff] [blame] | 305 | { |
Alexandre Julliard | 14e68ba | 2002-11-20 19:54:32 +0000 | [diff] [blame] | 306 | hook->proc = req->proc; |
| 307 | hook->unicode = req->unicode; |
| 308 | hook->module = module; |
| 309 | hook->module_size = module_size; |
Alexandre Julliard | 0286135 | 2002-10-29 00:41:42 +0000 | [diff] [blame] | 310 | reply->handle = hook->handle; |
| 311 | } |
Alexandre Julliard | 14e68ba | 2002-11-20 19:54:32 +0000 | [diff] [blame] | 312 | else if (module) free( module ); |
| 313 | |
| 314 | if (thread) release_object( thread ); |
Alexandre Julliard | 0286135 | 2002-10-29 00:41:42 +0000 | [diff] [blame] | 315 | } |
| 316 | |
| 317 | |
| 318 | /* remove a window hook */ |
| 319 | DECL_HANDLER(remove_hook) |
| 320 | { |
| 321 | struct hook *hook; |
| 322 | |
| 323 | if (req->handle) hook = get_user_object( req->handle, USER_HOOK ); |
| 324 | else |
| 325 | { |
| 326 | if (!req->proc || req->id < WH_MINHOOK || req->id > WH_MAXHOOK) |
| 327 | { |
| 328 | set_error( STATUS_INVALID_PARAMETER ); |
| 329 | return; |
| 330 | } |
| 331 | if (!(hook = find_hook( current, req->id - WH_MINHOOK, req->proc ))) |
| 332 | set_error( STATUS_INVALID_PARAMETER ); |
| 333 | } |
| 334 | if (hook) remove_hook( hook ); |
| 335 | } |
| 336 | |
| 337 | |
| 338 | /* start calling a hook chain */ |
| 339 | DECL_HANDLER(start_hook_chain) |
| 340 | { |
| 341 | struct hook *hook; |
Alexandre Julliard | d55e7f1 | 2003-07-03 18:16:48 +0000 | [diff] [blame] | 342 | struct hook_table *table = get_queue_hooks( current ); |
Alexandre Julliard | 0286135 | 2002-10-29 00:41:42 +0000 | [diff] [blame] | 343 | |
| 344 | if (req->id < WH_MINHOOK || req->id > WH_MAXHOOK) |
| 345 | { |
| 346 | set_error( STATUS_INVALID_PARAMETER ); |
| 347 | return; |
| 348 | } |
Alexandre Julliard | 14e68ba | 2002-11-20 19:54:32 +0000 | [diff] [blame] | 349 | |
| 350 | if (!table || !(hook = get_first_valid_hook( table, req->id - WH_MINHOOK ))) |
| 351 | { |
| 352 | /* try global table */ |
| 353 | if (!(table = global_hooks) || |
| 354 | !(hook = get_first_valid_hook( global_hooks, req->id - WH_MINHOOK ))) |
| 355 | return; /* no hook set */ |
| 356 | } |
Alexandre Julliard | ca3ac8f | 2003-07-11 21:55:58 +0000 | [diff] [blame] | 357 | |
| 358 | if (hook->thread && hook->thread != current) /* must run in other thread */ |
| 359 | { |
| 360 | reply->pid = get_process_id( hook->thread->process ); |
| 361 | reply->tid = get_thread_id( hook->thread ); |
| 362 | reply->proc = 0; |
| 363 | } |
| 364 | else |
| 365 | { |
| 366 | reply->pid = 0; |
| 367 | reply->tid = 0; |
| 368 | reply->proc = hook->proc; |
| 369 | } |
Alexandre Julliard | 0286135 | 2002-10-29 00:41:42 +0000 | [diff] [blame] | 370 | reply->handle = hook->handle; |
Alexandre Julliard | 0286135 | 2002-10-29 00:41:42 +0000 | [diff] [blame] | 371 | reply->unicode = hook->unicode; |
| 372 | table->counts[hook->index]++; |
Alexandre Julliard | 14e68ba | 2002-11-20 19:54:32 +0000 | [diff] [blame] | 373 | if (hook->module) set_reply_data( hook->module, hook->module_size ); |
Alexandre Julliard | 0286135 | 2002-10-29 00:41:42 +0000 | [diff] [blame] | 374 | } |
| 375 | |
| 376 | |
| 377 | /* finished calling a hook chain */ |
| 378 | DECL_HANDLER(finish_hook_chain) |
| 379 | { |
Alexandre Julliard | d55e7f1 | 2003-07-03 18:16:48 +0000 | [diff] [blame] | 380 | struct hook_table *table = get_queue_hooks( current ); |
Alexandre Julliard | 0286135 | 2002-10-29 00:41:42 +0000 | [diff] [blame] | 381 | int index = req->id - WH_MINHOOK; |
| 382 | |
| 383 | if (req->id < WH_MINHOOK || req->id > WH_MAXHOOK) |
| 384 | { |
| 385 | set_error( STATUS_INVALID_PARAMETER ); |
| 386 | return; |
| 387 | } |
| 388 | if (table) release_hook_chain( table, index ); |
Alexandre Julliard | 14e68ba | 2002-11-20 19:54:32 +0000 | [diff] [blame] | 389 | if (global_hooks) release_hook_chain( global_hooks, index ); |
Alexandre Julliard | 0286135 | 2002-10-29 00:41:42 +0000 | [diff] [blame] | 390 | } |
| 391 | |
| 392 | |
| 393 | /* get the next hook to call */ |
| 394 | DECL_HANDLER(get_next_hook) |
| 395 | { |
| 396 | struct hook *hook, *next; |
| 397 | |
| 398 | if (!(hook = get_user_object( req->handle, USER_HOOK ))) return; |
Alexandre Julliard | 14e68ba | 2002-11-20 19:54:32 +0000 | [diff] [blame] | 399 | if (hook->thread && (hook->thread != current)) |
Alexandre Julliard | 0286135 | 2002-10-29 00:41:42 +0000 | [diff] [blame] | 400 | { |
| 401 | set_error( STATUS_INVALID_HANDLE ); |
| 402 | return; |
| 403 | } |
| 404 | if ((next = get_next_hook( hook ))) |
| 405 | { |
| 406 | reply->next = next->handle; |
| 407 | reply->id = next->index + WH_MINHOOK; |
Alexandre Julliard | 0286135 | 2002-10-29 00:41:42 +0000 | [diff] [blame] | 408 | reply->prev_unicode = hook->unicode; |
| 409 | reply->next_unicode = next->unicode; |
Alberto Massari | 66da6c8 | 2002-12-17 21:01:01 +0000 | [diff] [blame] | 410 | if (next->module) set_reply_data( next->module, next->module_size ); |
Alexandre Julliard | ca3ac8f | 2003-07-11 21:55:58 +0000 | [diff] [blame] | 411 | if (next->thread && next->thread != current) |
| 412 | { |
| 413 | reply->pid = get_process_id( next->thread->process ); |
| 414 | reply->tid = get_thread_id( next->thread ); |
| 415 | reply->proc = 0; |
| 416 | } |
| 417 | else |
| 418 | { |
| 419 | reply->pid = 0; |
| 420 | reply->tid = 0; |
| 421 | reply->proc = next->proc; |
| 422 | } |
Alexandre Julliard | 0286135 | 2002-10-29 00:41:42 +0000 | [diff] [blame] | 423 | } |
| 424 | } |