dbghelp: Filter on machine when searching for Wine system PE modules.

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
This commit is contained in:
Eric Pouech 2023-02-01 16:22:57 +01:00 committed by Alexandre Julliard
parent 4d2cbb4104
commit aac4e9df0a
6 changed files with 9 additions and 9 deletions

View file

@ -764,8 +764,8 @@ extern BOOL path_find_symbol_file(const struct process* pcs, const struc
PCSTR full_path, enum module_type type, const GUID* guid, DWORD dw1, DWORD dw2,
WCHAR *buffer, BOOL* is_unmatched) DECLSPEC_HIDDEN;
extern WCHAR *get_dos_file_name(const WCHAR *filename) __WINE_DEALLOC(HeapFree, 3) __WINE_MALLOC DECLSPEC_HIDDEN;
extern BOOL search_dll_path(const struct process* process, const WCHAR *name,
BOOL (*match)(void*, HANDLE, const WCHAR*), void *param) DECLSPEC_HIDDEN;
extern BOOL search_dll_path(const struct process* process, const WCHAR *name, WORD machine,
BOOL (*match)(void*, HANDLE, const WCHAR*), void *param) DECLSPEC_HIDDEN;
extern BOOL search_unix_path(const WCHAR *name, const WCHAR *path, BOOL (*match)(void*, HANDLE, const WCHAR*), void *param) DECLSPEC_HIDDEN;
extern const WCHAR* file_name(const WCHAR* str) DECLSPEC_HIDDEN;
extern const char* file_nameA(const char* str) DECLSPEC_HIDDEN;

View file

@ -1445,7 +1445,7 @@ static BOOL elf_search_and_load_file(struct process* pcs, const WCHAR* filename,
load_elf.elf_info = elf_info;
ret = search_unix_path(filename, process_getenv(pcs, L"LD_LIBRARY_PATH"), elf_load_file_cb, &load_elf)
|| search_dll_path(pcs, filename, elf_load_file_cb, &load_elf);
|| search_dll_path(pcs, filename, IMAGE_FILE_MACHINE_UNKNOWN, elf_load_file_cb, &load_elf);
}
return ret;

View file

@ -1583,7 +1583,7 @@ static BOOL macho_search_and_load_file(struct process* pcs, const WCHAR* filenam
ret = search_unix_path(p, fallback, macho_load_file_cb, &load_params);
}
if (!ret && p == filename)
ret = search_dll_path(pcs, filename, macho_load_file_cb, &load_params);
ret = search_dll_path(pcs, filename, IMAGE_FILE_MACHINE_UNKNOWN, macho_load_file_cb, &load_params);
return ret;
}

View file

@ -722,7 +722,7 @@ static BOOL try_match_file(const WCHAR *name, BOOL (*match)(void*, HANDLE, const
return FALSE;
}
BOOL search_dll_path(const struct process *process, const WCHAR *name, BOOL (*match)(void*, HANDLE, const WCHAR*), void *param)
BOOL search_dll_path(const struct process *process, const WCHAR *name, WORD machine, BOOL (*match)(void*, HANDLE, const WCHAR*), void *param)
{
const WCHAR *env;
WCHAR *p, *end;
@ -733,7 +733,8 @@ BOOL search_dll_path(const struct process *process, const WCHAR *name, BOOL (*ma
name = file_name(name);
cpu = process_get_cpu(process);
cpu = machine == IMAGE_FILE_MACHINE_UNKNOWN ? process_get_cpu(process) : cpu_find(machine);
for (machine_dir = all_machine_dir; machine_dir < all_machine_dir + ARRAY_SIZE(all_machine_dir); machine_dir++)
if (machine_dir->machine == cpu->machine) break;
if (machine_dir >= all_machine_dir + ARRAY_SIZE(all_machine_dir)) return FALSE;

View file

@ -824,7 +824,8 @@ struct module* pe_load_native_module(struct process* pcs, const WCHAR* name,
if (pe_map_file(hFile, &modfmt->u.pe_info->fmap, DMT_PE))
{
struct builtin_search builtin = { NULL };
if (opened && modfmt->u.pe_info->fmap.u.pe.builtin && search_dll_path(pcs, loaded_name, search_builtin_pe, &builtin))
if (opened && modfmt->u.pe_info->fmap.u.pe.builtin &&
search_dll_path(pcs, loaded_name, modfmt->u.pe_info->fmap.u.pe.file_header.Machine, search_builtin_pe, &builtin))
{
TRACE("reloaded %s from %s\n", debugstr_w(loaded_name), debugstr_w(builtin.path));
image_unmap_file(&modfmt->u.pe_info->fmap);

View file

@ -240,7 +240,6 @@ static void test_modules(void)
ret = SymGetModuleInfoW64(GetCurrentProcess(), base2, &im);
ok(ret, "SymGetModuleInfoW64 failed: %lu\n", GetLastError());
ok(im.BaseOfImage == base2, "Wrong base address\n");
todo_wine_if(sizeof(void*) == 8)
ok(im.MachineType == get_module_machine("C:\\windows\\syswow64\\notepad.exe"),
"Wrong machine %lx\n", im.MachineType);
}
@ -272,7 +271,6 @@ static void test_modules(void)
ret = SymGetModuleInfoW64(GetCurrentProcess(), base2, &im);
ok(ret, "SymGetModuleInfoW64 failed: %lu\n", GetLastError());
ok(im.BaseOfImage == base2, "Wrong base address\n");
todo_wine_if(sizeof(void*) == 8)
ok(im.MachineType == get_module_machine("C:\\windows\\syswow64\\notepad.exe"),
"Wrong machine %lx\n", im.MachineType);
}