R_API RAnalBlock *r_anal_bb_from_offset(RAnal *anal, ut64 off) { RListIter *iter, *iter2; RAnalFunction *fcn; RAnalBlock *bb; r_list_foreach (anal->fcns, iter, fcn) r_list_foreach (fcn->bbs, iter2, bb) if (r_anal_bb_is_in_offset (bb, off)) return bb; return NULL; }
static bool extract_sections(pyc_object *obj, RList *sections, char *prefix) { RListIter *i; pyc_code_object *cobj; RBinSection *section; if (!obj || (obj->type != TYPE_CODE_v1)) return false; cobj = obj->data; if (!cobj || !cobj->name) return false; if (cobj->name->type != TYPE_ASCII && cobj->name->type != TYPE_STRING) return false; if (!cobj->name->data) return false; section = R_NEW0 (RBinSection); prefix = r_str_newf ("%s%s%s", prefix ? prefix : "", prefix ? "." : "", cobj->name->data); if (!prefix || !section) goto fail; if (!strncpy ((char*)§ion->name, prefix, R_BIN_SIZEOF_STRINGS)) goto fail; if (!r_list_append (sections, section)) goto fail; if (cobj->consts->type != TYPE_TUPLE) return false; r_list_foreach (((RList*)(cobj->consts->data)), i, obj) extract_sections (obj, sections, prefix); free (prefix); return true; fail: free (section); free (prefix); return false; }
static int rabin_extract(int all) { int res = R_FALSE; RBinFile *bf = r_bin_cur (bin); RBinObject *obj = NULL; if (!bf) return res; if (all) { int idx = 0; RListIter *iter = NULL; r_list_foreach (bf->objs, iter, obj) res = extract_binobj (bf, obj, idx++); } else { obj = r_bin_cur_object (bin); if (!obj) return res; res = extract_binobj (bf, obj, 0); } return res; }
/* Compute the len and the starting address * when disassembling `nb` opcodes backward. */ R_API ut32 r_core_asm_bwdis_len (RCore* core, int* instr_len, ut64* start_addr, ut32 nb) { ut32 instr_run = 0; RCoreAsmHit *hit; RListIter *iter = NULL; RList* hits = r_core_asm_bwdisassemble (core, core->offset, nb, core->blocksize); if (instr_len) *instr_len = 0; if (hits && r_list_length (hits) > 0) { hit = r_list_get_bottom (hits); if (start_addr) *start_addr = hit->addr; r_list_foreach (hits, iter, hit) instr_run += hit->len; if (instr_len) *instr_len = instr_run; } r_list_free (hits); return instr_run; }
void emu_free(emu *e) { if (e->reg == e->anal->reg) e->reg = NULL; else r_reg_free(e->reg); r_io_free(e->io); r_bin_free(e->bin); r_lib_free(e->lib); r_list_free(e->plugins); r_asm_free(e->a); r_asm_op_free(e->op); r_anal_op_free(e->anop); r_anal_free(e->anal); if (e->vsections) { RListIter *iter; VSection *vs; r_list_foreach(e->vsections, iter, vs) virtual_section_rm_i(e, vs->id); } r_list_free(e->vsections); if (e->screen) sdb_free (e->screen); free(e); }