server: Make TEB and PEB client_ptr_t instead of void pointers.
diff --git a/server/process.c b/server/process.c
index 09dd041..8a4fb15 100644
--- a/server/process.c
+++ b/server/process.c
@@ -331,7 +331,7 @@
process->startup_info = NULL;
process->idle_event = NULL;
process->queue = NULL;
- process->peb = NULL;
+ process->peb = 0;
process->ldt_copy = 0;
process->winstation = 0;
process->desktop = 0;
@@ -829,7 +829,7 @@
char data = (flag != 0);
/* BeingDebugged flag is the byte at offset 2 in the PEB */
- return write_process_memory( process, (client_ptr_t)(unsigned long)((char *)process->peb + 2), 1, &data );
+ return write_process_memory( process, process->peb + 2, 1, &data );
}
/* take a snapshot of currently running processes */
diff --git a/server/process.h b/server/process.h
index 5d3b456..5311ae3 100644
--- a/server/process.h
+++ b/server/process.h
@@ -79,7 +79,7 @@
obj_handle_t desktop; /* handle to desktop to use for new threads */
struct token *token; /* security token associated with this process */
struct list dlls; /* list of loaded dlls */
- void *peb; /* PEB address in client address space */
+ client_ptr_t peb; /* PEB address in client address space */
client_ptr_t ldt_copy; /* pointer to LDT copy in client addr space */
unsigned int trace_data; /* opaque data used by the process tracing mechanism */
};
diff --git a/server/protocol.def b/server/protocol.def
index 3c6c55d..996d790 100644
--- a/server/protocol.def
+++ b/server/protocol.def
@@ -78,7 +78,7 @@
struct debug_event_create_thread
{
obj_handle_t handle; /* handle to the new thread */
- void *teb; /* thread teb (in debugged process address space) */
+ client_ptr_t teb; /* thread teb (in debugged process address space) */
client_ptr_t start; /* thread startup routine */
};
struct debug_event_create_process
@@ -89,7 +89,7 @@
mod_handle_t base; /* base of executable image */
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) */
+ client_ptr_t teb; /* thread teb (in debugged process address space) */
client_ptr_t start; /* thread startup routine */
client_ptr_t name; /* image name (optional) */
int unicode; /* is it Unicode? */
@@ -546,11 +546,11 @@
int unix_pid; /* Unix pid of new thread */
int unix_tid; /* Unix tid of new thread */
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) */
+ client_ptr_t teb; /* TEB of new thread (in thread address space) */
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 */
+ client_ptr_t peb; /* address of PEB (in thread address space) */
@REPLY
process_id_t pid; /* process id of the new thread's process */
thread_id_t tid; /* thread id of the new thread */
@@ -585,12 +585,12 @@
@REPLY
process_id_t pid; /* server process id */
process_id_t ppid; /* server process id of parent */
- int exit_code; /* process exit code */
int priority; /* priority class */
unsigned int affinity; /* process affinity mask */
- void* peb; /* PEB address in process address space */
+ client_ptr_t peb; /* PEB address in process address space */
timeout_t start_time; /* process start time */
timeout_t end_time; /* process end time */
+ int exit_code; /* process exit code */
@END
@@ -612,12 +612,12 @@
@REPLY
process_id_t pid; /* server process id */
thread_id_t tid; /* server thread id */
- void* teb; /* thread teb pointer */
- int exit_code; /* thread exit code */
+ client_ptr_t teb; /* thread teb pointer */
int priority; /* thread priority level */
unsigned int affinity; /* thread affinity mask */
timeout_t creation_time; /* thread creation time */
timeout_t exit_time; /* thread exit time */
+ int exit_code; /* thread exit code */
int last; /* last thread in process */
@END
diff --git a/server/thread.c b/server/thread.c
index fd7ebfa..aea0c70 100644
--- a/server/thread.c
+++ b/server/thread.c
@@ -154,7 +154,7 @@
thread->unix_tid = -1; /* not known yet */
thread->context = NULL;
thread->suspend_context = NULL;
- thread->teb = NULL;
+ thread->teb = 0;
thread->debug_ctx = NULL;
thread->debug_event = NULL;
thread->debug_break = 0;
@@ -188,9 +188,9 @@
}
/* check if address looks valid for a client-side data structure (TEB etc.) */
-static inline int is_valid_address( void *addr )
+static inline int is_valid_address( client_ptr_t addr )
{
- return addr && !((unsigned long)addr % sizeof(int));
+ return addr && !(addr % sizeof(int));
}
/* create a new thread */
@@ -291,8 +291,8 @@
struct thread *thread = (struct thread *)obj;
assert( obj->ops == &thread_ops );
- fprintf( stderr, "Thread id=%04x unix pid=%d unix tid=%d teb=%p state=%d\n",
- thread->id, thread->unix_pid, thread->unix_tid, thread->teb, thread->state );
+ fprintf( stderr, "Thread id=%04x unix pid=%d unix tid=%d state=%d\n",
+ thread->id, thread->unix_pid, thread->unix_tid, thread->state );
}
static int thread_signaled( struct object *obj, struct thread *thread )
diff --git a/server/thread.h b/server/thread.h
index b4ca567..e282499 100644
--- a/server/thread.h
+++ b/server/thread.h
@@ -78,7 +78,7 @@
int unix_tid; /* Unix tid of client */
CONTEXT *context; /* current context if in an exception handler */
CONTEXT *suspend_context; /* current context if suspended */
- void *teb; /* TEB address (in client address space) */
+ client_ptr_t teb; /* TEB address (in client address space) */
int priority; /* priority level */
unsigned int affinity; /* affinity mask */
int suspend; /* suspend count */
diff --git a/server/trace.c b/server/trace.c
index 5cf5f82..7fc865e 100644
--- a/server/trace.c
+++ b/server/trace.c
@@ -499,8 +499,9 @@
fprintf( stderr, ",first=%d}", event->info.exception.first );
break;
case CREATE_THREAD_DEBUG_EVENT:
- fprintf( stderr, "{create_thread,thread=%04x,teb=%p,start=",
- event->info.create_thread.handle, event->info.create_thread.teb );
+ fprintf( stderr, "{create_thread,thread=%04x,teb=", event->info.create_thread.handle );
+ dump_uint64( &event->info.create_thread.teb );
+ fprintf( stderr, ",start=" );
dump_uint64( &event->info.create_thread.start );
fputc( '}', stderr );
break;
@@ -509,9 +510,10 @@
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=",
- event->info.create_process.dbg_offset, event->info.create_process.dbg_size,
- event->info.create_process.teb );
+ fprintf( stderr, ",offset=%d,size=%d,teb=",
+ event->info.create_process.dbg_offset, event->info.create_process.dbg_size );
+ dump_uint64( &event->info.create_process.teb );
+ fprintf( stderr, ",start=" );
dump_uint64( &event->info.create_process.start );
fprintf( stderr, ",name=" );
dump_uint64( &event->info.create_process.name );
@@ -986,13 +988,16 @@
fprintf( stderr, " unix_pid=%d,", req->unix_pid );
fprintf( stderr, " unix_tid=%d,", req->unix_tid );
fprintf( stderr, " debug_level=%d,", req->debug_level );
- fprintf( stderr, " teb=%p,", req->teb );
- fprintf( stderr, " peb=%p,", req->peb );
+ fprintf( stderr, " teb=" );
+ dump_uint64( &req->teb );
+ fprintf( stderr, "," );
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 );
+ fprintf( stderr, " wait_fd=%d,", req->wait_fd );
+ fprintf( stderr, " peb=" );
+ dump_uint64( &req->peb );
}
static void dump_init_thread_reply( const struct init_thread_reply *req )
@@ -1038,15 +1043,18 @@
{
fprintf( stderr, " pid=%04x,", req->pid );
fprintf( stderr, " ppid=%04x,", req->ppid );
- fprintf( stderr, " exit_code=%d,", req->exit_code );
fprintf( stderr, " priority=%d,", req->priority );
fprintf( stderr, " affinity=%08x,", req->affinity );
- fprintf( stderr, " peb=%p,", req->peb );
+ fprintf( stderr, " peb=" );
+ dump_uint64( &req->peb );
+ fprintf( stderr, "," );
fprintf( stderr, " start_time=" );
dump_timeout( &req->start_time );
fprintf( stderr, "," );
fprintf( stderr, " end_time=" );
dump_timeout( &req->end_time );
+ fprintf( stderr, "," );
+ fprintf( stderr, " exit_code=%d", req->exit_code );
}
static void dump_set_process_info_request( const struct set_process_info_request *req )
@@ -1067,8 +1075,9 @@
{
fprintf( stderr, " pid=%04x,", req->pid );
fprintf( stderr, " tid=%04x,", req->tid );
- fprintf( stderr, " teb=%p,", req->teb );
- fprintf( stderr, " exit_code=%d,", req->exit_code );
+ fprintf( stderr, " teb=" );
+ dump_uint64( &req->teb );
+ fprintf( stderr, "," );
fprintf( stderr, " priority=%d,", req->priority );
fprintf( stderr, " affinity=%08x,", req->affinity );
fprintf( stderr, " creation_time=" );
@@ -1077,6 +1086,7 @@
fprintf( stderr, " exit_time=" );
dump_timeout( &req->exit_time );
fprintf( stderr, "," );
+ fprintf( stderr, " exit_code=%d,", req->exit_code );
fprintf( stderr, " last=%d", req->last );
}