Module: wine Branch: master Commit: 168c7a475d43cb7688636f0eb13b3892322333c0 URL: https://gitlab.winehq.org/wine/wine/-/commit/168c7a475d43cb7688636f0eb13b389...
Author: Eric Pouech eric.pouech@gmail.com Date: Thu Jan 5 12:58:20 2023 +0100
dbghelp: Don't search path when we have a file handle to loaded image.
When the handle to the loaded module is passed in SymLoadModule*(), don't try to search for the module's image path and use only the file handle.
Co-authored-by: Ake Rehnman ake.rehnman@gmail.com Signed-off-by: Eric Pouech eric.pouech@gmail.com
---
dlls/dbghelp/pe_module.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/dlls/dbghelp/pe_module.c b/dlls/dbghelp/pe_module.c index 4a7e68d5483..91a018c526b 100644 --- a/dlls/dbghelp/pe_module.c +++ b/dlls/dbghelp/pe_module.c @@ -784,6 +784,7 @@ struct module* pe_load_native_module(struct process* pcs, const WCHAR* name, BOOL opened = FALSE; struct module_format* modfmt; WCHAR loaded_name[MAX_PATH]; + WCHAR* real_path = NULL;
loaded_name[0] = '\0'; if (!hFile) @@ -802,11 +803,12 @@ 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 (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, 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); modfmt->u.pe_info->fmap = builtin.fmap; + real_path = builtin.path; } if (!base) base = PE_FROM_OPTHDR(&modfmt->u.pe_info->fmap, ImageBase); if (!size) size = PE_FROM_OPTHDR(&modfmt->u.pe_info->fmap, SizeOfImage); @@ -817,7 +819,7 @@ struct module* pe_load_native_module(struct process* pcs, const WCHAR* name, modfmt->u.pe_info->fmap.u.pe.file_header.Machine); if (module) { - module->real_path = builtin.path; + module->real_path = real_path; modfmt->module = module; modfmt->remove = pe_module_remove; modfmt->loc_compute = NULL; @@ -827,7 +829,7 @@ struct module* pe_load_native_module(struct process* pcs, const WCHAR* name, else { ERR("could not load the module '%s'\n", debugstr_w(loaded_name)); - heap_free(builtin.path); + heap_free(real_path); image_unmap_file(&modfmt->u.pe_info->fmap); } }