Skip to content

Commit

Permalink
Add information about register used in a function radareorg#381 (rad…
Browse files Browse the repository at this point in the history
…areorg#442)

* Add information about register used in a function radareorg#381
  • Loading branch information
rrreeezzz authored and xarkes committed Apr 18, 2018
1 parent d5bd3aa commit 6642f60
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/Cutter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/Cutter.h
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ class CutterCore: public QObject
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);
Expand Down
39 changes: 38 additions & 1 deletion src/widgets/SidebarWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
#include <QFont>
#include <QUrl>
#include <QSettings>

#include <QJsonObject>
#include <QJsonArray>

SidebarWidget::SidebarWidget(MainWindow *main, QAction *action) :
CutterDockWidget(main, action),
Expand Down Expand Up @@ -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*/)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
2 changes: 2 additions & 0 deletions src/widgets/SidebarWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class SidebarWidget : public CutterDockWidget
void updateRefs(RVA addr);
void fillRefs(QList<XrefDescription> refs, QList<XrefDescription> xrefs);
void fillOffsetInfo(QString off);
void fillRegistersInfo();

void setScrollMode();

Expand All @@ -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
86 changes: 86 additions & 0 deletions src/widgets/SidebarWidget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down

0 comments on commit 6642f60

Please sign in to comment.