Fix XrefsDialog, X-Refs in Sidebar from JSON

This commit is contained in:
Florian Märkl 2017-06-07 21:35:38 +02:00 committed by radare
parent 132cebf8a1
commit f35ce99495
9 changed files with 127 additions and 191 deletions

View File

@ -3,10 +3,15 @@
#include "mainwindow.h" #include "mainwindow.h"
#include <QJsonArray>
XrefsDialog::XrefsDialog(MainWindow *main, QWidget *parent) : XrefsDialog::XrefsDialog(MainWindow *main, QWidget *parent) :
QDialog(parent), QDialog(parent),
ui(new Ui::XrefsDialog) ui(new Ui::XrefsDialog)
{ {
addr = 0;
func_name = QString::null;
ui->setupUi(this); ui->setupUi(this);
setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint)); setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint));
this->main = main; this->main = main;
@ -27,12 +32,12 @@ XrefsDialog::~XrefsDialog()
delete ui; delete ui;
} }
void XrefsDialog::fillRefs(QList<XRefDescription> refs, QList<XRefDescription> xrefs) void XrefsDialog::fillRefs(QList<XrefDescription> refs, QList<XrefDescription> xrefs)
{ {
ui->fromTreeWidget->clear(); ui->fromTreeWidget->clear();
for (int i = 0; i < refs.size(); ++i) for (int i = 0; i < refs.size(); ++i)
{ {
XRefDescription xref = refs[i]; XrefDescription xref = refs[i];
QTreeWidgetItem *tempItem = new QTreeWidgetItem(); QTreeWidgetItem *tempItem = new QTreeWidgetItem();
tempItem->setText(0, RAddressString(xref.to)); tempItem->setText(0, RAddressString(xref.to));
@ -53,7 +58,7 @@ void XrefsDialog::fillRefs(QList<XRefDescription> refs, QList<XRefDescription> x
ui->toTreeWidget->clear(); ui->toTreeWidget->clear();
for (int i = 0; i < xrefs.size(); ++i) for (int i = 0; i < xrefs.size(); ++i)
{ {
XRefDescription xref = xrefs[i]; XrefDescription xref = xrefs[i];
QTreeWidgetItem *tempItem = new QTreeWidgetItem(); QTreeWidgetItem *tempItem = new QTreeWidgetItem();
tempItem->setText(0, RAddressString(xref.from)); tempItem->setText(0, RAddressString(xref.from));
@ -77,10 +82,10 @@ void XrefsDialog::on_fromTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int
{ {
QNOTUSED(column); QNOTUSED(column);
QString offset = item->text(0); XrefDescription xref = item->data(0, Qt::UserRole).value<XrefDescription>();
RAnalFunction *fcn = this->main->core->functionAt(offset.toLongLong(0, 16)); RAnalFunction *fcn = this->main->core->functionAt(xref.to);
//this->add_debug_output( fcn->name ); this->main->seek(xref.to, fcn ? QString::fromUtf8(fcn->name) : QString::null, true);
this->main->seek(offset, fcn->name);
this->close(); this->close();
} }
@ -88,10 +93,10 @@ void XrefsDialog::on_toTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int c
{ {
QNOTUSED(column); QNOTUSED(column);
QString offset = item->text(0); XrefDescription xref = item->data(0, Qt::UserRole).value<XrefDescription>();
RAnalFunction *fcn = this->main->core->functionAt(offset.toLongLong(0, 16)); RAnalFunction *fcn = this->main->core->functionAt(xref.from);
//this->add_debug_output( fcn->name ); this->main->seek(xref.from, fcn ? QString::fromUtf8(fcn->name) : QString::null, true);
this->main->seek(offset, fcn->name);
this->close(); this->close();
} }
@ -135,24 +140,39 @@ void XrefsDialog::highlightCurrentLine()
void XrefsDialog::on_fromTreeWidget_itemSelectionChanged() void XrefsDialog::on_fromTreeWidget_itemSelectionChanged()
{ {
if (ui->fromTreeWidget->selectedItems().isEmpty())
return;
ui->toTreeWidget->clearSelection();
QTreeWidgetItem *item = ui->fromTreeWidget->currentItem(); QTreeWidgetItem *item = ui->fromTreeWidget->currentItem();
QString offset = item->text(0); XrefDescription xref = item->data(0, Qt::UserRole).value<XrefDescription>();
ui->previewTextEdit->setPlainText(this->main->core->cmd("pdf @ " + offset).trimmed()); updatePreview(xref.to);
ui->previewTextEdit->moveCursor(QTextCursor::End);
// Does it make any sense?
ui->previewTextEdit->find(this->normalizeAddr(offset), QTextDocument::FindBackward);
ui->previewTextEdit->moveCursor(QTextCursor::StartOfWord, QTextCursor::MoveAnchor);
} }
void XrefsDialog::on_toTreeWidget_itemSelectionChanged() void XrefsDialog::on_toTreeWidget_itemSelectionChanged()
{ {
if (ui->toTreeWidget->selectedItems().isEmpty())
return;
ui->fromTreeWidget->clearSelection();
QTreeWidgetItem *item = ui->toTreeWidget->currentItem(); QTreeWidgetItem *item = ui->toTreeWidget->currentItem();
QString offset = item->text(0); XrefDescription xref = item->data(0, Qt::UserRole).value<XrefDescription>();
ui->previewTextEdit->setPlainText(this->main->core->cmd("pdf @ " + offset).trimmed()); updatePreview(xref.from);
}
void XrefsDialog::updatePreview(RVA addr)
{
QString disass;
// is the address part of a function, so we can use pdf?
if (!main->core->cmdj("afij@" + QString::number(addr)).array().isEmpty())
disass = main->core->cmd("pdf @ " + QString::number(addr));
else
disass = main->core->cmd("pd 10 @ " + QString::number(addr));
ui->previewTextEdit->setPlainText(disass.trimmed());
// Does it make any sense?
ui->previewTextEdit->moveCursor(QTextCursor::End); ui->previewTextEdit->moveCursor(QTextCursor::End);
// Again, does it make any sense? ui->previewTextEdit->find(this->normalizeAddr(RAddressString(addr)), QTextDocument::FindBackward);
// Also, this code should be refactored and shared instead of copied & pasted
ui->previewTextEdit->find(this->normalizeAddr(offset), QTextDocument::FindBackward);
ui->previewTextEdit->moveCursor(QTextCursor::StartOfWord, QTextCursor::MoveAnchor); ui->previewTextEdit->moveCursor(QTextCursor::StartOfWord, QTextCursor::MoveAnchor);
} }
@ -164,15 +184,18 @@ void XrefsDialog::updateLabels(QString name)
void XrefsDialog::fillRefsForFunction(RVA addr, QString name) void XrefsDialog::fillRefsForFunction(RVA addr, QString name)
{ {
this->addr = addr;
this->func_name = func_name;
setWindowTitle(tr("X-Refs for function %1").arg(name)); setWindowTitle(tr("X-Refs for function %1").arg(name));
updateLabels(name); updateLabels(name);
// Get Refs and Xrefs // Get Refs and Xrefs
// refs = calls q hace esa funcion // refs = calls q hace esa funcion
QList<XRefDescription> refs = main->core->getXRefs(addr, false, "C"); QList<XrefDescription> refs = main->core->getXRefs(addr, false, "C");
// xrefs = calls a esa funcion // xrefs = calls a esa funcion
QList<XRefDescription> xrefs = main->core->getXRefs(addr, true); QList<XrefDescription> xrefs = main->core->getXRefs(addr, true);
fillRefs(refs, xrefs); fillRefs(refs, xrefs);
} }

View File

@ -38,13 +38,17 @@ private slots:
void on_toTreeWidget_itemSelectionChanged(); void on_toTreeWidget_itemSelectionChanged();
private: private:
RVA addr;
QString func_name;
Ui::XrefsDialog *ui; Ui::XrefsDialog *ui;
MainWindow *main; MainWindow *main;
Highlighter *highlighter; Highlighter *highlighter;
void fillRefs(QList<XRefDescription> refs, QList<XRefDescription> xrefs); void fillRefs(QList<XrefDescription> refs, QList<XrefDescription> xrefs);
void updateLabels(QString name); void updateLabels(QString name);
void updatePreview(RVA addr);
}; };

View File

@ -327,7 +327,6 @@ void MainWindow::finalizeOpen()
core->cmd("fs sections"); core->cmd("fs sections");
updateFrames(); updateFrames();
get_refs(core->cmd("?v entry0"));
memoryDock->selectHexPreview(); memoryDock->selectHexPreview();
// Restore project notes // Restore project notes
@ -770,7 +769,7 @@ void MainWindow::seek(const RVA offset, const QString &name, bool raise_memory_d
core->seek(offset); core->seek(offset);
setCursorAddress(offset); setCursorAddress(offset);
refreshMem(offset); refreshMem();
this->memoryDock->disasTextEdit->setFocus(); this->memoryDock->disasTextEdit->setFocus();
// Rise and shine baby! // Rise and shine baby!
@ -781,22 +780,8 @@ void MainWindow::seek(const RVA offset, const QString &name, bool raise_memory_d
void MainWindow::refreshMem() void MainWindow::refreshMem()
{ {
this->memoryDock->updateViews(); this->memoryDock->updateViews();
} }
void MainWindow::refreshMem(RVA offset)
{
//add_debug_output("Refreshing to: " + off);
//graphicsBar->refreshColorBar();
/*
this->memoryDock->refreshDisasm(off);
this->memoryDock->refreshHexdump(off);
this->memoryDock->create_graph(off);
*/
refreshMem();
this->memoryDock->get_refs_data(RAddressString(offset));
//this->memoryDock->setFcnName(offset);
}
void MainWindow::on_backButton_clicked() void MainWindow::on_backButton_clicked()
{ {
@ -922,11 +907,6 @@ void MainWindow::on_actionFunctionsRename_triggered()
r->open(); r->open();
} }
void MainWindow::get_refs(const QString &offset)
{
this->memoryDock->get_refs_data(offset);
}
void MainWindow::addOutput(const QString &msg) void MainWindow::addOutput(const QString &msg)
{ {
consoleWidget->addOutput(msg); consoleWidget->addOutput(msg);

View File

@ -71,7 +71,6 @@ public:
void updateFrames(); void updateFrames();
void refreshFunctions(); void refreshFunctions();
void refreshComments(); void refreshComments();
void get_refs(const QString &offset);
void addOutput(const QString &msg); void addOutput(const QString &msg);
void addDebugOutput(const QString &msg); void addDebugOutput(const QString &msg);
void sendToNotepad(const QString &txt); void sendToNotepad(const QString &txt);
@ -180,7 +179,6 @@ private:
bool doLock; bool doLock;
void refreshMem(); void refreshMem();
void refreshMem(RVA offset);
ut64 hexdumpTopOffset; ut64 hexdumpTopOffset;
ut64 hexdumpBottomOffset; ut64 hexdumpBottomOffset;
QString filename; QString filename;

View File

@ -463,15 +463,13 @@ int QRCore::fcnBasicBlockCount(ut64 addr)
return 0; return 0;
} }
int QRCore::fcnEndBbs(QString addr) int QRCore::fcnEndBbs(RVA addr)
{ {
CORE_LOCK(); CORE_LOCK();
bool ok; RAnalFunction *fcn = r_anal_get_fcn_in(core_->anal, addr, 0);
int offset = addr.toLong(&ok, 16);
RAnalFunction *fcn = r_anal_get_fcn_in(core_->anal, offset, 0);
if (fcn) if (fcn)
{ {
QString tmp = this->cmd("afi @ " + addr + " ~end-bbs").split("\n")[0]; QString tmp = this->cmd("afi @ " + QString::number(addr) + " ~end-bbs").split("\n")[0];
if (tmp.contains(":")) if (tmp.contains(":"))
{ {
QString endbbs = tmp.split(": ")[1]; QString endbbs = tmp.split(": ")[1];
@ -1092,52 +1090,9 @@ QList<SectionDescription> QRCore::getAllSections()
return ret; return ret;
} }
QList<XrefDescription> QRCore::getXRefs(RVA addr, bool to, const QString &filterType)
QList<QString> QRCore::getFunctionXrefs(ut64 addr)
{ {
CORE_LOCK(); QList<XrefDescription> ret = QList<XrefDescription>();
QList<QString> ret = QList<QString>();
RList *list = r_anal_xrefs_get(core_->anal, addr);
RAnalRef *ref;
RListIter *it;
QRListForeach(list, it, RAnalRef, ref)
{
ret << QString("%1,0x%2,0x%3").arg(
QString(ref->type),
QString::number(ref->addr, 16),
QString::number(ref->at, 16));
}
return ret;
}
QList<QString> QRCore::getFunctionRefs(ut64 addr, char type)
{
CORE_LOCK();
QList<QString> ret = QList<QString>();
//RAnalFunction *fcn = r_anal_get_fcn_at(core_->anal, addr, addr);
RAnalFunction *fcn = r_anal_get_fcn_in(core_->anal, addr, 0);
if (!fcn)
{
eprintf("qcore->getFunctionRefs: No function found\n");
return ret;
}
//eprintf(fcn->name);
RAnalRef *ref;
RListIter *it;
QRListForeach(fcn->refs, it, RAnalRef, ref)
{
if (type == ref->type || type == 0)
ret << QString("%1,0x%2,0x%3").arg(
QString(ref->type),
QString::number(ref->addr, 16),
QString::number(ref->at, 16));
}
return ret;
}
QList<XRefDescription> QRCore::getXRefs(RVA addr, bool to, const QString &filterType)
{
QList<XRefDescription> ret = QList<XRefDescription>();
QJsonArray xrefsArray; QJsonArray xrefsArray;
@ -1150,7 +1105,7 @@ QList<XRefDescription> QRCore::getXRefs(RVA addr, bool to, const QString &filter
{ {
QJsonObject xrefObject = value.toObject(); QJsonObject xrefObject = value.toObject();
XRefDescription xref; XrefDescription xref;
xref.type = xrefObject["type"].toString(); xref.type = xrefObject["type"].toString();
if (!filterType.isNull() && filterType != xref.type) if (!filterType.isNull() && filterType != xref.type)

View File

@ -134,7 +134,7 @@ struct SectionDescription
QString flags; QString flags;
}; };
struct XRefDescription struct XrefDescription
{ {
RVA from; RVA from;
RVA to; RVA to;
@ -150,7 +150,7 @@ Q_DECLARE_METATYPE(RelocDescription)
Q_DECLARE_METATYPE(StringDescription) Q_DECLARE_METATYPE(StringDescription)
Q_DECLARE_METATYPE(FlagspaceDescription) Q_DECLARE_METATYPE(FlagspaceDescription)
Q_DECLARE_METATYPE(FlagDescription) Q_DECLARE_METATYPE(FlagDescription)
Q_DECLARE_METATYPE(XRefDescription) Q_DECLARE_METATYPE(XrefDescription)
class QRCore : public QObject class QRCore : public QObject
{ {
@ -167,7 +167,7 @@ public:
int getFcnSize(ut64 addr); int getFcnSize(ut64 addr);
int fcnCyclomaticComplexity(ut64 addr); int fcnCyclomaticComplexity(ut64 addr);
int fcnBasicBlockCount(ut64 addr); int fcnBasicBlockCount(ut64 addr);
int fcnEndBbs(QString addr); int fcnEndBbs(RVA addr);
QString cmd(const QString &str); QString cmd(const QString &str);
QJsonDocument cmdj(const QString &str); QJsonDocument cmdj(const QString &str);
void renameFunction(QString prev_name, QString new_name); void renameFunction(QString prev_name, QString new_name);
@ -234,10 +234,7 @@ public:
QList<FlagDescription> getAllFlags(QString flagspace = NULL); QList<FlagDescription> getAllFlags(QString flagspace = NULL);
QList<SectionDescription> getAllSections(); QList<SectionDescription> getAllSections();
QList<XrefDescription> getXRefs(RVA addr, bool to, const QString &filterType = QString::null);
QList<QString> getFunctionXrefs(ut64 addr);
QList<QString> getFunctionRefs(ut64 addr, char type);
QList<XRefDescription> getXRefs(RVA addr, bool to, const QString &filterType = QString::null);
RCoreLocked core() const; RCoreLocked core() const;

View File

@ -202,6 +202,7 @@ MemoryWidget::MemoryWidget(MainWindow *main) :
void MemoryWidget::on_cursorAddressChanged(RVA addr) void MemoryWidget::on_cursorAddressChanged(RVA addr)
{ {
setFcnName(addr); setFcnName(addr);
get_refs_data(addr);
} }
/* /*
@ -404,7 +405,7 @@ void MemoryWidget::setup()
refreshDisasm(off); refreshDisasm(off);
refreshHexdump(off); refreshHexdump(off);
create_graph(off); create_graph(off);
get_refs_data(off); get_refs_data(off.toLongLong(0, 16));
//setFcnName(off); //setFcnName(off);
} }
@ -1296,7 +1297,6 @@ void MemoryWidget::on_actionFunctionsRename_triggered()
this->main->core->renameFunction(fcn->name, new_name); this->main->core->renameFunction(fcn->name, new_name);
// Seek to new renamed function // Seek to new renamed function
this->main->seek(new_name); this->main->seek(new_name);
// TODO: Refresh functions tree widget
} }
} }
this->main->refreshFunctions(); this->main->refreshFunctions();
@ -1346,18 +1346,16 @@ void MemoryWidget::on_action1column_triggered()
void MemoryWidget::on_xreFromTreeWidget_2_itemDoubleClicked(QTreeWidgetItem *item, int /*column*/) void MemoryWidget::on_xreFromTreeWidget_2_itemDoubleClicked(QTreeWidgetItem *item, int /*column*/)
{ {
QString offset = item->text(0); XrefDescription xref = item->data(0, Qt::UserRole).value<XrefDescription>();
RAnalFunction *fcn = this->main->core->functionAt(offset.toLongLong(0, 16)); RAnalFunction *fcn = this->main->core->functionAt(xref.to);
//this->add_debug_output( fcn->name ); this->main->seek(xref.to, fcn ? QString::fromUtf8(fcn->name) : QString::null, true);
this->main->seek(offset, fcn->name);
} }
void MemoryWidget::on_xrefToTreeWidget_2_itemDoubleClicked(QTreeWidgetItem *item, int /*column*/) void MemoryWidget::on_xrefToTreeWidget_2_itemDoubleClicked(QTreeWidgetItem *item, int /*column*/)
{ {
QString offset = item->text(0); XrefDescription xref = item->data(0, Qt::UserRole).value<XrefDescription>();
RAnalFunction *fcn = this->main->core->functionAt(offset.toLongLong(0, 16)); RAnalFunction *fcn = this->main->core->functionAt(xref.from);
//this->add_debug_output( fcn->name ); this->main->seek(xref.from, fcn ? QString::fromUtf8(fcn->name) : QString::null, true);
this->main->seek(offset, fcn->name);
} }
void MemoryWidget::on_xrefFromToolButton_2_clicked() void MemoryWidget::on_xrefFromToolButton_2_clicked()
@ -1402,47 +1400,13 @@ void MemoryWidget::on_codeCombo_2_currentTextChanged(const QString &arg1)
} }
} }
void MemoryWidget::get_refs_data(const QString &offset) void MemoryWidget::get_refs_data(RVA addr)
{ {
// Get Refs and Xrefs
bool ok;
QList<QStringList> ret_refs;
QList<QStringList> ret_xrefs;
// refs = calls q hace esa funcion // refs = calls q hace esa funcion
QList<QString> refs = this->main->core->getFunctionRefs(offset.toLong(&ok, 16), 'C'); QList<XrefDescription> refs = main->core->getXRefs(addr, false, "C");
if (refs.size() > 0)
{
for (int i = 0; i < refs.size(); ++i)
{
//this->add_debug_output(refs.at(i));
QStringList retlist = refs.at(i).split(",");
QStringList temp;
QString addr = retlist.at(2);
temp << addr;
QString op = this->main->core->cmd("pi 1 @ " + addr);
temp << op.simplified();
ret_refs << temp;
}
}
// xrefs = calls a esa funcion // xrefs = calls a esa funcion
//qDebug() << this->main->core->getFunctionXrefs(offset.toLong(&ok, 16)); QList<XrefDescription> xrefs = main->core->getXRefs(addr, true);
QList<QString> xrefs = this->main->core->getFunctionXrefs(offset.toLong(&ok, 16));
if (xrefs.size() > 0)
{
for (int i = 0; i < xrefs.size(); ++i)
{
//this->add_debug_output(xrefs.at(i));
QStringList retlist = xrefs.at(i).split(",");
QStringList temp;
QString addr = retlist.at(1);
temp << addr;
QString op = this->main->core->cmd("pi 1 @ " + addr);
temp << op.simplified();
ret_xrefs << temp;
}
}
// Data for the disasm side graph // Data for the disasm side graph
QList<int> data; QList<int> data;
@ -1452,27 +1416,29 @@ void MemoryWidget::get_refs_data(const QString &offset)
data << xrefs.size(); data << xrefs.size();
//qDebug() << "CC: " << this->main->core->fcnCyclomaticComplexity(offset.toLong(&ok, 16)); //qDebug() << "CC: " << this->main->core->fcnCyclomaticComplexity(offset.toLong(&ok, 16));
//data << this->main->core->fcnCyclomaticComplexity(offset.toLong(&ok, 16)); //data << this->main->core->fcnCyclomaticComplexity(offset.toLong(&ok, 16));
data << this->main->core->getCycloComplex(offset.toLong(&ok, 16)); data << this->main->core->getCycloComplex(addr);
//qDebug() << "BB: " << this->main->core->fcnBasicBlockCount(offset.toLong(&ok, 16)); //qDebug() << "BB: " << this->main->core->fcnBasicBlockCount(offset.toLong(&ok, 16));
data << this->main->core->fcnBasicBlockCount(offset.toLong(&ok, 16)); data << this->main->core->fcnBasicBlockCount(addr);
data << this->main->core->fcnEndBbs(offset); data << this->main->core->fcnEndBbs(addr);
//qDebug() << "MEOW: " + this->main->core->fcnEndBbs(offset); //qDebug() << "MEOW: " + this->main->core->fcnEndBbs(offset);
// Update disasm side bar // Update disasm side bar
this->fill_refs(ret_refs, ret_xrefs, data); this->fill_refs(refs, xrefs, data);
} }
void MemoryWidget::fill_refs(QList<QStringList> refs, QList<QStringList> xrefs, QList<int> graph_data) void MemoryWidget::fill_refs(QList<XrefDescription> refs, QList<XrefDescription> xrefs, QList<int> graph_data)
{ {
this->xreFromTreeWidget_2->clear(); this->xreFromTreeWidget_2->clear();
for (int i = 0; i < refs.size(); ++i) 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(); QTreeWidgetItem *tempItem = new QTreeWidgetItem();
tempItem->setText(0, refs.at(i).at(0)); tempItem->setText(0, RAddressString(xref.to));
tempItem->setText(1, refs.at(i).at(1)); tempItem->setText(1, main->core->disassembleSingleInstruction(xref.from));
tempItem->setToolTip(0, this->main->core->cmd("pdi 10 @ " + refs.at(i).at(0)).trimmed()); tempItem->setData(0, Qt::UserRole, QVariant::fromValue(xref));
tempItem->setToolTip(1, this->main->core->cmd("pdi 10 @ " + refs.at(i).at(0)).trimmed()); QString tooltip = this->main->core->cmd("pdi 10 @ " + QString::number(xref.to)).trimmed();
tempItem->setToolTip(0, tooltip);
tempItem->setToolTip(1, tooltip);
this->xreFromTreeWidget_2->insertTopLevelItem(0, tempItem); this->xreFromTreeWidget_2->insertTopLevelItem(0, tempItem);
} }
// Adjust columns to content // Adjust columns to content
@ -1485,12 +1451,15 @@ void MemoryWidget::fill_refs(QList<QStringList> refs, QList<QStringList> xrefs,
this->xrefToTreeWidget_2->clear(); this->xrefToTreeWidget_2->clear();
for (int i = 0; i < xrefs.size(); ++i) 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(); QTreeWidgetItem *tempItem = new QTreeWidgetItem();
tempItem->setText(0, xrefs.at(i).at(0)); tempItem->setText(0, RAddressString(xref.from));
tempItem->setText(1, xrefs.at(i).at(1)); tempItem->setText(1, main->core->disassembleSingleInstruction(xref.from));
tempItem->setToolTip(0, this->main->core->cmd("pdi 10 @ " + xrefs.at(i).at(0)).trimmed()); tempItem->setData(0, Qt::UserRole, QVariant::fromValue(xref));
tempItem->setToolTip(1, this->main->core->cmd("pdi 10 @ " + xrefs.at(i).at(0)).trimmed()); QString tooltip = this->main->core->cmd("pdi 10 @ " + QString::number(xref.from)).trimmed();
tempItem->setToolTip(0, this->main->core->cmd("pdi 10 @ " + tooltip).trimmed());
tempItem->setToolTip(1, this->main->core->cmd("pdi 10 @ " + tooltip).trimmed());
this->xrefToTreeWidget_2->insertTopLevelItem(0, tempItem); this->xrefToTreeWidget_2->insertTopLevelItem(0, tempItem);
} }
// Adjust columns to content // Adjust columns to content
@ -1670,7 +1639,6 @@ void MemoryWidget::on_disasTextEdit_2_cursorPositionChanged()
// Refresh function information at sidebar // Refresh function information at sidebar
ui->fcnNameEdit->setText(at); ui->fcnNameEdit->setText(at);
this->main->memoryDock->setWindowTitle(at); this->main->memoryDock->setWindowTitle(at);
this->main->memoryDock->get_refs_data(ele);
//this->main->memoryDock->create_graph(ele); //this->main->memoryDock->create_graph(ele);
this->setMiniGraph(at); this->setMiniGraph(at);
} }

View File

@ -70,12 +70,10 @@ public slots:
void refreshHexdump(const QString &where = QString()); void refreshHexdump(const QString &where = QString());
void fill_refs(QList<QStringList> refs, QList<QStringList> xrefs, QList<int> graph_data); void fill_refs(QList<XrefDescription> refs, QList<XrefDescription> xrefs, QList<int> graph_data);
void fillOffsetInfo(QString off); void fillOffsetInfo(QString off);
void get_refs_data(const QString &offset);
void seek_to(const QString &offset); void seek_to(const QString &offset);
void create_graph(QString off); void create_graph(QString off);
@ -112,6 +110,7 @@ private:
RVA last_hexdump_fcn; RVA last_hexdump_fcn;
void setFcnName(RVA addr); void setFcnName(RVA addr);
void get_refs_data(RVA addr);
void setScrollMode(); void setScrollMode();

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>990</width> <width>1078</width>
<height>767</height> <height>815</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@ -1325,7 +1325,7 @@ border-top: 0px;
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>-175</y> <y>-127</y>
<width>256</width> <width>256</width>
<height>887</height> <height>887</height>
</rect> </rect>
@ -1866,20 +1866,17 @@ color: rgb(0, 0, 0);</string>
</widget> </widget>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_15"> <layout class="QHBoxLayout" name="horizontalLayout_16">
<property name="spacing"> <property name="spacing">
<number>5</number> <number>5</number>
</property> </property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin"> <property name="topMargin">
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
<widget class="QToolButton" name="xrefFromToolButton_2"> <widget class="QToolButton" name="xrefToToolButton_2">
<property name="text"> <property name="text">
<string/> <string>...</string>
</property> </property>
<property name="iconSize"> <property name="iconSize">
<size> <size>
@ -1899,16 +1896,22 @@ color: rgb(0, 0, 0);</string>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="xrefFromLabel_2"> <widget class="QLabel" name="xrefToLabel_2">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text"> <property name="text">
<string>&lt;b&gt;Xrefs from:&lt;/b&gt;</string> <string>X-Refs to current address:</string>
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</item> </item>
<item> <item>
<widget class="QTreeWidget" name="xreFromTreeWidget_2"> <widget class="QTreeWidget" name="xrefToTreeWidget_2">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding"> <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -1974,17 +1977,20 @@ QToolTip {
</widget> </widget>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_16"> <layout class="QHBoxLayout" name="horizontalLayout_15">
<property name="spacing"> <property name="spacing">
<number>5</number> <number>5</number>
</property> </property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin"> <property name="topMargin">
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
<widget class="QToolButton" name="xrefToToolButton_2"> <widget class="QToolButton" name="xrefFromToolButton_2">
<property name="text"> <property name="text">
<string>...</string> <string/>
</property> </property>
<property name="iconSize"> <property name="iconSize">
<size> <size>
@ -2004,16 +2010,22 @@ QToolTip {
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="xrefToLabel_2"> <widget class="QLabel" name="xrefFromLabel_2">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text"> <property name="text">
<string>&lt;b&gt;Xrefs To:&lt;/b&gt;</string> <string>X-Refs from current address:</string>
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</item> </item>
<item> <item>
<widget class="QTreeWidget" name="xrefToTreeWidget_2"> <widget class="QTreeWidget" name="xreFromTreeWidget_2">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding"> <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -3031,8 +3043,8 @@ QToolTip {
</resources> </resources>
<connections/> <connections/>
<buttongroups> <buttongroups>
<buttongroup name="buttonGroup_2"/>
<buttongroup name="buttonGroup"/> <buttongroup name="buttonGroup"/>
<buttongroup name="buttonGroup_3"/> <buttongroup name="buttonGroup_3"/>
<buttongroup name="buttonGroup_2"/>
</buttongroups> </buttongroups>
</ui> </ui>