server: Store the type of CPU that the client is running on.
diff --git a/dlls/ntdll/server.c b/dlls/ntdll/server.c index 46dfc1d2..db4f7ce 100644 --- a/dlls/ntdll/server.c +++ b/dlls/ntdll/server.c
@@ -76,6 +76,20 @@ #define SOCKETNAME "socket" /* name of the socket file */ #define LOCKNAME "lock" /* name of the lock file */ +#ifdef __i386__ +static const enum cpu_type client_cpu = CPU_x86; +#elif defined(__x86_64__) +static const enum cpu_type client_cpu = CPU_x86_64; +#elif defined(__ALPHA__) +static const enum cpu_type client_cpu = CPU_ALPHA; +#elif defined(__powerpc__) +static const enum cpu_type client_cpu = CPU_POWERPC; +#elif defined(__sparc__) +static const enum cpu_type client_cpu = CPU_SPARC; +#else +#error Unsupported CPU +#endif + #ifndef HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS /* data structure used to pass an fd with sendmsg/recvmsg */ struct cmsg_fd @@ -1030,6 +1044,7 @@ req->reply_fd = reply_pipe[1]; req->wait_fd = ntdll_get_thread_data()->wait_fd[1]; req->debug_level = (TRACE_ON(server) != 0); + req->cpu = client_cpu; ret = wine_server_call( req ); NtCurrentTeb()->ClientId.UniqueProcess = ULongToHandle(reply->pid); NtCurrentTeb()->ClientId.UniqueThread = ULongToHandle(reply->tid);
diff --git a/include/wine/server_protocol.h b/include/wine/server_protocol.h index a8865e6..7436626 100644 --- a/include/wine/server_protocol.h +++ b/include/wine/server_protocol.h
@@ -128,6 +128,13 @@ } debug_event_t; +enum cpu_type +{ + CPU_x86, CPU_x86_64, CPU_ALPHA, CPU_POWERPC, CPU_SPARC +}; +typedef int cpu_type_t; + + struct send_fd { thread_id_t tid; @@ -567,6 +574,7 @@ client_ptr_t entry; int reply_fd; int wait_fd; + cpu_type_t cpu; }; struct init_thread_reply { @@ -5214,6 +5222,6 @@ struct set_window_layered_info_reply set_window_layered_info_reply; }; -#define SERVER_PROTOCOL_VERSION 382 +#define SERVER_PROTOCOL_VERSION 383 #endif /* __WINE_WINE_SERVER_PROTOCOL_H */
diff --git a/server/process.h b/server/process.h index 5b6dcda..250c5ce 100644 --- a/server/process.h +++ b/server/process.h
@@ -58,6 +58,7 @@ process_id_t id; /* id of the process */ process_id_t group_id; /* group id of the process */ struct timeout_user *sigkill_timeout; /* timeout for final SIGKILL */ + enum cpu_type cpu; /* client CPU type */ int unix_pid; /* Unix pid for final SIGKILL */ int exit_code; /* process exit code */ int running_threads; /* number of threads running in this process */
diff --git a/server/protocol.def b/server/protocol.def index 5cc93da..0ef309e 100644 --- a/server/protocol.def +++ b/server/protocol.def
@@ -143,6 +143,13 @@ } rip_info; } debug_event_t; +/* supported CPU types */ +enum cpu_type +{ + CPU_x86, CPU_x86_64, CPU_ALPHA, CPU_POWERPC, CPU_SPARC +}; +typedef int cpu_type_t; + /* structure used in sending an fd from client to server */ struct send_fd { @@ -554,6 +561,7 @@ client_ptr_t entry; /* entry point or PEB if initial thread (in thread address space) */ int reply_fd; /* fd for reply pipe */ int wait_fd; /* fd for blocking calls pipe */ + cpu_type_t cpu; /* CPU that this thread is running on */ @REPLY process_id_t pid; /* process id of the new thread's process */ thread_id_t tid; /* thread id of the new thread */
diff --git a/server/request.h b/server/request.h index 1adc03b..29ed8c9 100644 --- a/server/request.h +++ b/server/request.h
@@ -600,6 +600,7 @@ C_ASSERT( sizeof(char) == 1 ); C_ASSERT( sizeof(char_info_t) == 4 ); C_ASSERT( sizeof(client_ptr_t) == 8 ); +C_ASSERT( sizeof(cpu_type_t) == 4 ); C_ASSERT( sizeof(data_size_t) == 4 ); C_ASSERT( sizeof(file_pos_t) == 8 ); C_ASSERT( sizeof(int) == 4 ); @@ -663,6 +664,7 @@ C_ASSERT( FIELD_OFFSET(struct init_thread_request, entry) == 32 ); C_ASSERT( FIELD_OFFSET(struct init_thread_request, reply_fd) == 40 ); C_ASSERT( FIELD_OFFSET(struct init_thread_request, wait_fd) == 44 ); +C_ASSERT( FIELD_OFFSET(struct init_thread_request, cpu) == 48 ); C_ASSERT( FIELD_OFFSET(struct init_thread_reply, pid) == 8 ); C_ASSERT( FIELD_OFFSET(struct init_thread_reply, tid) == 12 ); C_ASSERT( FIELD_OFFSET(struct init_thread_reply, server_start) == 16 );
diff --git a/server/thread.c b/server/thread.c index 6c68a9e..dcf1da2 100644 --- a/server/thread.c +++ b/server/thread.c
@@ -1045,10 +1045,16 @@ { process->unix_pid = current->unix_pid; process->peb = req->entry; + process->cpu = req->cpu; reply->info_size = init_process( current ); } else { + if (req->cpu != process->cpu) + { + set_error( STATUS_INVALID_PARAMETER ); + return; + } if (process->unix_pid != current->unix_pid) process->unix_pid = -1; /* can happen with linuxthreads */ if (current->suspend + process->suspend > 0) stop_thread( current );
diff --git a/server/trace.c b/server/trace.c index 13a3ddc..3583cc3 100644 --- a/server/trace.c +++ b/server/trace.c
@@ -105,6 +105,21 @@ } } +static void dump_cpu_type( const cpu_type_t *code ) +{ + switch (*code) + { +#define CASE(c) case CPU_##c: fputs( #c, stderr ); break + CASE(x86); + CASE(x86_64); + CASE(ALPHA); + CASE(POWERPC); + CASE(SPARC); + default: fprintf( stderr, "%u", *code ); break; +#undef CASE + } +} + static void dump_apc_call( const apc_call_t *call ) { fputc( '{', stderr ); @@ -991,7 +1006,9 @@ 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, " cpu=" ); + dump_cpu_type( &req->cpu ); } static void dump_init_thread_reply( const struct init_thread_reply *req )
diff --git a/tools/make_requests b/tools/make_requests index b43fe85..95c5647 100755 --- a/tools/make_requests +++ b/tools/make_requests
@@ -50,6 +50,7 @@ "async_data_t" => [ 40, 8, "&dump_async_data" ], "luid_t" => [ 8, 4, "&dump_luid" ], "ioctl_code_t" => [ 4, 4, "&dump_ioctl_code" ], + "cpu_type_t" => [ 4, 4, "&dump_cpu_type" ], ); my @requests = ();