コード例 #1
0
    def _handle_branch(il: LowLevelILFunction, nmemonic, inst_length, value):
        true_label = il.get_label_for_address(Architecture['M6800'], value)

        if true_label is None:
            true_label = LowLevelILLabel()
            indirect = True
        else:
            indirect = False

        false_label_found = True

        false_label = il.get_label_for_address(
            Architecture['M6800'], il.current_address + inst_length)

        if false_label is None:
            false_label = LowLevelILLabel()
            false_label_found = False

        il.append(
            il.if_expr(LLIL_OPERATIONS[nmemonic](il, None, None), true_label,
                       false_label))

        if indirect:
            il.mark_label(true_label)
            il.append(il.jump(il.const(2, value)))

        if not false_label_found:
            il.mark_label(false_label)
コード例 #2
0
ファイル: superh.py プロジェクト: mothran/binaryninja_superh
    def lift_tst(il: LowLevelILFunction, insn: SHInsn):
        assert len(insn.opcode["args"]
                   ) == 2, f"Invalid instruction at: 0x{insn.addr:x}"

        op_1 = insn.opcode["args"][0]
        op_2 = insn.opcode["args"][1]

        t = LowLevelILLabel()
        f = LowLevelILLabel()
        next_insn = LowLevelILLabel()

        il.append(
            il.if_expr(
                il.compare_equal(
                    RSIZE,
                    il.and_expr(RSIZE, Lifter._lift_op(il, insn, op_1),
                                Lifter._lift_op(il, insn, op_2)),
                    il.const(RSIZE, 0)), t, f))

        il.mark_label(t)
        il.append(il.set_flag('t', il.const(0, 1)))
        il.append(il.goto(next_insn))

        il.mark_label(f)
        il.append(il.set_flag('t', il.const(0, 0)))

        il.mark_label(next_insn)
コード例 #3
0
ファイル: superh.py プロジェクト: mothran/binaryninja_superh
    def lift_bf(il: LowLevelILFunction, insn: SHInsn):
        assert len(insn.opcode["args"]
                   ) == 1, f"Invalid instruction at: 0x{insn.addr:x}"

        op_1 = insn.opcode["args"][0]

        t = il.get_label_for_address(Architecture["superh"], op_1.val)

        if t is None:
            t = LowLevelILLabel()
            indirect = True
        else:
            indirect = False

        f = LowLevelILLabel()

        il.append(
            il.if_expr(il.compare_equal(0, il.flag("t"), il.const(0, 0)), t,
                       f))

        if indirect:
            il.mark_label(t)

            il.append(il.jump(il.const(RSIZE, op_1.val)))

        il.mark_label(f)
コード例 #4
0
ファイル: superh.py プロジェクト: mothran/binaryninja_superh
    def lift_cmp_eq(il: LowLevelILFunction, insn: SHInsn):
        assert len(insn.opcode["args"]
                   ) == 2, f"Invalid instruction at: 0x{insn.addr:x}"

        op_1 = insn.opcode["args"][0]
        op_2 = insn.opcode["args"][1]

        extend = False
        if op_1.type == OpType.IMM:
            extend = True

        t = LowLevelILLabel()
        f = LowLevelILLabel()
        next_insn = LowLevelILLabel()

        il.append(
            il.if_expr(
                il.compare_equal(
                    RSIZE, Lifter._lift_op(il, insn, op_1, sign_ext=extend),
                    Lifter._lift_op(il, insn, op_2)), t, f))

        il.mark_label(t)
        il.append(il.set_flag('t', il.const(0, 1)))
        il.append(il.goto(next_insn))

        il.mark_label(f)
        il.append(il.set_flag('t', il.const(0, 0)))

        il.mark_label(next_insn)