mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-14 22:20:42 +00:00
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: Eric Pouech <eric.pouech@gmail.com>
This commit is contained in:
parent
00bf7293af
commit
df5f6f66de
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue