Пример #1
0
    def _on_exports_contextmenu(self, pos):
        """ ExportsList ContextMenu
        """
        index = self.exports_list.indexAt(pos).row()
        if index != -1:
            context_menu = QMenu(self)
            func_name = self.exports_model.item(index, 0).text()
            addr = self.exports_model.item(index, 1).text()
            context_menu.addAction(
                'Add Breakpoint', lambda: self._add_breakpoint(addr, func_name))
            context_menu.addSeparator()
            context_menu.addAction(
                'Copy address', lambda: utils.copy_hex_to_clipboard(
                    self.exports_model.item(index, 1).text()))
            context_menu.addSeparator()
            context_menu.addAction(
                'Copy FunctionName', lambda: utils.copy_str_to_clipboard(
                    func_name))

            if self.exports_list.search_enabled:
                context_menu.addSeparator()
                context_menu.addAction(
                    'Search', self.exports_list._on_cm_search)

            # show contextmenu
            glbl_pt = self.exports_list.mapToGlobal(pos)
            context_menu.exec_(glbl_pt)
Пример #2
0
    def _on_context_menu(self, pos):
        context_menu = QMenu(self)
        context_menu.addMenu(self.new_menu)

        context_menu.addSeparator()
        index = self._breakpoints_list.indexAt(pos).row()
        if index != -1:
            context_menu.addAction(
                'Copy address', lambda: utils.copy_hex_to_clipboard(
                    self._breakpoints_model.item(index, 0).text()))
            context_menu.addAction(
                'Jump to address', lambda: self._app_window.jump_to_address(
                    self._breakpoints_model.item(index, 0).text()))
            context_menu.addSeparator()
            context_menu.addAction('Edit Condition',
                                   lambda: self._on_modify_condition(index))
            context_menu.addSeparator()
            context_menu.addAction('Delete Breakpoint',
                                   lambda: self._on_delete_breakpoint(index))

            if self._breakpoints_list.search_enabled:
                context_menu.addSeparator()
                context_menu.addAction('Search',
                                       self._breakpoints_list._on_cm_search)

        # show context menu
        global_pt = self._breakpoints_list.mapToGlobal(pos)
        context_menu.exec(global_pt)
Пример #3
0
    def _on_contextmenu(self, pos):
        context_menu = QMenu(self)
        index = self._bookmarks_list.indexAt(pos).row()
        if index != -1:
            context_menu.addAction(
                'Copy address', lambda: utils.copy_hex_to_clipboard(
                    self._bookmarks_model.item(index, 0).text()))
            context_menu.addAction(
                'Jump to address', lambda: self._app_window.jump_to_address(
                    self._bookmarks_model.item(index, 0).text()))

            # todo: add breakpoint address menu

            context_menu.addSeparator()
            context_menu.addAction('Edit',
                                   lambda: self._create_bookmark(index=index))
            context_menu.addAction('Delete',
                                   lambda: self._on_delete_bookmark(index))
            context_menu.addSeparator()
            if self._bookmarks_list.search_enabled:
                context_menu.addSeparator()
                context_menu.addAction('Search',
                                       self._bookmarks_list._on_cm_search)
                context_menu.addSeparator()
        context_menu.addAction('New', self._create_bookmark)
        global_pt = self._bookmarks_list.mapToGlobal(pos)
        context_menu.exec(global_pt)
Пример #4
0
    def _on_context_menu(self, pos):
        index = self.indexAt(pos).row()
        glbl_pt = self.mapToGlobal(pos)
        context_menu = QMenu(self)
        if index != -1:
            if self._mode == 'native':
                addr_item = self.model().item(index, 0).text()
                symbol_item = self.model().item(index, 1).text()
                # show contextmenu
                context_menu.addAction('Jump to {0}'.format(addr_item), lambda: self.onShowMemoryRequest.emit(['bt', addr_item]))
                context_menu.addSeparator()
                context_menu.addAction('Copy Address', lambda: utils.copy_hex_to_clipboard(addr_item))
                if symbol_item and symbol_item != '-':
                    context_menu.addAction('Copy Symbol', lambda: utils.copy_str_to_clipboard(symbol_item))
            elif self._mode == 'java':
                method_item = self.model().item(index, 0).text()
                if method_item.startswith('at '):
                    method_item = method_item.replace('at ', '')

                source_item = self.model().item(index, 1).text()
                if ':' in source_item:
                    source_item = source_item.split(':')[0]
                # show contextmenu
                # context_menu.addAction('Jump to', lambda: self._app_window.jump_to_address(addr_item.text()))
                # context_menu.addSeparator()
                # TODO: add jumpto java
                context_menu.addAction('Copy Method', lambda: utils.copy_str_to_clipboard(method_item))
                context_menu.addAction('Copy Source', lambda: utils.copy_str_to_clipboard(source_item))

            context_menu.exec_(glbl_pt)
Пример #5
0
 def _on_context_menu(self, pos):
     model_index = self.elf_info.indexAt(pos)
     if model_index.column() == 0 and model_index.data():
         if model_index.data().startswith('0x'):
             context_menu = QMenu()
             context_menu.addAction('Add to Bookmarks', lambda: self.parent().bookmarks_panel.insert_bookmark(model_index.data(), 'init_array'))
             context_menu.addAction('Copy Address', lambda: utils.copy_hex_to_clipboard(model_index.data()))
             # show contextmenu
             glbl_pt = self.elf_info.mapToGlobal(pos)
             context_menu.exec_(glbl_pt)
Пример #6
0
 def handle_offset_click(self, mouse_btn, offset_link):
     if mouse_btn == Qt.LeftButton:
         _offset = offset_link.split(':')
         line = self._debug_panel.disassembly_panel.get_line_for_address(
             _offset[1])
         self._debug_panel.disassembly_panel.verticalScrollBar().setValue(
             line)
         self._debug_panel.disassembly_panel._current_line = line
     elif mouse_btn == Qt.RightButton:
         _offset = offset_link.split(':')
         _offset = _offset[1]
         menu = QMenu()
         menu.addAction('Copy Offset',
                        lambda: utils.copy_hex_to_clipboard(_offset))
         menu.exec_(QCursor.pos())
Пример #7
0
    def _on_contextmenu(self, pos):
        """ ContextMenu
        """
        index = self.indexAt(pos).row()
        glbl_pt = self.mapToGlobal(pos)
        context_menu = QMenu(self)
        if index != -1:
            mem_prot = self._ranges_model.item(index, 2).text()
            # is readable
            if 'r' in mem_prot:
                context_menu.addAction(
                    'Dump Binary', lambda: self._on_dumprange(
                        self._ranges_model.item(index, 0).text(),
                        self._ranges_model.item(index, 1).text()))
                context_menu.addSeparator()

            context_menu.addAction(
                'Add Watchpoint', lambda: self._on_addwatchpoint(
                    self._ranges_model.item(index, 0).text()))

            context_menu.addAction(
                'Copy address', lambda: utils.copy_hex_to_clipboard(
                    self._ranges_model.item(index, 0).text()))
            context_menu.addSeparator()

            if self._ranges_model.item(index, 5):
                file_path = self._ranges_model.item(index, 5).text()
                if file_path:
                    context_menu.addAction(
                        'Copy Path', lambda: utils.copy_str_to_clipboard(
                            file_path))
                    context_menu.addSeparator()
                    if self._app_window.dwarf._platform == 'linux':
                        context_menu.addAction(
                            'Show ELF Info', lambda: self._on_parse_elf(
                                file_path))
                        context_menu.addSeparator()

            if self.search_enabled:
                context_menu.addSeparator()
                context_menu.addAction('Search', self._on_cm_search)
                context_menu.addSeparator()

        context_menu.addAction('Refresh', self.update_ranges)
        context_menu.exec_(glbl_pt)
Пример #8
0
 def _on_contextmenu(self, pos):
     index = self.list_view.indexAt(pos).row()
     glbl_pt = self.list_view.mapToGlobal(pos)
     context_menu = QMenu(self)
     context_menu.addAction('Add watchpoint', self._on_additem_clicked)
     if index != -1:
         context_menu.addSeparator()
         context_menu.addAction(
             'Copy address', lambda: utils.copy_hex_to_clipboard(
                 self._watchpoints_model.item(index, 0).text()))
         context_menu.addAction(
             'Jump to address', lambda: self._app_window.jump_to_address(
                 self._watchpoints_model.item(index, 0).text()))
         context_menu.addAction(
             'Delete watchpoint', lambda: self.remove_address(
                 self._watchpoints_model.item(index, 0).text()))
         if self.list_view.search_enabled:
             context_menu.addSeparator()
             context_menu.addAction('Search', self.list_view._on_cm_search)
     context_menu.exec_(glbl_pt)
Пример #9
0
    def _on_modules_contextmenu(self, pos):
        """ Modules ContextMenu
        """
        index = self.modules_list.indexAt(pos).row()
        glbl_pt = self.modules_list.mapToGlobal(pos)
        context_menu = QMenu(self)
        if index != -1:
            context_menu.addAction(
                'Dump Binary', lambda: self._on_dumpmodule(
                    self.modules_model.item(index, 1).text(),
                    self.modules_model.item(index, 2).text()))
            context_menu.addSeparator()
            context_menu.addAction(
                'Copy address', lambda: utils.copy_hex_to_clipboard(
                    self.modules_model.item(index, 1).text()))
            context_menu.addAction(
                'Copy Name', lambda: utils.copy_str_to_clipboard(
                    self.modules_model.item(index, 0).text()))
            context_menu.addAction(
                'Copy Path', lambda: utils.copy_str_to_clipboard(
                    self.modules_model.item(index, 3).text()))
            context_menu.addSeparator()
            file_path = self.modules_model.item(index, 3).text()
            if self._app_window.dwarf._platform == 'linux':
                context_menu.addAction(
                    'Show ELF Info', lambda: self._on_parse_elf(file_path))
                context_menu.addSeparator()
            # elif file_path and (file_path.endswith('.dll') or file_path.endswith('.exe')):
            #   context_menu.addAction('Show PE Info', lambda: self._on_parse_pe(file_path))
            #   context_menu.addSeparator()

            if self.modules_list.search_enabled:
                context_menu.addSeparator()
                context_menu.addAction(
                    'Search', self.modules_list._on_cm_search)
                context_menu.addSeparator()

        context_menu.addAction('Refresh', self.update_modules)
        context_menu.exec_(glbl_pt)
Пример #10
0
    def _on_context_menu(self, event):
        """ build and show contextmenu
        """
        loc_x = event.pos().x()
        loc_y = event.pos().y()

        context_menu = QMenu()

        def add_default_actions():
            context_menu.addAction(
                'Jump to address',
                lambda: self.debug_panel.on_cm_jump_to_address(view=1))

            # allow mode switch arm/thumb
            if self._app_window.dwarf.disassembler.capstone_arch == CS_ARCH_ARM:
                if self._app_window.dwarf.disassembler.capstone_mode == CS_MODE_THUMB:
                    mode_str = 'ARM'
                else:
                    mode_str = 'THUMB'
                entry_str = '&Switch to {0} mode'.format(mode_str)
                context_menu.addAction(entry_str, self._on_switch_mode)

        if not self._lines:
            add_default_actions()

            # allow jumpto in empty panel
            glbl_pt = self.mapToGlobal(event.pos())
            context_menu.exec_(glbl_pt)
            return

        index = self.pixel_to_line(loc_x, loc_y)
        address = -1
        if 0 <= index < self.visible_lines():
            if index + self.pos < len(self._lines):
                if isinstance(self._lines[index + self.pos], Instruction):
                    address = self._lines[index + self.pos].address
                    addr_str = hex(address)

                    context_menu.addAction(addr_str)
                    context_menu.addSeparator()

                    if self._app_window.watchpoints_panel:
                        if self._app_window.dwarf.is_address_watched(address):
                            context_menu.addAction(
                                'Remove watchpoint', lambda: self._app_window.
                                watchpoints_panel.remove_address(addr_str))
                        else:
                            context_menu.addAction(
                                'Watch address',
                                lambda: self._app_window.watchpoints_panel.
                                do_addwatchpoint_dlg(addr_str))
                    if self._app_window.breakpoints_panel:
                        if address in self._app_window.dwarf.breakpoints:
                            context_menu.addAction(
                                'Remove breakpoint',
                                lambda: self._app_window.dwarf.dwarf_api(
                                    'deleteBreakpoint', addr_str))
                        else:
                            context_menu.addAction(
                                'Breakpoint address', lambda: self._app_window.
                                dwarf.breakpoint_native(addr_str))

                    context_menu.addSeparator()

                    context_menu.addAction(
                        'Copy address',
                        lambda: utils.copy_hex_to_clipboard(address))

        context_menu.addAction(
            "&Jump to address",
            lambda: self.debug_panel.on_cm_jump_to_address(view=1))

        glbl_pt = self.mapToGlobal(event.pos())
        context_menu.exec_(glbl_pt)