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@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Akihiro Sagawa 2018-01-19 23:50:38 +09:00 committed by Alexandre Julliard
parent 74b386d4a2
commit 844ae22fcf
2 changed files with 11 additions and 5 deletions

View File

@ -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,9 +1508,16 @@ 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;
}

View File

@ -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);