diff --git a/src/dialogs/xrefsdialog.cpp b/src/dialogs/xrefsdialog.cpp index 00442ecc..af306c27 100644 --- a/src/dialogs/xrefsdialog.cpp +++ b/src/dialogs/xrefsdialog.cpp @@ -32,12 +32,15 @@ void XrefsDialog::fillRefs(QList refs, QList x ui->fromTreeWidget->clear(); for (int i = 0; i < refs.size(); ++i) { - //this->add_debug_output(refs.at(i).at(0) + " " + refs.at(i).at(1)); + XRefDescription xref = refs[i]; + QTreeWidgetItem *tempItem = new QTreeWidgetItem(); - tempItem->setText(0, RAddressString(refs.at(i).to)); - tempItem->setText(1, refs.at(i).opcode); + tempItem->setText(0, RAddressString(xref.to)); + tempItem->setText(1, main->core->disassembleSingleInstruction(xref.from)); + tempItem->setData(0, Qt::UserRole, QVariant::fromValue(xref)); //tempItem->setToolTip( 0, this->main->core->cmd("pdi 10 @ " + refs.at(i).at(0)) ); //tempItem->setToolTip( 1, this->main->core->cmd("pdi 10 @ " + refs.at(i).at(0)) ); + ui->fromTreeWidget->insertTopLevelItem(0, tempItem); } // Adjust columns to content @@ -50,12 +53,15 @@ void XrefsDialog::fillRefs(QList refs, QList x ui->toTreeWidget->clear(); for (int i = 0; i < xrefs.size(); ++i) { - //this->add_debug_output(xrefs.at(i).at(0) + " " + xrefs.at(i).at(1)); + XRefDescription xref = xrefs[i]; + QTreeWidgetItem *tempItem = new QTreeWidgetItem(); - tempItem->setText(0, RAddressString(xrefs.at(i).from)); - tempItem->setText(1, xrefs.at(i).opcode); + tempItem->setText(0, RAddressString(xref.from)); + tempItem->setText(1, main->core->disassembleSingleInstruction(xref.from)); + tempItem->setData(0, Qt::UserRole, QVariant::fromValue(xref)); //tempItem->setToolTip( 0, this->main->core->cmd("pdi 10 @ " + xrefs.at(i).at(0)) ); //tempItem->setToolTip( 1, this->main->core->cmd("pdi 10 @ " + xrefs.at(i).at(0)) ); + ui->toTreeWidget->insertTopLevelItem(0, tempItem); } // Adjust columns to content @@ -152,6 +158,21 @@ void XrefsDialog::on_toTreeWidget_itemSelectionChanged() void XrefsDialog::updateLabels(QString name) { - ui->label_2->setText(ui->label_2->text() + name); - ui->label_3->setText(ui->label_3->text() + name); + ui->label_2->setText(tr("X-Refs to %1:").arg(name)); + ui->label_3->setText(tr("X-Refs from %1:").arg(name)); } + +void XrefsDialog::fillRefsForFunction(RVA addr, QString name) +{ + setWindowTitle(tr("X-Refs for function %1").arg(name)); + updateLabels(name); + // Get Refs and Xrefs + + // refs = calls q hace esa funcion + QList refs = main->core->getXRefs(addr, false, "C"); + + // xrefs = calls a esa funcion + QList xrefs = main->core->getXRefs(addr, true); + + fillRefs(refs, xrefs); +} \ No newline at end of file diff --git a/src/dialogs/xrefsdialog.h b/src/dialogs/xrefsdialog.h index 6d54e15e..7af77b2d 100644 --- a/src/dialogs/xrefsdialog.h +++ b/src/dialogs/xrefsdialog.h @@ -22,8 +22,7 @@ public: explicit XrefsDialog(MainWindow *main, QWidget *parent = 0); ~XrefsDialog(); - void fillRefs(QList refs, QList xrefs); - void updateLabels(QString name); + void fillRefsForFunction(RVA addr, QString name); private slots: @@ -44,6 +43,9 @@ private: Highlighter *highlighter; + void fillRefs(QList refs, QList xrefs); + void updateLabels(QString name); + }; #endif // XREFSDIALOG_H diff --git a/src/qrcore.cpp b/src/qrcore.cpp index 2ab64d3b..df58d83c 100644 --- a/src/qrcore.cpp +++ b/src/qrcore.cpp @@ -398,6 +398,8 @@ bool QRCore::tryFile(QString path, bool rw) return true; } + + QList QRCore::getList(const QString &type, const QString &subtype) { CORE_LOCK(); @@ -563,6 +565,11 @@ QString QRCore::disassemble(const QString &hex) return code; } +QString QRCore::disassembleSingleInstruction(RVA addr) +{ + return cmd("pi 1@" + QString::number(addr)).simplified(); +} + RAnalFunction *QRCore::functionAt(ut64 addr) { CORE_LOCK(); @@ -1156,10 +1163,6 @@ QList QRCore::getXRefs(RVA addr, bool to, const QString &filter else xref.to = xrefObject["to"].toVariant().toULongLong(); - xref.opcode = xrefObject["opcode"].toString(); - - printf("xref %s %s\n", to ? "to" : "from", xref.opcode.toLocal8Bit().constData()); - ret << xref; } diff --git a/src/qrcore.h b/src/qrcore.h index 8bc73a49..237882e0 100644 --- a/src/qrcore.h +++ b/src/qrcore.h @@ -139,7 +139,6 @@ struct XRefDescription RVA from; RVA to; QString type; - QString opcode; }; Q_DECLARE_METATYPE(FunctionDescription) @@ -151,6 +150,7 @@ Q_DECLARE_METATYPE(RelocDescription) Q_DECLARE_METATYPE(StringDescription) Q_DECLARE_METATYPE(FlagspaceDescription) Q_DECLARE_METATYPE(FlagDescription) +Q_DECLARE_METATYPE(XRefDescription) class QRCore : public QObject { @@ -187,6 +187,7 @@ public: int config(const QString &k, int v); QString assemble(const QString &code); QString disassemble(const QString &hex); + QString disassembleSingleInstruction(RVA addr); void setDefaultCPU(); void setCPU(QString arch, QString cpu, int bits, bool temporary = false); RAnalFunction *functionAt(ut64 addr); diff --git a/src/widgets/functionswidget.cpp b/src/widgets/functionswidget.cpp index 77f6626d..72a23844 100644 --- a/src/widgets/functionswidget.cpp +++ b/src/widgets/functionswidget.cpp @@ -508,24 +508,8 @@ void FunctionsWidget::on_action_References_triggered() // Get selected item in functions tree view QTreeView *treeView = getCurrentTreeView(); FunctionDescription function = treeView->selectionModel()->currentIndex().data(FunctionModel::FunctionDescriptionRole).value(); - - //this->main->add_debug_output("Addr: " + address); - - // Get function for clicked offset - RAnalFunction *fcn = this->main->core->functionAt(function.offset); - XrefsDialog *x = new XrefsDialog(this->main, this); - x->setWindowTitle("X-Refs for function " + QString::fromUtf8(fcn->name)); - - // Get Refs and Xrefs - - // refs = calls q hace esa funcion - QList refs = main->core->getXRefs(fcn->addr, false, "C"); - - // xrefs = calls a esa funcion - QList xrefs = main->core->getXRefs(fcn->addr, true); - - x->fillRefs(refs, xrefs); + x->fillRefsForFunction(function.offset, function.name); x->exec(); } diff --git a/src/widgets/memorywidget.cpp b/src/widgets/memorywidget.cpp index c10db4df..7872dcbf 100644 --- a/src/widgets/memorywidget.cpp +++ b/src/widgets/memorywidget.cpp @@ -1876,18 +1876,7 @@ void MemoryWidget::on_actionXRefs_triggered() return; } XrefsDialog *x = new XrefsDialog(this->main, this); - x->setWindowTitle("X-Refs for function " + QString(fcn->name)); - x->updateLabels(QString(fcn->name)); - - // Get Refs and Xrefs - - // refs = calls q hace esa funcion - QList refs = main->core->getXRefs(fcn->addr, false, "C"); - - // xrefs = calls a esa funcion - QList xrefs = main->core->getXRefs(fcn->addr, true); - - x->fillRefs(refs, xrefs); + x->fillRefsForFunction(fcn->addr, QString::fromUtf8(fcn->name)); x->exec(); } } diff --git a/src/widgets/memorywidget.ui b/src/widgets/memorywidget.ui index 414318dd..fd1aa04c 100644 --- a/src/widgets/memorywidget.ui +++ b/src/widgets/memorywidget.ui @@ -6,7 +6,7 @@ 0 0 - 950 + 990 767 @@ -933,7 +933,7 @@ QToolTip { 0 - + 0 @@ -954,7 +954,7 @@ QToolTip { font: 11pt "Monaco"; } - + about:blank @@ -1229,16 +1229,16 @@ p, li { white-space: pre-wrap; } 0 - + Qt::DefaultContextMenu - + about:blank - + 1.000000000000000 @@ -1325,9 +1325,9 @@ border-top: 0px; 0 - 0 - 257 - 885 + -175 + 256 + 887 @@ -1629,7 +1629,7 @@ QToolTip { 0 - + 0 @@ -1648,7 +1648,7 @@ QToolTip { 250 - + qrc:/html/fcn_graph.html @@ -1678,7 +1678,7 @@ QToolTip { 0 - + 0 @@ -1697,7 +1697,7 @@ QToolTip { 250 - + qrc:/html/fcn_radar.html @@ -1770,11 +1770,6 @@ QToolTip { 175 - - - 11 - - QFrame::NoFrame @@ -1926,11 +1921,6 @@ color: rgb(0, 0, 0); 100 - - - 11 - - QTreeWidget::item { @@ -2036,11 +2026,6 @@ QToolTip { 100 - - - 11 - - QTreeWidget::item { @@ -3038,7 +3023,7 @@ QToolTip { QWebEngineView QWidget -
QtWebEngineWidgets/QWebEngineView
+
QtWebEngineWidgets/QWebEngineView
@@ -3046,8 +3031,8 @@ QToolTip { - - + +