Module: wine Branch: master Commit: eb1f62bb31b2f99f9390c4c9e4d9db4cbbfdca2b URL: https://gitlab.winehq.org/wine/wine/-/commit/eb1f62bb31b2f99f9390c4c9e4d9db4...
Author: Eric Pouech epouech@codeweavers.com Date: Fri Jun 23 11:04:55 2023 +0200
dbghelp: Fix reading Wine loader's base address.
Note: the 32bit tests in new wow mode are still marked todo as the ELF debug header is located above the 4G limit and "default" module management in dbghelp compiled in 32bit is (mostly) done with 32 bit addresses. The correct fix should be to always consider ELF (and macho-O) modules with 64bit addresses (which means likely to move all modules handling to 64bit even in 32bit compilations). But that goes far beyond this patch.
This limitation will only impact debuggers compiled in 32bit, using 32bit builtin dbghelp on a 32bit debuggee.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55058 Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55096 Signed-off-by: Eric Pouech epouech@codeweavers.com
---
dlls/dbghelp/dbghelp.c | 2 +- dlls/dbghelp/tests/dbghelp.c | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/dlls/dbghelp/dbghelp.c b/dlls/dbghelp/dbghelp.c index d3003fc44d2..3ce3ef6f707 100644 --- a/dlls/dbghelp/dbghelp.c +++ b/dlls/dbghelp/dbghelp.c @@ -387,7 +387,7 @@ static BOOL check_live_target(struct process* pcs, BOOL wow64, BOOL child_wow64)
if (!pcs->is_64bit) peb_addr -= 0x1000; /* PEB32 => PEB64 */ if (!ReadProcessMemory(pcs->handle, peb_addr, &peb, sizeof(peb), NULL)) return FALSE; - base = peb.CloudFileFlags; + base = *(const DWORD64*)&peb.CloudFileFlags; pcs->is_system_64bit = TRUE; if (pcs->is_64bit) ReadProcessMemory(pcs->handle, diff --git a/dlls/dbghelp/tests/dbghelp.c b/dlls/dbghelp/tests/dbghelp.c index 1bd1122c642..575b9f76d20 100644 --- a/dlls/dbghelp/tests/dbghelp.c +++ b/dlls/dbghelp/tests/dbghelp.c @@ -763,14 +763,16 @@ static void test_loaded_modules(void) } }
+ pcskind = get_process_kind(pi.hProcess); + ret = SymRefreshModuleList(pi.hProcess); - todo_wine_if(pcskind != PCSKIND_32BIT && pcskind != PCSKIND_WINE_OLD_WOW64) + todo_wine_if(pcskind == PCSKIND_WOW64) ok(ret || broken(GetLastError() == STATUS_PARTIAL_COPY /* Win11 in some cases */), "SymRefreshModuleList failed: %lu\n", GetLastError());
if (!strcmp(winetest_platform, "wine")) { unsigned count = get_native_module_count(pi.hProcess); - todo_wine_if(pcskind != PCSKIND_32BIT && pcskind != PCSKIND_WINE_OLD_WOW64) + todo_wine_if(pcskind == PCSKIND_WOW64) ok(count > 0, "Didn't find any native (ELF/Macho) modules\n"); }
@@ -823,14 +825,12 @@ static void test_loaded_modules(void) "Wrong directory aggregation count %u %u\n", aggregation.count_systemdir, aggregation.count_wowdir); } - todo_wine_if(pcskind != PCSKIND_WINE_OLD_WOW64) ret = SymRefreshModuleList(pi.hProcess); ok(ret, "SymRefreshModuleList failed: %lu\n", GetLastError());
if (!strcmp(winetest_platform, "wine")) { unsigned count = get_native_module_count(pi.hProcess); - todo_wine_if(pcskind != PCSKIND_WINE_OLD_WOW64) ok(count > 0, "Didn't find any native (ELF/Macho) modules\n"); }
@@ -887,14 +887,12 @@ static void test_loaded_modules(void) break; }
- todo_wine_if(pcskind != PCSKIND_WINE_OLD_WOW64) ret = SymRefreshModuleList(pi.hProcess); ok(ret, "SymRefreshModuleList failed: %lu\n", GetLastError());
if (!strcmp(winetest_platform, "wine")) { unsigned count = get_native_module_count(pi.hProcess); - todo_wine_if(pcskind != PCSKIND_WINE_OLD_WOW64) ok(count > 0, "Didn't find any native (ELF/Macho) modules\n"); }