From 1fa162008677db5357266b41d641d0a135ee7a49 Mon Sep 17 00:00:00 2001 From: Eric Pouech Date: Mon, 30 Aug 2021 09:24:29 +0200 Subject: [PATCH] dbghelp: Introduce internal type (symt_module) to match SymTagExe. Signed-off-by: Eric Pouech Signed-off-by: Alexandre Julliard --- dlls/dbghelp/dbghelp_private.h | 9 +++++++++ dlls/dbghelp/module.c | 3 +++ dlls/dbghelp/symbol.c | 13 +++++++++++++ dlls/dbghelp/type.c | 9 +++++++++ 4 files changed, 34 insertions(+) diff --git a/dlls/dbghelp/dbghelp_private.h b/dlls/dbghelp/dbghelp_private.h index daf35fd655a..763d04a16a3 100644 --- a/dlls/dbghelp/dbghelp_private.h +++ b/dlls/dbghelp/dbghelp_private.h @@ -161,6 +161,12 @@ struct symt_block struct vector vchildren; /* sub-blocks & local variables */ }; +struct symt_module /* in fact any of .exe, .dll... */ +{ + struct symt symt; /* module */ + struct module* module; +}; + struct symt_compiland { struct symt symt; @@ -375,6 +381,7 @@ struct module unsigned sorttab_size; struct symt_ht** addr_sorttab; struct hash_table ht_symbols; + struct symt_module* top; /* types */ struct hash_table ht_types; @@ -708,6 +715,8 @@ extern void copy_symbolW(SYMBOL_INFOW* siw, const SYMBOL_INFO* si) DECLS extern void symbol_setname(SYMBOL_INFO* si, const char* name) DECLSPEC_HIDDEN; extern struct symt_ht* symt_find_nearest(struct module* module, DWORD_PTR addr) DECLSPEC_HIDDEN; +extern struct symt_module* + symt_new_module(struct module* module) DECLSPEC_HIDDEN; extern struct symt_compiland* symt_new_compiland(struct module* module, ULONG_PTR address, unsigned src_idx) DECLSPEC_HIDDEN; diff --git a/dlls/dbghelp/module.c b/dlls/dbghelp/module.c index 0a4d3c0b145..c278a627d37 100644 --- a/dlls/dbghelp/module.c +++ b/dlls/dbghelp/module.c @@ -233,6 +233,9 @@ struct module* module_new(struct process* pcs, const WCHAR* name, module->sources = 0; wine_rb_init(&module->sources_offsets_tree, source_rb_compare); + /* add top level symbol */ + module->top = symt_new_module(module); + return module; } diff --git a/dlls/dbghelp/symbol.c b/dlls/dbghelp/symbol.c index 8189f6a175e..286dc17310c 100644 --- a/dlls/dbghelp/symbol.c +++ b/dlls/dbghelp/symbol.c @@ -183,6 +183,19 @@ static WCHAR* file_regex(const char* srcfile) return mask; } +struct symt_module* symt_new_module(struct module* module) +{ + struct symt_module* sym; + + TRACE_(dbghelp_symt)("Adding toplevel exe symbol %s\n", debugstr_w(module->module.ModuleName)); + if ((sym = pool_alloc(&module->pool, sizeof(*sym)))) + { + sym->symt.tag = SymTagExe; + sym->module = module; + } + return sym; +} + struct symt_compiland* symt_new_compiland(struct module* module, ULONG_PTR address, unsigned src_idx) { diff --git a/dlls/dbghelp/type.c b/dlls/dbghelp/type.c index 7506d1ab574..10a2ff7a718 100644 --- a/dlls/dbghelp/type.c +++ b/dlls/dbghelp/type.c @@ -752,6 +752,15 @@ BOOL symt_get_info(struct module* module, const struct symt* type, break; case TI_GET_SYMNAME: + if (type->tag == SymTagExe) + { + DWORD len = (lstrlenW(module->modulename) + 1) * sizeof(WCHAR); + WCHAR* wname = HeapAlloc(GetProcessHeap(), 0, len); + if (!wname) return FALSE; + memcpy(wname, module->modulename, len); + X(WCHAR*) = wname; + } + else { const char* name = symt_get_name(type); if (!name) return FALSE;