Module: wine Branch: master Commit: bde065746e51e4cfdcf0cbf8583a933abbb2daea URL: https://gitlab.winehq.org/wine/wine/-/commit/bde065746e51e4cfdcf0cbf8583a933...
Author: Eric Pouech epouech@codeweavers.com Date: Wed Jul 5 19:29:04 2023 +0200
winedbg: Cache wow64 status inside struct process.
Signed-off-by: Eric Pouech epouech@codeweavers.com
---
programs/winedbg/debugger.h | 1 + programs/winedbg/gdbproxy.c | 10 +++------- programs/winedbg/tgt_active.c | 4 +--- programs/winedbg/winedbg.c | 5 +++-- 4 files changed, 8 insertions(+), 12 deletions(-)
diff --git a/programs/winedbg/debugger.h b/programs/winedbg/debugger.h index 59c923c38ad..28fb788b3c7 100644 --- a/programs/winedbg/debugger.h +++ b/programs/winedbg/debugger.h @@ -280,6 +280,7 @@ struct dbg_process struct backend_cpu* be_cpu; HANDLE event_on_first_exception; BOOL active_debuggee; + BOOL is_wow64; struct dbg_breakpoint bp[MAX_BREAKPOINTS]; unsigned next_bp; struct dbg_delayed_bp* delayed_bp; diff --git a/programs/winedbg/gdbproxy.c b/programs/winedbg/gdbproxy.c index 18e18289bee..238eecb1538 100644 --- a/programs/winedbg/gdbproxy.c +++ b/programs/winedbg/gdbproxy.c @@ -1685,7 +1685,6 @@ static BOOL CALLBACK packet_query_libraries_cb(PCSTR mod_name, DWORD64 base, PVO IMAGE_NT_HEADERS *nth = NULL; IMAGEHLP_MODULE64 mod; SIZE_T size, i; - BOOL is_wow64; char buffer[0x400];
mod.SizeOfStruct = sizeof(mod); @@ -1709,8 +1708,7 @@ static BOOL CALLBACK packet_query_libraries_cb(PCSTR mod_name, DWORD64 base, PVO
if ((unix_path = wine_get_unix_file_name(nt_name.Buffer))) { - if (IsWow64Process(gdbctx->process->handle, &is_wow64) && - is_wow64 && (tmp = strstr(unix_path, "system32"))) + if (gdbctx->process->is_wow64 && (tmp = strstr(unix_path, "system32"))) memcpy(tmp, "syswow64", 8); reply_buffer_append_xmlstr(reply, unix_path); } @@ -1743,7 +1741,7 @@ static BOOL CALLBACK packet_query_libraries_cb(PCSTR mod_name, DWORD64 base, PVO * the following computation valid in all cases. */ dos = (IMAGE_DOS_HEADER *)buffer; nth = (IMAGE_NT_HEADERS *)(buffer + dos->e_lfanew); - if (IsWow64Process(gdbctx->process->handle, &is_wow64) && is_wow64) + if (gdbctx->process->is_wow64) sec = IMAGE_FIRST_SECTION((IMAGE_NT_HEADERS32 *)nth); else sec = IMAGE_FIRST_SECTION((IMAGE_NT_HEADERS64 *)nth); @@ -1967,7 +1965,6 @@ static enum packet_return packet_query_exec_file(struct gdb_context* gdbctx) struct reply_buffer* reply = &gdbctx->qxfer_buffer; struct dbg_process* process = gdbctx->process; char *unix_path; - BOOL is_wow64; char *tmp;
if (!process) return packet_error; @@ -1978,8 +1975,7 @@ static enum packet_return packet_query_exec_file(struct gdb_context* gdbctx) if (!(unix_path = wine_get_unix_file_name(process->imageName))) return packet_reply_error(gdbctx, GetLastError() == ERROR_NOT_ENOUGH_MEMORY ? HOST_ENOMEM : HOST_ENOENT);
- if (IsWow64Process(process->handle, &is_wow64) && - is_wow64 && (tmp = strstr(unix_path, "system32"))) + if (process->is_wow64 && (tmp = strstr(unix_path, "system32"))) memcpy(tmp, "syswow64", 8);
reply_buffer_append_str(reply, unix_path); diff --git a/programs/winedbg/tgt_active.c b/programs/winedbg/tgt_active.c index 0d5ae754af5..7a5d71d8909 100644 --- a/programs/winedbg/tgt_active.c +++ b/programs/winedbg/tgt_active.c @@ -869,15 +869,13 @@ static void output_system_info(void)
const char *(CDECL *wine_get_build_id)(void); void (CDECL *wine_get_host_version)( const char **sysname, const char **release ); - BOOL is_wow64;
wine_get_build_id = (void *)GetProcAddress(GetModuleHandleA("ntdll.dll"), "wine_get_build_id"); wine_get_host_version = (void *)GetProcAddress(GetModuleHandleA("ntdll.dll"), "wine_get_host_version"); - if (!IsWow64Process( dbg_curr_process->handle, &is_wow64 )) is_wow64 = FALSE;
dbg_printf( "System information:\n" ); if (wine_get_build_id) dbg_printf( " Wine build: %s\n", wine_get_build_id() ); - dbg_printf( " Platform: %s%s\n", platform, is_wow64 ? " (WOW64)" : "" ); + dbg_printf( " Platform: %s%s\n", platform, dbg_curr_process->is_wow64 ? " (WOW64)" : "" ); dbg_printf( " Version: Windows %s\n", get_windows_version() ); if (wine_get_host_version) { diff --git a/programs/winedbg/winedbg.c b/programs/winedbg/winedbg.c index e7ba6afa2e4..438d4a3d94b 100644 --- a/programs/winedbg/winedbg.c +++ b/programs/winedbg/winedbg.c @@ -266,6 +266,8 @@ struct dbg_process* dbg_add_process(const struct be_process_io* pio, DWORD pid, if (!h) h = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
+ if (!IsWow64Process(h, &wow64)) wow64 = FALSE; + if (!(p = malloc(sizeof(struct dbg_process)))) return NULL; p->handle = h; p->pid = pid; @@ -276,6 +278,7 @@ struct dbg_process* dbg_add_process(const struct be_process_io* pio, DWORD pid, list_init(&p->modules); p->event_on_first_exception = NULL; p->active_debuggee = FALSE; + p->is_wow64 = wow64; p->next_bp = 1; /* breakpoint 0 is reserved for step-over */ memset(p->bp, 0, sizeof(p->bp)); p->delayed_bp = NULL; @@ -291,8 +294,6 @@ struct dbg_process* dbg_add_process(const struct be_process_io* pio, DWORD pid,
list_add_head(&dbg_process_list, &p->entry);
- IsWow64Process(h, &wow64); - #ifdef __i386__ p->be_cpu = &be_i386; #elif defined(__x86_64__)