Akihiro Sagawa : kernel32: Return the list of module handles even if the last argument is null.
Module: wine Branch: master Commit: 844ae22fcfcca14ae66bc0f2458a0a2487d56de3 URL: https://source.winehq.org/git/wine.git/?a=commit;h=844ae22fcfcca14ae66bc0f24... Author: Akihiro Sagawa <sagawa.aki(a)gmail.com> Date: Fri Jan 19 23:50:38 2018 +0900 kernel32: Return the list of module handles even if the last argument is null. Touhou Shinpiroku relies on this behaviour. Signed-off-by: Akihiro Sagawa <sagawa.aki(a)gmail.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/kernel32/module.c | 14 ++++++++++---- dlls/psapi/tests/psapi_main.c | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/dlls/kernel32/module.c b/dlls/kernel32/module.c index d068f2a..b97c79b 100644 --- a/dlls/kernel32/module.c +++ b/dlls/kernel32/module.c @@ -1489,19 +1489,18 @@ BOOL WINAPI K32EnumProcessModules(HANDLE process, HMODULE *lphModule, DWORD cb, DWORD *needed) { MODULE_ITERATOR iter; + DWORD size = 0; INT ret; if (!init_module_iterator(&iter, process)) return FALSE; - if ((cb && !lphModule) || !needed) + if (cb && !lphModule) { SetLastError(ERROR_NOACCESS); return FALSE; } - *needed = 0; - while ((ret = module_iterator_next(&iter)) > 0) { if (cb >= sizeof(HMODULE)) @@ -1509,8 +1508,15 @@ BOOL WINAPI K32EnumProcessModules(HANDLE process, HMODULE *lphModule, *lphModule++ = iter.ldr_module.BaseAddress; cb -= sizeof(HMODULE); } - *needed += sizeof(HMODULE); + size += sizeof(HMODULE); + } + + if (!needed) + { + SetLastError(ERROR_NOACCESS); + return FALSE; } + *needed = size; return ret == 0; } diff --git a/dlls/psapi/tests/psapi_main.c b/dlls/psapi/tests/psapi_main.c index 30059c5..8638d73 100644 --- a/dlls/psapi/tests/psapi_main.c +++ b/dlls/psapi/tests/psapi_main.c @@ -132,7 +132,7 @@ static void test_EnumProcessModules(void) ret = pEnumProcessModules(hpQV, &hMod, sizeof(HMODULE), NULL); ok(!ret, "succeeded\n"); ok(GetLastError() == ERROR_NOACCESS, "expected error=ERROR_NOACCESS but got %d\n", GetLastError()); - todo_wine ok(hMod == GetModuleHandleA(NULL), + ok(hMod == GetModuleHandleA(NULL), "hMod=%p GetModuleHandleA(NULL)=%p\n", hMod, GetModuleHandleA(NULL)); SetLastError(0xdeadbeef);
participants (1)
-
Alexandre Julliard