Commit 4f80a599 authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

dbghelp: Mimic native behavior for module name.

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: 's avatarEric Pouech <epouech@codeweavers.com>
parent d6d22677
...@@ -438,6 +438,7 @@ struct module ...@@ -438,6 +438,7 @@ struct module
struct process* process; struct process* process;
IMAGEHLP_MODULEW64 module; IMAGEHLP_MODULEW64 module;
WCHAR modulename[64]; /* used for enumeration */ WCHAR modulename[64]; /* used for enumeration */
WCHAR* alt_modulename; /* used in symbol lookup */
struct module* next; struct module* next;
enum dhext_module_type type : 16; enum dhext_module_type type : 16;
unsigned short is_virtual : 1, unsigned short is_virtual : 1,
......
...@@ -210,6 +210,7 @@ struct module* module_new(struct process* pcs, const WCHAR* name, ...@@ -210,6 +210,7 @@ struct module* module_new(struct process* pcs, const WCHAR* name,
module->module.BaseOfImage = mod_addr; module->module.BaseOfImage = mod_addr;
module->module.ImageSize = size; module->module.ImageSize = size;
module_set_module(module, name); module_set_module(module, name);
module->alt_modulename = NULL;
module->module.ImageName[0] = '\0'; module->module.ImageName[0] = '\0';
lstrcpynW(module->module.LoadedImageName, name, ARRAY_SIZE(module->module.LoadedImageName)); lstrcpynW(module->module.LoadedImageName, name, ARRAY_SIZE(module->module.LoadedImageName));
module->module.SymType = SymDeferred; module->module.SymType = SymDeferred;
...@@ -288,6 +289,7 @@ struct module* module_find_by_nameW(const struct process* pcs, const WCHAR* name ...@@ -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) for (module = pcs->lmodules; module; module = module->next)
{ {
if (!wcsicmp(name, module->modulename)) return module; if (!wcsicmp(name, module->modulename)) return module;
if (module->alt_modulename && !wcsicmp(name, module->alt_modulename)) return module;
} }
SetLastError(ERROR_INVALID_NAME); SetLastError(ERROR_INVALID_NAME);
return NULL; return NULL;
...@@ -995,11 +997,9 @@ DWORD64 WINAPI SymLoadModuleExW(HANDLE hProcess, HANDLE hFile, PCWSTR wImageNam ...@@ -995,11 +997,9 @@ DWORD64 WINAPI SymLoadModuleExW(HANDLE hProcess, HANDLE hFile, PCWSTR wImageNam
} }
} }
/* by default module_new fills module.ModuleName from a derivation /* Store alternate name for module when provided. */
* of LoadedImageName. Overwrite it, if we have better information
*/
if (wModuleName) if (wModuleName)
module_set_module(module, wModuleName); module->alt_modulename = pool_wcsdup(&module->pool, wModuleName);
if (wImageName) if (wImageName)
lstrcpynW(module->module.ImageName, wImageName, ARRAY_SIZE(module->module.ImageName)); lstrcpynW(module->module.ImageName, wImageName, ARRAY_SIZE(module->module.ImageName));
......
...@@ -1789,7 +1789,6 @@ static void test_load_modules_details(void) ...@@ -1789,7 +1789,6 @@ static void test_load_modules_details(void)
} }
else else
expected_module_name[0] = L'\0'; 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.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); 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) if ((test->options & SYMOPT_DEFERRED_LOADS) || !test->in_image_name)
...@@ -1853,7 +1852,6 @@ static void test_load_modules_details(void) ...@@ -1853,7 +1852,6 @@ static void test_load_modules_details(void)
ret = SymEnumerateModulesW64(dummy, aggregate_module_details_cb, &md); ret = SymEnumerateModulesW64(dummy, aggregate_module_details_cb, &md);
ok(ret, "SymEnumerateModules64 failed: %lu\n", GetLastError()); ok(ret, "SymEnumerateModules64 failed: %lu\n", GetLastError());
ok(md.count == 1, "Unexpected module count %u\n", md.count); 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); ok(!wcscmp(md.name, expected_module_name), "Unexpected module name %ls\n", md.name);
free(md.name); free(md.name);
/* native will fail loading symbol in deferred state, so force loading of debug symbols */ /* native will fail loading symbol in deferred state, so force loading of debug symbols */
......
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