- Various corner case bug fixes when loading modules - Reporting machine information for modules - Improved management of module's name: + native (W10) stores & matches with module's name truncated to 64 characters + updated builtin to have equivalent behavior
A+ ---
Eric Pouech (7): dbghelp: SymLoadModule* should return the base address in case of success, and 0 otherwise dbghelp: native allows loading virtual module at any address dbghelp: return correct error code when reloading a module in SymLoadModule* dbghelp: use module->modulename instead of module->module.ModuleName in traces dbghelp: use the correct module name for lookups including module's name include/imagehlp.h: extend IMAGEHLP_MODULE*64 with new fields (keeping in sync with dbghelp.h) dbghelp: Properly managing the new MachineType field in IMAGEHLP_MODULE(W)64
dlls/dbghelp/dbghelp_private.h | 2 +- dlls/dbghelp/dwarf.c | 6 +++--- dlls/dbghelp/elf_module.c | 33 ++++++++++++++++++++++++--------- dlls/dbghelp/macho_module.c | 11 ++++++----- dlls/dbghelp/module.c | 30 ++++++++++++++++++++++-------- dlls/dbghelp/msc.c | 2 +- dlls/dbghelp/pe_module.c | 8 +++++--- dlls/dbghelp/symbol.c | 24 ++++++++++++------------ dlls/dbghelp/type.c | 4 ++-- include/imagehlp.h | 4 ++++ 10 files changed, 80 insertions(+), 44 deletions(-)
- replace FALSE by 0 - fixed incorrect value for a virtual module
Signed-off-by: Eric Pouech eric.pouech@gmail.com
--- dlls/dbghelp/module.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/dlls/dbghelp/module.c b/dlls/dbghelp/module.c index 3bc2a9e143a..f2c0eca5df6 100644 --- a/dlls/dbghelp/module.c +++ b/dlls/dbghelp/module.c @@ -786,19 +786,19 @@ DWORD64 WINAPI SymLoadModuleExW(HANDLE hProcess, HANDLE hFile, PCWSTR wImageNam if (Data) FIXME("Unsupported load data parameter %p for %s\n", Data, debugstr_w(wImageName)); - if (!validate_addr64(BaseOfDll)) return FALSE; + if (!validate_addr64(BaseOfDll)) return 0;
- if (!(pcs = process_find_by_handle(hProcess))) return FALSE; + if (!(pcs = process_find_by_handle(hProcess))) return 0;
if (Flags & SLMFLAG_VIRTUAL) { - if (!wImageName) return FALSE; + if (!wImageName) return 0; module = module_new(pcs, wImageName, DMT_PE, TRUE, BaseOfDll, SizeOfDll, 0, 0); - if (!module) return FALSE; + if (!module) return 0; if (wModuleName) module_set_module(module, wModuleName); module->module.SymType = SymVirtual;
- return TRUE; + return module->module.BaseOfImage; } if (Flags & ~(SLMFLAG_VIRTUAL)) FIXME("Unsupported Flags %08x for %s\n", Flags, debugstr_w(wImageName));
Signed-off-by: Eric Pouech eric.pouech@gmail.com
--- dlls/dbghelp/module.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlls/dbghelp/module.c b/dlls/dbghelp/module.c index f2c0eca5df6..916aaf5ce53 100644 --- a/dlls/dbghelp/module.c +++ b/dlls/dbghelp/module.c @@ -786,7 +786,6 @@ DWORD64 WINAPI SymLoadModuleExW(HANDLE hProcess, HANDLE hFile, PCWSTR wImageNam if (Data) FIXME("Unsupported load data parameter %p for %s\n", Data, debugstr_w(wImageName)); - if (!validate_addr64(BaseOfDll)) return 0;
if (!(pcs = process_find_by_handle(hProcess))) return 0;
@@ -803,6 +802,8 @@ DWORD64 WINAPI SymLoadModuleExW(HANDLE hProcess, HANDLE hFile, PCWSTR wImageNam if (Flags & ~(SLMFLAG_VIRTUAL)) FIXME("Unsupported Flags %08x for %s\n", Flags, debugstr_w(wImageName));
+ if (!validate_addr64(BaseOfDll)) return 0; + pcs->loader->synchronize_module_list(pcs);
/* this is a Wine extension to the API just to redo the synchronisation */ @@ -923,7 +924,6 @@ BOOL WINAPI SymUnloadModule64(HANDLE hProcess, DWORD64 BaseOfDll)
pcs = process_find_by_handle(hProcess); if (!pcs) return FALSE; - if (!validate_addr64(BaseOfDll)) return FALSE; module = module_find_by_addr(pcs, BaseOfDll, DMT_UNKNOWN); if (!module) return FALSE; return module_remove(pcs, module);
Signed-off-by: Eric Pouech eric.pouech@gmail.com
--- dlls/dbghelp/module.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
diff --git a/dlls/dbghelp/module.c b/dlls/dbghelp/module.c index 916aaf5ce53..e0d1dce0c86 100644 --- a/dlls/dbghelp/module.c +++ b/dlls/dbghelp/module.c @@ -815,6 +815,20 @@ DWORD64 WINAPI SymLoadModuleExW(HANDLE hProcess, HANDLE hFile, PCWSTR wImageNam if (wImageName) { module = module_is_already_loaded(pcs, wImageName); + if (module) + { + if (module->module.BaseOfImage == BaseOfDll) + SetLastError(ERROR_SUCCESS); + else + { + /* native allows to load the same module at different addresses + * we don't support this for now + */ + SetLastError(ERROR_INVALID_PARAMETER); + FIXME("Reloading %s at different base address isn't supported\n", debugstr_w(module->modulename)); + } + return 0; + } if (!module && module_is_container_loaded(pcs, wImageName, BaseOfDll)) { /* force the loading of DLL as builtin */
the former is truncated to 64 chars while the later is truncated to 32 chars
Signed-off-by: Eric Pouech eric.pouech@gmail.com
--- dlls/dbghelp/dwarf.c | 6 +++--- dlls/dbghelp/elf_module.c | 12 ++++++------ dlls/dbghelp/macho_module.c | 8 ++++---- dlls/dbghelp/module.c | 4 ++-- dlls/dbghelp/msc.c | 2 +- dlls/dbghelp/pe_module.c | 2 +- dlls/dbghelp/symbol.c | 20 ++++++++++---------- dlls/dbghelp/type.c | 4 ++-- 8 files changed, 29 insertions(+), 29 deletions(-)
diff --git a/dlls/dbghelp/dwarf.c b/dlls/dbghelp/dwarf.c index e514a4fde3b..319f5c2673c 100644 --- a/dlls/dbghelp/dwarf.c +++ b/dlls/dbghelp/dwarf.c @@ -357,7 +357,7 @@ static const char* dwarf2_debug_traverse_ctx(const dwarf2_traverse_context_t* ct static const char* dwarf2_debug_ctx(const dwarf2_parse_context_t* ctx) { return wine_dbg_sprintf("ctx(%p,%s)", - ctx, debugstr_w(ctx->module->module.ModuleName)); + ctx, debugstr_w(ctx->module->modulename)); }
static const char* dwarf2_debug_di(const dwarf2_debug_info_t* di) @@ -2130,7 +2130,7 @@ static void dwarf2_set_line_number(struct module* module, ULONG_PTR address, if (!file || !(psrc = vector_at(v, file - 1))) return;
TRACE("%s %lx %s %u\n", - debugstr_w(module->module.ModuleName), address, debugstr_a(source_get(module, *psrc)), line); + debugstr_w(module->modulename), address, debugstr_a(source_get(module, *psrc)), line); symt = symt_find_nearest(module, address); if (symt && symt_check_tag(&symt->symt, SymTagFunction)) { @@ -3498,7 +3498,7 @@ BOOL dwarf2_parse(struct module* module, ULONG_PTR load_offset, load_offset += fmap->u.elf.elf_start - debug_sect.fmap->u.elf.elf_start; }
- TRACE("Loading Dwarf2 information for %s\n", debugstr_w(module->module.ModuleName)); + TRACE("Loading Dwarf2 information for %s\n", debugstr_w(module->modulename));
mod_ctx.data = section[section_debug].address; mod_ctx.end_data = mod_ctx.data + section[section_debug].size; diff --git a/dlls/dbghelp/elf_module.c b/dlls/dbghelp/elf_module.c index 7be7e8efce6..cc3fbcdb7ba 100644 --- a/dlls/dbghelp/elf_module.c +++ b/dlls/dbghelp/elf_module.c @@ -803,7 +803,7 @@ static const struct elf_sym *elf_lookup_symtab(const struct module* module, if (!result && !(result = weak_result)) { FIXME("Couldn't find symbol %s!%s in symtab\n", - debugstr_w(module->module.ModuleName), name); + debugstr_w(module->modulename), name); return NULL; } return &result->sym; @@ -847,19 +847,19 @@ static void elf_finish_stabs_info(struct module* module, const struct hash_table if (((struct symt_function*)sym)->address != elf_info->elf_addr && ((struct symt_function*)sym)->address != elf_info->elf_addr + symp->st_value) FIXME("Changing address for %p/%s!%s from %08lx to %s\n", - sym, debugstr_w(module->module.ModuleName), sym->hash_elt.name, + sym, debugstr_w(module->modulename), sym->hash_elt.name, ((struct symt_function*)sym)->address, wine_dbgstr_longlong(elf_info->elf_addr + symp->st_value)); if (((struct symt_function*)sym)->size && ((struct symt_function*)sym)->size != symp->st_size) FIXME("Changing size for %p/%s!%s from %08lx to %08x\n", - sym, debugstr_w(module->module.ModuleName), sym->hash_elt.name, + sym, debugstr_w(module->modulename), sym->hash_elt.name, ((struct symt_function*)sym)->size, (unsigned int)symp->st_size);
((struct symt_function*)sym)->address = elf_info->elf_addr + symp->st_value; ((struct symt_function*)sym)->size = symp->st_size; } else FIXME("Couldn't find %s!%s\n", - debugstr_w(module->module.ModuleName), sym->hash_elt.name); + debugstr_w(module->modulename), sym->hash_elt.name); break; case SymTagData: switch (((struct symt_data*)sym)->kind) @@ -876,7 +876,7 @@ static void elf_finish_stabs_info(struct module* module, const struct hash_table if (((struct symt_data*)sym)->u.var.offset != elf_info->elf_addr && ((struct symt_data*)sym)->u.var.offset != elf_info->elf_addr + symp->st_value) FIXME("Changing address for %p/%s!%s from %08lx to %s\n", - sym, debugstr_w(module->module.ModuleName), sym->hash_elt.name, + sym, debugstr_w(module->modulename), sym->hash_elt.name, ((struct symt_function*)sym)->address, wine_dbgstr_longlong(elf_info->elf_addr + symp->st_value)); ((struct symt_data*)sym)->u.var.offset = elf_info->elf_addr + symp->st_value; @@ -884,7 +884,7 @@ static void elf_finish_stabs_info(struct module* module, const struct hash_table DataIsFileStatic : DataIsGlobal; } else FIXME("Couldn't find %s!%s\n", - debugstr_w(module->module.ModuleName), sym->hash_elt.name); + debugstr_w(module->modulename), sym->hash_elt.name); break; default:; } diff --git a/dlls/dbghelp/macho_module.c b/dlls/dbghelp/macho_module.c index 7b0b80c4900..7b17d1c30df 100644 --- a/dlls/dbghelp/macho_module.c +++ b/dlls/dbghelp/macho_module.c @@ -1066,7 +1066,7 @@ static void macho_finish_stabs(struct module* module, struct hash_table* ht_symt if (func->address == module->format_info[DFI_MACHO]->u.macho_info->load_addr) { TRACE("Adjusting function %p/%s!%s from 0x%08lx to 0x%08lx\n", func, - debugstr_w(module->module.ModuleName), sym->hash_elt.name, + debugstr_w(module->modulename), sym->hash_elt.name, func->address, ste->addr); func->address = ste->addr; adjusted = TRUE; @@ -1083,7 +1083,7 @@ static void macho_finish_stabs(struct module* module, struct hash_table* ht_symt if (data->u.var.offset == module->format_info[DFI_MACHO]->u.macho_info->load_addr) { TRACE("Adjusting data symbol %p/%s!%s from 0x%08lx to 0x%08lx\n", - data, debugstr_w(module->module.ModuleName), sym->hash_elt.name, + data, debugstr_w(module->modulename), sym->hash_elt.name, data->u.var.offset, ste->addr); data->u.var.offset = ste->addr; adjusted = TRUE; @@ -1096,7 +1096,7 @@ static void macho_finish_stabs(struct module* module, struct hash_table* ht_symt if (data->kind != new_kind) { WARN("Changing kind for %p/%s!%s from %d to %d\n", sym, - debugstr_w(module->module.ModuleName), sym->hash_elt.name, + debugstr_w(module->modulename), sym->hash_elt.name, (int)data->kind, (int)new_kind); data->kind = new_kind; adjusted = TRUE; @@ -1155,7 +1155,7 @@ static void macho_finish_stabs(struct module* module, struct hash_table* ht_symt symt_get_info(module, &sym->symt, TI_GET_DATAKIND, &kind); if (size && kind == (ste->is_global ? DataIsGlobal : DataIsFileStatic)) FIXME("Duplicate in %s: %s<%08lx> %s<%s-%s>\n", - debugstr_w(module->module.ModuleName), + debugstr_w(module->modulename), ste->ht_elt.name, ste->addr, sym->hash_elt.name, wine_dbgstr_longlong(addr), wine_dbgstr_longlong(size)); diff --git a/dlls/dbghelp/module.c b/dlls/dbghelp/module.c index e0d1dce0c86..df341284d6a 100644 --- a/dlls/dbghelp/module.c +++ b/dlls/dbghelp/module.c @@ -715,7 +715,7 @@ BOOL image_check_alternate(struct image_file_map* fmap, const struct module* mod ret = image_locate_debug_link(module, fmap, dbg_link, crc); if (!ret) WARN("Couldn't load linked debug file for %s\n", - debugstr_w(module->module.ModuleName)); + debugstr_w(module->modulename)); } image_unmap_section(&debuglink_sect); } @@ -882,7 +882,7 @@ BOOL module_remove(struct process* pcs, struct module* module) struct module** p; unsigned i;
- TRACE("%s (%p)\n", debugstr_w(module->module.ModuleName), module); + TRACE("%s (%p)\n", debugstr_w(module->modulename), module);
for (i = 0; i < DFI_LAST; i++) { diff --git a/dlls/dbghelp/msc.c b/dlls/dbghelp/msc.c index 905e3b0eaf1..36ab355d0a3 100644 --- a/dlls/dbghelp/msc.c +++ b/dlls/dbghelp/msc.c @@ -3369,7 +3369,7 @@ static BOOL codeview_process_info(const struct process* pcs, } default: ERR("Unknown CODEVIEW signature %08x in module %s\n", - *signature, debugstr_w(msc_dbg->module->module.ModuleName)); + *signature, debugstr_w(msc_dbg->module->modulename)); break; } if (ret) diff --git a/dlls/dbghelp/pe_module.c b/dlls/dbghelp/pe_module.c index 7cfe5f4dc37..383d2b52429 100644 --- a/dlls/dbghelp/pe_module.c +++ b/dlls/dbghelp/pe_module.c @@ -625,7 +625,7 @@ static BOOL pe_load_msc_debug_info(const struct process* pcs, struct module* mod misc->DataType != IMAGE_DEBUG_MISC_EXENAME) { ERR("-Debug info stripped, but no .DBG file in module %s\n", - debugstr_w(module->module.ModuleName)); + debugstr_w(module->modulename)); } else { diff --git a/dlls/dbghelp/symbol.c b/dlls/dbghelp/symbol.c index 9863a736299..7e79950906a 100644 --- a/dlls/dbghelp/symbol.c +++ b/dlls/dbghelp/symbol.c @@ -187,7 +187,7 @@ 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)); + TRACE_(dbghelp_symt)("Adding toplevel exe symbol %s\n", debugstr_w(module->modulename)); if ((sym = pool_alloc(&module->pool, sizeof(*sym)))) { sym->symt.tag = SymTagExe; @@ -202,7 +202,7 @@ struct symt_compiland* symt_new_compiland(struct module* module, struct symt_compiland* sym;
TRACE_(dbghelp_symt)("Adding compiland symbol %s:%s\n", - debugstr_w(module->module.ModuleName), source_get(module, src_idx)); + debugstr_w(module->modulename), source_get(module, src_idx)); if ((sym = pool_alloc(&module->pool, sizeof(*sym)))) { sym->symt.tag = SymTagCompiland; @@ -224,7 +224,7 @@ struct symt_public* symt_new_public(struct module* module, struct symt** p;
TRACE_(dbghelp_symt)("Adding public symbol %s:%s @%lx\n", - debugstr_w(module->module.ModuleName), name, address); + debugstr_w(module->modulename), name, address); if ((dbghelp_options & SYMOPT_AUTO_PUBLICS) && symt_find_nearest(module, address) != NULL) return NULL; @@ -257,7 +257,7 @@ struct symt_data* symt_new_global_variable(struct module* module, DWORD64 tsz;
TRACE_(dbghelp_symt)("Adding global symbol %s:%s %d@%lx %p\n", - debugstr_w(module->module.ModuleName), name, loc.kind, loc.offset, type); + debugstr_w(module->modulename), name, loc.kind, loc.offset, type); if ((sym = pool_alloc(&module->pool, sizeof(*sym)))) { sym->symt.tag = SymTagData; @@ -270,7 +270,7 @@ struct symt_data* symt_new_global_variable(struct module* module, { if (tsz != size) FIXME("Size mismatch for %s.%s between type (%s) and src (%lu)\n", - debugstr_w(module->module.ModuleName), name, + debugstr_w(module->modulename), name, wine_dbgstr_longlong(tsz), size); } symt_add_module_ht(module, (struct symt_ht*)sym); @@ -293,7 +293,7 @@ struct symt_function* symt_new_function(struct module* module, struct symt** p;
TRACE_(dbghelp_symt)("Adding global function %s:%s @%lx-%lx\n", - debugstr_w(module->module.ModuleName), name, addr, addr + size - 1); + debugstr_w(module->modulename), name, addr, addr + size - 1);
assert(!sig_type || sig_type->tag == SymTagFunctionType); if ((sym = pool_alloc(&module->pool, sizeof(*sym)))) @@ -379,7 +379,7 @@ struct symt_data* symt_add_func_local(struct module* module, struct symt** p;
TRACE_(dbghelp_symt)("Adding local symbol (%s:%s): %s %p\n", - debugstr_w(module->module.ModuleName), func->hash_elt.name, + debugstr_w(module->modulename), func->hash_elt.name, name, type);
assert(func); @@ -494,7 +494,7 @@ struct symt_thunk* symt_new_thunk(struct module* module, struct symt_thunk* sym;
TRACE_(dbghelp_symt)("Adding global thunk %s:%s @%lx-%lx\n", - debugstr_w(module->module.ModuleName), name, addr, addr + size - 1); + debugstr_w(module->modulename), name, addr, addr + size - 1);
if ((sym = pool_alloc(&module->pool, sizeof(*sym)))) { @@ -523,7 +523,7 @@ struct symt_data* symt_new_constant(struct module* module, struct symt_data* sym;
TRACE_(dbghelp_symt)("Adding constant value %s:%s\n", - debugstr_w(module->module.ModuleName), name); + debugstr_w(module->modulename), name);
if ((sym = pool_alloc(&module->pool, sizeof(*sym)))) { @@ -551,7 +551,7 @@ struct symt_hierarchy_point* symt_new_label(struct module* module, struct symt_hierarchy_point* sym;
TRACE_(dbghelp_symt)("Adding global label value %s:%s\n", - debugstr_w(module->module.ModuleName), name); + debugstr_w(module->modulename), name);
if ((sym = pool_alloc(&module->pool, sizeof(*sym)))) { diff --git a/dlls/dbghelp/type.c b/dlls/dbghelp/type.c index 7ce85531162..23752cfed9f 100644 --- a/dlls/dbghelp/type.c +++ b/dlls/dbghelp/type.c @@ -222,7 +222,7 @@ struct symt_udt* symt_new_udt(struct module* module, const char* typename, struct symt_udt* sym;
TRACE_(dbghelp_symt)("Adding udt %s:%s\n", - debugstr_w(module->module.ModuleName), typename); + debugstr_w(module->modulename), typename); if ((sym = pool_alloc(&module->pool, sizeof(*sym)))) { sym->symt.tag = SymTagUDT; @@ -308,7 +308,7 @@ struct symt_enum* symt_new_enum(struct module* module, const char* typename, struct symt_enum* sym;
TRACE_(dbghelp_symt)("Adding enum %s:%s\n", - debugstr_w(module->module.ModuleName), typename); + debugstr_w(module->modulename), typename); if ((sym = pool_alloc(&module->pool, sizeof(*sym)))) { sym->symt.tag = SymTagEnum;
(modulename is truncated at 64 chars, while module.ModuleName at 32 chars)
Signed-off-by: Eric Pouech eric.pouech@gmail.com
--- dlls/dbghelp/elf_module.c | 3 +-- dlls/dbghelp/module.c | 2 +- dlls/dbghelp/symbol.c | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/dlls/dbghelp/elf_module.c b/dlls/dbghelp/elf_module.c index cc3fbcdb7ba..e23de1a8c63 100644 --- a/dlls/dbghelp/elf_module.c +++ b/dlls/dbghelp/elf_module.c @@ -1068,8 +1068,7 @@ static BOOL elf_load_debug_info_from_map(struct module* module, lret = dwarf2_parse(module, module->reloc_delta, thunks, fmap); ret = ret || lret; } - if (wcsstr(module->module.ModuleName, S_ElfW) || - !wcscmp(module->module.ModuleName, S_WineLoaderW)) + if (wcsstr(module->modulename, S_ElfW) || !wcscmp(module->modulename, S_WineLoaderW)) { /* add the thunks for native libraries */ if (!(dbghelp_options & SYMOPT_PUBLICS_ONLY)) diff --git a/dlls/dbghelp/module.c b/dlls/dbghelp/module.c index df341284d6a..01803b027d8 100644 --- a/dlls/dbghelp/module.c +++ b/dlls/dbghelp/module.c @@ -271,7 +271,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->module.ModuleName)) return module; + if (!wcsicmp(name, module->modulename)) return module; } SetLastError(ERROR_INVALID_NAME); return NULL; diff --git a/dlls/dbghelp/symbol.c b/dlls/dbghelp/symbol.c index 7e79950906a..09407e04fc0 100644 --- a/dlls/dbghelp/symbol.c +++ b/dlls/dbghelp/symbol.c @@ -1089,7 +1089,7 @@ static BOOL sym_enum(HANDLE hProcess, ULONG64 BaseOfDll, PCWSTR Mask, { if (pair.requested->type == DMT_PE && module_get_debug(&pair)) { - if (SymMatchStringW(pair.requested->module.ModuleName, mod, FALSE) && + if (SymMatchStringW(pair.requested->modulename, mod, FALSE) && symt_enum_module(&pair, bang + 1, se)) break; } @@ -1104,7 +1104,7 @@ static BOOL sym_enum(HANDLE hProcess, ULONG64 BaseOfDll, PCWSTR Mask, !module_get_containee(pair.pcs, pair.requested) && module_get_debug(&pair)) { - if (SymMatchStringW(pair.requested->module.ModuleName, mod, FALSE) && + if (SymMatchStringW(pair.requested->modulename, mod, FALSE) && symt_enum_module(&pair, bang + 1, se)) break; }
Signed-off-by: Eric Pouech eric.pouech@gmail.com
--- include/imagehlp.h | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/include/imagehlp.h b/include/imagehlp.h index 8c8250d1f19..5ee978a3d4c 100644 --- a/include/imagehlp.h +++ b/include/imagehlp.h @@ -459,6 +459,8 @@ typedef struct _IMAGEHLP_MODULE64 BOOL TypeInfo; BOOL SourceIndexed; BOOL Publics; + DWORD MachineType; + DWORD Reserved; } IMAGEHLP_MODULE64, *PIMAGEHLP_MODULE64;
typedef struct _IMAGEHLP_MODULEW64 @@ -486,6 +488,8 @@ typedef struct _IMAGEHLP_MODULEW64 BOOL TypeInfo; BOOL SourceIndexed; BOOL Publics; + DWORD MachineType; + DWORD Reserved; } IMAGEHLP_MODULEW64, *PIMAGEHLP_MODULEW64;
typedef struct _IMAGEHLP_LINE {
Signed-off-by: Eric Pouech eric.pouech@gmail.com
--- dlls/dbghelp/dbghelp_private.h | 2 +- dlls/dbghelp/elf_module.c | 18 +++++++++++++++++- dlls/dbghelp/macho_module.c | 3 ++- dlls/dbghelp/module.c | 6 +++--- dlls/dbghelp/pe_module.c | 6 ++++-- 5 files changed, 27 insertions(+), 8 deletions(-)
diff --git a/dlls/dbghelp/dbghelp_private.h b/dlls/dbghelp/dbghelp_private.h index d6280a5189b..0c324a827e9 100644 --- a/dlls/dbghelp/dbghelp_private.h +++ b/dlls/dbghelp/dbghelp_private.h @@ -636,7 +636,7 @@ extern struct module* module_new(struct process* pcs, const WCHAR* name, enum module_type type, BOOL virtual, DWORD64 addr, DWORD64 size, - ULONG_PTR stamp, ULONG_PTR checksum) DECLSPEC_HIDDEN; + ULONG_PTR stamp, ULONG_PTR checksum, WORD machine) DECLSPEC_HIDDEN; extern struct module* module_get_containee(const struct process* pcs, const struct module* inner) DECLSPEC_HIDDEN; diff --git a/dlls/dbghelp/elf_module.c b/dlls/dbghelp/elf_module.c index e23de1a8c63..553b212c526 100644 --- a/dlls/dbghelp/elf_module.c +++ b/dlls/dbghelp/elf_module.c @@ -121,6 +121,21 @@ struct elf_module_info
#define ELF_AT_SYSINFO_EHDR 33
+static DWORD elf_get_machine(unsigned mach) +{ + switch (mach) + { + default: + FIXME("No mapping yet for ELF e_machine %u\n", mach); + /* fall through */ + case /*EM_NONE*/ 0: return IMAGE_FILE_MACHINE_UNKNOWN; + case /*EM_386*/ 3: return IMAGE_FILE_MACHINE_I386; + case /*EM_ARM*/ 40: return IMAGE_FILE_MACHINE_ARMNT; + case /*EM_X86_64*/ 62: return IMAGE_FILE_MACHINE_AMD64; + case /*EM_AARCH64*/ 183: return IMAGE_FILE_MACHINE_ARM64; + } +} + /****************************************************************** * elf_map_section * @@ -1227,7 +1242,8 @@ static BOOL elf_load_file_from_fmap(struct process* pcs, const WCHAR* filename, sizeof(struct module_format) + sizeof(struct elf_module_info)); if (!modfmt) return FALSE; elf_info->module = module_new(pcs, filename, DMT_ELF, FALSE, modbase, - fmap->u.elf.elf_size, 0, calc_crc32(fmap->u.elf.handle)); + fmap->u.elf.elf_size, 0, calc_crc32(fmap->u.elf.handle), + elf_get_machine(fmap->u.elf.elfhdr.e_machine)); if (!elf_info->module) { HeapFree(GetProcessHeap(), 0, modfmt); diff --git a/dlls/dbghelp/macho_module.c b/dlls/dbghelp/macho_module.c index 7b17d1c30df..34bc4f2c4ea 100644 --- a/dlls/dbghelp/macho_module.c +++ b/dlls/dbghelp/macho_module.c @@ -1479,7 +1479,8 @@ static BOOL macho_load_file(struct process* pcs, const WCHAR* filename, if (!load_addr) load_addr = fmap.u.macho.segs_start; macho_info->module = module_new(pcs, filename, DMT_MACHO, FALSE, load_addr, - fmap.u.macho.segs_size, 0, calc_crc32(fmap.u.macho.handle)); + fmap.u.macho.segs_size, 0, calc_crc32(fmap.u.macho.handle), + IMAGE_FILE_MACHINE_UNKNOWN); if (!macho_info->module) { HeapFree(GetProcessHeap(), 0, modfmt); diff --git a/dlls/dbghelp/module.c b/dlls/dbghelp/module.c index 01803b027d8..cda12f4c350 100644 --- a/dlls/dbghelp/module.c +++ b/dlls/dbghelp/module.c @@ -185,7 +185,7 @@ static const char* get_module_type(enum module_type type, BOOL virtual) struct module* module_new(struct process* pcs, const WCHAR* name, enum module_type type, BOOL virtual, DWORD64 mod_addr, DWORD64 size, - ULONG_PTR stamp, ULONG_PTR checksum) + ULONG_PTR stamp, ULONG_PTR checksum, WORD machine) { struct module* module; unsigned i; @@ -229,7 +229,7 @@ struct module* module_new(struct process* pcs, const WCHAR* name, module->module.TypeInfo = FALSE; module->module.SourceIndexed = FALSE; module->module.Publics = FALSE; - module->module.MachineType = 0; + module->module.MachineType = machine; module->module.Reserved = 0;
module->reloc_delta = 0; @@ -792,7 +792,7 @@ DWORD64 WINAPI SymLoadModuleExW(HANDLE hProcess, HANDLE hFile, PCWSTR wImageNam if (Flags & SLMFLAG_VIRTUAL) { if (!wImageName) return 0; - module = module_new(pcs, wImageName, DMT_PE, TRUE, BaseOfDll, SizeOfDll, 0, 0); + module = module_new(pcs, wImageName, DMT_PE, TRUE, BaseOfDll, SizeOfDll, 0, 0, IMAGE_FILE_MACHINE_UNKNOWN); if (!module) return 0; if (wModuleName) module_set_module(module, wModuleName); module->module.SymType = SymVirtual; diff --git a/dlls/dbghelp/pe_module.c b/dlls/dbghelp/pe_module.c index 383d2b52429..38829d6e6de 100644 --- a/dlls/dbghelp/pe_module.c +++ b/dlls/dbghelp/pe_module.c @@ -815,7 +815,8 @@ struct module* pe_load_native_module(struct process* pcs, const WCHAR* name,
module = module_new(pcs, loaded_name, DMT_PE, FALSE, base, size, modfmt->u.pe_info->fmap.u.pe.file_header.TimeDateStamp, - PE_FROM_OPTHDR(&modfmt->u.pe_info->fmap, CheckSum)); + PE_FROM_OPTHDR(&modfmt->u.pe_info->fmap, CheckSum), + modfmt->u.pe_info->fmap.u.pe.file_header.Machine); if (module) { module->real_path = builtin.path; @@ -877,7 +878,8 @@ struct module* pe_load_builtin_module(struct process* pcs, const WCHAR* name, if (!size) size = nth.OptionalHeader.SizeOfImage; module = module_new(pcs, name, DMT_PE, FALSE, base, size, nth.FileHeader.TimeDateStamp, - nth.OptionalHeader.CheckSum); + nth.OptionalHeader.CheckSum, + nth.FileHeader.Machine); } } return module;