Module: wine Branch: master Commit: 07efff4e9ff3f3cb59da07c61ce80b25932ec957 URL: https://gitlab.winehq.org/wine/wine/-/commit/07efff4e9ff3f3cb59da07c61ce80b2...
Author: Eric Pouech eric.pouech@gmail.com Date: Mon Jan 30 13:45:49 2023 +0100
kernelbase: Let GetModuleBaseName succeed on 64bit modules in wow64.
Signed-off-by: Eric Pouech eric.pouech@gmail.com
---
dlls/kernelbase/debug.c | 23 ++++++++++++++++------- dlls/psapi/tests/psapi_main.c | 1 - 2 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/dlls/kernelbase/debug.c b/dlls/kernelbase/debug.c index c4c1bfa59e2..d34268c0828 100644 --- a/dlls/kernelbase/debug.c +++ b/dlls/kernelbase/debug.c @@ -876,6 +876,13 @@ static BOOL get_ldr_module32( HANDLE process, HMODULE module, LDR_DATA_TABLE_ENT struct module_iterator iter; INT ret;
+#ifdef _WIN64 + if ((ULONG_PTR)module >> 32) + { + SetLastError( ERROR_INVALID_HANDLE ); + return FALSE; + } +#endif if (!init_module_iterator( &iter, process, TRUE )) return FALSE;
while ((ret = module_iterator_next( &iter )) > 0) @@ -1320,7 +1327,7 @@ DWORD WINAPI DECLSPEC_HOTPATCH GetModuleBaseNameA( HANDLE process, HMODULE modul DWORD WINAPI DECLSPEC_HOTPATCH GetModuleBaseNameW( HANDLE process, HMODULE module, WCHAR *name, DWORD size ) { - BOOL wow64; + BOOL wow64, found = FALSE;
if (!IsWow64Process( process, &wow64 )) return 0;
@@ -1328,13 +1335,15 @@ DWORD WINAPI DECLSPEC_HOTPATCH GetModuleBaseNameW( HANDLE process, HMODULE modul { LDR_DATA_TABLE_ENTRY32 ldr_module32;
- if (!get_ldr_module32(process, module, &ldr_module32)) return 0; - size = min( ldr_module32.BaseDllName.Length / sizeof(WCHAR), size ); - if (!ReadProcessMemory( process, (void *)(DWORD_PTR)ldr_module32.BaseDllName.Buffer, - name, size * sizeof(WCHAR), NULL )) - return 0; + if (get_ldr_module32(process, module, &ldr_module32)) + { + size = min( ldr_module32.BaseDllName.Length / sizeof(WCHAR), size ); + if (ReadProcessMemory( process, (void *)(DWORD_PTR)ldr_module32.BaseDllName.Buffer, + name, size * sizeof(WCHAR), NULL )) + found = TRUE; + } } - else + if (!found) { LDR_DATA_TABLE_ENTRY ldr_module;
diff --git a/dlls/psapi/tests/psapi_main.c b/dlls/psapi/tests/psapi_main.c index 71eadc7114e..15b168cf83f 100644 --- a/dlls/psapi/tests/psapi_main.c +++ b/dlls/psapi/tests/psapi_main.c @@ -241,7 +241,6 @@ static BOOL test_EnumProcessModulesEx_snapshot(HANDLE proc, struct moduleex_snap case LIST_MODULES_64BIT: break; } ret = GetModuleBaseNameA(proc, mxsnap[i].modules[j], buffer, sizeof(buffer)); - todo_wine_if(fail) ok(ret, "GetModuleBaseName failed: %lu (%u/%lu=%p)\n", GetLastError(), j, mxsnap[i].num_modules, mxsnap[i].modules[j]); ret = GetModuleFileNameExA(proc, mxsnap[i].modules[j], buffer, sizeof(buffer)); todo_wine_if(fail)