From cc55fd317ad78b569f10359aef421bd831749d46 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Mon, 29 Dec 2008 17:35:35 +0100 Subject: [PATCH] server: Make hook procedures client_ptr_t instead of void pointers. --- dlls/user32/hook.c | 20 ++++++++++---------- dlls/user32/message.c | 2 +- include/wine/server_protocol.h | 12 ++++++------ server/hook.c | 6 +++--- server/protocol.def | 10 +++++----- server/queue.c | 2 +- server/trace.c | 18 +++++++++++++----- server/user.h | 2 +- 8 files changed, 40 insertions(+), 32 deletions(-) diff --git a/dlls/user32/hook.c b/dlls/user32/hook.c index c70af45f922..bd1994c350d 100644 --- a/dlls/user32/hook.c +++ b/dlls/user32/hook.c @@ -184,10 +184,10 @@ static HHOOK set_windows_hook( INT id, HOOKPROC proc, HINSTANCE inst, DWORD tid, req->unicode = unicode; if (inst) /* make proc relative to the module base */ { - req->proc = (void *)((char *)proc - (char *)inst); + req->proc = wine_server_client_ptr( (void *)((char *)proc - (char *)inst) ); wine_server_add_data( req, module, strlenW(module) * sizeof(WCHAR) ); } - else req->proc = proc; + else req->proc = wine_server_client_ptr( proc ); if (!wine_server_call_err( req )) { @@ -420,7 +420,7 @@ LRESULT HOOK_CallHooks( INT id, INT code, WPARAM wparam, LPARAM lparam, BOOL uni info.handle = wine_server_ptr_handle( reply->handle ); info.pid = reply->pid; info.tid = reply->tid; - info.proc = reply->proc; + info.proc = wine_server_get_ptr( reply->proc ); info.next_unicode = reply->unicode; thread_info->active_hooks = reply->active_hooks; } @@ -500,7 +500,7 @@ BOOL WINAPI UnhookWindowsHook( INT id, HOOKPROC proc ) { req->handle = 0; req->id = id; - req->proc = proc; + req->proc = wine_server_client_ptr( proc ); ret = !wine_server_call_err( req ); if (ret) get_user_thread_info()->active_hooks = reply->active_hooks; } @@ -554,7 +554,7 @@ LRESULT WINAPI CallNextHookEx( HHOOK hhook, INT code, WPARAM wparam, LPARAM lpar info.id = reply->id; info.pid = reply->pid; info.tid = reply->tid; - info.proc = reply->proc; + info.proc = wine_server_get_ptr( reply->proc ); info.next_unicode = reply->unicode; } } @@ -584,7 +584,7 @@ LRESULT call_current_hook( HHOOK hhook, INT code, WPARAM wparam, LPARAM lparam ) info.id = reply->id; info.pid = reply->pid; info.tid = reply->tid; - info.proc = reply->proc; + info.proc = wine_server_get_ptr( reply->proc ); info.next_unicode = reply->unicode; } } @@ -676,10 +676,10 @@ HWINEVENTHOOK WINAPI SetWinEventHook(DWORD event_min, DWORD event_max, req->unicode = 1; if (inst) /* make proc relative to the module base */ { - req->proc = (void *)((char *)proc - (char *)inst); + req->proc = wine_server_client_ptr( (void *)((char *)proc - (char *)inst) ); wine_server_add_data( req, module, strlenW(module) * sizeof(WCHAR) ); } - else req->proc = proc; + else req->proc = wine_server_client_ptr( proc ); if (!wine_server_call_err( req )) { @@ -746,7 +746,7 @@ static inline BOOL find_first_hook(DWORD id, DWORD event, HWND hwnd, LONG object { info->module[wine_server_reply_size(req) / sizeof(WCHAR)] = 0; info->handle = wine_server_ptr_handle( reply->handle ); - info->proc = reply->proc; + info->proc = wine_server_get_ptr( reply->proc ); info->tid = reply->tid; thread_info->active_hooks = reply->active_hooks; } @@ -774,7 +774,7 @@ static inline BOOL find_next_hook(DWORD event, HWND hwnd, LONG object_id, { info->module[wine_server_reply_size(req) / sizeof(WCHAR)] = 0; info->handle = wine_server_ptr_handle( reply->handle ); - info->proc = reply->proc; + info->proc = wine_server_get_ptr( reply->proc ); info->tid = reply->tid; } } diff --git a/dlls/user32/message.c b/dlls/user32/message.c index c97b1de6fb1..feaafd7d0f7 100644 --- a/dlls/user32/message.c +++ b/dlls/user32/message.c @@ -2106,7 +2106,7 @@ static BOOL peek_message( MSG *msg, HWND hwnd, UINT first, UINT last, UINT flags WINEVENTPROC hook_proc; const struct winevent_msg_data *data = buffer; - hook_proc = data->hook_proc; + hook_proc = wine_server_get_ptr( data->hook_proc ); size -= sizeof(*data); if (size) { diff --git a/include/wine/server_protocol.h b/include/wine/server_protocol.h index 807889b8bda..07b72d7c8ea 100644 --- a/include/wine/server_protocol.h +++ b/include/wine/server_protocol.h @@ -193,7 +193,7 @@ struct winevent_msg_data { user_handle_t hook; thread_id_t tid; - void *hook_proc; + client_ptr_t hook_proc; }; @@ -3564,8 +3564,8 @@ struct set_hook_request thread_id_t tid; int event_min; int event_max; + client_ptr_t proc; int flags; - void* proc; int unicode; /* VARARG(module,unicode_str); */ }; @@ -3582,8 +3582,8 @@ struct remove_hook_request { struct request_header __header; user_handle_t handle; + client_ptr_t proc; int id; - void* proc; }; struct remove_hook_reply { @@ -3608,8 +3608,8 @@ struct start_hook_chain_reply user_handle_t handle; process_id_t pid; thread_id_t tid; - void* proc; int unicode; + client_ptr_t proc; unsigned int active_hooks; /* VARARG(module,unicode_str); */ }; @@ -3645,7 +3645,7 @@ struct get_hook_info_reply int id; process_id_t pid; thread_id_t tid; - void* proc; + client_ptr_t proc; int unicode; /* VARARG(module,unicode_str); */ }; @@ -5052,6 +5052,6 @@ union generic_reply struct set_window_layered_info_reply set_window_layered_info_reply; }; -#define SERVER_PROTOCOL_VERSION 361 +#define SERVER_PROTOCOL_VERSION 362 #endif /* __WINE_WINE_SERVER_PROTOCOL_H */ diff --git a/server/hook.c b/server/hook.c index 4c168a34df6..f5ebc2b4df0 100644 --- a/server/hook.c +++ b/server/hook.c @@ -52,7 +52,7 @@ struct hook int event_min; int event_max; int flags; - void *proc; /* hook function */ + client_ptr_t proc; /* hook function */ int unicode; /* is it a unicode hook? */ WCHAR *module; /* module name for global hooks */ data_size_t module_size; @@ -167,7 +167,7 @@ static void free_hook( struct hook *hook ) } /* find a hook from its index and proc */ -static struct hook *find_hook( struct thread *thread, int index, void *proc ) +static struct hook *find_hook( struct thread *thread, int index, client_ptr_t proc ) { struct list *p; struct hook_table *table = get_queue_hooks( thread ); @@ -292,7 +292,7 @@ static void hook_table_destroy( struct object *obj ) static void remove_hook( struct hook *hook ) { if (hook->table->counts[hook->index]) - hook->proc = NULL; /* chain is in use, just mark it and return */ + hook->proc = 0; /* chain is in use, just mark it and return */ else free_hook( hook ); } diff --git a/server/protocol.def b/server/protocol.def index ffb8661d3cf..c0212e2a019 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -209,7 +209,7 @@ struct winevent_msg_data { user_handle_t hook; /* hook handle */ thread_id_t tid; /* thread id */ - void *hook_proc; /* hook proc address */ + client_ptr_t hook_proc; /* hook proc address */ /* followed by module name if any */ }; @@ -2575,8 +2575,8 @@ enum message_type thread_id_t tid; /* id of thread to set the hook into */ int event_min; int event_max; + client_ptr_t proc; /* hook procedure */ int flags; - void* proc; /* hook procedure */ int unicode; /* is it a unicode hook? */ VARARG(module,unicode_str); /* module name */ @REPLY @@ -2588,8 +2588,8 @@ enum message_type /* Remove a window hook */ @REQ(remove_hook) user_handle_t handle; /* handle to the hook */ + client_ptr_t proc; /* hook procedure if handle is 0 */ int id; /* id of the hook if handle is 0 */ - void* proc; /* hook procedure if handle is 0 */ @REPLY unsigned int active_hooks; /* active hooks bitmap */ @END @@ -2606,8 +2606,8 @@ enum message_type user_handle_t handle; /* handle to the next hook */ process_id_t pid; /* process id for low-level keyboard/mouse hooks */ thread_id_t tid; /* thread id for low-level keyboard/mouse hooks */ - void* proc; /* hook procedure */ 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 @@ -2632,7 +2632,7 @@ enum message_type int id; /* id of the hook */ process_id_t pid; /* process id for low-level keyboard/mouse hooks */ thread_id_t tid; /* thread id for low-level keyboard/mouse hooks */ - void* proc; /* hook procedure */ + client_ptr_t proc; /* hook procedure */ int unicode; /* is it a unicode hook? */ VARARG(module,unicode_str); /* module name */ @END diff --git a/server/queue.c b/server/queue.c index 28c79974b32..697a268fa33 100644 --- a/server/queue.c +++ b/server/queue.c @@ -1500,7 +1500,7 @@ void post_message( user_handle_t win, unsigned int message, lparam_t wparam, lpa /* post a win event */ void post_win_event( struct thread *thread, unsigned int event, user_handle_t win, unsigned int object_id, - unsigned int child_id, void *hook_proc, + unsigned int child_id, client_ptr_t hook_proc, const WCHAR *module, data_size_t module_size, user_handle_t hook) { diff --git a/server/trace.c b/server/trace.c index e9a9b36f1c9..7e3ccf52970 100644 --- a/server/trace.c +++ b/server/trace.c @@ -3245,8 +3245,10 @@ static void dump_set_hook_request( const struct set_hook_request *req ) fprintf( stderr, " tid=%04x,", req->tid ); fprintf( stderr, " event_min=%d,", req->event_min ); fprintf( stderr, " event_max=%d,", req->event_max ); + fprintf( stderr, " proc=" ); + dump_uint64( &req->proc ); + fprintf( stderr, "," ); fprintf( stderr, " flags=%d,", req->flags ); - fprintf( stderr, " proc=%p,", req->proc ); fprintf( stderr, " unicode=%d,", req->unicode ); fprintf( stderr, " module=" ); dump_varargs_unicode_str( cur_size ); @@ -3261,8 +3263,10 @@ static void dump_set_hook_reply( const struct set_hook_reply *req ) static void dump_remove_hook_request( const struct remove_hook_request *req ) { fprintf( stderr, " handle=%08x,", req->handle ); - fprintf( stderr, " id=%d,", req->id ); - fprintf( stderr, " proc=%p", req->proc ); + fprintf( stderr, " proc=" ); + dump_uint64( &req->proc ); + fprintf( stderr, "," ); + fprintf( stderr, " id=%d", req->id ); } static void dump_remove_hook_reply( const struct remove_hook_reply *req ) @@ -3284,8 +3288,10 @@ static void dump_start_hook_chain_reply( const struct start_hook_chain_reply *re fprintf( stderr, " handle=%08x,", req->handle ); fprintf( stderr, " pid=%04x,", req->pid ); fprintf( stderr, " tid=%04x,", req->tid ); - fprintf( stderr, " proc=%p,", req->proc ); fprintf( stderr, " unicode=%d,", req->unicode ); + fprintf( stderr, " proc=" ); + dump_uint64( &req->proc ); + fprintf( stderr, "," ); fprintf( stderr, " active_hooks=%08x,", req->active_hooks ); fprintf( stderr, " module=" ); dump_varargs_unicode_str( cur_size ); @@ -3312,7 +3318,9 @@ static void dump_get_hook_info_reply( const struct get_hook_info_reply *req ) fprintf( stderr, " id=%d,", req->id ); fprintf( stderr, " pid=%04x,", req->pid ); fprintf( stderr, " tid=%04x,", req->tid ); - fprintf( stderr, " proc=%p,", req->proc ); + fprintf( stderr, " proc=" ); + dump_uint64( &req->proc ); + fprintf( stderr, "," ); fprintf( stderr, " unicode=%d,", req->unicode ); fprintf( stderr, " module=" ); dump_varargs_unicode_str( cur_size ); diff --git a/server/user.h b/server/user.h index b4f35a82244..166d20b75b6 100644 --- a/server/user.h +++ b/server/user.h @@ -95,7 +95,7 @@ extern void post_message( user_handle_t win, unsigned int message, lparam_t wparam, lparam_t lparam ); extern void post_win_event( struct thread *thread, unsigned int event, user_handle_t win, unsigned int object_id, - unsigned int child_id, void *proc, + unsigned int child_id, client_ptr_t proc, const WCHAR *module, data_size_t module_size, user_handle_t handle );