Exemplo n.º 1
0
    def createEditor(self, parent, option, index):

        parsed_val_list = index.data(role=DIE.UI.ParsedValuesRole)

        # Show combobox only if parsed_value as two or more items.
        if parsed_val_list is not None and len(parsed_val_list) > 1:
            lines = []
            for parsed_val in parsed_val_list:
                line_txt = "%d, %s, %s" % (parsed_val.score, parsed_val.data,
                                           parsed_val.description)
                lines.append(line_txt)

            combo_box = QtWidgets.QComboBox(parent)
            combo_box.addItems(lines)

            return combo_box
Exemplo n.º 2
0
    def OnCreate(self, form):
        """
        Called when the view is created
        """
        self.die_db = DIE.Lib.DIEDb.get_db()
        self.function_view = DIE.UI.FunctionViewEx.get_view()

        # Get parent widget
        self.parent = form_to_widget(form)

        self.valueModel = QtGui.QStandardItemModel()
        self.valueTreeView = QtWidgets.QTreeView()
        self.valueTreeView.setExpandsOnDoubleClick(False)

        self.valueTreeView.doubleClicked.connect(self.itemDoubleClickSlot)

        self._model_builder(self.valueModel)
        self.valueTreeView.setModel(self.valueModel)

        # Toolbar
        self.value_toolbar = QtWidgets.QToolBar()

        # Value type combobox
        type_list = []
        if self.die_db:
            type_list = self.die_db.get_all_value_types()
            type_list.insert(0, "All Values")

        self.value_type_combo = QtWidgets.QComboBox()
        self.value_type_combo.addItems(type_list)
        self.value_type_combo.activated[str].connect(
            self.on_value_type_combobox_change)

        self.value_type_label = QtWidgets.QLabel("Value Type:  ")
        self.value_toolbar.addWidget(self.value_type_label)
        self.value_toolbar.addWidget(self.value_type_combo)

        # Layout
        layout = QtWidgets.QGridLayout()
        layout.addWidget(self.value_toolbar)
        layout.addWidget(self.valueTreeView)

        self.parent.setLayout(layout)
Exemplo n.º 3
0
    def OnCreate(self, form):
        """
        Called when the plugin form is created
        """
        self.value_view = DIE.UI.ValueViewEx.get_view()
        self.bp_handler = DIE.Lib.BpHandler.get_bp_handler()
        self.die_icons = DIE.UI.Die_Icons.get_die_icons()
        self.die_db = DIE.Lib.DIEDb.get_db()

        # Get parent widget
        self.parent = form_to_widget(form)

        self.functionModel = QtGui.QStandardItemModel()
        self.functionTreeView = QtWidgets.QTreeView()
        self.functionTreeView.setExpandsOnDoubleClick(False)
        #self.functionTreeView.setSortingEnabled(True)

        delegate = TreeViewDelegate(self.functionTreeView)
        self.functionTreeView.setItemDelegate(delegate)

        self.functionTreeView.doubleClicked.connect(self.itemDoubleClickSlot)

        self._model_builder(self.functionModel)
        self.functionTreeView.setModel(self.functionModel)

        self.functionTreeView.setColumnWidth(0, 200)
        self.functionTreeView.setColumnWidth(1, 20)
        self.functionTreeView.setColumnWidth(2, 20)
        self.functionTreeView.setColumnWidth(3, 20)
        self.functionTreeView.setColumnWidth(4, 250)
        self.functionTreeView.setColumnWidth(5, 100)
        self.functionTreeView.setColumnWidth(6, 20)
        self.functionTreeView.setColumnWidth(7, 450)
        self.functionTreeView.setColumnWidth(8, 20)
        self.functionTreeView.setColumnWidth(9, 450)

        # Context menus
        self.functionTreeView.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        self.functionTreeView.customContextMenuRequested.connect(
            self.onCustomContextMenu)

        # Actions
        self.context_menu_param = None  # Parameter to be passed to context menu slots

        action_exclude_func = QtWidgets.QAction(
            "Exclude Function",
            self.functionTreeView,
            triggered=lambda: self.on_exclude_func(self.context_menu_param))
        action_exclude_func_adrs = QtWidgets.QAction(
            "Exclude All Function Calls",
            self.functionTreeView,
            triggered=lambda: self.on_exclude_func_adrs(self.context_menu_param
                                                        ))
        action_exclude_ea = QtWidgets.QAction(
            "Exclude Address",
            self.functionTreeView,
            triggered=lambda: self.on_exclude_ea(self.context_menu_param))
        action_exclude_library = QtWidgets.QAction(
            "Exclude Library",
            self.functionTreeView,
            triggered=lambda: self.on_exclude_library(self.context_menu_param))
        action_value_detail = QtWidgets.QAction(
            "Inspect Value Details",
            self.functionTreeView,
            triggered=lambda: self.on_value_detail(self.context_menu_param))

        action_show_callgraph = QtWidgets.QAction(
            "Show Call-Graph",
            self.functionTreeView,
            triggered=lambda: self.on_show_callgraph(self.context_menu_param))

        # Function ContextMenu
        self.function_context_menu = QtWidgets.QMenu(self.functionTreeView)
        self.function_context_menu.addAction(action_exclude_func)
        self.function_context_menu.addAction(action_exclude_library)
        self.function_context_menu.addAction(action_exclude_func_adrs)

        # Function ea ContextMenu
        self.ea_context_menu = QtWidgets.QMenu(self.functionTreeView)
        self.ea_context_menu.addAction(action_exclude_ea)
        self.ea_context_menu.addAction(action_show_callgraph)

        # Argument value ContextMenu
        self.value_context_menu = QtWidgets.QMenu(self.functionTreeView)
        self.value_context_menu.addAction(action_value_detail)

        # Therad ComboBox
        threads = []
        if self.die_db is not None:
            threads = self.die_db.get_thread_list()

        thread_id_list = []
        thread_id_list.append("All Threads")
        for thread in threads:
            thread_id_list.append(str(thread.thread_num))

        self.thread_id_combo = QtWidgets.QComboBox()
        self.thread_id_combo.addItems(thread_id_list)
        self.thread_id_combo.activated[str].connect(
            self.on_thread_combobox_change)

        self.thread_id_label = QtWidgets.QLabel("Thread:  ")

        # Toolbar
        self.function_toolbar = QtWidgets.QToolBar()
        self.function_toolbar.addWidget(self.thread_id_label)
        self.function_toolbar.addWidget(self.thread_id_combo)

        # Grid
        layout = QtWidgets.QGridLayout()
        layout.addWidget(self.function_toolbar)
        layout.addWidget(self.functionTreeView)

        self.parent.setLayout(layout)
Exemplo n.º 4
0
    def __init__(self,
                 return_type='void',
                 owner_type='',
                 name='',
                 args='',
                 is_const=False,
                 ctor_type=1,
                 dtor_type=1,
                 fixed_return_type=False,
                 fixed_owner_type=False,
                 fixed_name=False,
                 fixed_args=False,
                 fixed_is_const=False,
                 fixed_ctor_type=False,
                 fixed_dtor_type=False):
        super(SignatureDialog, self).__init__()

        self.return_type = return_type
        self.owner_type = owner_type
        self.name = name
        self.args = args
        self.is_const = is_const
        self.ctor_type = ctor_type
        self.dtor_type = dtor_type

        self.setWindowTitle('Set function signature')

        layout = QtWidgets.QGridLayout(self)

        self.signature_w = QtWidgets.QLabel()
        self.signature_w.setMinimumWidth(220)
        layout.addWidget(self.signature_w, 0, 0, 1, 2)

        layout.addWidget(QtWidgets.QLabel('Return type'), 1, 0)
        self.return_type_w = QtWidgets.QLineEdit()
        self.return_type_w.setText(self.return_type)
        self.return_type_w.setDisabled(fixed_return_type)
        self.return_type_w.textChanged.connect(self.update_signature)
        layout.addWidget(self.return_type_w, 1, 1)

        layout.addWidget(QtWidgets.QLabel('Owner type'), 2, 0)
        self.owner_type_w = QtWidgets.QLineEdit()
        self.owner_type_w.setText(self.owner_type)
        self.owner_type_w.setDisabled(fixed_owner_type)
        self.owner_type_w.textChanged.connect(self.update_signature)
        layout.addWidget(self.owner_type_w, 2, 1)

        layout.addWidget(QtWidgets.QLabel('Name'), 3, 0)
        self.name_w = QtWidgets.QLineEdit()
        self.name_w.setText(self.name)
        self.name_w.setDisabled(fixed_name)
        self.name_w.textChanged.connect(self.update_signature)
        layout.addWidget(self.name_w, 3, 1)

        layout.addWidget(QtWidgets.QLabel('Arguments'), 4, 0)
        self.args_w = QtWidgets.QLineEdit()
        self.args_w.setText(self.args)
        self.args_w.setDisabled(fixed_args)
        self.args_w.textChanged.connect(self.update_signature)
        layout.addWidget(self.args_w, 4, 1)

        layout.addWidget(QtWidgets.QLabel('Const'), 5, 0)
        self.is_const_w = QtWidgets.QCheckBox()
        self.is_const_w.setChecked(self.is_const)
        self.is_const_w.setDisabled(fixed_is_const)
        self.is_const_w.stateChanged.connect(self.update_signature)
        layout.addWidget(self.is_const_w, 5, 1)

        layout.addWidget(QtWidgets.QLabel('Ctor'), 6, 0)
        self.ctor_type_w = QtWidgets.QComboBox()
        self.ctor_type_w.addItem("C1: complete")
        self.ctor_type_w.addItem("C2: base")
        self.ctor_type_w.addItem("C3: complete allocating")
        self.ctor_type_w.setCurrentIndex(ctor_type - 1)
        self.ctor_type_w.setDisabled(fixed_ctor_type)
        self.ctor_type_w.currentIndexChanged.connect(self.update_signature)
        layout.addWidget(self.ctor_type_w, 6, 1)

        layout.addWidget(QtWidgets.QLabel('Dtor'), 7, 0)
        self.dtor_type_w = QtWidgets.QComboBox()
        self.dtor_type_w.addItem("D0: deleting")
        self.dtor_type_w.addItem("D1: complete")
        self.dtor_type_w.addItem("D2: base")
        self.dtor_type_w.setCurrentIndex(dtor_type)
        self.dtor_type_w.setDisabled(fixed_dtor_type)
        self.dtor_type_w.currentIndexChanged.connect(self.update_signature)
        layout.addWidget(self.dtor_type_w, 7, 1)

        layout.addWidget(QtWidgets.QLabel('Status'), 8, 0)
        self.status_w = QtWidgets.QLabel()
        layout.addWidget(self.status_w, 8, 1)

        layout.addWidget(QtWidgets.QLabel('Mangled'), 9, 0)
        self.mangled_w = QtWidgets.QLabel()
        layout.addWidget(self.mangled_w, 9, 1)

        self.buttonBox = QtWidgets.QDialogButtonBox()
        self.buttonBox.addButton("OK", QtWidgets.QDialogButtonBox.AcceptRole)
        self.buttonBox.addButton("Cancel",
                                 QtWidgets.QDialogButtonBox.RejectRole)
        layout.addWidget(self.buttonBox, 10, 0, 1, 2)
        self.buttonBox.accepted.connect(self.handle_ok)
        self.buttonBox.rejected.connect(self.reject)

        self.signature = None
        self.is_signature_valid = False
        self.mangled = None
        self.status = ''
        self.update_signature()