From: Eric Pouech epouech@codeweavers.com
Module names appear in three spots in dbghelp: A) SymGetModuleInfo() .ModuleName B) module enumeration (as parameter in callback) C) in symbol/type research in module!name form
Tests show that: - A) and B) always use only the derivation of the image name, whatever the passed module name in SymLoadModule(). - C) can use either the form derived from image name {as A) and B)}, but also the passed module name in SymLoadModule().
Note: B) is limited to 64 characters, while A) is limited to 32 characters (not tested here).
Signed-off-by: Eric Pouech epouech@codeweavers.com --- dlls/dbghelp/dbghelp_private.h | 1 + dlls/dbghelp/module.c | 8 ++++---- dlls/dbghelp/tests/path.c | 2 -- 3 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/dlls/dbghelp/dbghelp_private.h b/dlls/dbghelp/dbghelp_private.h index b3a073ff41f..628cb1e6442 100644 --- a/dlls/dbghelp/dbghelp_private.h +++ b/dlls/dbghelp/dbghelp_private.h @@ -438,6 +438,7 @@ struct module struct process* process; IMAGEHLP_MODULEW64 module; WCHAR modulename[64]; /* used for enumeration */ + WCHAR* alt_modulename; /* used in symbol lookup */ struct module* next; enum dhext_module_type type : 16; unsigned short is_virtual : 1, diff --git a/dlls/dbghelp/module.c b/dlls/dbghelp/module.c index 2507e65e169..a0de4f65056 100644 --- a/dlls/dbghelp/module.c +++ b/dlls/dbghelp/module.c @@ -210,6 +210,7 @@ struct module* module_new(struct process* pcs, const WCHAR* name, module->module.BaseOfImage = mod_addr; module->module.ImageSize = size; module_set_module(module, name); + module->alt_modulename = NULL; module->module.ImageName[0] = '\0'; lstrcpynW(module->module.LoadedImageName, name, ARRAY_SIZE(module->module.LoadedImageName)); module->module.SymType = SymDeferred; @@ -288,6 +289,7 @@ struct module* module_find_by_nameW(const struct process* pcs, const WCHAR* name for (module = pcs->lmodules; module; module = module->next) { if (!wcsicmp(name, module->modulename)) return module; + if (module->alt_modulename && !wcsicmp(name, module->alt_modulename)) return module; } SetLastError(ERROR_INVALID_NAME); return NULL; @@ -995,11 +997,9 @@ DWORD64 WINAPI SymLoadModuleExW(HANDLE hProcess, HANDLE hFile, PCWSTR wImageNam } }
- /* by default module_new fills module.ModuleName from a derivation - * of LoadedImageName. Overwrite it, if we have better information - */ + /* Store alternate name for module when provided. */ if (wModuleName) - module_set_module(module, wModuleName); + module->alt_modulename = pool_wcsdup(&module->pool, wModuleName); if (wImageName) lstrcpynW(module->module.ImageName, wImageName, ARRAY_SIZE(module->module.ImageName));
diff --git a/dlls/dbghelp/tests/path.c b/dlls/dbghelp/tests/path.c index 45b71ed4718..fc9a2e13bf9 100644 --- a/dlls/dbghelp/tests/path.c +++ b/dlls/dbghelp/tests/path.c @@ -1789,7 +1789,6 @@ static void test_load_modules_details(void) } else expected_module_name[0] = L'\0'; - todo_wine_if(i >= 2) ok(!wcsicmp(im.ModuleName, expected_module_name), "Unexpected module name '%ls'\n", im.ModuleName); ok(!wcsicmp(im.ImageName, test->in_image_name ? test->in_image_name : L""), "Unexpected image name '%ls'\n", im.ImageName); if ((test->options & SYMOPT_DEFERRED_LOADS) || !test->in_image_name) @@ -1853,7 +1852,6 @@ static void test_load_modules_details(void) ret = SymEnumerateModulesW64(dummy, aggregate_module_details_cb, &md); ok(ret, "SymEnumerateModules64 failed: %lu\n", GetLastError()); ok(md.count == 1, "Unexpected module count %u\n", md.count); - todo_wine_if(i >= 2) ok(!wcscmp(md.name, expected_module_name), "Unexpected module name %ls\n", md.name); free(md.name); /* native will fail loading symbol in deferred state, so force loading of debug symbols */