Commit cc55fd31 authored by Alexandre Julliard's avatar Alexandre Julliard

server: Make hook procedures client_ptr_t instead of void pointers.

parent 923310aa
...@@ -184,10 +184,10 @@ static HHOOK set_windows_hook( INT id, HOOKPROC proc, HINSTANCE inst, DWORD tid, ...@@ -184,10 +184,10 @@ static HHOOK set_windows_hook( INT id, HOOKPROC proc, HINSTANCE inst, DWORD tid,
req->unicode = unicode; req->unicode = unicode;
if (inst) /* make proc relative to the module base */ 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) ); 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 )) if (!wine_server_call_err( req ))
{ {
...@@ -420,7 +420,7 @@ LRESULT HOOK_CallHooks( INT id, INT code, WPARAM wparam, LPARAM lparam, BOOL uni ...@@ -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.handle = wine_server_ptr_handle( reply->handle );
info.pid = reply->pid; info.pid = reply->pid;
info.tid = reply->tid; info.tid = reply->tid;
info.proc = reply->proc; info.proc = wine_server_get_ptr( reply->proc );
info.next_unicode = reply->unicode; info.next_unicode = reply->unicode;
thread_info->active_hooks = reply->active_hooks; thread_info->active_hooks = reply->active_hooks;
} }
...@@ -500,7 +500,7 @@ BOOL WINAPI UnhookWindowsHook( INT id, HOOKPROC proc ) ...@@ -500,7 +500,7 @@ BOOL WINAPI UnhookWindowsHook( INT id, HOOKPROC proc )
{ {
req->handle = 0; req->handle = 0;
req->id = id; req->id = id;
req->proc = proc; req->proc = wine_server_client_ptr( proc );
ret = !wine_server_call_err( req ); ret = !wine_server_call_err( req );
if (ret) get_user_thread_info()->active_hooks = reply->active_hooks; 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 ...@@ -554,7 +554,7 @@ LRESULT WINAPI CallNextHookEx( HHOOK hhook, INT code, WPARAM wparam, LPARAM lpar
info.id = reply->id; info.id = reply->id;
info.pid = reply->pid; info.pid = reply->pid;
info.tid = reply->tid; info.tid = reply->tid;
info.proc = reply->proc; info.proc = wine_server_get_ptr( reply->proc );
info.next_unicode = reply->unicode; info.next_unicode = reply->unicode;
} }
} }
...@@ -584,7 +584,7 @@ LRESULT call_current_hook( HHOOK hhook, INT code, WPARAM wparam, LPARAM lparam ) ...@@ -584,7 +584,7 @@ LRESULT call_current_hook( HHOOK hhook, INT code, WPARAM wparam, LPARAM lparam )
info.id = reply->id; info.id = reply->id;
info.pid = reply->pid; info.pid = reply->pid;
info.tid = reply->tid; info.tid = reply->tid;
info.proc = reply->proc; info.proc = wine_server_get_ptr( reply->proc );
info.next_unicode = reply->unicode; info.next_unicode = reply->unicode;
} }
} }
...@@ -676,10 +676,10 @@ HWINEVENTHOOK WINAPI SetWinEventHook(DWORD event_min, DWORD event_max, ...@@ -676,10 +676,10 @@ HWINEVENTHOOK WINAPI SetWinEventHook(DWORD event_min, DWORD event_max,
req->unicode = 1; req->unicode = 1;
if (inst) /* make proc relative to the module base */ 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) ); 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 )) if (!wine_server_call_err( req ))
{ {
...@@ -746,7 +746,7 @@ static inline BOOL find_first_hook(DWORD id, DWORD event, HWND hwnd, LONG object ...@@ -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->module[wine_server_reply_size(req) / sizeof(WCHAR)] = 0;
info->handle = wine_server_ptr_handle( reply->handle ); info->handle = wine_server_ptr_handle( reply->handle );
info->proc = reply->proc; info->proc = wine_server_get_ptr( reply->proc );
info->tid = reply->tid; info->tid = reply->tid;
thread_info->active_hooks = reply->active_hooks; thread_info->active_hooks = reply->active_hooks;
} }
...@@ -774,7 +774,7 @@ static inline BOOL find_next_hook(DWORD event, HWND hwnd, LONG object_id, ...@@ -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->module[wine_server_reply_size(req) / sizeof(WCHAR)] = 0;
info->handle = wine_server_ptr_handle( reply->handle ); info->handle = wine_server_ptr_handle( reply->handle );
info->proc = reply->proc; info->proc = wine_server_get_ptr( reply->proc );
info->tid = reply->tid; info->tid = reply->tid;
} }
} }
......
...@@ -2106,7 +2106,7 @@ static BOOL peek_message( MSG *msg, HWND hwnd, UINT first, UINT last, UINT flags ...@@ -2106,7 +2106,7 @@ static BOOL peek_message( MSG *msg, HWND hwnd, UINT first, UINT last, UINT flags
WINEVENTPROC hook_proc; WINEVENTPROC hook_proc;
const struct winevent_msg_data *data = buffer; const struct winevent_msg_data *data = buffer;
hook_proc = data->hook_proc; hook_proc = wine_server_get_ptr( data->hook_proc );
size -= sizeof(*data); size -= sizeof(*data);
if (size) if (size)
{ {
......
...@@ -193,7 +193,7 @@ struct winevent_msg_data ...@@ -193,7 +193,7 @@ struct winevent_msg_data
{ {
user_handle_t hook; user_handle_t hook;
thread_id_t tid; thread_id_t tid;
void *hook_proc; client_ptr_t hook_proc;
}; };
...@@ -3564,8 +3564,8 @@ struct set_hook_request ...@@ -3564,8 +3564,8 @@ struct set_hook_request
thread_id_t tid; thread_id_t tid;
int event_min; int event_min;
int event_max; int event_max;
client_ptr_t proc;
int flags; int flags;
void* proc;
int unicode; int unicode;
/* VARARG(module,unicode_str); */ /* VARARG(module,unicode_str); */
}; };
...@@ -3582,8 +3582,8 @@ struct remove_hook_request ...@@ -3582,8 +3582,8 @@ struct remove_hook_request
{ {
struct request_header __header; struct request_header __header;
user_handle_t handle; user_handle_t handle;
client_ptr_t proc;
int id; int id;
void* proc;
}; };
struct remove_hook_reply struct remove_hook_reply
{ {
...@@ -3608,8 +3608,8 @@ struct start_hook_chain_reply ...@@ -3608,8 +3608,8 @@ struct start_hook_chain_reply
user_handle_t handle; user_handle_t handle;
process_id_t pid; process_id_t pid;
thread_id_t tid; thread_id_t tid;
void* proc;
int unicode; int unicode;
client_ptr_t proc;
unsigned int active_hooks; unsigned int active_hooks;
/* VARARG(module,unicode_str); */ /* VARARG(module,unicode_str); */
}; };
...@@ -3645,7 +3645,7 @@ struct get_hook_info_reply ...@@ -3645,7 +3645,7 @@ struct get_hook_info_reply
int id; int id;
process_id_t pid; process_id_t pid;
thread_id_t tid; thread_id_t tid;
void* proc; client_ptr_t proc;
int unicode; int unicode;
/* VARARG(module,unicode_str); */ /* VARARG(module,unicode_str); */
}; };
...@@ -5052,6 +5052,6 @@ union generic_reply ...@@ -5052,6 +5052,6 @@ union generic_reply
struct set_window_layered_info_reply set_window_layered_info_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 */ #endif /* __WINE_WINE_SERVER_PROTOCOL_H */
...@@ -52,7 +52,7 @@ struct hook ...@@ -52,7 +52,7 @@ struct hook
int event_min; int event_min;
int event_max; int event_max;
int flags; int flags;
void *proc; /* hook function */ client_ptr_t proc; /* hook function */
int unicode; /* is it a unicode hook? */ int unicode; /* is it a unicode hook? */
WCHAR *module; /* module name for global hooks */ WCHAR *module; /* module name for global hooks */
data_size_t module_size; data_size_t module_size;
...@@ -167,7 +167,7 @@ static void free_hook( struct hook *hook ) ...@@ -167,7 +167,7 @@ static void free_hook( struct hook *hook )
} }
/* find a hook from its index and proc */ /* 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 list *p;
struct hook_table *table = get_queue_hooks( thread ); struct hook_table *table = get_queue_hooks( thread );
...@@ -292,7 +292,7 @@ static void hook_table_destroy( struct object *obj ) ...@@ -292,7 +292,7 @@ static void hook_table_destroy( struct object *obj )
static void remove_hook( struct hook *hook ) static void remove_hook( struct hook *hook )
{ {
if (hook->table->counts[hook->index]) 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 else
free_hook( hook ); free_hook( hook );
} }
......
...@@ -209,7 +209,7 @@ struct winevent_msg_data ...@@ -209,7 +209,7 @@ struct winevent_msg_data
{ {
user_handle_t hook; /* hook handle */ user_handle_t hook; /* hook handle */
thread_id_t tid; /* thread id */ 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 */ /* followed by module name if any */
}; };
...@@ -2575,8 +2575,8 @@ enum message_type ...@@ -2575,8 +2575,8 @@ enum message_type
thread_id_t tid; /* id of thread to set the hook into */ thread_id_t tid; /* id of thread to set the hook into */
int event_min; int event_min;
int event_max; int event_max;
client_ptr_t proc; /* hook procedure */
int flags; int flags;
void* proc; /* hook procedure */
int unicode; /* is it a unicode hook? */ int unicode; /* is it a unicode hook? */
VARARG(module,unicode_str); /* module name */ VARARG(module,unicode_str); /* module name */
@REPLY @REPLY
...@@ -2588,8 +2588,8 @@ enum message_type ...@@ -2588,8 +2588,8 @@ enum message_type
/* Remove a window hook */ /* Remove a window hook */
@REQ(remove_hook) @REQ(remove_hook)
user_handle_t handle; /* handle to the 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 */ int id; /* id of the hook if handle is 0 */
void* proc; /* hook procedure if handle is 0 */
@REPLY @REPLY
unsigned int active_hooks; /* active hooks bitmap */ unsigned int active_hooks; /* active hooks bitmap */
@END @END
...@@ -2606,8 +2606,8 @@ enum message_type ...@@ -2606,8 +2606,8 @@ enum message_type
user_handle_t handle; /* handle to the next hook */ user_handle_t handle; /* handle to the next hook */
process_id_t pid; /* process id for low-level keyboard/mouse hooks */ process_id_t pid; /* process id for low-level keyboard/mouse hooks */
thread_id_t tid; /* thread 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? */ int unicode; /* is it a unicode hook? */
client_ptr_t proc; /* hook procedure */
unsigned int active_hooks; /* active hooks bitmap */ unsigned int active_hooks; /* active hooks bitmap */
VARARG(module,unicode_str); /* module name */ VARARG(module,unicode_str); /* module name */
@END @END
...@@ -2632,7 +2632,7 @@ enum message_type ...@@ -2632,7 +2632,7 @@ enum message_type
int id; /* id of the hook */ int id; /* id of the hook */
process_id_t pid; /* process id for low-level keyboard/mouse hooks */ process_id_t pid; /* process id for low-level keyboard/mouse hooks */
thread_id_t tid; /* thread 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? */ int unicode; /* is it a unicode hook? */
VARARG(module,unicode_str); /* module name */ VARARG(module,unicode_str); /* module name */
@END @END
......
...@@ -1500,7 +1500,7 @@ void post_message( user_handle_t win, unsigned int message, lparam_t wparam, lpa ...@@ -1500,7 +1500,7 @@ void post_message( user_handle_t win, unsigned int message, lparam_t wparam, lpa
/* post a win event */ /* post a win event */
void post_win_event( struct thread *thread, unsigned int event, void post_win_event( struct thread *thread, unsigned int event,
user_handle_t win, unsigned int object_id, 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, const WCHAR *module, data_size_t module_size,
user_handle_t hook) user_handle_t hook)
{ {
......
...@@ -3245,8 +3245,10 @@ static void dump_set_hook_request( const struct set_hook_request *req ) ...@@ -3245,8 +3245,10 @@ static void dump_set_hook_request( const struct set_hook_request *req )
fprintf( stderr, " tid=%04x,", req->tid ); fprintf( stderr, " tid=%04x,", req->tid );
fprintf( stderr, " event_min=%d,", req->event_min ); fprintf( stderr, " event_min=%d,", req->event_min );
fprintf( stderr, " event_max=%d,", req->event_max ); 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, " flags=%d,", req->flags );
fprintf( stderr, " proc=%p,", req->proc );
fprintf( stderr, " unicode=%d,", req->unicode ); fprintf( stderr, " unicode=%d,", req->unicode );
fprintf( stderr, " module=" ); fprintf( stderr, " module=" );
dump_varargs_unicode_str( cur_size ); dump_varargs_unicode_str( cur_size );
...@@ -3261,8 +3263,10 @@ static void dump_set_hook_reply( const struct set_hook_reply *req ) ...@@ -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 ) static void dump_remove_hook_request( const struct remove_hook_request *req )
{ {
fprintf( stderr, " handle=%08x,", req->handle ); fprintf( stderr, " handle=%08x,", req->handle );
fprintf( stderr, " id=%d,", req->id ); fprintf( stderr, " proc=" );
fprintf( stderr, " proc=%p", req->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 ) 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 ...@@ -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, " handle=%08x,", req->handle );
fprintf( stderr, " pid=%04x,", req->pid ); fprintf( stderr, " pid=%04x,", req->pid );
fprintf( stderr, " tid=%04x,", req->tid ); fprintf( stderr, " tid=%04x,", req->tid );
fprintf( stderr, " proc=%p,", req->proc );
fprintf( stderr, " unicode=%d,", req->unicode ); 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, " active_hooks=%08x,", req->active_hooks );
fprintf( stderr, " module=" ); fprintf( stderr, " module=" );
dump_varargs_unicode_str( cur_size ); dump_varargs_unicode_str( cur_size );
...@@ -3312,7 +3318,9 @@ static void dump_get_hook_info_reply( const struct get_hook_info_reply *req ) ...@@ -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, " id=%d,", req->id );
fprintf( stderr, " pid=%04x,", req->pid ); fprintf( stderr, " pid=%04x,", req->pid );
fprintf( stderr, " tid=%04x,", req->tid ); 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, " unicode=%d,", req->unicode );
fprintf( stderr, " module=" ); fprintf( stderr, " module=" );
dump_varargs_unicode_str( cur_size ); dump_varargs_unicode_str( cur_size );
......
...@@ -95,7 +95,7 @@ extern void post_message( user_handle_t win, unsigned int message, ...@@ -95,7 +95,7 @@ extern void post_message( user_handle_t win, unsigned int message,
lparam_t wparam, lparam_t lparam ); lparam_t wparam, lparam_t lparam );
extern void post_win_event( struct thread *thread, unsigned int event, extern void post_win_event( struct thread *thread, unsigned int event,
user_handle_t win, unsigned int object_id, 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, const WCHAR *module, data_size_t module_size,
user_handle_t handle ); user_handle_t handle );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment