dbghelp: Manage the new MachineType field in IMAGEHLP_MODULE(W)64.

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Eric Pouech 2021-09-06 10:40:29 +02:00 committed by Alexandre Julliard
parent 55fda3a415
commit ffc3efe775
5 changed files with 27 additions and 8 deletions

View file

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

View file

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

View file

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

View file

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

View file

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