Пример #1
0
    def print_insn_detail(insn):
        # print address, mnemonic and operands
        print("0x%x:\t%s\t%s" % (insn.address, insn.mnemonic, insn.op_str))

        # "data" instruction generated by SKIPDATA option has no detail
        if insn.id == 0:
            return

        if len(insn.operands) > 0:
            print("\top_count: %u" % len(insn.operands))
            c = -1
            for i in insn.operands:
                c += 1
                if i.type == MIPS_OP_REG:
                    print("\t\toperands[%u].type: REG = %s" % (c, insn.reg_name(i.reg)))
                if i.type == MIPS_OP_IMM:
                    print("\t\toperands[%u].type: IMM = 0x%s" % (c, to_x(i.imm)))
                if i.type == MIPS_OP_MEM:
                    print("\t\toperands[%u].type: MEM" % c)
                    if i.mem.base != 0:
                        print("\t\t\toperands[%u].mem.base: REG = %s" \
                            % (c, insn.reg_name(i.mem.base)))
                    if i.mem.disp != 0:
                        print("\t\t\toperands[%u].mem.disp: 0x%s" \
                            % (c, to_x(i.mem.disp)))
Пример #2
0
    def print_insn_detail(insn):
        # print address, mnemonic and operands
        print("0x%x:\t%s\t%s" % (insn.address, insn.mnemonic, insn.op_str))

        # "data" instruction generated by SKIPDATA option has no detail
        if insn.id == 0:
            return

        if len(insn.operands) > 0:
            print("\top_count: %u" % len(insn.operands))
            c = -1
            for i in insn.operands:
                c += 1
                if i.type == ARM64_OP_REG:
                    print("\t\toperands[%u].type: REG = %s" %
                          (c, insn.reg_name(i.reg)))
                if i.type == ARM64_OP_IMM:
                    print("\t\toperands[%u].type: IMM = 0x%s" %
                          (c, to_x(i.imm)))
                if i.type == ARM64_OP_CIMM:
                    print("\t\toperands[%u].type: C-IMM = %u" % (c, i.imm))
                if i.type == ARM64_OP_FP:
                    print("\t\toperands[%u].type: FP = %f" % (c, i.fp))
                if i.type == ARM64_OP_MEM:
                    print("\t\toperands[%u].type: MEM" % c)
                    if i.mem.base != 0:
                        print("\t\t\toperands[%u].mem.base: REG = %s" \
                            % (c, insn.reg_name(i.mem.base)))
                    if i.mem.index != 0:
                        print("\t\t\toperands[%u].mem.index: REG = %s" \
                            % (c, insn.reg_name(i.mem.index)))
                    if i.mem.disp != 0:
                        print("\t\t\toperands[%u].mem.disp: 0x%s" \
                            % (c, to_x(i.mem.disp)))

                if i.shift.type != ARM64_SFT_INVALID and i.shift.value:
                    print("\t\t\tShift: type = %u, value = %u" %
                          (i.shift.type, i.shift.value))

                if i.ext != ARM64_EXT_INVALID:
                    print("\t\t\tExt: %u" % i.ext)

        if insn.writeback:
            print("\tWrite-back: True")
        if not insn.cc in [ARM64_CC_AL, ARM64_CC_INVALID]:
            print("\tCode condition: %u" % insn.cc)
        if insn.update_flags:
            print("\tUpdate-flags: True")
Пример #3
0
    def print_insn_detail(insn):
        # print address, mnemonic and operands
        print("0x%x:\t%s\t%s" % (insn.address, insn.mnemonic, insn.op_str))

        # "data" instruction generated by SKIPDATA option has no detail
        if insn.id == 0:
            return

        if len(insn.operands) > 0:
            print("\top_count: %u" % len(insn.operands))
            c = -1
            for i in insn.operands:
                c += 1
                if i.type == ARM64_OP_REG:
                    print("\t\toperands[%u].type: REG = %s" % (c, insn.reg_name(i.reg)))
                if i.type == ARM64_OP_IMM:
                    print("\t\toperands[%u].type: IMM = 0x%s" % (c, to_x(i.imm)))
                if i.type == ARM64_OP_CIMM:
                    print("\t\toperands[%u].type: C-IMM = %u" % (c, i.imm))
                if i.type == ARM64_OP_FP:
                    print("\t\toperands[%u].type: FP = %f" % (c, i.fp))
                if i.type == ARM64_OP_MEM:
                    print("\t\toperands[%u].type: MEM" % c)
                    if i.mem.base != 0:
                        print("\t\t\toperands[%u].mem.base: REG = %s" \
                            % (c, insn.reg_name(i.mem.base)))
                    if i.mem.index != 0:
                        print("\t\t\toperands[%u].mem.index: REG = %s" \
                            % (c, insn.reg_name(i.mem.index)))
                    if i.mem.disp != 0:
                        print("\t\t\toperands[%u].mem.disp: 0x%s" \
                            % (c, to_x(i.mem.disp)))

                if i.shift.type != ARM64_SFT_INVALID and i.shift.value:
                    print("\t\t\tShift: type = %u, value = %u" % (i.shift.type, i.shift.value))

                if i.ext != ARM64_EXT_INVALID:
                    print("\t\t\tExt: %u" % i.ext)

        if insn.writeback:
            print("\tWrite-back: True")
        if not insn.cc in [ARM64_CC_AL, ARM64_CC_INVALID]:
            print("\tCode condition: %u" % insn.cc)
        if insn.update_flags:
            print("\tUpdate-flags: True")
Пример #4
0
    def print_insn_detail(mode, insn):
        # print address, mnemonic and operands
        print("0x%x:\t%s\t%s" % (insn.address, insn.mnemonic, insn.op_str))

        # "data" instruction generated by SKIPDATA option has no detail
        if insn.id == 0:
            return

        # print instruction prefix
        print_string_hex("\tPrefix:", insn.prefix)

        # print segment override (if applicable)
        if insn.segment != X86_REG_INVALID:
            print("\tSegment override: %s" % insn.reg_name(insn.segment))

        # print instruction's opcode
        print_string_hex("\tOpcode:", insn.opcode)

        # print operand's size, address size, displacement size & immediate size
        print("\top_size: %u, addr_size: %u, disp_size: %u, imm_size: %u" \
            % (insn.op_size, insn.addr_size, insn.disp_size, insn.imm_size))

        # print modRM byte
        print("\tmodrm: 0x%x" % (insn.modrm))

        # print displacement value
        print("\tdisp: 0x%s" % to_x_32(insn.disp))

        # SIB is not available in 16-bit mode
        if (mode & CS_MODE_16 == 0):
            # print SIB byte
            print("\tsib: 0x%x" % (insn.sib))
            if (insn.sib):
                print("\tsib_index: %s, sib_scale: %d, sib_base: %s" % (insn.reg_name(insn.sib_index), insn.sib_scale, insn.reg_name(insn.sib_base)))

        count = insn.op_count(X86_OP_IMM)
        if count > 0:
            print("\timm_count: %u" % count)
            for i in range(count):
                op = insn.op_find(X86_OP_IMM, i + 1)
                print("\t\timms[%u]: 0x%s" % (i + 1, to_x(op.imm)))

        if len(insn.operands) > 0:
            print("\top_count: %u" % len(insn.operands))
            c = -1
            for i in insn.operands:
                c += 1
                if i.type == X86_OP_REG:
                    print("\t\toperands[%u].type: REG = %s" % (c, insn.reg_name(i.reg)))
                if i.type == X86_OP_IMM:
                    print("\t\toperands[%u].type: IMM = 0x%s" % (c, to_x(i.imm)))
                if i.type == X86_OP_FP:
                    print("\t\toperands[%u].type: FP = %f" % (c, i.fp))
                if i.type == X86_OP_MEM:
                    print("\t\toperands[%u].type: MEM" % c)
                    if i.mem.base != 0:
                        print("\t\t\toperands[%u].mem.base: REG = %s" % (c, insn.reg_name(i.mem.base)))
                    if i.mem.index != 0:
                        print("\t\t\toperands[%u].mem.index: REG = %s" % (c, insn.reg_name(i.mem.index)))
                    if i.mem.scale != 1:
                        print("\t\t\toperands[%u].mem.scale: %u" % (c, i.mem.scale))
                    if i.mem.disp != 0:
                        print("\t\t\toperands[%u].mem.disp: 0x%s" % (c, to_x(i.mem.disp)))
Пример #5
0
    def print_insn_detail(mode, insn):
        # print address, mnemonic and operands
        print("0x%x:\t%s\t%s" % (insn.address, insn.mnemonic, insn.op_str))

        # "data" instruction generated by SKIPDATA option has no detail
        if insn.id == 0:
            return

        # print instruction prefix
        print_string_hex("\tPrefix:", insn.prefix)

        # print segment override (if applicable)
        if insn.segment != X86_REG_INVALID:
            print("\tSegment override: %s" % insn.reg_name(insn.segment))

        # print instruction's opcode
        print_string_hex("\tOpcode:", insn.opcode)

        # print operand's size, address size, displacement size & immediate size
        print("\top_size: %u, addr_size: %u, disp_size: %u, imm_size: %u" \
            % (insn.op_size, insn.addr_size, insn.disp_size, insn.imm_size))

        # print modRM byte
        print("\tmodrm: 0x%x" % (insn.modrm))

        # print displacement value
        print("\tdisp: 0x%s" % to_x_32(insn.disp))

        # SIB is not available in 16-bit mode
        if (mode & CS_MODE_16 == 0):
            # print SIB byte
            print("\tsib: 0x%x" % (insn.sib))
            if (insn.sib):
                print("\tsib_index: %s, sib_scale: %d, sib_base: %s" %
                      (insn.reg_name(insn.sib_index), insn.sib_scale,
                       insn.reg_name(insn.sib_base)))

        count = insn.op_count(X86_OP_IMM)
        if count > 0:
            print("\timm_count: %u" % count)
            for i in range(count):
                op = insn.op_find(X86_OP_IMM, i + 1)
                print("\t\timms[%u]: 0x%s" % (i + 1, to_x(op.imm)))

        if len(insn.operands) > 0:
            print("\top_count: %u" % len(insn.operands))
            c = -1
            for i in insn.operands:
                c += 1
                if i.type == X86_OP_REG:
                    print("\t\toperands[%u].type: REG = %s" %
                          (c, insn.reg_name(i.reg)))
                if i.type == X86_OP_IMM:
                    print("\t\toperands[%u].type: IMM = 0x%s" %
                          (c, to_x(i.imm)))
                if i.type == X86_OP_FP:
                    print("\t\toperands[%u].type: FP = %f" % (c, i.fp))
                if i.type == X86_OP_MEM:
                    print("\t\toperands[%u].type: MEM" % c)
                    if i.mem.base != 0:
                        print("\t\t\toperands[%u].mem.base: REG = %s" %
                              (c, insn.reg_name(i.mem.base)))
                    if i.mem.index != 0:
                        print("\t\t\toperands[%u].mem.index: REG = %s" %
                              (c, insn.reg_name(i.mem.index)))
                    if i.mem.scale != 1:
                        print("\t\t\toperands[%u].mem.scale: %u" %
                              (c, i.mem.scale))
                    if i.mem.disp != 0:
                        print("\t\t\toperands[%u].mem.disp: 0x%s" %
                              (c, to_x(i.mem.disp)))