Add information about register used in a function #381 (#442)

* Add information about register used in a function #381
This commit is contained in:
rrreeezzz 2018-04-18 10:13:08 +01:00 committed by xarkes
parent d5bd3aa2cf
commit 6642f60f75
5 changed files with 132 additions and 1 deletions

View File

@ -671,6 +671,11 @@ QString CutterCore::getOffsetInfo(QString addr)
return cmd("ao @ " + addr);
}
QJsonDocument CutterCore::getRegistersInfo()
{
return cmdj("aeafj");
}
RVA CutterCore::getOffsetJump(RVA addr)
{
bool ok;

View File

@ -385,6 +385,7 @@ public:
ulong get_baddr();
QList<QList<QString>> get_exec_sections();
QString getOffsetInfo(QString addr);
QJsonDocument getRegistersInfo();
RVA getOffsetJump(RVA addr);
QString getDecompiledCode(RVA addr);
QString getDecompiledCode(QString addr);

View File

@ -14,7 +14,8 @@
#include <QFont>
#include <QUrl>
#include <QSettings>
#include <QJsonObject>
#include <QJsonArray>
SidebarWidget::SidebarWidget(MainWindow *main, QAction *action) :
CutterDockWidget(main, action),
@ -52,6 +53,7 @@ void SidebarWidget::refresh(RVA addr)
updateRefs(addr);
setFcnName(addr);
fillOffsetInfo(RAddressString(addr));
fillRegistersInfo();
}
void SidebarWidget::on_xrefFromTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int /*column*/)
@ -110,6 +112,17 @@ void SidebarWidget::on_xrefToToolButton_clicked()
}
}
void SidebarWidget::on_regInfoToolButton_clicked()
{
if (ui->regInfoToolButton->isChecked()) {
ui->regInfoTreeWidget->hide();
ui->regInfoToolButton->setArrowType(Qt::RightArrow);
} else {
ui->regInfoTreeWidget->show();
ui->regInfoToolButton->setArrowType(Qt::DownArrow);
}
}
void SidebarWidget::updateRefs(RVA addr)
{
// refs = calls q hace esa funcion
@ -211,3 +224,27 @@ void SidebarWidget::setScrollMode()
qhelpers::setVerticalScrollMode(ui->xrefFromTreeWidget);
qhelpers::setVerticalScrollMode(ui->xrefToTreeWidget);
}
void SidebarWidget::fillRegistersInfo()
{
TempConfig tempConfig;
tempConfig.set("scr.html", false)
.set("scr.color", COLOR_MODE_DISABLED);
ui->regInfoTreeWidget->clear();
QJsonObject jsonRoot = Core()->getRegistersInfo().object();
foreach (QString key, jsonRoot.keys()) {
QTreeWidgetItem *tempItem = new QTreeWidgetItem();
QString tempString;
tempItem->setText(0, key.toUpper());
foreach (QJsonValue value, jsonRoot[key].toArray()) {
tempString.append(value.toString() + " ");
}
tempItem->setText(1, tempString);
ui->regInfoTreeWidget->addTopLevelItem(tempItem);
}
// Adjust columns to content
qhelpers::adjustColumns(ui->regInfoTreeWidget, 0);
}

View File

@ -39,6 +39,7 @@ private:
void updateRefs(RVA addr);
void fillRefs(QList<XrefDescription> refs, QList<XrefDescription> xrefs);
void fillOffsetInfo(QString off);
void fillRegistersInfo();
void setScrollMode();
@ -54,6 +55,7 @@ private slots:
void on_opcodeDescToolButton_clicked();
void on_xrefFromToolButton_clicked();
void on_xrefToToolButton_clicked();
void on_regInfoToolButton_clicked();
};
#endif // SIDEBARWIDGET_H

View File

@ -317,6 +317,92 @@
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_17">
<property name="spacing">
<number>5</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<item>
<widget class="QToolButton" name="regInfoToolButton">
<property name="text">
<string/>
</property>
<property name="iconSize">
<size>
<width>8</width>
<height>8</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
<property name="arrowType">
<enum>Qt::DownArrow</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_4">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="mouseTracking">
<bool>true</bool>
</property>
<property name="text">
<string>Function registers info:</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QTreeWidget" name="regInfoTreeWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>100</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="indentation">
<number>10</number>
</property>
<property name="headerHidden">
<bool>true</bool>
</property>
<column>
<property name="text">
<string>Info</string>
</property>
</column>
<column>
<property name="text">
<string>Value</string>
</property>
</column>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_16">
<property name="spacing">