From: Zebediah Figura z.figura12@gmail.com
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/kernel32/module.c | 26 ++++++++++++++++++++++---- dlls/psapi/tests/psapi_main.c | 7 +++++++ 2 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/dlls/kernel32/module.c b/dlls/kernel32/module.c index 01d28a8..3ab70e8 100644 --- a/dlls/kernel32/module.c +++ b/dlls/kernel32/module.c @@ -1907,6 +1907,7 @@ BOOL WINAPI K32GetModuleInformation(HANDLE process, HMODULE module, MODULEINFO *modinfo, DWORD cb) { LDR_MODULE ldr_module; + BOOL wow64;
if (cb < sizeof(MODULEINFO)) { @@ -1914,12 +1915,29 @@ BOOL WINAPI K32GetModuleInformation(HANDLE process, HMODULE module, return FALSE; }
- if (!get_ldr_module(process, module, &ldr_module)) + if (!IsWow64Process(process, &wow64)) return FALSE;
- modinfo->lpBaseOfDll = ldr_module.BaseAddress; - modinfo->SizeOfImage = ldr_module.SizeOfImage; - modinfo->EntryPoint = ldr_module.EntryPoint; + if (sizeof(void *) == 8 && wow64) + { + LDR_MODULE32 ldr_module32; + + if (!get_ldr_module32(process, module, &ldr_module32)) + return FALSE; + + modinfo->lpBaseOfDll = (void *)(DWORD_PTR)ldr_module32.BaseAddress; + modinfo->SizeOfImage = ldr_module32.SizeOfImage; + modinfo->EntryPoint = (void *)(DWORD_PTR)ldr_module32.EntryPoint; + } + else + { + if (!get_ldr_module(process, module, &ldr_module)) + return FALSE; + + modinfo->lpBaseOfDll = ldr_module.BaseAddress; + modinfo->SizeOfImage = ldr_module.SizeOfImage; + modinfo->EntryPoint = ldr_module.EntryPoint; + } return TRUE; }
diff --git a/dlls/psapi/tests/psapi_main.c b/dlls/psapi/tests/psapi_main.c index 8f65296..7e874a0 100644 --- a/dlls/psapi/tests/psapi_main.c +++ b/dlls/psapi/tests/psapi_main.c @@ -182,6 +182,7 @@ static void test_EnumProcessModules(void)
if (sizeof(void *) == 8) { + MODULEINFO info; char name[40];
strcpy(buffer, "C:\windows\syswow64\notepad.exe"); @@ -207,6 +208,12 @@ static void test_EnumProcessModules(void) todo_wine ok(!strcmp(name, buffer), "got %s\n", name);
+ ret = GetModuleInformation(pi.hProcess, hMod, &info, sizeof(info)); + ok(ret, "got error %u\n", GetLastError()); + ok(info.lpBaseOfDll == hMod, "expected %p, got %p\n", hMod, info.lpBaseOfDll); + ok(info.SizeOfImage, "image size was 0\n"); + ok(info.EntryPoint >= info.lpBaseOfDll, "got entry point %p\n", info.EntryPoint); + TerminateProcess(pi.hProcess, 0); } else if (wow64)