def do_switch_or_return(ea): if ida.is_ret_insn(ea): return c_ast.Return(None) else: # switch try: sw = ida.switch_cases(ea) except ida.NoSwitchError: raise utils.BugError('unhandled jr at ea %s' % ida.atoa(ea)) default = sw.default defexpr = [c_ast.Default([c_ast.Goto(ida.name(default))])] cases = list(c_ast.Case(c_ast.Constant('int', str(addr)), [c_ast.Goto(ida.name(loc))]) for (addr, loc) in sw.cases.iteritems()) (mnem, opnd, opn) = data.get_swval(ea) swval = fmt_op(opnd, mnem, opn) return c_ast.Switch(swval, c_ast.Compound(cases + defexpr))
def labelize(ea, stmt): if from_delay is False: label = ida.name(ea) if label != '': return c_ast.Label(label, stmt) else: return stmt else: return stmt
def get_callee(ea, mnem, args): """ea_t -> str -> formatter_args -> str""" # XXX we don't handle function pointers yet, but it should be easy now that # we handle all internal functions as having the same signature...i think if mnem == "jalr": nn = ida.netnode("$ mips") fun = nn.altval(ea) - 1 if fun == -1: raise FunctionPointerError("unknown target for function pointer at %s" % ida.atoa(ea)) return ida.name(fun) elif mnem == "jal": return args["rs"].name else: raise utils.BugError("unhandled call insn: %s" % mnem)
def get_callee(ea, mnem, args): '''ea_t -> str -> formatter_args -> str''' # XXX we don't handle function pointers yet, but it should be easy now that # we handle all internal functions as having the same signature...i think if mnem == 'jalr': nn = ida.netnode('$ mips') fun = nn.altval(ea) - 1 if fun == -1: raise FunctionPointerError('unknown target for function pointer at %s' % ida.atoa(ea)) return ida.name(fun) elif mnem == 'jal': return args['rs'].name else: raise utils.BugError('unhandled call insn: %s' % mnem)
def get_callee(ea, mnem, args): '''ea_t -> str -> formatter_args -> str''' # XXX we don't handle function pointers yet, but it should be easy now that # we handle all internal functions as having the same signature...i think if mnem == 'jalr': nn = ida.netnode('$ mips') fun = nn.altval(ea) - 1 if fun == -1: raise FunctionPointerError( 'unknown target for function pointer at %s' % ida.atoa(ea)) return ida.name(fun) elif mnem == 'jal': return args['rs'].name else: raise utils.BugError('unhandled call insn: %s' % mnem)
def get_tinfo_and_declstr(ea): ti = ida.get_or_guess_tinfo(ea) return (ti, ea, ida.print_tinfo(ida.name(ea), ti))