/****************************************************************** * SymGetModuleInfoW64 (DBGHELP.@) * */ BOOL WINAPI SymGetModuleInfoW64(HANDLE hProcess, DWORD64 dwAddr, PIMAGEHLP_MODULEW64 ModuleInfo) { struct process* pcs = process_find_by_handle(hProcess); struct module* module; IMAGEHLP_MODULEW64 miw64; TRACE("%p %s %p\n", hProcess, wine_dbgstr_longlong(dwAddr), ModuleInfo); if (!pcs) return FALSE; if (ModuleInfo->SizeOfStruct > sizeof(*ModuleInfo)) return FALSE; module = module_find_by_addr(pcs, dwAddr, DMT_UNKNOWN); if (!module) return FALSE; miw64 = module->module; /* update debug information from container if any */ if (module->module.SymType == SymNone) { module = module_get_container(pcs, module); if (module && module->module.SymType != SymNone) { miw64.SymType = module->module.SymType; miw64.NumSyms = module->module.NumSyms; } } memcpy(ModuleInfo, &miw64, ModuleInfo->SizeOfStruct); return TRUE; }
/****************************************************************** * SymGetModuleInfo (DBGHELP.@) * */ BOOL WINAPI SymGetModuleInfo(HANDLE hProcess, DWORD dwAddr, PIMAGEHLP_MODULE ModuleInfo) { struct process* pcs = process_find_by_handle(hProcess); struct module* module; IMAGEHLP_MODULE mod; if (!pcs) return FALSE; if (ModuleInfo->SizeOfStruct < sizeof(*ModuleInfo)) return FALSE; module = module_find_by_addr(pcs, dwAddr, DMT_UNKNOWN); if (!module) return FALSE; mod.SizeOfStruct = ModuleInfo->SizeOfStruct; mod.BaseOfImage = module->module.BaseOfImage; mod.ImageSize = module->module.ImageSize; mod.TimeDateStamp = module->module.TimeDateStamp; mod.CheckSum = module->module.CheckSum; mod.NumSyms = module->module.NumSyms; mod.SymType = module->module.SymType; strcpy(mod.ModuleName, module->module.ModuleName); strcpy(mod.ImageName, module->module.ImageName); strcpy(mod.LoadedImageName, module->module.LoadedImageName); if (module->module.SymType == SymNone) { module = module_get_container(pcs, module); if (module && module->module.SymType != SymNone) { mod.SymType = module->module.SymType; mod.NumSyms = module->module.NumSyms; } } memcpy(ModuleInfo, &mod, ModuleInfo->SizeOfStruct); return TRUE; }
/****************************************************************** * SymGetModuleInfo64 (DBGHELP.@) * */ BOOL WINAPI SymGetModuleInfo64(HANDLE hProcess, DWORD64 dwAddr, PIMAGEHLP_MODULE64 ModuleInfo) { struct process* pcs = process_find_by_handle(hProcess); struct module* module; TRACE("%p %s %p\n", hProcess, wine_dbgstr_longlong(dwAddr), ModuleInfo); if (!pcs) return FALSE; if (ModuleInfo->SizeOfStruct > sizeof(*ModuleInfo)) return FALSE; module = module_find_by_addr(pcs, dwAddr, DMT_UNKNOWN); if (!module) return FALSE; memcpy(ModuleInfo, &module->module, ModuleInfo->SizeOfStruct); if (module->module.SymType == SymNone) { module = module_get_container(pcs, module); if (module && module->module.SymType != SymNone) { ModuleInfo->SymType = module->module.SymType; ModuleInfo->NumSyms = module->module.NumSyms; } } return TRUE; }
/****************************************************************** * module_get_debug * * get the debug information from a module: * - if the module's type is deferred, then force loading of debug info (and return * the module itself) * - if the module has no debug info and has an ELF container, then return the ELF * container (and also force the ELF container's debug info loading if deferred) * - otherwise return the module itself if it has some debug info */ BOOL module_get_debug(struct module_pair* pair) { IMAGEHLP_DEFERRED_SYMBOL_LOADW64 idslW64; if (!pair->requested) return FALSE; /* for a PE builtin, always get info from container */ if (!(pair->effective = module_get_container(pair->pcs, pair->requested))) pair->effective = pair->requested; /* if deferred, force loading */ if (pair->effective->module.SymType == SymDeferred) { BOOL ret; if (pair->effective->is_virtual) ret = FALSE; else switch (pair->effective->type) { #ifndef DBGHELP_STATIC_LIB case DMT_ELF: ret = elf_load_debug_info(pair->effective); break; #endif case DMT_PE: idslW64.SizeOfStruct = sizeof(idslW64); idslW64.BaseOfImage = pair->effective->module.BaseOfImage; idslW64.CheckSum = pair->effective->module.CheckSum; idslW64.TimeDateStamp = pair->effective->module.TimeDateStamp; memcpy(idslW64.FileName, pair->effective->module.ImageName, sizeof(pair->effective->module.ImageName)); idslW64.Reparse = FALSE; idslW64.hFile = INVALID_HANDLE_VALUE; pcs_callback(pair->pcs, CBA_DEFERRED_SYMBOL_LOAD_START, &idslW64); ret = pe_load_debug_info(pair->pcs, pair->effective); pcs_callback(pair->pcs, ret ? CBA_DEFERRED_SYMBOL_LOAD_COMPLETE : CBA_DEFERRED_SYMBOL_LOAD_FAILURE, &idslW64); break; #ifndef DBGHELP_STATIC_LIB case DMT_MACHO: ret = macho_load_debug_info(pair->effective); break; #endif default: ret = FALSE; break; } if (!ret) pair->effective->module.SymType = SymNone; assert(pair->effective->module.SymType != SymDeferred); pair->effective->module.NumSyms = pair->effective->ht_symbols.num_elts; } return pair->effective->module.SymType != SymNone; }
/****************************************************************** * module_get_debug * * get the debug information from a module: * - if the module's type is deferred, then force loading of debug info (and return * the module itself) * - if the module has no debug info and has an ELF container, then return the ELF * container (and also force the ELF container's debug info loading if deferred) * - otherwise return the module itself if it has some debug info */ BOOL module_get_debug(const struct process* pcs, struct module_pair* pair) { IMAGEHLP_DEFERRED_SYMBOL_LOAD64 idsl64; if (!pair->requested) return FALSE; /* for a PE builtin, always get info from container */ if (!(pair->effective = module_get_container(pcs, pair->requested))) pair->effective = pair->requested; /* if deferred, force loading */ if (pair->effective->module.SymType == SymDeferred) { BOOL ret; if (pair->effective->is_virtual) ret = FALSE; else switch (pair->effective->type) { case DMT_ELF: ret = elf_load_debug_info(pair->effective, NULL); break; case DMT_PE: idsl64.SizeOfStruct = sizeof(idsl64); idsl64.BaseOfImage = pair->effective->module.BaseOfImage; idsl64.CheckSum = pair->effective->module.CheckSum; idsl64.TimeDateStamp = pair->effective->module.TimeDateStamp; strcpy(idsl64.FileName, pair->effective->module.ImageName); idsl64.Reparse = FALSE; idsl64.hFile = INVALID_HANDLE_VALUE; pcs_callback(pcs, CBA_DEFERRED_SYMBOL_LOAD_START, &idsl64); ret = pe_load_debug_info(pcs, pair->effective); pcs_callback(pcs, ret ? CBA_DEFERRED_SYMBOL_LOAD_COMPLETE : CBA_DEFERRED_SYMBOL_LOAD_FAILURE, &idsl64); break; default: ret = FALSE; break; } if (!ret) pair->effective->module.SymType = SymNone; assert(pair->effective->module.SymType != SymDeferred); module_compute_num_syms(pair->effective); } return pair->effective->module.SymType != SymNone; }