server: Make thread entry points client_ptr_t instead of void pointers.

This commit is contained in:
Alexandre Julliard 2008-12-30 22:56:15 +01:00
parent 2cf868c0be
commit c6c335d70e
9 changed files with 58 additions and 51 deletions

View File

@ -80,7 +80,7 @@ BOOL WINAPI WaitForDebugEvent(
case CREATE_THREAD_DEBUG_EVENT: case CREATE_THREAD_DEBUG_EVENT:
event->u.CreateThread.hThread = wine_server_ptr_handle( data.info.create_thread.handle ); 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.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; break;
case CREATE_PROCESS_DEBUG_EVENT: case CREATE_PROCESS_DEBUG_EVENT:
event->u.CreateProcessInfo.hFile = wine_server_ptr_handle( data.info.create_process.file ); 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.dwDebugInfoFileOffset = data.info.create_process.dbg_offset;
event->u.CreateProcessInfo.nDebugInfoSize = data.info.create_process.dbg_size; event->u.CreateProcessInfo.nDebugInfoSize = data.info.create_process.dbg_size;
event->u.CreateProcessInfo.lpThreadLocalBase = data.info.create_process.teb; 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.lpImageName = wine_server_get_ptr( data.info.create_process.name );
event->u.CreateProcessInfo.fUnicode = data.info.create_process.unicode; event->u.CreateProcessInfo.fUnicode = data.info.create_process.unicode;
break; break;

View File

@ -997,7 +997,7 @@ NTSTATUS server_init_process_done(void)
#ifdef __i386__ #ifdef __i386__
req->ldt_copy = wine_server_client_ptr( &wine_ldt_copy ); req->ldt_copy = wine_server_client_ptr( &wine_ldt_copy );
#endif #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); req->gui = (nt->OptionalHeader.Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CUI);
status = wine_server_call( req ); 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->unix_tid = unix_tid;
req->teb = NtCurrentTeb(); req->teb = NtCurrentTeb();
req->peb = NtCurrentTeb()->Peb; req->peb = NtCurrentTeb()->Peb;
req->entry = entry_point; req->entry = wine_server_client_ptr( entry_point );
req->reply_fd = reply_pipe[1]; req->reply_fd = reply_pipe[1];
req->wait_fd = ntdll_get_thread_data()->wait_fd[1]; req->wait_fd = ntdll_get_thread_data()->wait_fd[1];
req->debug_level = (TRACE_ON(server) != 0); req->debug_level = (TRACE_ON(server) != 0);

View File

@ -63,7 +63,7 @@ struct debug_event_create_thread
{ {
obj_handle_t handle; obj_handle_t handle;
void *teb; void *teb;
void *start; client_ptr_t start;
}; };
struct debug_event_create_process struct debug_event_create_process
{ {
@ -74,7 +74,7 @@ struct debug_event_create_process
int dbg_offset; int dbg_offset;
int dbg_size; int dbg_size;
void *teb; void *teb;
void *start; client_ptr_t start;
client_ptr_t name; client_ptr_t name;
int unicode; int unicode;
}; };
@ -543,7 +543,7 @@ struct init_process_done_request
int gui; int gui;
mod_handle_t module; mod_handle_t module;
client_ptr_t ldt_copy; client_ptr_t ldt_copy;
void* entry; client_ptr_t entry;
}; };
struct init_process_done_reply struct init_process_done_reply
{ {
@ -560,8 +560,7 @@ struct init_thread_request
int debug_level; int debug_level;
void* teb; void* teb;
void* peb; void* peb;
void* entry; client_ptr_t entry;
int unused;
int reply_fd; int reply_fd;
int wait_fd; int wait_fd;
}; };
@ -693,7 +692,7 @@ struct get_dll_info_request
struct get_dll_info_reply struct get_dll_info_reply
{ {
struct reply_header __header; struct reply_header __header;
void* entry_point; client_ptr_t entry_point;
data_size_t size; data_size_t size;
data_size_t filename_len; data_size_t filename_len;
/* VARARG(filename,unicode_str); */ /* VARARG(filename,unicode_str); */
@ -5062,6 +5061,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 374 #define SERVER_PROTOCOL_VERSION 375
#endif /* __WINE_WINE_SERVER_PROTOCOL_H */ #endif /* __WINE_WINE_SERVER_PROTOCOL_H */

View File

@ -112,32 +112,34 @@ static const struct object_ops debug_ctx_ops =
/* routines to build an event according to its type */ /* 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) ); memcpy( &event->data.info.exception, arg, sizeof(event->data.info.exception) );
return 1; 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 process *debugger = event->debugger->process;
struct thread *thread = event->sender; struct thread *thread = event->sender;
const client_ptr_t *entry = arg;
obj_handle_t handle; obj_handle_t handle;
/* documented: THREAD_GET_CONTEXT | THREAD_SET_CONTEXT | THREAD_SUSPEND_RESUME */ /* documented: THREAD_GET_CONTEXT | THREAD_SET_CONTEXT | THREAD_SUSPEND_RESUME */
if (!(handle = alloc_handle( debugger, thread, THREAD_ALL_ACCESS, 0 ))) return 0; if (!(handle = alloc_handle( debugger, thread, THREAD_ALL_ACCESS, 0 ))) return 0;
event->data.info.create_thread.handle = handle; event->data.info.create_thread.handle = handle;
event->data.info.create_thread.teb = thread->teb; event->data.info.create_thread.teb = thread->teb;
event->data.info.create_thread.start = arg; event->data.info.create_thread.start = *entry;
return 1; 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 process *debugger = event->debugger->process;
struct thread *thread = event->sender; struct thread *thread = event->sender;
struct process *process = thread->process; struct process *process = thread->process;
struct process_dll *exe_module = get_process_exe_module( process ); struct process_dll *exe_module = get_process_exe_module( process );
const client_ptr_t *entry = arg;
obj_handle_t handle; obj_handle_t handle;
/* documented: PROCESS_VM_READ | PROCESS_VM_WRITE */ /* 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.file = handle;
event->data.info.create_process.teb = thread->teb; event->data.info.create_process.teb = thread->teb;
event->data.info.create_process.base = exe_module->base; 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_offset = exe_module->dbg_offset;
event->data.info.create_process.dbg_size = exe_module->dbg_size; event->data.info.create_process.dbg_size = exe_module->dbg_size;
event->data.info.create_process.name = exe_module->name; 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; 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; event->data.info.exit.exit_code = thread->exit_code;
return 1; 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; event->data.info.exit.exit_code = process->exit_code;
return 1; 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 *debugger = event->debugger->process;
struct process_dll *dll = arg; const struct process_dll *dll = arg;
obj_handle_t handle = 0; obj_handle_t handle = 0;
if (dll->file && !(handle = alloc_handle( debugger, dll->file, GENERIC_READ, 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; 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; event->data.info.unload_dll.base = *base;
return 1; 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; event->data.info.output_string = *data;
return 1; 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 */ #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 */ /* alloc a debug event for a debugger */
static struct debug_event *alloc_debug_event( struct thread *thread, int code, 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 thread *debugger = thread->process->debugger;
struct debug_event *event; 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 */ /* 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) 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 */ /* 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 list *ptr;
struct thread *thread, *first_thread = get_process_first_thread( process ); 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 ) LIST_FOR_EACH_ENTRY( thread, &process->thread_list, struct thread, proc_entry )
{ {
if (thread == first_thread) if (thread == first_thread)
generate_debug_event( thread, CREATE_PROCESS_DEBUG_EVENT, entry ); generate_debug_event( thread, CREATE_PROCESS_DEBUG_EVENT, &entry );
else else
generate_debug_event( thread, CREATE_THREAD_DEBUG_EVENT, NULL ); generate_debug_event( thread, CREATE_THREAD_DEBUG_EVENT, NULL );
} }
@ -619,7 +621,7 @@ DECL_HANDLER(debug_process)
} }
else if (debugger_attach( process, current )) else if (debugger_attach( process, current ))
{ {
generate_startup_debug_events( process, NULL ); generate_startup_debug_events( process, 0 );
break_process( process ); break_process( process );
resume_process( process ); resume_process( process );
} }

View File

@ -175,8 +175,8 @@ extern void sock_init(void);
/* debugger functions */ /* debugger functions */
extern int set_process_debugger( struct process *process, struct thread *debugger ); 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_debug_event( struct thread *thread, int code, const void *arg );
extern void generate_startup_debug_events( struct process *process, void *entry ); extern void generate_startup_debug_events( struct process *process, client_ptr_t entry );
extern void debug_exit_thread( struct thread *thread ); extern void debug_exit_thread( struct thread *thread );
/* mapping functions */ /* mapping functions */

View File

@ -1168,7 +1168,7 @@ DECL_HANDLER(get_dll_info)
if (dll) if (dll)
{ {
reply->size = dll->size; reply->size = dll->size;
reply->entry_point = NULL; /* FIXME */ reply->entry_point = 0; /* FIXME */
reply->filename_len = dll->namelen; reply->filename_len = dll->namelen;
if (dll->filename) if (dll->filename)
{ {

View File

@ -79,7 +79,7 @@ struct debug_event_create_thread
{ {
obj_handle_t handle; /* handle to the new thread */ obj_handle_t handle; /* handle to the new thread */
void *teb; /* thread teb (in debugged process address space) */ 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 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_offset; /* offset of debug info in file */
int dbg_size; /* size of debug info */ int dbg_size; /* size of debug info */
void *teb; /* thread teb (in debugged process address space) */ 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) */ client_ptr_t name; /* image name (optional) */
int unicode; /* is it Unicode? */ int unicode; /* is it Unicode? */
}; };
@ -537,7 +537,7 @@ typedef union
int gui; /* is it a GUI process? */ int gui; /* is it a GUI process? */
mod_handle_t module; /* main module base address */ mod_handle_t module; /* main module base address */
client_ptr_t ldt_copy; /* address of LDT copy (in thread address space) */ 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 @END
@ -548,8 +548,7 @@ typedef union
int debug_level; /* new debug level */ int debug_level; /* new debug level */
void* teb; /* TEB of new thread (in thread address space) */ void* teb; /* TEB of new thread (in thread address space) */
void* peb; /* address of PEB (in thread address space) */ void* peb; /* address of PEB (in thread address space) */
void* entry; /* thread entry point (in thread address space) */ client_ptr_t entry; /* thread entry point (in thread address space) */
int unused; /* was: ldt_copy */
int reply_fd; /* fd for reply pipe */ int reply_fd; /* fd for reply pipe */
int wait_fd; /* fd for blocking calls pipe */ int wait_fd; /* fd for blocking calls pipe */
@REPLY @REPLY
@ -641,7 +640,7 @@ typedef union
obj_handle_t handle; /* process handle */ obj_handle_t handle; /* process handle */
mod_handle_t base_address; /* base address of module */ mod_handle_t base_address; /* base address of module */
@REPLY @REPLY
void* entry_point; client_ptr_t entry_point;
data_size_t size; /* module size */ data_size_t size; /* module size */
data_size_t filename_len; /* buffer len in bytes required to store filename */ data_size_t filename_len; /* buffer len in bytes required to store filename */
VARARG(filename,unicode_str); /* file name of module */ VARARG(filename,unicode_str); /* file name of module */

View File

@ -1053,7 +1053,7 @@ DECL_HANDLER(init_thread)
if (process->unix_pid != current->unix_pid) if (process->unix_pid != current->unix_pid)
process->unix_pid = -1; /* can happen with linuxthreads */ process->unix_pid = -1; /* can happen with linuxthreads */
if (current->suspend + process->suspend > 0) stop_thread( current ); 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 ); debug_level = max( debug_level, req->debug_level );

View File

@ -499,18 +499,21 @@ static void dump_varargs_debug_event( data_size_t size )
fprintf( stderr, ",first=%d}", event->info.exception.first ); fprintf( stderr, ",first=%d}", event->info.exception.first );
break; break;
case CREATE_THREAD_DEBUG_EVENT: case CREATE_THREAD_DEBUG_EVENT:
fprintf( stderr, "{create_thread,thread=%04x,teb=%p,start=%p}", fprintf( stderr, "{create_thread,thread=%04x,teb=%p,start=",
event->info.create_thread.handle, event->info.create_thread.teb, event->info.create_thread.handle, event->info.create_thread.teb );
event->info.create_thread.start ); dump_uint64( &event->info.create_thread.start );
fputc( '}', stderr );
break; break;
case CREATE_PROCESS_DEBUG_EVENT: case CREATE_PROCESS_DEBUG_EVENT:
fprintf( stderr, "{create_process,file=%04x,process=%04x,thread=%04x,base=", 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.file, event->info.create_process.process,
event->info.create_process.thread ); event->info.create_process.thread );
dump_uint64( &event->info.create_process.base ); 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.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 ); dump_uint64( &event->info.create_process.name );
fprintf( stderr, ",unicode=%d}", event->info.create_process.unicode ); fprintf( stderr, ",unicode=%d}", event->info.create_process.unicode );
break; break;
@ -974,7 +977,8 @@ static void dump_init_process_done_request( const struct init_process_done_reque
fprintf( stderr, " ldt_copy=" ); fprintf( stderr, " ldt_copy=" );
dump_uint64( &req->ldt_copy ); dump_uint64( &req->ldt_copy );
fprintf( stderr, "," ); 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 ) 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, " debug_level=%d,", req->debug_level );
fprintf( stderr, " teb=%p,", req->teb ); fprintf( stderr, " teb=%p,", req->teb );
fprintf( stderr, " peb=%p,", req->peb ); fprintf( stderr, " peb=%p,", req->peb );
fprintf( stderr, " entry=%p,", req->entry ); fprintf( stderr, " entry=" );
fprintf( stderr, " unused=%d,", req->unused ); dump_uint64( &req->entry );
fprintf( stderr, "," );
fprintf( stderr, " reply_fd=%d,", req->reply_fd ); fprintf( stderr, " reply_fd=%d,", req->reply_fd );
fprintf( stderr, " wait_fd=%d", req->wait_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 ) 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, " size=%u,", req->size );
fprintf( stderr, " filename_len=%u,", req->filename_len ); fprintf( stderr, " filename_len=%u,", req->filename_len );
fprintf( stderr, " filename=" ); fprintf( stderr, " filename=" );