diff --git a/src/cutter.cpp b/src/cutter.cpp index 42833deb..ec2b1161 100644 --- a/src/cutter.cpp +++ b/src/cutter.cpp @@ -203,6 +203,13 @@ QString CutterCore::cmd(const QString &str) return o; } +QString CutterCore::cmdRaw(const QString &str) +{ + QString cmdStr = str; + cmdStr.replace('\"', "\\\""); + return cmd("\"" + cmdStr + "\""); +} + QJsonDocument CutterCore::cmdj(const QString &str) { CORE_LOCK(); @@ -322,10 +329,10 @@ void CutterCore::analyze(int level, QList advanced) } } -void CutterCore::renameFunction(QString old_name, QString new_name) +void CutterCore::renameFunction(const QString &oldName, const QString &newName) { - cmd("afn " + new_name + " " + old_name); - emit functionRenamed(old_name, new_name); + cmdRaw("afn " + newName + " " + oldName); + emit functionRenamed(oldName, newName); } void CutterCore::delFunction(RVA addr) @@ -336,7 +343,7 @@ void CutterCore::delFunction(RVA addr) void CutterCore::renameFlag(QString old_name, QString new_name) { - cmd("fr " + old_name + " " + new_name); + cmdRaw("fr " + old_name + " " + new_name); emit flagsChanged(); } diff --git a/src/cutter.h b/src/cutter.h index 47cd48a4..14bd74a5 100644 --- a/src/cutter.h +++ b/src/cutter.h @@ -206,12 +206,13 @@ public: int fcnEndBbs(RVA addr); static QString sanitizeStringForCommand(QString s); QString cmd(const QString &str); + QString cmdRaw(const QString &str); QJsonDocument cmdj(const QString &str); QStringList cmdList(const QString &str) { auto l = cmd(str).split("\n"); l.removeAll(""); return l; } QList disassembleLines(RVA offset, int lines); - void renameFunction(QString prev_name, QString new_name); + void renameFunction(const QString &oldName, const QString &newName); void delFunction(RVA addr); void renameFlag(QString old_name, QString new_name); void delFlag(RVA addr); @@ -346,7 +347,7 @@ public: signals: void refreshAll(); - void functionRenamed(QString prev_name, QString new_name); + void functionRenamed(const QString &prev_name, const QString &new_name); void varsChanged(); void functionsChanged(); void flagsChanged(); diff --git a/src/widgets/DisassemblerGraphView.cpp b/src/widgets/DisassemblerGraphView.cpp index 48149f3a..651bf0dc 100644 --- a/src/widgets/DisassemblerGraphView.cpp +++ b/src/widgets/DisassemblerGraphView.cpp @@ -22,7 +22,7 @@ DisassemblerGraphView::DisassemblerGraphView(QWidget *parent) // Signals that require a refresh all connect(Core(), SIGNAL(refreshAll()), this, SLOT(refreshView())); connect(Core(), SIGNAL(commentsChanged()), this, SLOT(refreshView())); - connect(Core(), SIGNAL(functionRenamed(QString, QString)), this, SLOT(refreshView())); + connect(Core(), SIGNAL(functionRenamed(const QString &, const QString &)), this, SLOT(refreshView())); connect(Core(), SIGNAL(flagsChanged()), this, SLOT(refreshView())); connect(Core(), SIGNAL(varsChanged()), this, SLOT(refreshView())); connect(Core(), SIGNAL(instructionChanged(RVA)), this, SLOT(refreshView())); diff --git a/src/widgets/DisassemblyWidget.cpp b/src/widgets/DisassemblyWidget.cpp index 585ff899..51a70445 100644 --- a/src/widgets/DisassemblyWidget.cpp +++ b/src/widgets/DisassemblyWidget.cpp @@ -109,7 +109,7 @@ DisassemblyWidget::DisassemblyWidget(QWidget *parent) connect(Core(), SIGNAL(commentsChanged()), this, SLOT(refreshDisasm())); connect(Core(), SIGNAL(flagsChanged()), this, SLOT(refreshDisasm())); connect(Core(), SIGNAL(functionsChanged()), this, SLOT(refreshDisasm())); - connect(Core(), SIGNAL(functionRenamed(QString, QString)), this, SLOT(refreshDisasm())); + connect(Core(), SIGNAL(functionRenamed(const QString &, const QString &)), this, SLOT(refreshDisasm())); connect(Core(), SIGNAL(varsChanged()), this, SLOT(refreshDisasm())); connect(Core(), SIGNAL(asmOptionsChanged()), this, SLOT(refreshDisasm())); connect(Core(), &CutterCore::instructionChanged, this, [this](RVA offset) { diff --git a/src/widgets/FunctionsWidget.cpp b/src/widgets/FunctionsWidget.cpp index c87ce0bd..cde46c1f 100644 --- a/src/widgets/FunctionsWidget.cpp +++ b/src/widgets/FunctionsWidget.cpp @@ -25,7 +25,7 @@ FunctionModel::FunctionModel(QList *functions, QSet *i { connect(Core(), SIGNAL(seekChanged(RVA)), this, SLOT(seekChanged(RVA))); - connect(Core(), SIGNAL(functionRenamed(QString, QString)), this, SLOT(functionRenamed(QString, QString))); + connect(Core(), SIGNAL(functionRenamed(const QString &, const QString &)), this, SLOT(functionRenamed(QString, QString))); } QModelIndex FunctionModel::index(int row, int column, const QModelIndex &parent) const diff --git a/src/widgets/SidebarWidget.cpp b/src/widgets/SidebarWidget.cpp index aa1820d1..ab695975 100644 --- a/src/widgets/SidebarWidget.cpp +++ b/src/widgets/SidebarWidget.cpp @@ -56,7 +56,7 @@ void SidebarWidget::refresh(RVA addr) if(addr == RVA_INVALID) addr = Core()->getOffset(); - get_refs_data(addr); + updateRefs(addr); setFcnName(addr); fillOffsetInfo(RAddressString(addr)); } @@ -129,7 +129,7 @@ void SidebarWidget::on_xrefToToolButton_clicked() } } -void SidebarWidget::get_refs_data(RVA addr) +void SidebarWidget::updateRefs(RVA addr) { // refs = calls q hace esa funcion QList refs = Core()->getXRefs(addr, false, false); @@ -137,28 +137,12 @@ void SidebarWidget::get_refs_data(RVA addr) // xrefs = calls a esa funcion QList xrefs = Core()->getXRefs(addr, true, false); - // Data for the disasm side graph - QList data; - //qDebug() << "Refs:" << refs.size(); - data << refs.size(); - //qDebug() << "XRefs:" << xrefs.size(); - data << xrefs.size(); - //qDebug() << "CC: " << this->core->fcnCyclomaticComplexity(offset.toLong(&ok, 16)); - //data << this->core->fcnCyclomaticComplexity(offset.toLong(&ok, 16)); - data << Core()->getCycloComplex(addr); - //qDebug() << "BB: " << this->core->fcnBasicBlockCount(offset.toLong(&ok, 16)); - data << Core()->fcnBasicBlockCount(addr); - data << Core()->fcnEndBbs(addr); - //qDebug() << "MEOW: " + this->core->fcnEndBbs(offset); - // Update disasm side bar - this->fill_refs(refs, xrefs, data); + this->fillRefs(refs, xrefs); } -void SidebarWidget::fill_refs(QList refs, QList xrefs, QList graph_data) +void SidebarWidget::fillRefs(QList refs, QList xrefs) { - Q_UNUSED(graph_data); - TempConfig tempConfig; tempConfig.set("scr.html", false) .set("scr.color", false); diff --git a/src/widgets/SidebarWidget.h b/src/widgets/SidebarWidget.h index 19285487..33c7a50b 100644 --- a/src/widgets/SidebarWidget.h +++ b/src/widgets/SidebarWidget.h @@ -37,8 +37,8 @@ private: std::unique_ptr ui; void setFcnName(RVA addr); - void get_refs_data(RVA addr); - void fill_refs(QList refs, QList xrefs, QList graph_data); + void updateRefs(RVA addr); + void fillRefs(QList refs, QList xrefs); void fillOffsetInfo(QString off); void setScrollMode();