Commit 844ae22f authored by Akihiro Sagawa's avatar Akihiro Sagawa Committed by Alexandre Julliard

kernel32: Return the list of module handles even if the last argument is null.

Touhou Shinpiroku relies on this behaviour. Signed-off-by: 's avatarAkihiro Sagawa <sagawa.aki@gmail.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 74b386d4
......@@ -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;
}
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment