Exemple #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 = 0
            for i in insn.operands:
                if i.type == SPARC_OP_REG:
                    print("\t\toperands[%u].type: REG = %s" % (c, insn.reg_name(i.reg)))
                if i.type == SPARC_OP_IMM:
                    print("\t\toperands[%u].type: IMM = 0x%s" % (c, to_x_32(i.imm)))
                if i.type == SPARC_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_32(i.mem.disp)))
                c += 1

        if insn.cc:
            print("\tConditional code: %u" % insn.cc)
        if insn.hint:
            print("\tBranch hint: %u" % insn.hint)
Exemple #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 = 0
            for i in insn.operands:
                if i.type == PPC_OP_REG:
                    print("\t\toperands[%u].type: REG = %s" % (c, insn.reg_name(i.reg)))
                if i.type == PPC_OP_IMM:
                    print("\t\toperands[%u].type: IMM = 0x%s" % (c, to_x_32(i.imm)))
                if i.type == PPC_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_32(i.mem.disp)))
                c += 1

        if insn.bc:
            print("\tBranch code: %u" % insn.bc)
        if insn.bh:
            print("\tBranch hint: %u" % insn.bh)
        if insn.update_cr0:
            print("\tUpdate-CR0: True")
Exemple #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 = 0
            for i in insn.operands:
                if i.type == ARM_OP_REG:
                    print("\t\toperands[%u].type: REG = %s" %
                          (c, insn.reg_name(i.reg)))
                if i.type == ARM_OP_IMM:
                    print("\t\toperands[%u].type: IMM = 0x%s" %
                          (c, to_x_32(i.imm)))
                if i.type == ARM_OP_PIMM:
                    print("\t\toperands[%u].type: P-IMM = %u" % (c, i.imm))
                if i.type == ARM_OP_CIMM:
                    print("\t\toperands[%u].type: C-IMM = %u" % (c, i.imm))
                if i.type == ARM_OP_FP:
                    print("\t\toperands[%u].type: FP = %f" % (c, i.fp))
                if i.type == ARM_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_32(i.mem.disp)))

                if i.shift.type != ARM_SFT_INVALID and i.shift.value:
                    print("\t\t\tShift: type = %u, value = %u\n" \
                        % (i.shift.type, i.shift.value))
                c += 1

        if insn.update_flags:
            print("\tUpdate-flags: True")
        if insn.writeback:
            print("\tWrite-back: True")
        if not insn.cc in [ARM_CC_AL, ARM_CC_INVALID]:
            print("\tCode condition: %u" % insn.cc)
Exemple #4
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 = 0
            for i in insn.operands:
                if i.type == ARM_OP_REG:
                    print("\t\toperands[%u].type: REG = %s" % (c, insn.reg_name(i.reg)))
                if i.type == ARM_OP_IMM:
                    print("\t\toperands[%u].type: IMM = 0x%s" % (c, to_x_32(i.imm)))
                if i.type == ARM_OP_PIMM:
                    print("\t\toperands[%u].type: P-IMM = %u" % (c, i.imm))
                if i.type == ARM_OP_CIMM:
                    print("\t\toperands[%u].type: C-IMM = %u" % (c, i.imm))
                if i.type == ARM_OP_FP:
                    print("\t\toperands[%u].type: FP = %f" % (c, i.fp))
                if i.type == ARM_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_32(i.mem.disp)))

                if i.shift.type != ARM_SFT_INVALID and i.shift.value:
                    print("\t\t\tShift: type = %u, value = %u\n" \
                        % (i.shift.type, i.shift.value))
                c += 1

        if insn.update_flags:
            print("\tUpdate-flags: True")
        if insn.writeback:
            print("\tWrite-back: True")
        if not insn.cc in [ARM_CC_AL, ARM_CC_INVALID]:
            print("\tCode condition: %u" % insn.cc)
Exemple #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)))
Exemple #6
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)))