Beispiel #1
0
    def __init__(self, width, height, data, cursor, widget=None, plugin=None):
        super(DisasmViewMode, self).__init__()

        self.plugin = plugin

        self.dataModel = data
        self.addHandler(self.dataModel)


        self.width = width
        self.height = height

        self.cursor = cursor
        self.widget = widget

        self.refresh = True

        self.selector = TextSelection.DefaultSelection(self)

        # background brush
        self.backgroundBrush = QtGui.QBrush(QtGui.QColor(0, 0, 128))

        # text font
        self.font = QtGui.QFont('Terminus', 11, QtGui.QFont.Light)

        # font metrics. assume font is monospaced
        self.font.setKerning(False)
        self.font.setFixedPitch(True)
        fm = QtGui.QFontMetrics(self.font)
        self._fontWidth  = fm.width('a')
        self._fontHeight = fm.height()

        self.textPen = QtGui.QPen(QtGui.QColor(192, 192, 192), 0, QtCore.Qt.SolidLine)
        self.resize(width, height)

        self.Paints = {}

        self.Ops = []
        self.newPix = None

        self.FlowHistory = []
        self.OPCODES = []

        self.selector = TextSelection.DisasmSelection(self)

        self.init_disassembler_engine()
Beispiel #2
0
    def __init__(self, themes, width, height, data, cursor, widget=None):
        super(DisasmViewMode, self).__init__()

        self.themes = themes

        self.dataModel = data
        self.addHandler(self.dataModel)

        self.width = width
        self.height = height

        self.cursor = cursor
        self.widget = widget

        self.refresh = True

        # background brush
        self.backgroundBrush = QtGui.QBrush(self.themes['background'])

        # text font
        self.font = themes['font']

        # font metrics. assume font is monospaced
        self.font.setKerning(False)
        self.font.setFixedPitch(True)
        fm = QtGui.QFontMetrics(self.font)
        self._fontWidth = fm.width('a')
        self._fontHeight = fm.height()

        self.FlowHistory = []
        self.CACHE_OPCODES = []
        self.CACHE_IDX_OPCODES = {}
        self.CACHE_IDX_OPCODES_OFF = {}

        self.OPCODES = []

        vm_analysis = self.dataModel.current_class.CM.get_vmanalysis()

        methods = [i for i in self.dataModel.current_class.get_methods()]
        print methods
        methods = sorted(methods, key=lambda x: x.get_address(), reverse=True)

        offset = 0
        cnt = 0
        for method in methods:
            mx = vm_analysis.get_method(method)
            for DVMBasicMethodBlockInstruction in method.get_instructions():
                #for DVMBasicMethodBlock in mx.basic_blocks.gets():
                #    for DVMBasicMethodBlockInstruction in DVMBasicMethodBlock.get_instructions():
                ins = InstructionView(DVMBasicMethodBlockInstruction)
                self.CACHE_OPCODES.append(ins)
                self.CACHE_IDX_OPCODES[offset] = ins
                self.CACHE_IDX_OPCODES_OFF[offset] = cnt
                offset += ins.get_length()
                cnt += 1

        self.max_offset = offset

        print sorted(self.CACHE_IDX_OPCODES_OFF.keys())

        self.textPen = QtGui.QPen(self.themes['pen'], 0, QtCore.Qt.SolidLine)
        self.resize(width, height)

        self.Paints = {}

        self.Ops = []
        self.newPix = None

        self.selector = TextSelection.DisasmSelection(themes, self)