def __init__(self, parent, view, data): super(ExportsWidget, self).__init__(parent) layout = QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) self.imports = ExportsTreeView(self, view, data) self.filter = FilteredView(self, self.imports, self.imports) layout.addWidget(self.filter, 1) self.setLayout(layout) self.setMinimumSize(UIContext.getScaledWindowSize(100, 196))
def __init__(self, parent, data): super(SegmentsWidget, self).__init__(parent) layout = QGridLayout() layout.setContentsMargins(0, 0, 0, 0) layout.setVerticalSpacing(1) layout.setHorizontalSpacing( UIContext.getScaledWindowSize(16, 16).width()) self.segments = [] for segment in data.segments: if segment.readable or segment.writable or segment.executable: self.segments.append(segment) self.segments.sort(key=lambda segment: segment.start) row = 0 for segment in self.segments: begin = "0x%x" % segment.start end = "0x%x" % segment.end permissions = "" if segment.readable: permissions += "r" else: permissions += "-" if segment.writable: permissions += "w" else: permissions += "-" if segment.executable: permissions += "x" else: permissions += "-" rangeLayout = QHBoxLayout() rangeLayout.setContentsMargins(0, 0, 0, 0) beginLabel = headers.ClickableAddressLabel(begin) dashLabel = QLabel("-") dashLabel.setFont(binaryninjaui.getMonospaceFont(self)) endLabel = headers.ClickableAddressLabel(end) rangeLayout.addWidget(beginLabel) rangeLayout.addWidget(dashLabel) rangeLayout.addWidget(endLabel) layout.addLayout(rangeLayout, row, 0) permissionsLabel = QLabel(permissions) permissionsLabel.setFont(binaryninjaui.getMonospaceFont(self)) layout.addWidget(permissionsLabel, row, 1) row += 1 layout.setColumnStretch(2, 1) self.setLayout(layout)
def __init__(self, parent, header): super(HeaderWidget, self).__init__(parent) layout = QGridLayout() layout.setContentsMargins(0, 0, 0, 0) layout.setVerticalSpacing(1) row = 0 col = 0 for field in header.fields: name = field[0] value = field[1] fieldType = "" if len(field) > 2: fieldType = field[2] layout.addWidget(QLabel(name + ": "), row, col * 3) if isinstance(value, list): for i in range(0, len(value)): if fieldType == "ptr": label = ClickableAddressLabel(value[i]) elif fieldType == "code": label = ClickableCodeLabel(value[i]) else: label = QLabel(value[i]) label.setFont(binaryninjaui.getMonospaceFont(self)) layout.addWidget(label, row, col * 3 + 1) row += 1 else: if fieldType == "ptr": label = ClickableAddressLabel(value) elif fieldType == "code": label = ClickableCodeLabel(value) else: label = QLabel(value) label.setFont(binaryninjaui.getMonospaceFont(self)) layout.addWidget(label, row, col * 3 + 1) row += 1 if (header.columns > 1) and (row >= header.rows_per_column) and ( (col + 1) < header.columns): row = 0 col += 1 for col in range(1, header.columns): layout.setColumnMinimumWidth( col * 3 - 1, UIContext.getScaledWindowSize(20, 20).width()) layout.setColumnStretch(header.columns * 3 - 1, 1) self.setLayout(layout)
def __init__(self, parent, view, data): super(EntropyWidget, self).__init__(parent) self.view = view self.data = data self.raw_data = data.file.raw self.block_size = (len(self.raw_data) / 4096) + 1 if self.block_size < 1024: self.block_size = 1024 self.width = int(len(self.raw_data) / self.block_size) self.image = QImage(self.width, 1, QImage.Format_ARGB32) self.image.fill(QColor(0, 0, 0, 0)) self.thread = EntropyThread(self.raw_data, self.image, self.block_size) self.started = False self.timer = QTimer() self.timer.timeout.connect(self.timerEvent) self.timer.setInterval(100) self.timer.setSingleShot(False) self.timer.start() self.setMinimumHeight(UIContext.getScaledWindowSize(32, 32).height())
def __init__(self, parent, data): assert type(data) == BinaryView self.bv = data QDialog.__init__(self, parent) debug_state = binjaplug.get_state(self.bv) self.setWindowTitle("Debug Adapter Settings") self.setMinimumSize(UIContext.getScaledWindowSize(400, 130)) self.setAttribute(Qt.WA_DeleteOnClose) layout = QVBoxLayout() layout.setSpacing(0) titleLabel = QLabel("Adapter Settings") titleLayout = QHBoxLayout() titleLayout.setContentsMargins(0, 0, 0, 0) titleLayout.addWidget(titleLabel) self.adapterEntry = QPushButton(self) self.adapterMenu = QMenu(self) for adapter in DebugAdapter.ADAPTER_TYPE: if not DebugAdapter.ADAPTER_TYPE.can_use(adapter): continue def select_adapter(adapter): return lambda: self.selectAdapter(adapter) self.adapterMenu.addAction(adapter.name, select_adapter(adapter)) if adapter == debug_state.adapter_type: self.adapterEntry.setText(adapter.name) self.adapterEntry.setMenu(self.adapterMenu) self.argumentsEntry = QLineEdit(self) self.addressEntry = QLineEdit(self) self.portEntry = QLineEdit(self) self.requestTerminalEmulator = QCheckBox(self) self.formLayout = QFormLayout() self.formLayout.addRow("Adapter Type", self.adapterEntry) self.formLayout.addRow("Command Line Arguments", self.argumentsEntry) self.formLayout.addRow("Address", self.addressEntry) self.formLayout.addRow("Port", self.portEntry) self.formLayout.addRow("Request Terminal Emulator", self.requestTerminalEmulator) buttonLayout = QHBoxLayout() buttonLayout.setContentsMargins(0, 0, 0, 0) self.cancelButton = QPushButton("Cancel") self.cancelButton.clicked.connect(lambda: self.reject()) self.acceptButton = QPushButton("Accept") self.acceptButton.clicked.connect(lambda: self.accept()) self.acceptButton.setDefault(True) buttonLayout.addStretch(1) buttonLayout.addWidget(self.cancelButton) buttonLayout.addWidget(self.acceptButton) layout.addLayout(titleLayout) layout.addSpacing(10) layout.addLayout(self.formLayout) layout.addStretch(1) layout.addSpacing(10) layout.addLayout(buttonLayout) self.setLayout(layout) self.addressEntry.setText(debug_state.remote_host) self.portEntry.setText(str(debug_state.remote_port)) self.addressEntry.textEdited.connect(lambda: self.apply()) self.portEntry.textEdited.connect(lambda: self.apply()) self.argumentsEntry.setText(' '.join( shlex.quote(arg) for arg in debug_state.command_line_args)) self.argumentsEntry.textEdited.connect(lambda: self.updateArguments()) self.requestTerminalEmulator.setChecked( debug_state.request_terminal_emulator) self.requestTerminalEmulator.stateChanged.connect(lambda: self.apply()) self.accepted.connect(lambda: self.apply())
def __init__(self, parent, data): assert type(data) == binaryninja.binaryview.BinaryView self.bv = data QDialog.__init__(self, parent) self.setWindowTitle("Debug Adapter Settings") self.setMinimumSize(UIContext.getScaledWindowSize(400, 130)) self.setAttribute(Qt.WA_DeleteOnClose) layout = QVBoxLayout() layout.setSpacing(0) titleLabel = QLabel("Adapter Settings") titleLayout = QHBoxLayout() titleLayout.setContentsMargins(0, 0, 0, 0) titleLayout.addWidget(titleLabel) self.argumentsEntry = QLineEdit(self) # self.addressEntry = QLineEdit(self) # self.portEntry = QLineEdit(self) formLayout = QFormLayout() formLayout.addRow("Command Line Arguments", self.argumentsEntry) # formLayout.addRow("Address", self.addressEntry) # formLayout.addRow("Port", self.portEntry) buttonLayout = QHBoxLayout() buttonLayout.setContentsMargins(0, 0, 0, 0) self.cancelButton = QPushButton("Cancel") self.cancelButton.clicked.connect(lambda: self.reject()) self.acceptButton = QPushButton("Accept") self.acceptButton.clicked.connect(lambda: self.accept()) self.acceptButton.setDefault(True) buttonLayout.addStretch(1) buttonLayout.addWidget(self.cancelButton) buttonLayout.addWidget(self.acceptButton) layout.addLayout(titleLayout) layout.addSpacing(10) layout.addLayout(formLayout) layout.addStretch(1) layout.addSpacing(10) layout.addLayout(buttonLayout) self.setLayout(layout) debug_state = binjaplug.get_state(self.bv) # settings = Settings() # address = settings.get_string_with_scope("debugger.adapter.address", data, SettingsScope.SettingsContextScope) # port = settings.get_integer_with_scope("debugger.adapter.port", data, SettingsScope.SettingsContextScope) # self.addressEntry.setText(address[0]) # self.portEntry.setText(str(port[0])) # self.addressEntry.textEdited.connect(lambda: self.updateSettings()) # self.portEntry.textEdited.connect(lambda: self.updateSettings()) self.argumentsEntry.setText(' ' .join(shlex.quote(arg) for arg in debug_state.command_line_args)) self.argumentsEntry.textEdited.connect(lambda: self.updateArguments()) self.accepted.connect(lambda: self.apply())
def __init__(self, parent, data): super(SectionsWidget, self).__init__(parent) layout = QGridLayout() layout.setContentsMargins(0, 0, 0, 0) layout.setVerticalSpacing(1) layout.setHorizontalSpacing( UIContext.getScaledWindowSize(16, 16).width()) maxNameLen = 0 for section in data.sections.values(): if len(section.name) > maxNameLen: maxNameLen = len(section.name) if maxNameLen > 32: maxNameLen = 32 self.sections = [] for section in data.sections.values(): if section.semantics != SectionSemantics.ExternalSectionSemantics: self.sections.append(section) self.sections.sort(key=lambda section: section.start) row = 0 for section in self.sections: name = section.name if len(name) > maxNameLen: name = name[:maxNameLen - 1] + "…" begin = "0x%x" % section.start end = "0x%x" % section.end typeName = section.type permissions = "" if data.is_offset_readable(section.start): permissions += "r" else: permissions += "-" if data.is_offset_writable(section.start): permissions += "w" else: permissions += "-" if data.is_offset_executable(section.start): permissions += "x" else: permissions += "-" semantics = "" if section.semantics == SectionSemantics.ReadOnlyCodeSectionSemantics: semantics = "Code" elif section.semantics == SectionSemantics.ReadOnlyDataSectionSemantics: semantics = "Ready-only Data" elif section.semantics == SectionSemantics.ReadWriteDataSectionSemantics: semantics = "Writable Data" nameLabel = QLabel(name) nameLabel.setFont(binaryninjaui.getMonospaceFont(self)) layout.addWidget(nameLabel, row, 0) rangeLayout = QHBoxLayout() rangeLayout.setContentsMargins(0, 0, 0, 0) beginLabel = headers.ClickableAddressLabel(begin) dashLabel = QLabel("-") dashLabel.setFont(binaryninjaui.getMonospaceFont(self)) endLabel = headers.ClickableAddressLabel(end) rangeLayout.addWidget(beginLabel) rangeLayout.addWidget(dashLabel) rangeLayout.addWidget(endLabel) layout.addLayout(rangeLayout, row, 1) permissionsLabel = QLabel(permissions) permissionsLabel.setFont(binaryninjaui.getMonospaceFont(self)) layout.addWidget(permissionsLabel, row, 2) typeLabel = QLabel(typeName) typeLabel.setFont(binaryninjaui.getMonospaceFont(self)) layout.addWidget(typeLabel, row, 3) semanticsLabel = QLabel(semantics) semanticsLabel.setFont(binaryninjaui.getMonospaceFont(self)) layout.addWidget(semanticsLabel, row, 4) row += 1 layout.setColumnStretch(5, 1) self.setLayout(layout)