def mips_op_hack(cmd, op): '''insn_t -> int''' # see note for get_operands if cpu_ida.ida_current_cpu_name() == 'mips': mnem = get_mnem(cmd.ea) if (len(cpu_ida.ida_current_cpu().insns.insns[mnem].opfs) != len(ida_operands(cmd))): if op > 0: return op - 1 else: return op else: return op else: return op
def op_ret_for_ti(ti, name, target, val): '''tinfo_t -> str -> int -> int -> op_ret''' if ti.is_array(): return op_ret(op_ty.array, name, target) elif ti.is_ptr(): return op_ret(op_ty.ptr, name, target) elif ti.is_func(): return op_ret(op_ty.func, name, target) elif name != '': # XXX name types are a misfeature, see mips/gen.py return op_ret(op_ty.name, name, target) else: if cpu_ida.ida_current_cpu_name() == 'mips': return op_ret(op_ty.value, cpu_ida.ida_current_cpu().data.interpret_li_arg(val), 0) else: return op_ret(op_ty.value, val, 0)
def mips_op_hack(cmd, op): '''insn_t -> int''' # see note for get_operands if cpu_ida.ida_current_cpu_name() == 'mips': mnem = get_mnem(cmd.ea) if (len(cpu_ida.ida_current_cpu().insns.insns[mnem].opfs) != len( ida_operands(cmd))): if op > 0: return op - 1 else: return op else: return op else: return op
def get_operands(cmd): '''insn_t -> [op_t]''' opnds = ida_operands(cmd) if cpu_ida.ida_current_cpu_name() == 'mips': # IDA returns "simplified" instructions with only two operands when the # first and second operands are the same register, but this forces you # to handle multiple formats for a single instruction, so here we # transform them into their canonical form mnem = get_mnem(cmd.ea) if len(cpu_ida.ida_current_cpu().insns.insns[mnem].opfs) != len(opnds): return [opnds[0], opnds[0], opnds[1]] else: return opnds else: return opnds