diff --git a/src/common/Highlighter.cpp b/src/common/Highlighter.cpp index 5431a398..03a9e3bf 100644 --- a/src/common/Highlighter.cpp +++ b/src/common/Highlighter.cpp @@ -9,15 +9,6 @@ Highlighter::Highlighter(QTextDocument *parent) : QSyntaxHighlighter(parent) core = Core(); - keywordFormat.setForeground(QColor(65, 131, 215)); - - for (const QString &pattern : this->core->opcodes) { - rule.pattern.setPattern("\\b" + pattern + "\\b"); - rule.pattern.setPatternOptions(QRegularExpression::CaseInsensitiveOption); - rule.format = keywordFormat; - highlightingRules.append(rule); - } - regFormat.setForeground(QColor(236, 100, 75)); for (const QString &pattern : this->core->regs) { diff --git a/src/core/Cutter.cpp b/src/core/Cutter.cpp index 5e25c9dc..c69c4df5 100644 --- a/src/core/Cutter.cpp +++ b/src/core/Cutter.cpp @@ -2944,11 +2944,9 @@ bool CutterCore::isGraphEmpty() return emptyGraph; } -void CutterCore::getOpcodes() +void CutterCore::getRegs() { CORE_LOCK(); - this->opcodes = cmdList("?O"); - this->regs = {}; const RzList *rs = rz_reg_get_list(getReg(), RZ_REG_TYPE_ANY); if (!rs) { diff --git a/src/core/Cutter.h b/src/core/Cutter.h index b92167e3..01bcc24d 100644 --- a/src/core/Cutter.h +++ b/src/core/Cutter.h @@ -188,11 +188,6 @@ public: CutterJson cmdj(const char *str); CutterJson cmdj(const QString &str) { return cmdj(str.toUtf8().constData()); } CutterJson cmdjAt(const char *str, RVA address); - QStringList cmdList(const char *str) - { - return cmd(str).split(QLatin1Char('\n'), CUTTER_QT_SKIP_EMPTY_PARTS); - } - QStringList cmdList(const QString &str) { return cmdList(str.toUtf8().constData()); } QString cmdTask(const QString &str); CutterJson cmdjTask(const QString &str); /** @@ -595,8 +590,7 @@ public: void setGraphEmpty(bool empty); bool isGraphEmpty(); - void getOpcodes(); - QList opcodes; + void getRegs(); QList regs; void setSettings(); diff --git a/src/core/MainWindow.cpp b/src/core/MainWindow.cpp index 339884cc..bfd3434d 100644 --- a/src/core/MainWindow.cpp +++ b/src/core/MainWindow.cpp @@ -637,7 +637,7 @@ bool MainWindow::openProject(const QString &file) void MainWindow::finalizeOpen() { - core->getOpcodes(); + core->getRegs(); core->updateSeek(); refreshAll(); // Add fortune message @@ -1762,10 +1762,16 @@ void MainWindow::on_actionExport_as_code_triggered() QTextStream fileOut(&file); auto ps = core->seekTemp(0); auto rc = core->core(); + const auto size = static_cast(rz_io_fd_size(rc->io, rc->file->fd)); + auto buffer = std::vector(size); + if (!rz_io_read_at(Core()->core()->io, 0, buffer.data(), size)) { + return; + } + std::unique_ptr string { dialog.selectedNameFilter() != instructionsInComments - ? rz_lang_byte_array(rc->block, rc->blocksize, typMap[dialog.selectedNameFilter()]) - : rz_core_print_bytes_with_inst(rc, rc->block, rc->offset, rc->blocksize), + ? rz_lang_byte_array(buffer.data(), size, typMap[dialog.selectedNameFilter()]) + : rz_core_print_bytes_with_inst(rc, buffer.data(), 0, size), free }; fileOut << string.get(); diff --git a/src/widgets/FunctionsWidget.cpp b/src/widgets/FunctionsWidget.cpp index b59cfb34..864780c4 100644 --- a/src/widgets/FunctionsWidget.cpp +++ b/src/widgets/FunctionsWidget.cpp @@ -231,7 +231,17 @@ QVariant FunctionModel::data(const QModelIndex &index, int role) const QStringList disasmPreview = Core()->getDisassemblyPreview(function.offset, kMaxTooltipDisasmPreviewLines); - const QStringList &summary = Core()->cmdList(QString("pdsf @ %1").arg(function.offset)); + QStringList summary {}; + { + auto seeker = Core()->seekTemp(function.offset); + auto strings = std::unique_ptr { + rz_core_print_disasm_strings(Core()->core(), RZ_CORE_DISASM_STRINGS_MODE_FUNCTION, + 0, NULL), + free + }; + summary = QString(strings.get()).split('\n', CUTTER_QT_SKIP_EMPTY_PARTS); + } + const QFont &fnt = Config()->getFont(); QFontMetrics fm { fnt }; @@ -245,7 +255,7 @@ QVariant FunctionModel::data(const QModelIndex &index, int role) const } } if (disasmPreview.isEmpty() && highlights.isEmpty()) - return QVariant(); + return {}; QString toolTipContent = QString("
contains(function.offset); default: - return QVariant(); + return {}; } }