1
0
Fork 0
mirror of synced 2025-03-07 03:53:26 +01:00

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: Eric Pouech <epouech@codeweavers.com>
This commit is contained in:
Eric Pouech 2024-01-17 16:04:14 +01:00 committed by Alexandre Julliard
parent d6d22677da
commit 4f80a599b6
3 changed files with 5 additions and 6 deletions

View file

@ -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,

View file

@ -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));

View file

@ -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 */