search_result ImpAddrMod( imp_image_handle *ii, address a, imp_mod_handle *im ) { int left; seg_desc *map; struct find_mod d; map = &ii->mapping[0]; left = ii->map_count; for( ;; ) { if( left <= 0 ) return( SR_NONE ); if( map->ovl == a.sect_id && map->frame == a.mach.segment && map->offset <= a.mach.offset && (map->offset+map->cbseg) > a.mach.offset ) break; ++map; --left; } /* We know the address is in the image. If it's an executable segment, we can find the module by checking all the sstModule sections and look at the code section information. If it's a data segment, or we can't find it, return IMH_GBL. */ *im = IMH_GBL; if( map->u.b.fExecute ) { d.d = &a; if( WalkDirList( ii, FindAddr, &d ) == WR_STOP ) { *im = d.im; } } return( SR_CLOSEST ); }
walk_result DIGENTRY DIPImpWalkModList( imp_image_handle *ii, IMP_MOD_WKR *wk, void *d ) { struct find_mod find; walk_result wr; find.wk = wk; find.d = d; wr = WalkDirList( ii, &FindMods, &find ); if( wr == WR_CONTINUE ) wr = wk( ii, IMH_GBL, d ); return( wr ); }
static dip_status SetMADType( imp_image_handle *ii ) { cs_compile *rec; walk_result wr; wr = WalkDirList( ii, &FindCompUnit, &rec ); if( wr != WR_STOP ) return( DS_OK ); switch( rec->machine & 0xf0 ) { case MACH_INTEL_8080: ii->mad = MAD_X86; break; case MACH_DECALPHA: ii->mad = MAD_AXP; break; default: return( DS_ERR|DS_INFO_INVALID ); } return( DS_OK ); }