Exemple #1
0
async def main():
    from pre_workbench import configs
    params = configs.getValue("rpcnet_opt", {})

    cm = ConnectionManager(**params)
    configs.setValue("rpcnet", cm.saveParams())
    await cm.add_transport(UdpSimpleRpcTransport, "/ip/0.0.0.0/udp/5432")
Exemple #2
0
 def fileOpenFormatInfo(self):
     fileName, _ = QFileDialog.getOpenFileName(
         self, "Load format info",
         configs.getValue(self.optionsConfigKey + "_lastOpenFile", ""),
         "Format Info files (*.pfi *.txt)")
     if fileName:
         configs.setValue(self.optionsConfigKey + "_lastOpenFile", fileName)
         self.loadFormatInfo(load_from_file=fileName)
Exemple #3
0
    def keyPressEvent(self, e: QKeyEvent) -> None:
        mod = e.modifiers() & ~QtCore.Qt.KeypadModifier

        arrow = None
        if e.key() == QtCore.Qt.Key_Left:
            arrow = self.selEnd - 1
        elif e.key() == QtCore.Qt.Key_Right:
            arrow = self.selEnd + 1
        elif e.key() == QtCore.Qt.Key_Up:
            arrow = self.selEnd - self.bytesPerLine
        elif e.key() == QtCore.Qt.Key_Down:
            arrow = self.selEnd + self.bytesPerLine

        #print("hexView Key Press %d 0x%x %d"%(e.key(), int(e.modifiers()), arrow))
        if arrow and mod == QtCore.Qt.ShiftModifier:
            self.select(self.selStart, arrow)
        elif arrow and mod == QtCore.Qt.NoModifier:
            self.select(arrow, arrow)

        if mod == QtCore.Qt.ControlModifier:
            if e.key() == QtCore.Qt.Key_A:
                self.selectAll()
            elif e.key() == QtCore.Qt.Key_C:
                self.copySelection()
            elif e.key() == QtCore.Qt.Key_I:
                self.fiTreeWidget.loadFormatInfo(
                    load_from_file=configs.getValue(
                        self.fiTreeWidget.optionsConfigKey +
                        "_lastOpenFile", ""))
            elif e.key() == QtCore.Qt.Key_F5:
                self.applyFormatInfo()
            elif e.key() == QtCore.Qt.Key_Plus:
                self.options['addressFontSize'] += 1
                self.options['hexFontSize'] += 1
                self.options['asciiFontSize'] += 1
                self.options['sectionFontSize'] += 1
                self.setOptions({})
                self.storeOptions()
            elif e.key() == QtCore.Qt.Key_Minus:
                self.options['addressFontSize'] -= 1
                self.options['hexFontSize'] -= 1
                self.options['asciiFontSize'] -= 1
                self.options['sectionFontSize'] -= 1
                self.setOptions({})
                self.storeOptions()
            elif e.key() == QtCore.Qt.Key_0:
                self.options['addressFontSize'] = 10
                self.options['hexFontSize'] = 10
                self.options['asciiFontSize'] = 10
                self.options['sectionFontSize'] = 8
                self.setOptions({})
                self.storeOptions()

        if mod == QtCore.Qt.ControlModifier | QtCore.Qt.ShiftModifier:
            if e.key() == QtCore.Qt.Key_C:
                self.copySelection("hexdump")
            elif e.key() == QtCore.Qt.Key_I:
                self.fiTreeWidget.fileOpenFormatInfo()
Exemple #4
0
    def __init__(self,
                 byteBuffer=None,
                 options=dict(),
                 optionsConfigKey="HexViewParams"):
        super().__init__()
        self.buffers = list()
        self.firstLine = 0
        self.scrollY = 0
        self.setFocusPolicy(QtCore.Qt.StrongFocus)
        self.fiTreeWidget = RangeTreeWidget(self)
        self.fiTreeWidget.show()
        self.fiTreeWidget.currentItemChanged.connect(self.fiTreeItemSelected)
        self.fiTreeWidget.formatInfoUpdated.connect(self.applyFormatInfo)
        self.backgroundPixmap = QPixmap()
        self.textPixmap = QPixmap()

        self.options = {
            'addressFontFamily': 'monospace',
            'addressFontSize': 10,
            'addressColor': '#888888',
            'hexFontFamily': 'monospace',
            'hexFontSize': 10,
            'hexColor': '#ffffff',
            'asciiFontFamily': 'monospace',
            'asciiFontSize': 10,
            'asciiColor': '#bbffbb',
            'sectionFontFamily': 'Serif',
            'sectionFontSize': 8,
            'sectionColor': '#aaaaaa',
            'lineHeight': 1.1,
            'addressFormat': '{:08x}',
            'bytesPerLine': 16,
            'hexSpaceAfter': 8,
            'hexSpaceWidth': 8
        }
        self.optionsConfigKey = optionsConfigKey
        if optionsConfigKey is not None:
            self.setOptions(configs.getValue(optionsConfigKey, {}))
        self.setOptions(options)

        self.selBuffer = 0
        self.selStart = 0
        self.selEnd = 0
        self.itemY = list()
        self.lastHit = None
        self.selecting = False
        self.setContextMenuPolicy(Qt.CustomContextMenu)
        self.customContextMenuRequested.connect(
            self.onCustomContextMenuRequested)
        if byteBuffer == None:
            self.setBytes(bytes())
        else:
            self.setBuffer(byteBuffer)
        self.setMouseTracking(True)
        self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
Exemple #5
0
 def ok_callback(params):
     fileName, _ = QFileDialog.getSaveFileName(
         self, "Save format info",
         configs.getValue(self.optionsConfigKey + "_lastOpenFile", ""),
         "Format Info files (*.pfi *.txt)")
     if not fileName: return
     self.formatInfoContainer = InteractiveFormatInfoContainer(self, )
     self.formatInfoContainer.main_name = "DEFAULT"
     self.formatInfoContainer.definitions[
         "DEFAULT"] = structinfo.deserialize_fi(params)
     self.formatInfoContainer.file_name = fileName
     self.formatInfoUpdated.emit()
     self.saveFormatInfo(self.formatInfoContainer.file_name)