diff --git a/server/process.c b/server/process.c
index 8319129d65a5b953280024a9e19ccc4b78168eb1..ba0e19ab2c3ddaef7ef20f628d7765523b57a5ad 100644
--- a/server/process.c
+++ b/server/process.c
@@ -114,6 +114,79 @@ static const struct object_ops startup_info_ops =
 };
 
 
+struct ptid_entry
+{
+    void        *ptr;   /* entry ptr */
+    unsigned int next;  /* next free entry */
+};
+
+static struct ptid_entry *ptid_entries;     /* array of ptid entries */
+static unsigned int used_ptid_entries;      /* number of entries in use */
+static unsigned int alloc_ptid_entries;     /* number of allocated entries */
+static unsigned int next_free_ptid;         /* next free entry */
+static unsigned int last_free_ptid;         /* last free entry */
+
+#define PTID_OFFSET 8  /* offset for first ptid value */
+
+/* allocate a new process or thread id */
+unsigned int alloc_ptid( void *ptr )
+{
+    struct ptid_entry *entry;
+    unsigned int id;
+
+    if (used_ptid_entries < alloc_ptid_entries)
+    {
+        id = used_ptid_entries + PTID_OFFSET;
+        entry = &ptid_entries[used_ptid_entries++];
+    }
+    else if (next_free_ptid)
+    {
+        id = next_free_ptid;
+        entry = &ptid_entries[id - PTID_OFFSET];
+        if (!(next_free_ptid = entry->next)) last_free_ptid = 0;
+    }
+    else  /* need to grow the array */
+    {
+        unsigned int count = alloc_ptid_entries + (alloc_ptid_entries / 2);
+        if (!count) count = 64;
+        if (!(entry = realloc( ptid_entries, count * sizeof(*entry) )))
+        {
+            set_error( STATUS_NO_MEMORY );
+            return 0;
+        }
+        ptid_entries = entry;
+        alloc_ptid_entries = count;
+        id = used_ptid_entries + PTID_OFFSET;
+        entry = &ptid_entries[used_ptid_entries++];
+    }
+
+    entry->ptr = ptr;
+    return id;
+}
+
+/* free a process or thread id */
+void free_ptid( unsigned int id )
+{
+    struct ptid_entry *entry = &ptid_entries[id - PTID_OFFSET];
+
+    entry->ptr  = NULL;
+    entry->next = 0;
+
+    /* append to end of free list so that we don't reuse it too early */
+    if (last_free_ptid) ptid_entries[last_free_ptid - PTID_OFFSET].next = id;
+    else next_free_ptid = id;
+
+    last_free_ptid = id;
+}
+
+/* retrieve the pointer corresponding to a process or thread id */
+void *get_ptid_entry( unsigned int id )
+{
+    if (id < PTID_OFFSET) return NULL;
+    if (id - PTID_OFFSET >= used_ptid_entries) return NULL;
+    return ptid_entries[id - PTID_OFFSET].ptr;
+}
+
 /* set the state of the process startup info */
 static void set_process_startup_state( struct process *process, enum startup_state state )
 {
@@ -225,6 +298,8 @@ struct thread *create_process( int fd )
     if ((process->next = first_process) != NULL) process->next->prev = process;
     first_process = process;
 
+    if (!(process->id = alloc_ptid( process ))) goto error;
+
     /* create the main thread */
     if (pipe( request_pipe ) == -1)
     {
@@ -339,6 +414,7 @@ static void process_destroy( struct object *obj )
     if (process->atom_table) release_object( process->atom_table );
     if (process->exe.file) release_object( process->exe.file );
     if (process->exe.filename) free( process->exe.filename );
+    if (process->id) free_ptid( process->id );
 }
 
 /* dump a process on stdout for debugging purposes */
@@ -347,8 +423,8 @@ static void process_dump( struct object *obj, int verbose )
     struct process *process = (struct process *)obj;
     assert( obj->ops == &process_ops );
 
-    fprintf( stderr, "Process next=%p prev=%p handles=%p\n",
-             process->next, process->prev, process->handles );
+    fprintf( stderr, "Process id=%04x next=%p prev=%p handles=%p\n",
+             process->id, process->next, process->prev, process->handles );
 }
 
 static int process_signaled( struct object *obj, struct thread *thread )
@@ -400,11 +476,11 @@ static int startup_info_signaled( struct object *obj, struct thread *thread )
 /* get a process from an id (and increment the refcount) */
 struct process *get_process_from_id( process_id_t id )
 {
-    struct process *p = first_process;
-    while (p && (get_process_id(p) != id)) p = p->next;
-    if (p) grab_object( p );
-    else set_error( STATUS_INVALID_PARAMETER );
-    return p;
+    struct object *obj = get_ptid_entry( id );
+
+    if (obj && obj->ops == &process_ops) return (struct process *)grab_object( obj );
+    set_error( STATUS_INVALID_PARAMETER );
+    return NULL;
 }
 
 /* get a process from a handle (and increment the refcount) */
diff --git a/server/process.h b/server/process.h
index c56af7fb9a636d92d06952cbf46593811c909bbc..55bda89bbab1b13cb33035aa11ffb649bd3ec9da 100644
--- a/server/process.h
+++ b/server/process.h
@@ -56,6 +56,8 @@ struct process
     struct thread       *thread_list;     /* head of the thread list */
     struct thread       *debugger;        /* thread debugging this process */
     struct handle_table *handles;         /* handle entries */
+    process_id_t         id;              /* id of the process */
+    process_id_t         group_id;        /* group id of the process */
     int                  exit_code;       /* process exit code */
     int                  running_threads; /* number of threads running in this process */
     struct timeval       start_time;      /* absolute time at process start */
@@ -73,7 +75,6 @@ struct process
     struct process_dll   exe;             /* main exe file */
     void                *ldt_copy;        /* pointer to LDT copy in client addr space */
     void                *ldt_flags;       /* pointer to LDT flags in client addr space */
-    process_id_t         group_id;        /* group ID of the process */
 };
 
 struct process_snapshot
@@ -94,6 +95,9 @@ struct module_snapshot
 
 /* process functions */
 
+extern unsigned int alloc_ptid( void *ptr );
+extern void free_ptid( unsigned int id );
+extern void *get_ptid_entry( unsigned int id );
 extern struct thread *create_process( int fd );
 extern struct process *get_process_from_id( process_id_t id );
 extern struct process *get_process_from_handle( obj_handle_t handle, unsigned int access );
@@ -115,7 +119,8 @@ extern struct process_snapshot *process_snap( int *count );
 extern struct module_snapshot *module_snap( struct process *process, int *count );
 extern void enum_processes( int (*cb)(struct process*, void*), void *user);
 
-inline static process_id_t get_process_id( struct process *process ) { return (process_id_t)process; }
+inline static process_id_t get_process_id( struct process *process ) { return process->id; }
+
 inline static int is_process_init_done( struct process *process )
 {
     return process->startup_state == STARTUP_DONE;
diff --git a/server/ptrace.c b/server/ptrace.c
index 7aa0c88a955d4a849da334b321d7dd8d3ca99126..a74dad1987df54d87cf290af63afc94945a879ed 100644
--- a/server/ptrace.c
+++ b/server/ptrace.c
@@ -75,7 +75,7 @@ static int handle_child_status( struct thread *thread, int pid, int status )
     {
         int sig = WSTOPSIG(status);
         if (debug_level && thread)
-            fprintf( stderr, "%08x: *signal* signal=%d\n", (unsigned int)thread, sig );
+            fprintf( stderr, "%04x: *signal* signal=%d\n", thread->id, sig );
         switch(sig)
         {
         case SIGSTOP:  /* continue at once if not suspended */
@@ -97,11 +97,11 @@ static int handle_child_status( struct thread *thread, int pid, int status )
         if (debug_level)
         {
             if (WIFSIGNALED(status))
-                fprintf( stderr, "%08x: *exited* signal=%d\n",
-                         (unsigned int)thread, WTERMSIG(status) );
+                fprintf( stderr, "%04x: *exited* signal=%d\n",
+                         thread->id, WTERMSIG(status) );
             else
-                fprintf( stderr, "%08x: *exited* status=%d\n",
-                         (unsigned int)thread, WEXITSTATUS(status) );
+                fprintf( stderr, "%04x: *exited* status=%d\n",
+                         thread->id, WEXITSTATUS(status) );
         }
     }
     return 0;
@@ -146,7 +146,7 @@ static int attach_thread( struct thread *thread )
         if (errno == ESRCH) thread->unix_pid = 0;  /* process got killed */
         return 0;
     }
-    if (debug_level) fprintf( stderr, "%08x: *attached*\n", (unsigned int)thread );
+    if (debug_level) fprintf( stderr, "%04x: *attached*\n", thread->id );
     thread->attached = 1;
     wait4_thread( thread, SIGSTOP );
     return 1;
@@ -161,7 +161,7 @@ void detach_thread( struct thread *thread, int sig )
         /* make sure it is stopped */
         suspend_thread( thread, 0 );
         if (sig) kill( thread->unix_pid, sig );
-        if (debug_level) fprintf( stderr, "%08x: *detached*\n", (unsigned int)thread );
+        if (debug_level) fprintf( stderr, "%04x: *detached*\n", thread->id );
         ptrace( PTRACE_DETACH, thread->unix_pid, (caddr_t)1, sig );
         thread->suspend = 0;  /* detach makes it continue */
         thread->attached = 0;
diff --git a/server/request.c b/server/request.c
index 98bec45d8dd1a28ec8db06c202f114d06b0b3120..15c4883a6c1d26ddfb77dc3eb2b1f80b45df0c44 100644
--- a/server/request.c
+++ b/server/request.c
@@ -351,15 +351,15 @@ int receive_fd( struct process *process )
         if (!thread || thread->process != process || thread->state == TERMINATED)
         {
             if (debug_level)
-                fprintf( stderr, "%08x: *fd* %d <- %d bad thread id\n",
-                         (unsigned int)data.tid, data.fd, fd );
+                fprintf( stderr, "%04x: *fd* %d <- %d bad thread id\n",
+                         data.tid, data.fd, fd );
             close( fd );
         }
         else
         {
             if (debug_level)
-                fprintf( stderr, "%08x: *fd* %d <- %d\n",
-                         (unsigned int)thread, data.fd, fd );
+                fprintf( stderr, "%04x: *fd* %d <- %d\n",
+                         thread->id, data.fd, fd );
             thread_add_inflight_fd( thread, data.fd, fd );
         }
         if (thread) release_object( thread );
@@ -391,7 +391,8 @@ int send_client_fd( struct process *process, int fd, obj_handle_t handle )
     int ret;
 
     if (debug_level)
-        fprintf( stderr, "%08x: *fd* %p -> %d\n", (unsigned int)current, handle, fd );
+        fprintf( stderr, "%04x: *fd* %p -> %d\n",
+                 current ? current->id : process->id, handle, fd );
 
 #ifdef HAVE_MSGHDR_ACCRIGHTS
     msghdr.msg_accrightslen = sizeof(fd);
diff --git a/server/thread.c b/server/thread.c
index dceeef4e679efe34cb871c3741ec1eea6b467dd1..a649da3fbea934d9805cf7da1be446d19ad81775 100644
--- a/server/thread.c
+++ b/server/thread.c
@@ -167,6 +167,12 @@ struct thread *create_thread( int fd, struct process *process )
     if ((thread->next = first_thread) != NULL) thread->next->prev = thread;
     first_thread = thread;
 
+    if (!(thread->id = alloc_ptid( thread )))
+    {
+        release_object( thread );
+        return NULL;
+    }
+
     set_select_events( &thread->obj, POLLIN );  /* start listening to events */
     add_process_thread( thread->process, thread );
     return thread;
@@ -236,6 +242,7 @@ static void destroy_thread( struct object *obj )
     if (thread->info) release_object( thread->info );
     cleanup_thread( thread );
     release_object( thread->process );
+    if (thread->id) free_ptid( thread->id );
 }
 
 /* dump a thread on stdout for debugging purposes */
@@ -244,8 +251,8 @@ static void dump_thread( struct object *obj, int verbose )
     struct thread *thread = (struct thread *)obj;
     assert( obj->ops == &thread_ops );
 
-    fprintf( stderr, "Thread pid=%d teb=%p state=%d\n",
-             thread->unix_pid, thread->teb, thread->state );
+    fprintf( stderr, "Thread id=%04x unix pid=%d teb=%p state=%d\n",
+             thread->id, thread->unix_pid, thread->teb, thread->state );
 }
 
 static int thread_signaled( struct object *obj, struct thread *thread )
@@ -257,11 +264,11 @@ static int thread_signaled( struct object *obj, struct thread *thread )
 /* get a thread pointer from a thread id (and increment the refcount) */
 struct thread *get_thread_from_id( thread_id_t id )
 {
-    struct thread *t = first_thread;
-    while (t && (get_thread_id(t) != id)) t = t->next;
-    if (t) grab_object( t );
-    else set_error( STATUS_INVALID_PARAMETER );
-    return t;
+    struct object *obj = get_ptid_entry( id );
+
+    if (obj && obj->ops == &thread_ops) return (struct thread *)grab_object( obj );
+    set_error( STATUS_INVALID_PARAMETER );
+    return NULL;
 }
 
 /* get a thread from a handle (and increment the refcount) */
@@ -465,8 +472,8 @@ static int wake_thread( struct thread *thread )
         if ((signaled = check_wait( thread )) == -1) break;
 
         cookie = thread->wait->cookie;
-        if (debug_level) fprintf( stderr, "%08x: *wakeup* signaled=%d cookie=%p\n",
-                                  (unsigned int)thread, signaled, cookie );
+        if (debug_level) fprintf( stderr, "%04x: *wakeup* signaled=%d cookie=%p\n",
+                                  thread->id, signaled, cookie );
         end_wait( thread );
         if (send_thread_wakeup( thread, cookie, signaled ) == -1) /* error */
 	    break;
@@ -484,8 +491,8 @@ static void thread_timeout( void *ptr )
     wait->user = NULL;
     if (thread->wait != wait) return; /* not the top-level wait, ignore it */
 
-    if (debug_level) fprintf( stderr, "%08x: *wakeup* signaled=%d cookie=%p\n",
-                              (unsigned int)thread, STATUS_TIMEOUT, cookie );
+    if (debug_level) fprintf( stderr, "%04x: *wakeup* signaled=%d cookie=%p\n",
+                              thread->id, STATUS_TIMEOUT, cookie );
     end_wait( thread );
     if (send_thread_wakeup( thread, cookie, STATUS_TIMEOUT ) == -1) return;
     /* check if other objects have become signaled in the meantime */
@@ -717,8 +724,8 @@ void kill_thread( struct thread *thread, int violent_death )
     thread->exit_time = time(NULL);
     if (current == thread) current = NULL;
     if (debug_level)
-        fprintf( stderr,"%08x: *killed* exit_code=%d\n",
-                 (unsigned int)thread, thread->exit_code );
+        fprintf( stderr,"%04x: *killed* exit_code=%d\n",
+                 thread->id, thread->exit_code );
     if (thread->wait)
     {
         while (thread->wait) end_wait( thread );
diff --git a/server/thread.h b/server/thread.h
index 218a7b3a4b2ec775451df8c318f4fe6068a90097..cc37f25134ddd9633fb6a9a4dbd27153f5eb32f6 100644
--- a/server/thread.h
+++ b/server/thread.h
@@ -63,6 +63,7 @@ struct thread
     struct thread         *proc_next;     /* per-process thread list */
     struct thread         *proc_prev;
     struct process        *process;
+    thread_id_t            id;            /* thread id */
     struct mutex          *mutex;         /* list of currently owned mutexes */
     struct debug_ctx      *debug_ctx;     /* debugger context if this thread is a debugger */
     struct debug_event    *debug_event;   /* debug event being sent to debugger */
@@ -143,6 +144,6 @@ static inline unsigned int get_error(void)       { return current ? current->err
 static inline void set_error( unsigned int err ) { global_error = err; if (current) current->error = err; }
 static inline void clear_error(void)    { set_error(0); }
 
-static inline thread_id_t get_thread_id( struct thread *thread ) { return (thread_id_t)thread; }
+static inline thread_id_t get_thread_id( struct thread *thread ) { return thread->id; }
 
 #endif  /* __WINE_SERVER_THREAD_H */
diff --git a/server/trace.c b/server/trace.c
index aac9e74505a9f22c20c46a954aa1d97234af585b..1dd85f1ac573f6805a6157f0914e3e3953f22522 100644
--- a/server/trace.c
+++ b/server/trace.c
@@ -372,9 +372,9 @@ static void dump_get_new_process_info_request( const struct get_new_process_info
 
 static void dump_get_new_process_info_reply( const struct get_new_process_info_reply *req )
 {
-    fprintf( stderr, " pid=%08x,", req->pid );
+    fprintf( stderr, " pid=%04x,", req->pid );
     fprintf( stderr, " phandle=%p,", req->phandle );
-    fprintf( stderr, " tid=%08x,", req->tid );
+    fprintf( stderr, " tid=%04x,", req->tid );
     fprintf( stderr, " thandle=%p,", req->thandle );
     fprintf( stderr, " success=%d", req->success );
 }
@@ -388,7 +388,7 @@ static void dump_new_thread_request( const struct new_thread_request *req )
 
 static void dump_new_thread_reply( const struct new_thread_reply *req )
 {
-    fprintf( stderr, " tid=%08x,", req->tid );
+    fprintf( stderr, " tid=%04x,", req->tid );
     fprintf( stderr, " handle=%p", req->handle );
 }
 
@@ -452,8 +452,8 @@ static void dump_init_thread_request( const struct init_thread_request *req )
 
 static void dump_init_thread_reply( const struct init_thread_reply *req )
 {
-    fprintf( stderr, " pid=%08x,", req->pid );
-    fprintf( stderr, " tid=%08x,", req->tid );
+    fprintf( stderr, " pid=%04x,", req->pid );
+    fprintf( stderr, " tid=%04x,", req->tid );
     fprintf( stderr, " boot=%d,", req->boot );
     fprintf( stderr, " version=%d", req->version );
 }
@@ -488,7 +488,7 @@ static void dump_get_process_info_request( const struct get_process_info_request
 
 static void dump_get_process_info_reply( const struct get_process_info_reply *req )
 {
-    fprintf( stderr, " pid=%08x,", req->pid );
+    fprintf( stderr, " pid=%04x,", req->pid );
     fprintf( stderr, " debugged=%d,", req->debugged );
     fprintf( stderr, " exit_code=%d,", req->exit_code );
     fprintf( stderr, " priority=%d,", req->priority );
@@ -507,12 +507,12 @@ static void dump_set_process_info_request( const struct set_process_info_request
 static void dump_get_thread_info_request( const struct get_thread_info_request *req )
 {
     fprintf( stderr, " handle=%p,", req->handle );
-    fprintf( stderr, " tid_in=%08x", req->tid_in );
+    fprintf( stderr, " tid_in=%04x", req->tid_in );
 }
 
 static void dump_get_thread_info_reply( const struct get_thread_info_reply *req )
 {
-    fprintf( stderr, " tid=%08x,", req->tid );
+    fprintf( stderr, " tid=%04x,", req->tid );
     fprintf( stderr, " teb=%p,", req->teb );
     fprintf( stderr, " exit_code=%d,", req->exit_code );
     fprintf( stderr, " priority=%d,", req->priority );
@@ -642,7 +642,7 @@ static void dump_dup_handle_reply( const struct dup_handle_reply *req )
 
 static void dump_open_process_request( const struct open_process_request *req )
 {
-    fprintf( stderr, " pid=%08x,", req->pid );
+    fprintf( stderr, " pid=%04x,", req->pid );
     fprintf( stderr, " access=%08x,", req->access );
     fprintf( stderr, " inherit=%d", req->inherit );
 }
@@ -654,7 +654,7 @@ static void dump_open_process_reply( const struct open_process_reply *req )
 
 static void dump_open_thread_request( const struct open_thread_request *req )
 {
-    fprintf( stderr, " tid=%08x,", req->tid );
+    fprintf( stderr, " tid=%04x,", req->tid );
     fprintf( stderr, " access=%08x,", req->access );
     fprintf( stderr, " inherit=%d", req->inherit );
 }
@@ -967,7 +967,7 @@ static void dump_alloc_console_request( const struct alloc_console_request *req
 {
     fprintf( stderr, " access=%08x,", req->access );
     fprintf( stderr, " inherit=%d,", req->inherit );
-    fprintf( stderr, " pid=%08x", req->pid );
+    fprintf( stderr, " pid=%04x", req->pid );
 }
 
 static void dump_alloc_console_reply( const struct alloc_console_reply *req )
@@ -1212,7 +1212,7 @@ static void dump_move_console_output_request( const struct move_console_output_r
 static void dump_send_console_signal_request( const struct send_console_signal_request *req )
 {
     fprintf( stderr, " signal=%d,", req->signal );
-    fprintf( stderr, " group_id=%08x", req->group_id );
+    fprintf( stderr, " group_id=%04x", req->group_id );
 }
 
 static void dump_create_change_notification_request( const struct create_change_notification_request *req )
@@ -1289,7 +1289,7 @@ static void dump_create_snapshot_request( const struct create_snapshot_request *
 {
     fprintf( stderr, " inherit=%d,", req->inherit );
     fprintf( stderr, " flags=%d,", req->flags );
-    fprintf( stderr, " pid=%08x", req->pid );
+    fprintf( stderr, " pid=%04x", req->pid );
 }
 
 static void dump_create_snapshot_reply( const struct create_snapshot_reply *req )
@@ -1306,8 +1306,8 @@ static void dump_next_process_request( const struct next_process_request *req )
 static void dump_next_process_reply( const struct next_process_reply *req )
 {
     fprintf( stderr, " count=%d,", req->count );
-    fprintf( stderr, " pid=%08x,", req->pid );
-    fprintf( stderr, " ppid=%08x,", req->ppid );
+    fprintf( stderr, " pid=%04x,", req->pid );
+    fprintf( stderr, " ppid=%04x,", req->ppid );
     fprintf( stderr, " heap=%p,", req->heap );
     fprintf( stderr, " module=%p,", req->module );
     fprintf( stderr, " threads=%d,", req->threads );
@@ -1325,8 +1325,8 @@ static void dump_next_thread_request( const struct next_thread_request *req )
 static void dump_next_thread_reply( const struct next_thread_reply *req )
 {
     fprintf( stderr, " count=%d,", req->count );
-    fprintf( stderr, " pid=%08x,", req->pid );
-    fprintf( stderr, " tid=%08x,", req->tid );
+    fprintf( stderr, " pid=%04x,", req->pid );
+    fprintf( stderr, " tid=%04x,", req->tid );
     fprintf( stderr, " base_pri=%d,", req->base_pri );
     fprintf( stderr, " delta_pri=%d", req->delta_pri );
 }
@@ -1339,7 +1339,7 @@ static void dump_next_module_request( const struct next_module_request *req )
 
 static void dump_next_module_reply( const struct next_module_reply *req )
 {
-    fprintf( stderr, " pid=%08x,", req->pid );
+    fprintf( stderr, " pid=%04x,", req->pid );
     fprintf( stderr, " base=%p,", req->base );
     fprintf( stderr, " size=%d,", req->size );
     fprintf( stderr, " filename=" );
@@ -1353,8 +1353,8 @@ static void dump_wait_debug_event_request( const struct wait_debug_event_request
 
 static void dump_wait_debug_event_reply( const struct wait_debug_event_reply *req )
 {
-    fprintf( stderr, " pid=%08x,", req->pid );
-    fprintf( stderr, " tid=%08x,", req->tid );
+    fprintf( stderr, " pid=%04x,", req->pid );
+    fprintf( stderr, " tid=%04x,", req->tid );
     fprintf( stderr, " wait=%p,", req->wait );
     fprintf( stderr, " event=" );
     dump_varargs_debug_event( cur_size );
@@ -1393,14 +1393,14 @@ static void dump_output_debug_string_request( const struct output_debug_string_r
 
 static void dump_continue_debug_event_request( const struct continue_debug_event_request *req )
 {
-    fprintf( stderr, " pid=%08x,", req->pid );
-    fprintf( stderr, " tid=%08x,", req->tid );
+    fprintf( stderr, " pid=%04x,", req->pid );
+    fprintf( stderr, " tid=%04x,", req->tid );
     fprintf( stderr, " status=%d", req->status );
 }
 
 static void dump_debug_process_request( const struct debug_process_request *req )
 {
-    fprintf( stderr, " pid=%08x,", req->pid );
+    fprintf( stderr, " pid=%04x,", req->pid );
     fprintf( stderr, " attach=%d", req->attach );
 }
 
@@ -1761,7 +1761,7 @@ static void dump_wait_input_idle_reply( const struct wait_input_idle_reply *req
 
 static void dump_send_message_request( const struct send_message_request *req )
 {
-    fprintf( stderr, " id=%08x,", req->id );
+    fprintf( stderr, " id=%04x,", req->id );
     fprintf( stderr, " type=%d,", req->type );
     fprintf( stderr, " win=%p,", req->win );
     fprintf( stderr, " msg=%08x,", req->msg );
@@ -2032,8 +2032,8 @@ static void dump_get_window_info_reply( const struct get_window_info_reply *req
 {
     fprintf( stderr, " full_handle=%p,", req->full_handle );
     fprintf( stderr, " last_active=%p,", req->last_active );
-    fprintf( stderr, " pid=%08x,", req->pid );
-    fprintf( stderr, " tid=%08x,", req->tid );
+    fprintf( stderr, " pid=%04x,", req->pid );
+    fprintf( stderr, " tid=%04x,", req->tid );
     fprintf( stderr, " atom=%04x", req->atom );
 }
 
@@ -2073,7 +2073,7 @@ static void dump_get_window_children_request( const struct get_window_children_r
 {
     fprintf( stderr, " parent=%p,", req->parent );
     fprintf( stderr, " atom=%04x,", req->atom );
-    fprintf( stderr, " tid=%08x", req->tid );
+    fprintf( stderr, " tid=%04x", req->tid );
 }
 
 static void dump_get_window_children_reply( const struct get_window_children_reply *req )
@@ -2204,14 +2204,14 @@ static void dump_get_window_properties_reply( const struct get_window_properties
 
 static void dump_attach_thread_input_request( const struct attach_thread_input_request *req )
 {
-    fprintf( stderr, " tid_from=%08x,", req->tid_from );
-    fprintf( stderr, " tid_to=%08x,", req->tid_to );
+    fprintf( stderr, " tid_from=%04x,", req->tid_from );
+    fprintf( stderr, " tid_to=%04x,", req->tid_to );
     fprintf( stderr, " attach=%d", req->attach );
 }
 
 static void dump_get_thread_input_request( const struct get_thread_input_request *req )
 {
-    fprintf( stderr, " tid=%08x", req->tid );
+    fprintf( stderr, " tid=%04x", req->tid );
 }
 
 static void dump_get_thread_input_reply( const struct get_thread_input_reply *req )
@@ -2229,7 +2229,7 @@ static void dump_get_thread_input_reply( const struct get_thread_input_reply *re
 
 static void dump_get_key_state_request( const struct get_key_state_request *req )
 {
-    fprintf( stderr, " tid=%08x,", req->tid );
+    fprintf( stderr, " tid=%04x,", req->tid );
     fprintf( stderr, " key=%d", req->key );
 }
 
@@ -2242,7 +2242,7 @@ static void dump_get_key_state_reply( const struct get_key_state_reply *req )
 
 static void dump_set_key_state_request( const struct set_key_state_request *req )
 {
-    fprintf( stderr, " tid=%08x,", req->tid );
+    fprintf( stderr, " tid=%04x,", req->tid );
     fprintf( stderr, " keystate=" );
     dump_varargs_bytes( cur_size );
 }
@@ -2331,7 +2331,7 @@ static void dump_set_caret_info_reply( const struct set_caret_info_reply *req )
 static void dump_set_hook_request( const struct set_hook_request *req )
 {
     fprintf( stderr, " id=%d,", req->id );
-    fprintf( stderr, " tid=%08x,", req->tid );
+    fprintf( stderr, " tid=%04x,", req->tid );
     fprintf( stderr, " proc=%p,", req->proc );
     fprintf( stderr, " unicode=%d,", req->unicode );
     fprintf( stderr, " module=" );
@@ -2978,7 +2978,7 @@ void trace_request(void)
     enum request req = current->req.request_header.req;
     if (req < REQ_NB_REQUESTS)
     {
-        fprintf( stderr, "%08x: %s(", (unsigned int)current, req_names[req] );
+        fprintf( stderr, "%04x: %s(", current->id, req_names[req] );
         if (req_dumpers[req])
         {
             cur_pos = 0;
@@ -2988,15 +2988,15 @@ void trace_request(void)
         }
         fprintf( stderr, " )\n" );
     }
-    else fprintf( stderr, "%08x: %d(?)\n", (unsigned int)current, req );
+    else fprintf( stderr, "%04x: %d(?)\n", current->id, req );
 }
 
 void trace_reply( enum request req, const union generic_reply *reply )
 {
     if (req < REQ_NB_REQUESTS)
     {
-        fprintf( stderr, "%08x: %s() = %s",
-                 (unsigned int)current, req_names[req], get_status_name(current->error) );
+        fprintf( stderr, "%04x: %s() = %s",
+                 current->id, req_names[req], get_status_name(current->error) );
         if (reply_dumpers[req])
         {
             fprintf( stderr, " {" );
@@ -3008,6 +3008,6 @@ void trace_reply( enum request req, const union generic_reply *reply )
         }
         fputc( '\n', stderr );
     }
-    else fprintf( stderr, "%08x: %d() = %s\n",
-                  (unsigned int)current, req, get_status_name(current->error) );
+    else fprintf( stderr, "%04x: %d() = %s\n",
+                  current->id, req, get_status_name(current->error) );
 }
diff --git a/tools/make_requests b/tools/make_requests
index df8506feebbcce1ae61b7d817a42d392a9852225..86043e1373dbf94db4e33de5f2c029acf42b9832 100755
--- a/tools/make_requests
+++ b/tools/make_requests
@@ -34,8 +34,8 @@
     "obj_handle_t"  => "%p",
     "atom_t"        => "%04x",
     "user_handle_t" => "%p",
-    "process_id_t"  => "%08x",
-    "thread_id_t"   => "%08x",
+    "process_id_t"  => "%04x",
+    "thread_id_t"   => "%04x",
     "rectangle_t"   => "&dump_rectangle",
     "char_info_t"   => "&dump_char_info",
 );