From c6c335d70e1495c03821e6227ef715dcb71594b7 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Tue, 30 Dec 2008 22:56:15 +0100 Subject: [PATCH] server: Make thread entry points client_ptr_t instead of void pointers. --- dlls/kernel32/debugger.c | 4 ++-- dlls/ntdll/server.c | 4 ++-- include/wine/server_protocol.h | 13 +++++----- server/debugger.c | 44 ++++++++++++++++++---------------- server/object.h | 4 ++-- server/process.c | 2 +- server/protocol.def | 11 ++++----- server/thread.c | 2 +- server/trace.c | 25 ++++++++++++------- 9 files changed, 58 insertions(+), 51 deletions(-) diff --git a/dlls/kernel32/debugger.c b/dlls/kernel32/debugger.c index 645fca993cb..4156a82ea93 100644 --- a/dlls/kernel32/debugger.c +++ b/dlls/kernel32/debugger.c @@ -80,7 +80,7 @@ BOOL WINAPI WaitForDebugEvent( case CREATE_THREAD_DEBUG_EVENT: event->u.CreateThread.hThread = wine_server_ptr_handle( data.info.create_thread.handle ); event->u.CreateThread.lpThreadLocalBase = data.info.create_thread.teb; - event->u.CreateThread.lpStartAddress = data.info.create_thread.start; + event->u.CreateThread.lpStartAddress = wine_server_get_ptr( data.info.create_thread.start ); break; case CREATE_PROCESS_DEBUG_EVENT: event->u.CreateProcessInfo.hFile = wine_server_ptr_handle( data.info.create_process.file ); @@ -90,7 +90,7 @@ BOOL WINAPI WaitForDebugEvent( event->u.CreateProcessInfo.dwDebugInfoFileOffset = data.info.create_process.dbg_offset; event->u.CreateProcessInfo.nDebugInfoSize = data.info.create_process.dbg_size; event->u.CreateProcessInfo.lpThreadLocalBase = data.info.create_process.teb; - event->u.CreateProcessInfo.lpStartAddress = data.info.create_process.start; + event->u.CreateProcessInfo.lpStartAddress = wine_server_get_ptr( data.info.create_process.start ); event->u.CreateProcessInfo.lpImageName = wine_server_get_ptr( data.info.create_process.name ); event->u.CreateProcessInfo.fUnicode = data.info.create_process.unicode; break; diff --git a/dlls/ntdll/server.c b/dlls/ntdll/server.c index 95bba731f74..a39c22755ff 100644 --- a/dlls/ntdll/server.c +++ b/dlls/ntdll/server.c @@ -997,7 +997,7 @@ NTSTATUS server_init_process_done(void) #ifdef __i386__ req->ldt_copy = wine_server_client_ptr( &wine_ldt_copy ); #endif - req->entry = (char *)peb->ImageBaseAddress + nt->OptionalHeader.AddressOfEntryPoint; + req->entry = wine_server_client_ptr( (char *)peb->ImageBaseAddress + nt->OptionalHeader.AddressOfEntryPoint ); req->gui = (nt->OptionalHeader.Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CUI); status = wine_server_call( req ); } @@ -1050,7 +1050,7 @@ size_t server_init_thread( int unix_pid, int unix_tid, void *entry_point ) req->unix_tid = unix_tid; req->teb = NtCurrentTeb(); req->peb = NtCurrentTeb()->Peb; - req->entry = entry_point; + req->entry = wine_server_client_ptr( entry_point ); req->reply_fd = reply_pipe[1]; req->wait_fd = ntdll_get_thread_data()->wait_fd[1]; req->debug_level = (TRACE_ON(server) != 0); diff --git a/include/wine/server_protocol.h b/include/wine/server_protocol.h index 1a8f0dee59c..6b626f950a1 100644 --- a/include/wine/server_protocol.h +++ b/include/wine/server_protocol.h @@ -63,7 +63,7 @@ struct debug_event_create_thread { obj_handle_t handle; void *teb; - void *start; + client_ptr_t start; }; struct debug_event_create_process { @@ -74,7 +74,7 @@ struct debug_event_create_process int dbg_offset; int dbg_size; void *teb; - void *start; + client_ptr_t start; client_ptr_t name; int unicode; }; @@ -543,7 +543,7 @@ struct init_process_done_request int gui; mod_handle_t module; client_ptr_t ldt_copy; - void* entry; + client_ptr_t entry; }; struct init_process_done_reply { @@ -560,8 +560,7 @@ struct init_thread_request int debug_level; void* teb; void* peb; - void* entry; - int unused; + client_ptr_t entry; int reply_fd; int wait_fd; }; @@ -693,7 +692,7 @@ struct get_dll_info_request struct get_dll_info_reply { struct reply_header __header; - void* entry_point; + client_ptr_t entry_point; data_size_t size; data_size_t filename_len; /* VARARG(filename,unicode_str); */ @@ -5062,6 +5061,6 @@ union generic_reply struct set_window_layered_info_reply set_window_layered_info_reply; }; -#define SERVER_PROTOCOL_VERSION 374 +#define SERVER_PROTOCOL_VERSION 375 #endif /* __WINE_WINE_SERVER_PROTOCOL_H */ diff --git a/server/debugger.c b/server/debugger.c index f663e162c1e..a865ebb1b57 100644 --- a/server/debugger.c +++ b/server/debugger.c @@ -112,32 +112,34 @@ static const struct object_ops debug_ctx_ops = /* routines to build an event according to its type */ -static int fill_exception_event( struct debug_event *event, void *arg ) +static int fill_exception_event( struct debug_event *event, const void *arg ) { memcpy( &event->data.info.exception, arg, sizeof(event->data.info.exception) ); return 1; } -static int fill_create_thread_event( struct debug_event *event, void *arg ) +static int fill_create_thread_event( struct debug_event *event, const void *arg ) { struct process *debugger = event->debugger->process; struct thread *thread = event->sender; + const client_ptr_t *entry = arg; obj_handle_t handle; /* documented: THREAD_GET_CONTEXT | THREAD_SET_CONTEXT | THREAD_SUSPEND_RESUME */ if (!(handle = alloc_handle( debugger, thread, THREAD_ALL_ACCESS, 0 ))) return 0; event->data.info.create_thread.handle = handle; event->data.info.create_thread.teb = thread->teb; - event->data.info.create_thread.start = arg; + event->data.info.create_thread.start = *entry; return 1; } -static int fill_create_process_event( struct debug_event *event, void *arg ) +static int fill_create_process_event( struct debug_event *event, const void *arg ) { struct process *debugger = event->debugger->process; struct thread *thread = event->sender; struct process *process = thread->process; struct process_dll *exe_module = get_process_exe_module( process ); + const client_ptr_t *entry = arg; obj_handle_t handle; /* documented: PROCESS_VM_READ | PROCESS_VM_WRITE */ @@ -164,7 +166,7 @@ static int fill_create_process_event( struct debug_event *event, void *arg ) event->data.info.create_process.file = handle; event->data.info.create_process.teb = thread->teb; event->data.info.create_process.base = exe_module->base; - event->data.info.create_process.start = arg; + event->data.info.create_process.start = *entry; event->data.info.create_process.dbg_offset = exe_module->dbg_offset; event->data.info.create_process.dbg_size = exe_module->dbg_size; event->data.info.create_process.name = exe_module->name; @@ -172,24 +174,24 @@ static int fill_create_process_event( struct debug_event *event, void *arg ) return 1; } -static int fill_exit_thread_event( struct debug_event *event, void *arg ) +static int fill_exit_thread_event( struct debug_event *event, const void *arg ) { - struct thread *thread = arg; + const struct thread *thread = arg; event->data.info.exit.exit_code = thread->exit_code; return 1; } -static int fill_exit_process_event( struct debug_event *event, void *arg ) +static int fill_exit_process_event( struct debug_event *event, const void *arg ) { - struct process *process = arg; + const struct process *process = arg; event->data.info.exit.exit_code = process->exit_code; return 1; } -static int fill_load_dll_event( struct debug_event *event, void *arg ) +static int fill_load_dll_event( struct debug_event *event, const void *arg ) { struct process *debugger = event->debugger->process; - struct process_dll *dll = arg; + const struct process_dll *dll = arg; obj_handle_t handle = 0; if (dll->file && !(handle = alloc_handle( debugger, dll->file, GENERIC_READ, 0 ))) @@ -203,21 +205,21 @@ static int fill_load_dll_event( struct debug_event *event, void *arg ) return 1; } -static int fill_unload_dll_event( struct debug_event *event, void *arg ) +static int fill_unload_dll_event( struct debug_event *event, const void *arg ) { - mod_handle_t *base = arg; + const mod_handle_t *base = arg; event->data.info.unload_dll.base = *base; return 1; } -static int fill_output_debug_string_event( struct debug_event *event, void *arg ) +static int fill_output_debug_string_event( struct debug_event *event, const void *arg ) { - struct debug_event_output_string *data = arg; + const struct debug_event_output_string *data = arg; event->data.info.output_string = *data; return 1; } -typedef int (*fill_event_func)( struct debug_event *event, void *arg ); +typedef int (*fill_event_func)( struct debug_event *event, const void *arg ); #define NB_DEBUG_EVENTS OUTPUT_DEBUG_STRING_EVENT /* RIP_EVENT not supported */ @@ -373,7 +375,7 @@ static int continue_debug_event( struct process *process, struct thread *thread, /* alloc a debug event for a debugger */ static struct debug_event *alloc_debug_event( struct thread *thread, int code, - void *arg, const CONTEXT *context ) + const void *arg, const CONTEXT *context ) { struct thread *debugger = thread->process->debugger; struct debug_event *event; @@ -404,7 +406,7 @@ static struct debug_event *alloc_debug_event( struct thread *thread, int code, } /* generate a debug event from inside the server and queue it */ -void generate_debug_event( struct thread *thread, int code, void *arg ) +void generate_debug_event( struct thread *thread, int code, const void *arg ) { if (thread->process->debugger) { @@ -499,7 +501,7 @@ int debugger_detach( struct process *process, struct thread *debugger ) } /* generate all startup events of a given process */ -void generate_startup_debug_events( struct process *process, void *entry ) +void generate_startup_debug_events( struct process *process, client_ptr_t entry ) { struct list *ptr; struct thread *thread, *first_thread = get_process_first_thread( process ); @@ -508,7 +510,7 @@ void generate_startup_debug_events( struct process *process, void *entry ) LIST_FOR_EACH_ENTRY( thread, &process->thread_list, struct thread, proc_entry ) { if (thread == first_thread) - generate_debug_event( thread, CREATE_PROCESS_DEBUG_EVENT, entry ); + generate_debug_event( thread, CREATE_PROCESS_DEBUG_EVENT, &entry ); else generate_debug_event( thread, CREATE_THREAD_DEBUG_EVENT, NULL ); } @@ -619,7 +621,7 @@ DECL_HANDLER(debug_process) } else if (debugger_attach( process, current )) { - generate_startup_debug_events( process, NULL ); + generate_startup_debug_events( process, 0 ); break_process( process ); resume_process( process ); } diff --git a/server/object.h b/server/object.h index cd46f5b8179..a5d0ffd304c 100644 --- a/server/object.h +++ b/server/object.h @@ -175,8 +175,8 @@ extern void sock_init(void); /* debugger functions */ extern int set_process_debugger( struct process *process, struct thread *debugger ); -extern void generate_debug_event( struct thread *thread, int code, void *arg ); -extern void generate_startup_debug_events( struct process *process, void *entry ); +extern void generate_debug_event( struct thread *thread, int code, const void *arg ); +extern void generate_startup_debug_events( struct process *process, client_ptr_t entry ); extern void debug_exit_thread( struct thread *thread ); /* mapping functions */ diff --git a/server/process.c b/server/process.c index a0c66ab4bcd..09dd041ea24 100644 --- a/server/process.c +++ b/server/process.c @@ -1168,7 +1168,7 @@ DECL_HANDLER(get_dll_info) if (dll) { reply->size = dll->size; - reply->entry_point = NULL; /* FIXME */ + reply->entry_point = 0; /* FIXME */ reply->filename_len = dll->namelen; if (dll->filename) { diff --git a/server/protocol.def b/server/protocol.def index e5c9676b033..3c6c55d22c7 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -79,7 +79,7 @@ struct debug_event_create_thread { obj_handle_t handle; /* handle to the new thread */ void *teb; /* thread teb (in debugged process address space) */ - void *start; /* thread startup routine */ + client_ptr_t start; /* thread startup routine */ }; struct debug_event_create_process { @@ -90,7 +90,7 @@ struct debug_event_create_process int dbg_offset; /* offset of debug info in file */ int dbg_size; /* size of debug info */ void *teb; /* thread teb (in debugged process address space) */ - void *start; /* thread startup routine */ + client_ptr_t start; /* thread startup routine */ client_ptr_t name; /* image name (optional) */ int unicode; /* is it Unicode? */ }; @@ -537,7 +537,7 @@ typedef union int gui; /* is it a GUI process? */ mod_handle_t module; /* main module base address */ client_ptr_t ldt_copy; /* address of LDT copy (in thread address space) */ - void* entry; /* process entry point */ + client_ptr_t entry; /* process entry point */ @END @@ -548,8 +548,7 @@ typedef union int debug_level; /* new debug level */ void* teb; /* TEB of new thread (in thread address space) */ void* peb; /* address of PEB (in thread address space) */ - void* entry; /* thread entry point (in thread address space) */ - int unused; /* was: ldt_copy */ + client_ptr_t entry; /* thread entry point (in thread address space) */ int reply_fd; /* fd for reply pipe */ int wait_fd; /* fd for blocking calls pipe */ @REPLY @@ -641,7 +640,7 @@ typedef union obj_handle_t handle; /* process handle */ mod_handle_t base_address; /* base address of module */ @REPLY - void* entry_point; + client_ptr_t entry_point; data_size_t size; /* module size */ data_size_t filename_len; /* buffer len in bytes required to store filename */ VARARG(filename,unicode_str); /* file name of module */ diff --git a/server/thread.c b/server/thread.c index 675deda296a..fd7ebfaa355 100644 --- a/server/thread.c +++ b/server/thread.c @@ -1053,7 +1053,7 @@ DECL_HANDLER(init_thread) if (process->unix_pid != current->unix_pid) process->unix_pid = -1; /* can happen with linuxthreads */ if (current->suspend + process->suspend > 0) stop_thread( current ); - generate_debug_event( current, CREATE_THREAD_DEBUG_EVENT, req->entry ); + generate_debug_event( current, CREATE_THREAD_DEBUG_EVENT, &req->entry ); } debug_level = max( debug_level, req->debug_level ); diff --git a/server/trace.c b/server/trace.c index db67b2a6880..5cf5f823422 100644 --- a/server/trace.c +++ b/server/trace.c @@ -499,18 +499,21 @@ static void dump_varargs_debug_event( data_size_t size ) fprintf( stderr, ",first=%d}", event->info.exception.first ); break; case CREATE_THREAD_DEBUG_EVENT: - fprintf( stderr, "{create_thread,thread=%04x,teb=%p,start=%p}", - event->info.create_thread.handle, event->info.create_thread.teb, - event->info.create_thread.start ); + fprintf( stderr, "{create_thread,thread=%04x,teb=%p,start=", + event->info.create_thread.handle, event->info.create_thread.teb ); + dump_uint64( &event->info.create_thread.start ); + fputc( '}', stderr ); break; case CREATE_PROCESS_DEBUG_EVENT: fprintf( stderr, "{create_process,file=%04x,process=%04x,thread=%04x,base=", event->info.create_process.file, event->info.create_process.process, event->info.create_process.thread ); dump_uint64( &event->info.create_process.base ); - fprintf( stderr, ",offset=%d,size=%d,teb=%p,start=%p,name=", + fprintf( stderr, ",offset=%d,size=%d,teb=%p,start=", event->info.create_process.dbg_offset, event->info.create_process.dbg_size, - event->info.create_process.teb, event->info.create_process.start ); + event->info.create_process.teb ); + dump_uint64( &event->info.create_process.start ); + fprintf( stderr, ",name=" ); dump_uint64( &event->info.create_process.name ); fprintf( stderr, ",unicode=%d}", event->info.create_process.unicode ); break; @@ -974,7 +977,8 @@ static void dump_init_process_done_request( const struct init_process_done_reque fprintf( stderr, " ldt_copy=" ); dump_uint64( &req->ldt_copy ); fprintf( stderr, "," ); - fprintf( stderr, " entry=%p", req->entry ); + fprintf( stderr, " entry=" ); + dump_uint64( &req->entry ); } static void dump_init_thread_request( const struct init_thread_request *req ) @@ -984,8 +988,9 @@ static void dump_init_thread_request( const struct init_thread_request *req ) fprintf( stderr, " debug_level=%d,", req->debug_level ); fprintf( stderr, " teb=%p,", req->teb ); fprintf( stderr, " peb=%p,", req->peb ); - fprintf( stderr, " entry=%p,", req->entry ); - fprintf( stderr, " unused=%d,", req->unused ); + fprintf( stderr, " entry=" ); + dump_uint64( &req->entry ); + fprintf( stderr, "," ); fprintf( stderr, " reply_fd=%d,", req->reply_fd ); fprintf( stderr, " wait_fd=%d", req->wait_fd ); } @@ -1093,7 +1098,9 @@ static void dump_get_dll_info_request( const struct get_dll_info_request *req ) static void dump_get_dll_info_reply( const struct get_dll_info_reply *req ) { - fprintf( stderr, " entry_point=%p,", req->entry_point ); + fprintf( stderr, " entry_point=" ); + dump_uint64( &req->entry_point ); + fprintf( stderr, "," ); fprintf( stderr, " size=%u,", req->size ); fprintf( stderr, " filename_len=%u,", req->filename_len ); fprintf( stderr, " filename=" );