예제 #1
0
    def __init__(self):
        super(AboutWindow, self).__init__()

        self.setFixedSize(260, 120)
        self.setWindowTitle('About Classy')

        layout = QtWidgets.QVBoxLayout(self)
        aboutLabel = QtWidgets.QLabel('Classy\n\nRicBent, Treeki', self)
        aboutLabel.setAlignment(QtCore.Qt.AlignCenter)
        layout.addWidget(aboutLabel)

        self.show()
예제 #2
0
파일: AboutScreen.py 프로젝트: bonomali/DIE
    def initUI(self):
        config = DIE.Lib.DieConfig.get_config()
        self.setFixedSize(400, 330)
        self.setWindowTitle("About DIE")

        image = QtGui.QImage(os.path.join(config.icons_path, "logo.png"))
        pixmap = QtGui.QPixmap.fromImage(image)

        logo = QtWidgets.QLabel(self)
        logo.setFixedSize(pixmap.size())
        logo.move(0.5 * (self.width() - logo.width()), 20)
        logo.setPixmap(pixmap)

        title = QtWidgets.QLabel("DIE", self)
        title.setAlignment(QtCore.Qt.AlignCenter)
        font = title.font()
        font.setPointSize(16)
        font.setBold(True)
        title.setFont(font)
        title.setFixedWidth(400)
        title.move(0, logo.height() + logo.y() + 20)

        subtitle = QtWidgets.QLabel("Dynamic IDA Enrichment framework", self)
        font = subtitle.font()
        font.setPointSize(14)
        subtitle.setFont(font)
        subtitle.setAlignment(QtCore.Qt.AlignCenter)
        subtitle.setFixedWidth(400)
        subtitle.move(0, title.height() + title.y() + 10)

        version = QtWidgets.QLabel("Version 0.1", self)
        font = subtitle.font()
        font.setPointSize(12)
        version.setFont(font)
        version.setAlignment(QtCore.Qt.AlignCenter)
        version.setFixedWidth(400)
        version.move(0, subtitle.height() + subtitle.y() + 30)

        author = QtWidgets.QLabel(
            "Written by Yaniv Balmas @ynvb - Check Point Software Technologies",
            self)
        font = subtitle.font()
        font.setPointSize(12)
        author.setFont(font)
        author.setAlignment(QtCore.Qt.AlignCenter)
        author.setFixedWidth(400)
        author.move(0, version.height() + version.y())

        self.show()
예제 #3
0
파일: gui.py 프로젝트: clayne/Classy
    def handle_methods_interaction(self, row, column):
        if self.edit_class is None:
            return

        m = self.methods.item(row, 0).data(QtCore.Qt.UserRole)
        if type(
                m
        ) != database_entries.Method or m not in self.edit_class.methods:
            return

        elif column == 0:  # Go to address
            idc.jumpto(m.ea)
        elif column == 1:  # Edit signature
            dlg = SignatureDialog(m.return_type,
                                  m.owner.name,
                                  m.name,
                                  m.args,
                                  m.is_const,
                                  m.ctor_type,
                                  m.dtor_type,
                                  fixed_owner_type=True)
            if dlg.exec_() != QtWidgets.QDialog.Accepted:
                return
            m.set_signature(dlg.name, dlg.args, dlg.return_type, dlg.is_const,
                            dlg.ctor_type, dlg.dtor_type)
            self.methods.setItem(row, 1,
                                 QtWidgets.QTableWidgetItem(m.get_signature()))
            idaapi.refresh_idaview_anyway()
예제 #4
0
    def __init__(self, *args, **kwargs):
        super(Popup, self).__init__(*args, **kwargs)

        pm = QtGui.QPixmap(IDABUDDY_AVATAR_PATH)
        transform = QtGui.QTransform()
        transform.scale(0.5, 0.5)
        self.pm = pm.transformed(transform)

        self.slide = Slide(self)

        self.image_label = QtWidgets.QLabel(self.slide)
        self.image_label.setPixmap(self.pm)

        self.image_label.setFixedSize(self.pm.size())
        self.image_label.setAlignment(QtCore.Qt.AlignTop)
        self.slide.initialize()
        self.talk_bubble = TalkBubble(self)

        self.talk_bubble.move(TALKBUBBLE_X_MOVE, TALKBUBBLE_Y_MOVE)
        self.talk_bubble.hide()
        self.slide.move(size_to_point(self.talk_bubble.size()))

        self.setFixedSize(self.talk_bubble.size() + self.slide.size() +
                          get_extra_size())

        connect_method_to_signal(self.talk_bubble, 'linkActivated(QString)',
                                 self.linkActivatedHandler)
        self._handlers = {}
        self._default_handler = None
예제 #5
0
    def OnCreate(self, form):
        """
        Called when the view is created
        """
        self.data_parser = DataParser.getParser()
        self.ptable_widget = QtWidgets.QTreeWidget()

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

        self._add_parser_data()

        layout = QtWidgets.QGridLayout()
        layout.addWidget(self.ptable_widget)

        self.parent.setLayout(layout)
예제 #6
0
파일: gui.py 프로젝트: clayne/Classy
    def handle_vtable_interaction(self, row, column):
        if self.edit_class is None:
            return

        vm = self.edit_class.vmethods[row]

        if column == 0:  # Go to vtable offset
            idc.jumpto(self.edit_class.vtable_start + row * 4)
        elif column == 1:  # Go to address
            idc.jumpto(vm.ea)
        elif column == 2:  # Edit signature
            dlg = SignatureDialog(vm.return_type,
                                  vm.owner.name,
                                  vm.name,
                                  vm.args,
                                  vm.is_const,
                                  vm.ctor_type,
                                  vm.dtor_type,
                                  fixed_owner_type=True)
            if dlg.exec_() != QtWidgets.QDialog.Accepted:
                return
            vm.set_signature(dlg.name, dlg.args, dlg.return_type, dlg.is_const,
                             dlg.ctor_type, dlg.dtor_type)
            self.vtable.setItem(row, 2,
                                QtWidgets.QTableWidgetItem(vm.get_signature()))
            idaapi.refresh_idaview_anyway()
예제 #7
0
    def __init__(self):
        super(TypedefDialog, self).__init__()

        self.setWindowTitle('Classy Typedefs')

        layout = QtWidgets.QVBoxLayout(self)

        self.list = QtWidgets.QListWidget()
        layout.addWidget(self.list)

        button_layout = QtWidgets.QHBoxLayout(self)
        layout.addLayout(button_layout)

        button_layout.addItem(
            QtWidgets.QSpacerItem(0, 0, QtWidgets.QSizePolicy.Expanding,
                                  QtWidgets.QSizePolicy.Minimum))

        add_btn = QtWidgets.QPushButton('Add')
        add_btn.clicked.connect(self.handle_add)
        button_layout.addWidget(add_btn)

        edit_btn = QtWidgets.QPushButton('Edit')
        edit_btn.clicked.connect(self.handle_edit)
        button_layout.addWidget(edit_btn)

        remove_btn = QtWidgets.QPushButton('Remove')
        remove_btn.clicked.connect(self.handle_remove)
        button_layout.addWidget(remove_btn)

        self.update_list()
예제 #8
0
    def update_list(self):
        db = database.get()

        self.list.clear()
        for t in db.typedefs:
            item = QtWidgets.QListWidgetItem('typedef %s %s;' %
                                             (db.typedefs[t], t))
            item.setData(QtCore.Qt.UserRole, t)
            self.list.addItem(item)
예제 #9
0
파일: gui.py 프로젝트: clayne/Classy
    def add_child_class_item(self, parent, c):
        if parent is None:
            parent = self.class_tree

        item = QtWidgets.QTreeWidgetItem(parent, [c.name])
        item.setData(0, QtCore.Qt.UserRole, c)
        self.items_by_class[c] = item
        for d in c.derived:
            self.add_child_class_item(item, d)
        return item
예제 #10
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)
예제 #11
0
파일: gui.py 프로젝트: clayne/Classy
    def handle_class_tree_context_menu(self, point):
        item = self.class_tree.itemAt(point)

        menu = QtWidgets.QMenu()
        menu.addAction('Add', self.add_class)

        if item is not None:
            menu.addAction('Remove', self.remove_class)
            menu.addAction('Generate C++ Header File',
                           self.generate_class_header)

        menu.exec_(self.class_tree.mapToGlobal(point))
예제 #12
0
    def __init__(self,
                 inital_new_name='',
                 title='Select a struct',
                 has_none_btn=False):
        super(ChooseStructDialog, self).__init__()

        self.struct_id = idc.BADADDR

        self.setWindowTitle(title)

        layout = QtWidgets.QHBoxLayout(self)

        self.new_name_w = QtWidgets.QLineEdit()
        self.new_name_w.setText(inital_new_name)
        self.new_name_w.setMinimumWidth(200)
        layout.addWidget(self.new_name_w)

        new_btn = QtWidgets.QPushButton('New')
        new_btn.clicked.connect(self.handle_new)
        layout.addWidget(new_btn)

        existing_btn = QtWidgets.QPushButton('Existing')
        existing_btn.clicked.connect(self.handle_existing)
        layout.addWidget(existing_btn)

        if has_none_btn:
            none_btn = QtWidgets.QPushButton('None')
            none_btn.clicked.connect(self.handle_none)
            layout.addWidget(none_btn)

        cancel_btn = QtWidgets.QPushButton('Cancel')
        cancel_btn.clicked.connect(self.reject)
        layout.addWidget(cancel_btn)
예제 #13
0
    def _install_idabuddy(self, idaview):
        if idaview in self._installed_views:
            return
        self._installed_views.add(idaview)
        layout = QtWidgets.QHBoxLayout(idaview)
        popup = AutoPopup(idaview)
        layout.addWidget(popup)
        layout.setAlignment(QtCore.Qt.AlignBottom | QtCore.Qt.AlignRight)
        layout.setContentsMargins(0, 0, 0, 0)
        popup.automate(sequences.say_address, *[sequences.say_random_saying]*10)
        popup.start()

        return popup
예제 #14
0
파일: gui.py 프로젝트: clayne/Classy
    def OnCreate(self, form):
        self.parent = self.FormToPyQtWidget(form)

        layout = QtWidgets.QVBoxLayout()

        # Setup left side
        left_widget = QtWidgets.QWidget()
        left_layout = QtWidgets.QVBoxLayout(left_widget)

        splitter = QtWidgets.QSplitter(QtCore.Qt.Horizontal)
        layout.addWidget(splitter)

        self.class_tree = QtWidgets.QTreeWidget()
        self.class_tree.header().hide()
        self.class_tree.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        self.class_tree.customContextMenuRequested.connect(
            self.handle_class_tree_context_menu)
        self.class_tree.setSelectionMode(
            QtWidgets.QAbstractItemView.SingleSelection)
        self.class_tree.itemSelectionChanged.connect(
            self.handle_class_tree_selection_change)
        left_layout.addWidget(self.class_tree)

        button_layout = QtWidgets.QHBoxLayout()

        add_button = QtWidgets.QPushButton('Add')
        add_button.clicked.connect(self.add_class)
        button_layout.addWidget(add_button)

        remove_button = QtWidgets.QPushButton('Remove')
        remove_button.clicked.connect(self.remove_class)
        button_layout.addWidget(remove_button)

        left_layout.addLayout(button_layout)

        splitter.addWidget(left_widget)

        # Setup right side
        self.class_edit = ClassWidget(self)
        splitter.addWidget(self.class_edit)

        splitter.setSizes([100, 100000])

        self.parent.setLayout(layout)

        self.update_fields()
예제 #15
0
파일: BPView.py 프로젝트: bonomali/DIE
    def OnCreate(self, form):
        """
        Called when the view is created
        """
        self.bp_tree_widget = QtWidgets.QTreeWidget()
        self.bp_handler = BpHandler.get_bp_handler()
        self.die_icons = DIE.UI.Die_Icons.get_die_icons()

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

        self._add_parser_data()

        toolbar = QtWidgets.QToolBar()
        action_refresh = QtWidgets.QAction(self.die_icons.icon_refresh,
                                           "Refresh", toolbar)
        action_refresh.triggered.connect(self.refresh)
        toolbar.addAction(action_refresh)

        layout = QtWidgets.QGridLayout()
        layout.addWidget(toolbar)
        layout.addWidget(self.bp_tree_widget)

        self.parent.setLayout(layout)
예제 #16
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
예제 #17
0
    def _add_parser_data(self):
        """
        Add parser data to the parser widget model
        @return:
        """
        row = 0
        parser_list = self.data_parser.get_parser_list()
        if not "headers" in parser_list:
            return

        header_list = parser_list["headers"]
        header_list.insert(0, "Plugin Name")

        del parser_list["headers"]  # Remove headers item

        self.ptable_widget.setHeaderLabels(header_list)

        self.ptable_widget.setColumnWidth(0, 200)
        self.ptable_widget.setColumnWidth(1, 500)
        self.ptable_widget.setColumnWidth(2, 80)
        self.ptable_widget.setColumnWidth(3, 80)
        self.ptable_widget.setColumnWidth(4, 200)

        root_item = self.ptable_widget.invisibleRootItem()

        for parser in parser_list:
            current_row_item = QtWidgets.QTreeWidgetItem()
            current_row_item.setFlags(QtCore.Qt.ItemIsEnabled)
            current_row_item.setText(0, parser)

            num_columns = len(parser_list[parser])
            for column in xrange(0, num_columns):
                currext_text = str(parser_list[parser][column])
                current_row_item.setText(column + 1, currext_text)

            root_item.insertChild(row, current_row_item)
            row += 1
예제 #18
0
파일: BPView.py 프로젝트: bonomali/DIE
    def _add_parser_data(self):
        """
        Add data to the breakpoint widget model
        """
        if self.bp_tree_widget is not None:
            self.bp_tree_widget.clear()
        else:
            self.bp_tree_widget = QtWidgets.QTreeWidget()

        root_item = self.bp_tree_widget.invisibleRootItem()

        self.bp_tree_widget.setHeaderLabel("Breakpoints")

        # Excluded Modules
        module_item = QtWidgets.QTreeWidgetItem()
        module_item.setText(0, "Excluded Modules")
        module_item.setFlags(QtCore.Qt.ItemIsEnabled)

        row = 0
        for module in self.bp_handler.excluded_modules:
            current_row_item = QtWidgets.QTreeWidgetItem()
            current_row_item.setFlags(QtCore.Qt.ItemIsEnabled)
            current_row_item.setText(0, module)
            module_item.insertChild(row, current_row_item)
            row += 1

        # Excluded Functions
        function_item = QtWidgets.QTreeWidgetItem()
        function_item.setText(0, "Excluded Functions")
        function_item.setFlags(QtCore.Qt.ItemIsEnabled)

        row = 0
        for function in self.bp_handler.excluded_funcNames:
            current_row_item = QtWidgets.QTreeWidgetItem()
            current_row_item.setFlags(QtCore.Qt.ItemIsEnabled)
            current_row_item.setText(0, function)
            function_item.insertChild(row, current_row_item)
            row += 1

        # Excluded Addresses
        ea_item = QtWidgets.QTreeWidgetItem()
        ea_item.setText(0, "Excluded Addresses")
        ea_item.setFlags(QtCore.Qt.ItemIsEnabled)

        row = 0
        for ea in self.bp_handler.excluded_bp_ea:
            current_row_item = QtWidgets.QTreeWidgetItem()
            current_row_item.setFlags(QtCore.Qt.ItemIsEnabled)
            current_row_item.setText(0, hex(ea))
            ea_item.insertChild(row, current_row_item)
            row += 1

        current_row = 0
        if module_item.childCount() > 0:
            root_item.insertChild(current_row, module_item)
            current_row += 1
        if function_item.childCount() > 0:
            root_item.insertChild(current_row, function_item)
            current_row += 1
        if ea_item.childCount() > 0:
            root_item.insertChild(current_row, ea_item)
            current_row += 1
예제 #19
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)
예제 #20
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()
예제 #21
0
def get_text_size(text, font):
    font_metrics = QtWidgets.QFontMetrics(font)
    text_size = font_metrics.size(
        0, text)  # Flags set to `0` to allow linebreaks.
    return text_size
예제 #22
0
파일: gui.py 프로젝트: clayne/Classy
    def __init__(self, parent_gui):
        QtWidgets.QWidget.__init__(self)

        self.parent_gui = parent_gui

        self.edit_class = None

        layout = QtWidgets.QGridLayout(self)

        self.name = QtWidgets.QLabel()
        layout.addWidget(self.name, 0, 0)

        self.set_name = QtWidgets.QPushButton('Set')
        self.set_name.setMaximumWidth(50)
        self.set_name.clicked.connect(self.handle_set_name)
        layout.addWidget(self.set_name, 0, 1)

        self.base_class = QtWidgets.QLabel()
        layout.addWidget(self.base_class, 1, 0, 1, 2)

        self.derived_classes = QtWidgets.QLabel()
        layout.addWidget(self.derived_classes, 2, 0, 1, 2)

        self.struct = util.ClickableQLabel()
        self.struct.doubleClicked.connect(self.handle_struct_double_clicked)
        layout.addWidget(self.struct, 3, 0)

        self.set_struct = QtWidgets.QPushButton('Set')
        self.set_struct.setMaximumWidth(50)
        self.set_struct.clicked.connect(self.handle_set_struct)
        layout.addWidget(self.set_struct, 3, 1)

        self.vtable_range = QtWidgets.QLabel()
        layout.addWidget(self.vtable_range, 4, 0)

        self.set_vtable_range = QtWidgets.QPushButton('Set')
        self.set_vtable_range.setMaximumWidth(50)
        self.set_vtable_range.clicked.connect(self.handle_set_vtable_range)
        layout.addWidget(self.set_vtable_range, 4, 1)

        self.vtable = util.EnterPressQTableWidget()
        self.vtable.setSizePolicy(QtWidgets.QSizePolicy.Expanding,
                                  QtWidgets.QSizePolicy.Expanding)
        self.vtable.setColumnCount(4)
        self.vtable.setHorizontalHeaderLabels(
            ['ID', 'Address', 'Function', 'Type'])
        vtable_header = self.vtable.horizontalHeader()
        vtable_header.setSectionResizeMode(2, QtWidgets.QHeaderView.Stretch)
        self.vtable.verticalHeader().hide()
        self.vtable.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers)
        self.vtable.cellDoubleClicked.connect(self.handle_vtable_interaction)
        self.vtable.cellEnterPressed.connect(self.handle_vtable_interaction)
        layout.addWidget(self.vtable, 5, 0, 1, 2)

        self.methods = util.EnterPressQTableWidget()
        self.methods.setSizePolicy(QtWidgets.QSizePolicy.Expanding,
                                   QtWidgets.QSizePolicy.Expanding)
        self.methods.setColumnCount(2)
        self.methods.setHorizontalHeaderLabels(['Address', 'Function'])
        methods_header = self.methods.horizontalHeader()
        methods_header.setSectionResizeMode(1, QtWidgets.QHeaderView.Stretch)
        self.methods.verticalHeader().hide()
        self.methods.setEditTriggers(
            QtWidgets.QAbstractItemView.NoEditTriggers)
        # self.methods.setSortingEnabled(True) Todo
        self.methods.cellDoubleClicked.connect(self.handle_methods_interaction)
        self.methods.cellEnterPressed.connect(self.handle_methods_interaction)
        layout.addWidget(self.methods, 6, 0, 1, 2)

        method_btn_layout = QtWidgets.QHBoxLayout()

        self.add_method_btn = QtWidgets.QPushButton('Add')
        self.add_method_btn.setMaximumWidth(50)
        self.add_method_btn.clicked.connect(self.handle_add_method)
        method_btn_layout.addWidget(self.add_method_btn)

        self.remove_method_btn = QtWidgets.QPushButton('Remove')
        self.remove_method_btn.setMaximumWidth(50)
        self.remove_method_btn.clicked.connect(self.handle_remove_method)
        method_btn_layout.addWidget(self.remove_method_btn)

        method_btn_layout.addItem(
            QtWidgets.QSpacerItem(0, 0, QtWidgets.QSizePolicy.Expanding,
                                  QtWidgets.QSizePolicy.Minimum))

        layout.addLayout(method_btn_layout, 7, 0, 1, 2)

        self.update_fields()
예제 #23
0
파일: gui.py 프로젝트: clayne/Classy
    def update_fields(self):
        if self.edit_class is None:
            self.setDisabled(True)
            self.name.setText('Name: -')
            self.base_class.setText('Base class: -')
            self.derived_classes.setText('Derived classes: -')
            self.struct.setText('Struct: -')
            self.vtable_range.setText('VTable: -')
            self.vtable.setRowCount(0)
            self.methods.setRowCount(0)

        else:
            self.setEnabled(True)
            self.name.setText('Name: %s' % self.edit_class.name)
            self.base_class.setText(
                'Base class: %s' %
                (self.edit_class.base.name
                 if self.edit_class.base is not None else 'None'))

            derived_classes_txts = []
            for dc in self.edit_class.derived:
                derived_classes_txts.append(dc.name)
            derived_classes_txt = ', '.join(derived_classes_txts)
            if not derived_classes_txt:
                derived_classes_txt = 'None'
            self.derived_classes.setText('Derived classes: %s' %
                                         derived_classes_txt)

            if self.edit_class.struct_id == idc.BADADDR:
                struct_txt = 'Not set'
            else:
                struct_txt = '%s (%d)' % (
                    idc.get_struc_name(self.edit_class.struct_id),
                    idc.get_struc_idx(self.edit_class.struct_id))
            self.struct.setText('Struct: %s' % struct_txt)

            if self.edit_class.vtable_start is None or self.edit_class.vtable_end is None:
                vtable_range_txt = 'Not set'
            else:
                vtable_range_txt = '0x%X - 0x%X' % (
                    self.edit_class.vtable_start, self.edit_class.vtable_end)
            self.vtable_range.setText('VTable: %s' % vtable_range_txt)

            self.vtable.setRowCount(len(self.edit_class.vmethods))
            for idx, vm in enumerate(self.edit_class.vmethods):
                self.vtable.setItem(idx, 0,
                                    QtWidgets.QTableWidgetItem(str(idx)))
                self.vtable.setItem(
                    idx, 1,
                    QtWidgets.QTableWidgetItem((
                        "0x%X" % vm.ea) if vm.ea != idc.BADADDR else '-'))
                self.vtable.setItem(
                    idx, 2, QtWidgets.QTableWidgetItem(vm.get_signature()))
                self.vtable.setItem(idx, 3,
                                    QtWidgets.QTableWidgetItem(vm.type_name()))

            # This way of doing won't work when allowing sorting
            self.methods.setRowCount(len(self.edit_class.methods))
            for idx, m in enumerate(self.edit_class.methods):
                address_item = QtWidgets.QTableWidgetItem(m.ea)
                address_item.setData(QtCore.Qt.DisplayRole, "0x%X" % m.ea)
                address_item.setData(QtCore.Qt.UserRole, m)
                self.methods.setItem(idx, 0, address_item)
                self.methods.setItem(
                    idx, 1, QtWidgets.QTableWidgetItem(m.get_signature()))