Commit df5f6f66 authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

kernelbase: Re-implement EnumProcessModules on top of EnumProcessModulesEx.

Note: this patch changes the results of EnumProcessModules for a wow64 target process called from a 64bit process. It now returns: - main module and all loaded 64bit modules (Wine multi-arch wow64 and Windows) - main module only (Wine "old" wow64). It used to return all the 32bit modules. You now must use EnumProcessModulesEx(..., LIST_MODULES_32BIT) to get that result. Signed-off-by: 's avatarEric Pouech <eric.pouech@gmail.com>
parent 00bf7293
......@@ -949,71 +949,7 @@ BOOL WINAPI /* DECLSPEC_HOTPATCH */ EnumPageFilesW( PENUM_PAGE_FILE_CALLBACKW ca
BOOL WINAPI DECLSPEC_HOTPATCH EnumProcessModules( HANDLE process, HMODULE *module,
DWORD count, DWORD *needed )
{
struct module_iterator iter;
DWORD size = 0;
BOOL target_wow64;
INT ret;
if (process == GetCurrentProcess())
{
PPEB_LDR_DATA ldr_data = NtCurrentTeb()->Peb->LdrData;
PLIST_ENTRY head = &ldr_data->InLoadOrderModuleList;
PLIST_ENTRY entry = head->Flink;
if (count && !module)
{
SetLastError( ERROR_NOACCESS );
return FALSE;
}
while (entry != head)
{
LDR_DATA_TABLE_ENTRY *ldr = CONTAINING_RECORD( entry, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks );
if (count >= sizeof(HMODULE))
{
*module++ = ldr->DllBase;
count -= sizeof(HMODULE);
}
size += sizeof(HMODULE);
entry = entry->Flink;
}
if (!needed)
{
SetLastError( ERROR_NOACCESS );
return FALSE;
}
*needed = size;
return TRUE;
}
if (!IsWow64Process( process, &target_wow64 )) return FALSE;
if (!init_module_iterator( &iter, process, is_win64 && target_wow64 )) return FALSE;
if (count && !module)
{
SetLastError( ERROR_NOACCESS );
return FALSE;
}
while ((ret = module_iterator_next( &iter )) > 0)
{
if (count >= sizeof(HMODULE))
{
if (sizeof(void *) == 8 && iter.wow64)
*module++ = (HMODULE) (DWORD_PTR)iter.ldr_module32.BaseAddress;
else
*module++ = iter.ldr_module.DllBase;
count -= sizeof(HMODULE);
}
size += sizeof(HMODULE);
}
if (!needed)
{
SetLastError( ERROR_NOACCESS );
return FALSE;
}
*needed = size;
return ret == 0;
return EnumProcessModulesEx( process, module, count, needed, LIST_MODULES_DEFAULT );
}
......
......@@ -181,7 +181,6 @@ static void test_EnumProcessModules(void)
{
ret = GetModuleBaseNameA(pi.hProcess, hmods[2], name, sizeof(name));
ok(ret, "got error %lu\n", GetLastError());
todo_wine
ok(strstr(CharLowerA(name), "wow64") != NULL, "third DLL in wow64 should be one of wow*.dll (%s)\n", name);
}
TerminateProcess(pi.hProcess, 0);
......@@ -207,7 +206,6 @@ static void test_EnumProcessModules(void)
SetLastError(0xdeadbeef);
ret = EnumProcessModules(pi.hProcess, &hMod, sizeof(HMODULE), &cbNeeded);
ok(!ret, "got %ld\n", ret);
todo_wine
ok(GetLastError() == ERROR_PARTIAL_COPY, "got error %lu\n", GetLastError());
TerminateProcess(pi.hProcess, 0);
......
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