Exemplo n.º 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)
Exemplo n.º 2
0
    def lift_bra(il: LowLevelILFunction, insn: SHInsn):
        assert len(insn.opcode["args"]
                   ) == 1, f"Invalid instruction at: 0x{insn.addr:x}"

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

        il.append(il.jump(il.const(RSIZE, op_1.val)))
Exemplo n.º 3
0
    def lift_jmp(il: LowLevelILFunction, insn: SHInsn):
        assert len(insn.opcode["args"]
                   ) == 1, f"Invalid instruction at: 0x{insn.addr:x}"

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

        il.append(il.jump(Lifter._lift_op(il, insn, op_1)))
Exemplo n.º 4
0
    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)
Exemplo n.º 5
0
    def _handle_jump(il: LowLevelILFunction, value):
        label = il.get_label_for_address(Architecture['M6800'], value)

        return il.jump(il.const(2, value)) if label is None else il.goto(label)