예제 #1
0
파일: ida.py 프로젝트: nihilus/epanos
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
예제 #2
0
파일: ida.py 프로젝트: nihilus/epanos
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)
예제 #3
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
예제 #4
0
파일: ida.py 프로젝트: nihilus/epanos
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
예제 #5
0
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)
예제 #6
0
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