mirror of
https://github.com/rizinorg/cutter.git
synced 2025-01-19 02:48:49 +00:00
Fix #68
This commit is contained in:
parent
b9a45ae00b
commit
e5859a8422
@ -35,6 +35,7 @@ XrefsDialog::~XrefsDialog() {}
|
|||||||
|
|
||||||
void XrefsDialog::fillRefs(QList<XrefDescription> refs, QList<XrefDescription> xrefs)
|
void XrefsDialog::fillRefs(QList<XrefDescription> refs, QList<XrefDescription> xrefs)
|
||||||
{
|
{
|
||||||
|
/* Fill refs */
|
||||||
ui->fromTreeWidget->clear();
|
ui->fromTreeWidget->clear();
|
||||||
for (int i = 0; i < refs.size(); ++i)
|
for (int i = 0; i < refs.size(); ++i)
|
||||||
{
|
{
|
||||||
@ -43,10 +44,10 @@ void XrefsDialog::fillRefs(QList<XrefDescription> refs, QList<XrefDescription> x
|
|||||||
QTreeWidgetItem *tempItem = new QTreeWidgetItem();
|
QTreeWidgetItem *tempItem = new QTreeWidgetItem();
|
||||||
tempItem->setText(0, RAddressString(xref.to));
|
tempItem->setText(0, RAddressString(xref.to));
|
||||||
tempItem->setText(1, core->disassembleSingleInstruction(xref.from));
|
tempItem->setText(1, core->disassembleSingleInstruction(xref.from));
|
||||||
|
tempItem->setText(2, xrefTypeString(xref.type));
|
||||||
tempItem->setData(0, Qt::UserRole, QVariant::fromValue(xref));
|
tempItem->setData(0, Qt::UserRole, QVariant::fromValue(xref));
|
||||||
//tempItem->setToolTip( 0, this->core->cmd("pdi 10 @ " + refs.at(i).at(0)) );
|
//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)) );
|
//tempItem->setToolTip( 1, this->core->cmd("pdi 10 @ " + refs.at(i).at(0)) );
|
||||||
|
|
||||||
ui->fromTreeWidget->insertTopLevelItem(0, tempItem);
|
ui->fromTreeWidget->insertTopLevelItem(0, tempItem);
|
||||||
}
|
}
|
||||||
// Adjust columns to content
|
// Adjust columns to content
|
||||||
@ -56,6 +57,7 @@ void XrefsDialog::fillRefs(QList<XrefDescription> refs, QList<XrefDescription> x
|
|||||||
ui->fromTreeWidget->resizeColumnToContents(i);
|
ui->fromTreeWidget->resizeColumnToContents(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Fill Xrefs */
|
||||||
ui->toTreeWidget->clear();
|
ui->toTreeWidget->clear();
|
||||||
for (int i = 0; i < xrefs.size(); ++i)
|
for (int i = 0; i < xrefs.size(); ++i)
|
||||||
{
|
{
|
||||||
@ -64,10 +66,10 @@ void XrefsDialog::fillRefs(QList<XrefDescription> refs, QList<XrefDescription> x
|
|||||||
QTreeWidgetItem *tempItem = new QTreeWidgetItem();
|
QTreeWidgetItem *tempItem = new QTreeWidgetItem();
|
||||||
tempItem->setText(0, RAddressString(xref.from));
|
tempItem->setText(0, RAddressString(xref.from));
|
||||||
tempItem->setText(1, core->disassembleSingleInstruction(xref.from));
|
tempItem->setText(1, core->disassembleSingleInstruction(xref.from));
|
||||||
|
tempItem->setText(2, xrefTypeString(xref.type));
|
||||||
tempItem->setData(0, Qt::UserRole, QVariant::fromValue(xref));
|
tempItem->setData(0, Qt::UserRole, QVariant::fromValue(xref));
|
||||||
//tempItem->setToolTip( 0, this->core->cmd("pdi 10 @ " + xrefs.at(i).at(0)) );
|
//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)) );
|
//tempItem->setToolTip( 1, this->core->cmd("pdi 10 @ " + xrefs.at(i).at(0)) );
|
||||||
|
|
||||||
ui->toTreeWidget->insertTopLevelItem(0, tempItem);
|
ui->toTreeWidget->insertTopLevelItem(0, tempItem);
|
||||||
}
|
}
|
||||||
// Adjust columns to content
|
// 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 XrefsDialog::normalizeAddr(const QString& addr) const
|
||||||
{
|
{
|
||||||
|
QString r = addr;
|
||||||
QString base = addr.split("0x")[1].trimmed();
|
QString base = addr.split("0x")[1].trimmed();
|
||||||
int len = base.length();
|
int len = base.length();
|
||||||
if (len < 8)
|
if (len < 8)
|
||||||
@ -106,13 +109,10 @@ QString XrefsDialog::normalizeAddr(const QString& addr) const
|
|||||||
int padding = 8 - len;
|
int padding = 8 - len;
|
||||||
QString zero = "0";
|
QString zero = "0";
|
||||||
QString zeroes = zero.repeated(padding);
|
QString zeroes = zero.repeated(padding);
|
||||||
QString s = "0x" + zeroes + base;
|
r = "0x" + zeroes + base;
|
||||||
return s;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return addr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
void XrefsDialog::setupPreviewFont()
|
void XrefsDialog::setupPreviewFont()
|
||||||
@ -218,3 +218,20 @@ void XrefsDialog::fillRefsForAddress(RVA addr, QString name, bool whole_function
|
|||||||
|
|
||||||
fillRefs(refs, xrefs);
|
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;
|
||||||
|
}
|
||||||
|
@ -49,6 +49,8 @@ private:
|
|||||||
void updateLabels(QString name);
|
void updateLabels(QString name);
|
||||||
void updatePreview(RVA addr);
|
void updatePreview(RVA addr);
|
||||||
|
|
||||||
|
QString xrefTypeString(const QString &type);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // XREFSDIALOG_H
|
#endif // XREFSDIALOG_H
|
||||||
|
@ -60,6 +60,9 @@
|
|||||||
<property name="indentation">
|
<property name="indentation">
|
||||||
<number>5</number>
|
<number>5</number>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="columnCount">
|
||||||
|
<number>3</number>
|
||||||
|
</property>
|
||||||
<column>
|
<column>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Address</string>
|
<string>Address</string>
|
||||||
@ -70,6 +73,11 @@
|
|||||||
<string>Code</string>
|
<string>Code</string>
|
||||||
</property>
|
</property>
|
||||||
</column>
|
</column>
|
||||||
|
<column>
|
||||||
|
<property name="text">
|
||||||
|
<string>Type</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
@ -90,6 +98,9 @@
|
|||||||
<property name="indentation">
|
<property name="indentation">
|
||||||
<number>5</number>
|
<number>5</number>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="columnCount">
|
||||||
|
<number>3</number>
|
||||||
|
</property>
|
||||||
<column>
|
<column>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Address</string>
|
<string>Address</string>
|
||||||
@ -100,6 +111,11 @@
|
|||||||
<string>Code</string>
|
<string>Code</string>
|
||||||
</property>
|
</property>
|
||||||
</column>
|
</column>
|
||||||
|
<column>
|
||||||
|
<property name="text">
|
||||||
|
<string>Type</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
Loading…
Reference in New Issue
Block a user