server: Store process/thread affinity as a 64-bit value.
diff --git a/dlls/ntdll/process.c b/dlls/ntdll/process.c
index 153ac8a..82bc6a7 100644
--- a/dlls/ntdll/process.c
+++ b/dlls/ntdll/process.c
@@ -146,7 +146,7 @@
     case ProcessBasicInformation:
         {
             PROCESS_BASIC_INFORMATION pbi;
-            const unsigned int affinity_mask = (1 << NtCurrentTeb()->Peb->NumberOfProcessors) - 1;
+            const ULONG_PTR affinity_mask = ((ULONG_PTR)1 << NtCurrentTeb()->Peb->NumberOfProcessors) - 1;
 
             if (ProcessInformationLength >= sizeof(PROCESS_BASIC_INFORMATION))
             {
@@ -363,7 +363,7 @@
     {
     case ProcessAffinityMask:
         if (ProcessInformationLength != sizeof(DWORD_PTR)) return STATUS_INVALID_PARAMETER;
-        if (*(PDWORD_PTR)ProcessInformation & ~((1 << NtCurrentTeb()->Peb->NumberOfProcessors) - 1))
+        if (*(PDWORD_PTR)ProcessInformation & ~(((DWORD_PTR)1 << NtCurrentTeb()->Peb->NumberOfProcessors) - 1))
             return STATUS_INVALID_PARAMETER;
         SERVER_START_REQ( set_process_info )
         {
diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c
index 7d4675a..0904125 100644
--- a/dlls/ntdll/thread.c
+++ b/dlls/ntdll/thread.c
@@ -1169,7 +1169,7 @@
     case ThreadBasicInformation:
         {
             THREAD_BASIC_INFORMATION info;
-            const unsigned int affinity_mask = (1 << NtCurrentTeb()->Peb->NumberOfProcessors) - 1;
+            const ULONG_PTR affinity_mask = ((ULONG_PTR)1 << NtCurrentTeb()->Peb->NumberOfProcessors) - 1;
 
             SERVER_START_REQ( get_thread_info )
             {
@@ -1420,9 +1420,9 @@
         return status;
     case ThreadAffinityMask:
         {
-            const DWORD affinity_mask = (1 << NtCurrentTeb()->Peb->NumberOfProcessors) - 1;
-            const DWORD *paff = data;
-            if (length != sizeof(DWORD)) return STATUS_INVALID_PARAMETER;
+            const ULONG_PTR affinity_mask = ((ULONG_PTR)1 << NtCurrentTeb()->Peb->NumberOfProcessors) - 1;
+            const ULONG_PTR *paff = data;
+            if (length != sizeof(ULONG_PTR)) return STATUS_INVALID_PARAMETER;
             if (*paff & ~affinity_mask) return STATUS_INVALID_PARAMETER;
             SERVER_START_REQ( set_thread_info )
             {
diff --git a/include/wine/server_protocol.h b/include/wine/server_protocol.h
index fd1c07f..fcf062b 100644
--- a/include/wine/server_protocol.h
+++ b/include/wine/server_protocol.h
@@ -27,6 +27,7 @@
 typedef unsigned __int64 mem_size_t;
 typedef unsigned __int64 file_pos_t;
 typedef unsigned __int64 client_ptr_t;
+typedef unsigned __int64 affinity_t;
 typedef client_ptr_t mod_handle_t;
 
 struct request_header
@@ -620,13 +621,12 @@
     struct reply_header __header;
     process_id_t pid;
     process_id_t ppid;
-    int          priority;
-    unsigned int affinity;
+    affinity_t   affinity;
     client_ptr_t peb;
     timeout_t    start_time;
     timeout_t    end_time;
     int          exit_code;
-    char __pad_52[4];
+    int          priority;
 };
 
 
@@ -637,8 +637,7 @@
     obj_handle_t handle;
     int          mask;
     int          priority;
-    unsigned int affinity;
-    char __pad_28[4];
+    affinity_t   affinity;
 };
 struct set_process_info_reply
 {
@@ -661,12 +660,13 @@
     process_id_t pid;
     thread_id_t  tid;
     client_ptr_t teb;
-    int          priority;
-    unsigned int affinity;
+    affinity_t   affinity;
     timeout_t    creation_time;
     timeout_t    exit_time;
     int          exit_code;
+    int          priority;
     int          last;
+    char __pad_60[4];
 };
 
 
@@ -677,8 +677,9 @@
     obj_handle_t handle;
     int          mask;
     int          priority;
-    unsigned int affinity;
+    affinity_t   affinity;
     obj_handle_t token;
+    char __pad_36[4];
 };
 struct set_thread_info_reply
 {
@@ -5214,6 +5215,6 @@
     struct set_window_layered_info_reply set_window_layered_info_reply;
 };
 
-#define SERVER_PROTOCOL_VERSION 380
+#define SERVER_PROTOCOL_VERSION 381
 
 #endif /* __WINE_WINE_SERVER_PROTOCOL_H */
diff --git a/server/process.h b/server/process.h
index 5311ae3..5b6dcda 100644
--- a/server/process.h
+++ b/server/process.h
@@ -63,8 +63,8 @@
     int                  running_threads; /* number of threads running in this process */
     timeout_t            start_time;      /* absolute time at process start */
     timeout_t            end_time;        /* absolute time at process end */
+    affinity_t           affinity;        /* process affinity mask */
     int                  priority;        /* priority class */
-    unsigned int         affinity;        /* process affinity mask */
     int                  suspend;         /* global process suspend count */
     int                  is_system;       /* is it a system process? */
     unsigned int         create_flags;    /* process creation flags */
diff --git a/server/protocol.def b/server/protocol.def
index 2f7f7c6..a8f3569 100644
--- a/server/protocol.def
+++ b/server/protocol.def
@@ -43,6 +43,7 @@
 typedef unsigned __int64 mem_size_t;
 typedef unsigned __int64 file_pos_t;
 typedef unsigned __int64 client_ptr_t;
+typedef unsigned __int64 affinity_t;
 typedef client_ptr_t mod_handle_t;
 
 struct request_header
@@ -588,12 +589,12 @@
 @REPLY
     process_id_t pid;              /* server process id */
     process_id_t ppid;             /* server process id of parent */
-    int          priority;         /* priority class */
-    unsigned int affinity;         /* process affinity mask */
+    affinity_t   affinity;         /* process affinity mask */
     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 */
+    int          priority;         /* priority class */
 @END
 
 
@@ -602,7 +603,7 @@
     obj_handle_t handle;       /* process handle */
     int          mask;         /* setting mask (see below) */
     int          priority;     /* priority class */
-    unsigned int affinity;     /* affinity mask */
+    affinity_t   affinity;     /* affinity mask */
 @END
 #define SET_PROCESS_INFO_PRIORITY 0x01
 #define SET_PROCESS_INFO_AFFINITY 0x02
@@ -616,11 +617,11 @@
     process_id_t pid;           /* server process id */
     thread_id_t  tid;           /* server thread id */
     client_ptr_t teb;           /* thread teb pointer */
-    int          priority;      /* thread priority level */
-    unsigned int affinity;      /* thread affinity mask */
+    affinity_t   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          priority;      /* thread priority level */
     int          last;          /* last thread in process */
 @END
 
@@ -630,7 +631,7 @@
     obj_handle_t handle;       /* thread handle */
     int          mask;         /* setting mask (see below) */
     int          priority;     /* priority class */
-    unsigned int affinity;     /* affinity mask */
+    affinity_t   affinity;     /* affinity mask */
     obj_handle_t token;        /* impersonation token */
 @END
 #define SET_THREAD_INFO_PRIORITY 0x01
diff --git a/server/request.h b/server/request.h
index 0c83bbf5..b8d78f3 100644
--- a/server/request.h
+++ b/server/request.h
@@ -591,6 +591,7 @@
     (req_handler)req_set_window_layered_info,
 };
 
+C_ASSERT( sizeof(affinity_t) == 8 );
 C_ASSERT( sizeof(apc_call_t) == 40 );
 C_ASSERT( sizeof(apc_param_t) == 8 );
 C_ASSERT( sizeof(apc_result_t) == 40 );
@@ -681,12 +682,12 @@
 C_ASSERT( FIELD_OFFSET(struct get_process_info_request, handle) == 12 );
 C_ASSERT( FIELD_OFFSET(struct get_process_info_reply, pid) == 8 );
 C_ASSERT( FIELD_OFFSET(struct get_process_info_reply, ppid) == 12 );
-C_ASSERT( FIELD_OFFSET(struct get_process_info_reply, priority) == 16 );
-C_ASSERT( FIELD_OFFSET(struct get_process_info_reply, affinity) == 20 );
+C_ASSERT( FIELD_OFFSET(struct get_process_info_reply, affinity) == 16 );
 C_ASSERT( FIELD_OFFSET(struct get_process_info_reply, peb) == 24 );
 C_ASSERT( FIELD_OFFSET(struct get_process_info_reply, start_time) == 32 );
 C_ASSERT( FIELD_OFFSET(struct get_process_info_reply, end_time) == 40 );
 C_ASSERT( FIELD_OFFSET(struct get_process_info_reply, exit_code) == 48 );
+C_ASSERT( FIELD_OFFSET(struct get_process_info_reply, priority) == 52 );
 C_ASSERT( sizeof(struct get_process_info_reply) == 56 );
 C_ASSERT( FIELD_OFFSET(struct set_process_info_request, handle) == 12 );
 C_ASSERT( FIELD_OFFSET(struct set_process_info_request, mask) == 16 );
@@ -698,19 +699,19 @@
 C_ASSERT( FIELD_OFFSET(struct get_thread_info_reply, pid) == 8 );
 C_ASSERT( FIELD_OFFSET(struct get_thread_info_reply, tid) == 12 );
 C_ASSERT( FIELD_OFFSET(struct get_thread_info_reply, teb) == 16 );
-C_ASSERT( FIELD_OFFSET(struct get_thread_info_reply, priority) == 24 );
-C_ASSERT( FIELD_OFFSET(struct get_thread_info_reply, affinity) == 28 );
+C_ASSERT( FIELD_OFFSET(struct get_thread_info_reply, affinity) == 24 );
 C_ASSERT( FIELD_OFFSET(struct get_thread_info_reply, creation_time) == 32 );
 C_ASSERT( FIELD_OFFSET(struct get_thread_info_reply, exit_time) == 40 );
 C_ASSERT( FIELD_OFFSET(struct get_thread_info_reply, exit_code) == 48 );
-C_ASSERT( FIELD_OFFSET(struct get_thread_info_reply, last) == 52 );
-C_ASSERT( sizeof(struct get_thread_info_reply) == 56 );
+C_ASSERT( FIELD_OFFSET(struct get_thread_info_reply, priority) == 52 );
+C_ASSERT( FIELD_OFFSET(struct get_thread_info_reply, last) == 56 );
+C_ASSERT( sizeof(struct get_thread_info_reply) == 64 );
 C_ASSERT( FIELD_OFFSET(struct set_thread_info_request, handle) == 12 );
 C_ASSERT( FIELD_OFFSET(struct set_thread_info_request, mask) == 16 );
 C_ASSERT( FIELD_OFFSET(struct set_thread_info_request, priority) == 20 );
 C_ASSERT( FIELD_OFFSET(struct set_thread_info_request, affinity) == 24 );
-C_ASSERT( FIELD_OFFSET(struct set_thread_info_request, token) == 28 );
-C_ASSERT( sizeof(struct set_thread_info_request) == 32 );
+C_ASSERT( FIELD_OFFSET(struct set_thread_info_request, token) == 32 );
+C_ASSERT( sizeof(struct set_thread_info_request) == 40 );
 C_ASSERT( FIELD_OFFSET(struct get_dll_info_request, handle) == 12 );
 C_ASSERT( FIELD_OFFSET(struct get_dll_info_request, base_address) == 16 );
 C_ASSERT( FIELD_OFFSET(struct get_dll_info_reply, entry_point) == 8 );
diff --git a/server/thread.h b/server/thread.h
index 1815f0b..2e33470 100644
--- a/server/thread.h
+++ b/server/thread.h
@@ -79,8 +79,8 @@
     CONTEXT               *context;       /* current context if in an exception handler */
     CONTEXT               *suspend_context; /* current context if suspended */
     client_ptr_t           teb;           /* TEB address (in client address space) */
+    affinity_t             affinity;      /* affinity mask */
     int                    priority;      /* priority level */
-    unsigned int           affinity;      /* affinity mask */
     int                    suspend;       /* suspend count */
     obj_handle_t           desktop;       /* desktop handle */
     int                    desktop_users; /* number of objects using the thread desktop */
diff --git a/server/trace.c b/server/trace.c
index e30517d..9643feb 100644
--- a/server/trace.c
+++ b/server/trace.c
@@ -1039,8 +1039,9 @@
 {
     fprintf( stderr, " pid=%04x,", req->pid );
     fprintf( stderr, " ppid=%04x,", req->ppid );
-    fprintf( stderr, " priority=%d,", req->priority );
-    fprintf( stderr, " affinity=%08x,", req->affinity );
+    fprintf( stderr, " affinity=" );
+    dump_uint64( &req->affinity );
+    fprintf( stderr, "," );
     fprintf( stderr, " peb=" );
     dump_uint64( &req->peb );
     fprintf( stderr, "," );
@@ -1050,7 +1051,8 @@
     fprintf( stderr, " end_time=" );
     dump_timeout( &req->end_time );
     fprintf( stderr, "," );
-    fprintf( stderr, " exit_code=%d", req->exit_code );
+    fprintf( stderr, " exit_code=%d,", req->exit_code );
+    fprintf( stderr, " priority=%d", req->priority );
 }
 
 static void dump_set_process_info_request( const struct set_process_info_request *req )
@@ -1058,7 +1060,8 @@
     fprintf( stderr, " handle=%04x,", req->handle );
     fprintf( stderr, " mask=%d,", req->mask );
     fprintf( stderr, " priority=%d,", req->priority );
-    fprintf( stderr, " affinity=%08x", req->affinity );
+    fprintf( stderr, " affinity=" );
+    dump_uint64( &req->affinity );
 }
 
 static void dump_get_thread_info_request( const struct get_thread_info_request *req )
@@ -1074,8 +1077,9 @@
     fprintf( stderr, " teb=" );
     dump_uint64( &req->teb );
     fprintf( stderr, "," );
-    fprintf( stderr, " priority=%d,", req->priority );
-    fprintf( stderr, " affinity=%08x,", req->affinity );
+    fprintf( stderr, " affinity=" );
+    dump_uint64( &req->affinity );
+    fprintf( stderr, "," );
     fprintf( stderr, " creation_time=" );
     dump_timeout( &req->creation_time );
     fprintf( stderr, "," );
@@ -1083,6 +1087,7 @@
     dump_timeout( &req->exit_time );
     fprintf( stderr, "," );
     fprintf( stderr, " exit_code=%d,", req->exit_code );
+    fprintf( stderr, " priority=%d,", req->priority );
     fprintf( stderr, " last=%d", req->last );
 }
 
@@ -1091,7 +1096,9 @@
     fprintf( stderr, " handle=%04x,", req->handle );
     fprintf( stderr, " mask=%d,", req->mask );
     fprintf( stderr, " priority=%d,", req->priority );
-    fprintf( stderr, " affinity=%08x,", req->affinity );
+    fprintf( stderr, " affinity=" );
+    dump_uint64( &req->affinity );
+    fprintf( stderr, "," );
     fprintf( stderr, " token=%04x", req->token );
 }
 
diff --git a/tools/make_requests b/tools/make_requests
index 0981949..b43fe85 100755
--- a/tools/make_requests
+++ b/tools/make_requests
@@ -41,6 +41,7 @@
     "apc_param_t"   => [  8,   8,  "&dump_uint64" ],
     "file_pos_t"    => [  8,   8,  "&dump_uint64" ],
     "mem_size_t"    => [  8,   8,  "&dump_uint64" ],
+    "affinity_t"    => [  8,   8,  "&dump_uint64" ],
     "timeout_t"     => [  8,   8,  "&dump_timeout" ],
     "rectangle_t"   => [  16,  4,  "&dump_rectangle" ],
     "char_info_t"   => [  4,   2,  "&dump_char_info" ],