Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/kernel32/module.c | 29 ++++++++++++++++++++++++----- dlls/psapi/tests/psapi_main.c | 5 +++++ 2 files changed, 29 insertions(+), 5 deletions(-)
diff --git a/dlls/kernel32/module.c b/dlls/kernel32/module.c index 0ae5343..6cef536 100644 --- a/dlls/kernel32/module.c +++ b/dlls/kernel32/module.c @@ -1818,17 +1818,36 @@ DWORD WINAPI K32GetModuleFileNameExW(HANDLE process, HMODULE module, LPWSTR file_name, DWORD size) { LDR_MODULE ldr_module; + BOOL wow64; DWORD len;
if (!size) return 0;
- if(!get_ldr_module(process, module, &ldr_module)) + if (!IsWow64Process(process, &wow64)) return 0;
- len = ldr_module.FullDllName.Length / sizeof(WCHAR); - if (!ReadProcessMemory(process, ldr_module.FullDllName.Buffer, - file_name, min( len, size ) * sizeof(WCHAR), NULL)) - return 0; + if (!is_wow64 && wow64) + { + LDR_MODULE32 ldr_module32; + + if (!get_ldr_module32(process, module, &ldr_module32)) + return 0; + + len = ldr_module32.FullDllName.Length / sizeof(WCHAR); + if (!ReadProcessMemory(process, (void *)(DWORD_PTR)ldr_module32.FullDllName.Buffer, + file_name, min( len, size ) * sizeof(WCHAR), NULL)) + return 0; + } + else + { + if (!get_ldr_module(process, module, &ldr_module)) + return 0; + + len = ldr_module.FullDllName.Length / sizeof(WCHAR); + if (!ReadProcessMemory(process, ldr_module.FullDllName.Buffer, + file_name, min( len, size ) * sizeof(WCHAR), NULL)) + return 0; + }
if (len < size) { diff --git a/dlls/psapi/tests/psapi_main.c b/dlls/psapi/tests/psapi_main.c index 782fb6f..8f65296 100644 --- a/dlls/psapi/tests/psapi_main.c +++ b/dlls/psapi/tests/psapi_main.c @@ -202,6 +202,11 @@ static void test_EnumProcessModules(void) ok(ret, "got error %u\n", GetLastError()); ok(!strcmp(name, "notepad.exe"), "got %s\n", name);
+ ret = GetModuleFileNameExA(pi.hProcess, hMod, name, sizeof(name)); + ok(ret, "got error %u\n", GetLastError()); +todo_wine + ok(!strcmp(name, buffer), "got %s\n", name); + TerminateProcess(pi.hProcess, 0); } else if (wow64)