From e5859a8422da1df3f71e31b17928fb84aa1776ab Mon Sep 17 00:00:00 2001 From: xarkes Date: Mon, 27 Nov 2017 12:18:47 +0100 Subject: [PATCH] Fix #68 --- src/dialogs/XrefsDialog.cpp | 33 +++++++++++++++++++++++++-------- src/dialogs/XrefsDialog.h | 2 ++ src/dialogs/XrefsDialog.ui | 16 ++++++++++++++++ 3 files changed, 43 insertions(+), 8 deletions(-) diff --git a/src/dialogs/XrefsDialog.cpp b/src/dialogs/XrefsDialog.cpp index 388e8f5f..051d376c 100644 --- a/src/dialogs/XrefsDialog.cpp +++ b/src/dialogs/XrefsDialog.cpp @@ -35,6 +35,7 @@ XrefsDialog::~XrefsDialog() {} void XrefsDialog::fillRefs(QList refs, QList xrefs) { + /* Fill refs */ ui->fromTreeWidget->clear(); for (int i = 0; i < refs.size(); ++i) { @@ -43,10 +44,10 @@ void XrefsDialog::fillRefs(QList refs, QList x QTreeWidgetItem *tempItem = new QTreeWidgetItem(); tempItem->setText(0, RAddressString(xref.to)); tempItem->setText(1, core->disassembleSingleInstruction(xref.from)); + tempItem->setText(2, xrefTypeString(xref.type)); tempItem->setData(0, Qt::UserRole, QVariant::fromValue(xref)); //tempItem->setToolTip( 0, this->core->cmd("pdi 10 @ " + refs.at(i).at(0)) ); //tempItem->setToolTip( 1, this->core->cmd("pdi 10 @ " + refs.at(i).at(0)) ); - ui->fromTreeWidget->insertTopLevelItem(0, tempItem); } // Adjust columns to content @@ -56,6 +57,7 @@ void XrefsDialog::fillRefs(QList refs, QList x ui->fromTreeWidget->resizeColumnToContents(i); } + /* Fill Xrefs */ ui->toTreeWidget->clear(); for (int i = 0; i < xrefs.size(); ++i) { @@ -64,10 +66,10 @@ void XrefsDialog::fillRefs(QList refs, QList x QTreeWidgetItem *tempItem = new QTreeWidgetItem(); tempItem->setText(0, RAddressString(xref.from)); tempItem->setText(1, core->disassembleSingleInstruction(xref.from)); + tempItem->setText(2, xrefTypeString(xref.type)); tempItem->setData(0, Qt::UserRole, QVariant::fromValue(xref)); //tempItem->setToolTip( 0, this->core->cmd("pdi 10 @ " + xrefs.at(i).at(0)) ); //tempItem->setToolTip( 1, this->core->cmd("pdi 10 @ " + xrefs.at(i).at(0)) ); - ui->toTreeWidget->insertTopLevelItem(0, tempItem); } // Adjust columns to content @@ -99,6 +101,7 @@ void XrefsDialog::on_toTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int c QString XrefsDialog::normalizeAddr(const QString& addr) const { + QString r = addr; QString base = addr.split("0x")[1].trimmed(); int len = base.length(); if (len < 8) @@ -106,13 +109,10 @@ QString XrefsDialog::normalizeAddr(const QString& addr) const int padding = 8 - len; QString zero = "0"; QString zeroes = zero.repeated(padding); - QString s = "0x" + zeroes + base; - return s; - } - else - { - return addr; + r = "0x" + zeroes + base; } + + return r; } void XrefsDialog::setupPreviewFont() @@ -218,3 +218,20 @@ void XrefsDialog::fillRefsForAddress(RVA addr, QString name, bool whole_function fillRefs(refs, xrefs); } + +QString XrefsDialog::xrefTypeString(const QString &type) +{ + switch (type.toStdString()[0]) { + case R_ANAL_REF_TYPE_CALL: + return QString("Call"); + case R_ANAL_REF_TYPE_CODE: + return QString("Code"); + case R_ANAL_REF_TYPE_DATA: + return QString("Data"); + case R_ANAL_REF_TYPE_NULL: + return QString(""); + case R_ANAL_REF_TYPE_STRING: + return QString("String"); + } + return type; +} diff --git a/src/dialogs/XrefsDialog.h b/src/dialogs/XrefsDialog.h index d1b7eb29..8faaf0ae 100644 --- a/src/dialogs/XrefsDialog.h +++ b/src/dialogs/XrefsDialog.h @@ -49,6 +49,8 @@ private: void updateLabels(QString name); void updatePreview(RVA addr); + QString xrefTypeString(const QString &type); + }; #endif // XREFSDIALOG_H diff --git a/src/dialogs/XrefsDialog.ui b/src/dialogs/XrefsDialog.ui index a22eebdd..e80aaf14 100644 --- a/src/dialogs/XrefsDialog.ui +++ b/src/dialogs/XrefsDialog.ui @@ -60,6 +60,9 @@ 5 + + 3 + Address @@ -70,6 +73,11 @@ Code + + + Type + + @@ -90,6 +98,9 @@ 5 + + 3 + Address @@ -100,6 +111,11 @@ Code + + + Type + +