From 2ff7a7676c721c2fd5fb8097b38f17f3f5fd1faf Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Wed, 23 Jun 2021 11:32:40 +0200 Subject: [PATCH] server: Add a native_machine global variable. Signed-off-by: Alexandre Julliard --- server/debugger.c | 2 +- server/mapping.c | 2 +- server/object.h | 1 + server/process.c | 2 +- server/registry.c | 4 +++- 5 files changed, 7 insertions(+), 4 deletions(-) diff --git a/server/debugger.c b/server/debugger.c index 9b814469b19..b718c7c283f 100644 --- a/server/debugger.c +++ b/server/debugger.c @@ -134,7 +134,7 @@ static const struct object_ops debug_obj_ops = /* get a pointer to TEB->ArbitraryUserPointer in the client address space */ static client_ptr_t get_teb_user_ptr( struct thread *thread ) { - unsigned int ptr_size = is_machine_64bit( supported_machines[0] ) ? 8 : 4; + unsigned int ptr_size = is_machine_64bit( native_machine ) ? 8 : 4; return thread->teb + 5 * ptr_size; } diff --git a/server/mapping.c b/server/mapping.c index cd918224caa..529ce43bac9 100644 --- a/server/mapping.c +++ b/server/mapping.c @@ -717,7 +717,7 @@ static unsigned int get_image_params( struct mapping *mapping, file_pos_t file_s break; case IMAGE_NT_OPTIONAL_HDR64_MAGIC: - if (!is_machine_64bit( supported_machines[0] )) return STATUS_INVALID_IMAGE_WIN_64; + if (!is_machine_64bit( native_machine )) return STATUS_INVALID_IMAGE_WIN_64; if (!is_machine_64bit( nt.FileHeader.Machine )) return STATUS_INVALID_IMAGE_FORMAT; if (!is_machine_supported( nt.FileHeader.Machine )) return STATUS_INVALID_IMAGE_FORMAT; diff --git a/server/object.h b/server/object.h index e9d9a87875e..039bf4e7d4e 100644 --- a/server/object.h +++ b/server/object.h @@ -240,6 +240,7 @@ extern void generate_startup_debug_events( struct process *process ); extern unsigned int supported_machines_count; extern unsigned short supported_machines[8]; +extern unsigned short native_machine; extern void init_registry(void); extern void flush_registry(void); diff --git a/server/process.c b/server/process.c index 5b271b12328..24b7abb49d5 100644 --- a/server/process.c +++ b/server/process.c @@ -1088,7 +1088,7 @@ int set_process_debug_flag( struct process *process, int flag ) char data = (flag != 0); client_ptr_t peb32 = 0; - if (!is_machine_64bit( process->machine ) && is_machine_64bit( supported_machines[0] )) + if (!is_machine_64bit( process->machine ) && is_machine_64bit( native_machine )) peb32 = process->peb + 0x1000; /* BeingDebugged flag is the byte at offset 2 in the PEB */ diff --git a/server/registry.c b/server/registry.c index 68ec4f9e39a..f36760e6cc1 100644 --- a/server/registry.c +++ b/server/registry.c @@ -147,6 +147,7 @@ static struct save_branch_info save_branch_info[MAX_SAVE_BRANCH_INFO]; unsigned int supported_machines_count = 0; unsigned short supported_machines[8]; +unsigned short native_machine = 0; /* information about a file being loaded */ struct file_load_info @@ -1790,6 +1791,7 @@ static void init_supported_machines(void) #error Unsupported machine #endif supported_machines_count = count; + native_machine = supported_machines[0]; } /* registry initialisation */ @@ -2071,7 +2073,7 @@ void flush_registry(void) /* determine if the thread is wow64 (32-bit client running on 64-bit prefix) */ static int is_wow64_thread( struct thread *thread ) { - return (is_machine_64bit( supported_machines[0] ) && !is_machine_64bit( thread->process->machine )); + return (is_machine_64bit( native_machine ) && !is_machine_64bit( thread->process->machine )); }