mirror of
https://github.com/rizinorg/cutter.git
synced 2025-01-18 18:38:51 +00:00
* Panel to list entrypoints Issue #77 * Panel to list entrypoints Issue #77 * Fix build error
This commit is contained in:
parent
76f3cc07fc
commit
6dd0bd1c6a
@ -67,6 +67,7 @@ SOURCES += \
|
||||
widgets/sectionsdock.cpp \
|
||||
widgets/consolewidget.cpp \
|
||||
radarewebserver.cpp \
|
||||
widgets/entrypointwidget.cpp \
|
||||
dialogs/flagdialog.cpp
|
||||
|
||||
HEADERS += \
|
||||
@ -106,10 +107,10 @@ HEADERS += \
|
||||
widgets/consolewidget.h \
|
||||
radarewebserver.h \
|
||||
settings.h \
|
||||
widgets/entrypointwidget.h \
|
||||
iaitorcore.h \
|
||||
iaitordisasm.h \
|
||||
dialogs/flagdialog.h
|
||||
|
||||
FORMS += \
|
||||
mainwindow.ui \
|
||||
newfiledialog.ui \
|
||||
@ -134,6 +135,7 @@ FORMS += \
|
||||
dialogs/xrefsdialog.ui \
|
||||
widgets/sectionsdock.ui \
|
||||
widgets/consolewidget.ui \
|
||||
widgets/entrypointwidget.ui \
|
||||
dialogs/flagdialog.ui
|
||||
|
||||
RESOURCES += \
|
||||
|
@ -136,6 +136,16 @@ struct SectionDescription
|
||||
QString flags;
|
||||
};
|
||||
|
||||
struct EntrypointDescription
|
||||
{
|
||||
RVA vaddr;
|
||||
RVA paddr;
|
||||
RVA baddr;
|
||||
RVA laddr;
|
||||
RVA haddr;
|
||||
QString type;
|
||||
};
|
||||
|
||||
struct XrefDescription
|
||||
{
|
||||
RVA from;
|
||||
@ -153,6 +163,7 @@ Q_DECLARE_METATYPE(StringDescription)
|
||||
Q_DECLARE_METATYPE(FlagspaceDescription)
|
||||
Q_DECLARE_METATYPE(FlagDescription)
|
||||
Q_DECLARE_METATYPE(XrefDescription)
|
||||
Q_DECLARE_METATYPE(EntrypointDescription)
|
||||
|
||||
class IaitoRCore : public QObject
|
||||
{
|
||||
@ -235,6 +246,7 @@ public:
|
||||
QList<FlagspaceDescription> getAllFlagspaces();
|
||||
QList<FlagDescription> getAllFlags(QString flagspace = NULL);
|
||||
QList<SectionDescription> getAllSections();
|
||||
QList<EntrypointDescription> getAllEntrypoint();
|
||||
|
||||
QList<XrefDescription> getXRefs(RVA addr, bool to, bool whole_function, const QString &filterType = QString::null);
|
||||
|
||||
|
@ -60,6 +60,7 @@
|
||||
#include "widgets/consolewidget.h"
|
||||
#include "settings.h"
|
||||
#include "optionsdialog.h"
|
||||
#include "widgets/entrypointwidget.h"
|
||||
|
||||
// graphics
|
||||
#include <QGraphicsEllipseItem>
|
||||
@ -107,6 +108,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
sidebar_action(nullptr),
|
||||
sectionsDock(nullptr),
|
||||
consoleWidget(nullptr),
|
||||
entrypointDock(nullptr),
|
||||
webserver(core)
|
||||
{
|
||||
doLock = false;
|
||||
@ -195,6 +197,10 @@ void MainWindow::initUI()
|
||||
this->sectionsDock = new SectionsDock(this);
|
||||
dockWidgets.push_back(sectionsDock);
|
||||
|
||||
// Add entrypoint DockWidget
|
||||
this->entrypointDock = new EntrypointWidget(this);
|
||||
dockWidgets.push_back(entrypointDock);
|
||||
|
||||
// Add functions DockWidget
|
||||
this->functionsDock = new FunctionsWidget(this);
|
||||
dockWidgets.push_back(functionsDock);
|
||||
@ -668,6 +674,11 @@ void MainWindow::on_actionMem_triggered()
|
||||
newMemDock->refreshHexdump();
|
||||
}
|
||||
|
||||
void MainWindow::on_actionEntry_points_triggered()
|
||||
{
|
||||
toggleDockWidget(entrypointDock);
|
||||
}
|
||||
|
||||
void MainWindow::on_actionFunctions_triggered()
|
||||
{
|
||||
toggleDockWidget(functionsDock);
|
||||
@ -832,6 +843,7 @@ void MainWindow::restoreDocks()
|
||||
addDockWidget(Qt::TopDockWidgetArea, this->dashboardDock);
|
||||
this->tabifyDockWidget(sectionsDock, this->commentsDock);
|
||||
this->tabifyDockWidget(this->dashboardDock, this->memoryDock);
|
||||
this->tabifyDockWidget(this->dashboardDock, this->entrypointDock);
|
||||
this->tabifyDockWidget(this->dashboardDock, this->functionsDock);
|
||||
this->tabifyDockWidget(this->dashboardDock, this->flagsDock);
|
||||
this->tabifyDockWidget(this->dashboardDock, this->stringsDock);
|
||||
@ -864,6 +876,7 @@ void MainWindow::hideAllDocks()
|
||||
void MainWindow::showDefaultDocks()
|
||||
{
|
||||
const QList<DockWidget *> defaultDocks = { sectionsDock,
|
||||
entrypointDock,
|
||||
functionsDock,
|
||||
memoryDock,
|
||||
commentsDock,
|
||||
|
@ -30,6 +30,7 @@ class SdbDock;
|
||||
class QAction;
|
||||
class SectionsDock;
|
||||
class ConsoleWidget;
|
||||
class EntrypointWidget;
|
||||
|
||||
class QDockWidget;
|
||||
|
||||
@ -89,6 +90,7 @@ public slots:
|
||||
|
||||
void def_theme();
|
||||
|
||||
void on_actionEntry_points_triggered();
|
||||
void on_actionFunctions_triggered();
|
||||
void on_actionImports_triggered();
|
||||
void on_actionExports_triggered();
|
||||
@ -188,6 +190,7 @@ private:
|
||||
Highlighter *highlighter;
|
||||
AsciiHighlighter *hex_highlighter;
|
||||
GraphicsBar *graphicsBar;
|
||||
EntrypointWidget *entrypointDock;
|
||||
FunctionsWidget *functionsDock;
|
||||
ImportsWidget *importsDock;
|
||||
ExportsWidget *exportsDock;
|
||||
|
@ -159,7 +159,7 @@ border-top: 0px;
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1013</width>
|
||||
<height>23</height>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="defaultUp">
|
||||
@ -173,8 +173,8 @@ border-top: 0px;
|
||||
<rect>
|
||||
<x>273</x>
|
||||
<y>136</y>
|
||||
<width>170</width>
|
||||
<height>214</height>
|
||||
<width>156</width>
|
||||
<height>182</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
@ -248,6 +248,7 @@ border-top: 0px;
|
||||
</property>
|
||||
<addaction name="actionDashboard"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionEntry_points"/>
|
||||
<addaction name="actionFunctions"/>
|
||||
<addaction name="actionImports"/>
|
||||
<addaction name="actionExports"/>
|
||||
@ -916,6 +917,11 @@ QToolButton .svg-icon path {
|
||||
<string>Refresh contents</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionEntry_points">
|
||||
<property name="text">
|
||||
<string>Entry points</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources>
|
||||
|
@ -1092,6 +1092,30 @@ QList<SectionDescription> IaitoRCore::getAllSections()
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
QList<EntrypointDescription> IaitoRCore::getAllEntrypoint()
|
||||
{
|
||||
CORE_LOCK();
|
||||
QList<EntrypointDescription> ret;
|
||||
|
||||
QJsonArray entrypointsArray = cmdj("iej").array();
|
||||
for (QJsonValue value : entrypointsArray)
|
||||
{
|
||||
QJsonObject entrypointObject = value.toObject();
|
||||
|
||||
EntrypointDescription entrypoint;
|
||||
entrypoint.vaddr = entrypointObject["vaddr"].toVariant().toULongLong();
|
||||
entrypoint.paddr = entrypointObject["paddr"].toVariant().toULongLong();
|
||||
entrypoint.baddr = entrypointObject["baddr"].toVariant().toULongLong();
|
||||
entrypoint.laddr = entrypointObject["laddr"].toVariant().toULongLong();
|
||||
entrypoint.haddr = entrypointObject["haddr"].toVariant().toULongLong();
|
||||
entrypoint.type = entrypointObject["type"].toString();
|
||||
|
||||
ret << entrypoint;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
QList<XrefDescription> IaitoRCore::getXRefs(RVA addr, bool to, bool whole_function, const QString &filterType)
|
||||
{
|
||||
QList<XrefDescription> ret = QList<XrefDescription>();
|
||||
@ -1134,4 +1158,4 @@ void IaitoRCore::addFlag(RVA offset, QString name, RVA size)
|
||||
name = sanitizeStringForCommand(name);
|
||||
cmd(QString("f %1 %2 @ %3").arg(name).arg(size).arg(offset));
|
||||
emit flagsChanged();
|
||||
}
|
||||
}
|
||||
|
69
src/widgets/entrypointwidget.cpp
Normal file
69
src/widgets/entrypointwidget.cpp
Normal file
@ -0,0 +1,69 @@
|
||||
#include "entrypointwidget.h"
|
||||
#include "ui_entrypointwidget.h"
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include "helpers.h"
|
||||
|
||||
#include <QTreeWidget>
|
||||
#include <QPen>
|
||||
|
||||
|
||||
/*
|
||||
* Entrypoint Widget
|
||||
*/
|
||||
|
||||
EntrypointWidget::EntrypointWidget(MainWindow *main, QWidget *parent) :
|
||||
DockWidget(parent),
|
||||
ui(new Ui::EntrypointWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
// Radare core found in:
|
||||
this->main = main;
|
||||
|
||||
// Delegate
|
||||
//CMyDelegate* delegate = new CMyDelegate(ui->importsTreeWidget);
|
||||
//ui->importsTreeWidget->setItemDelegate(delegate);
|
||||
|
||||
ui->entrypointTreeWidget->hideColumn(0);
|
||||
}
|
||||
|
||||
EntrypointWidget::~EntrypointWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void EntrypointWidget::setup()
|
||||
{
|
||||
setScrollMode();
|
||||
|
||||
fillEntrypoint();
|
||||
}
|
||||
|
||||
void EntrypointWidget::refresh()
|
||||
{
|
||||
setup();
|
||||
}
|
||||
|
||||
void EntrypointWidget::fillEntrypoint()
|
||||
{
|
||||
ui->entrypointTreeWidget->clear();
|
||||
for (auto i : this->main->core->getAllEntrypoint())
|
||||
{
|
||||
QTreeWidgetItem *item = qhelpers::appendRow(ui->entrypointTreeWidget, RAddressString(i.vaddr), i.type);
|
||||
item->setData(0, Qt::UserRole, QVariant::fromValue(i));
|
||||
}
|
||||
|
||||
qhelpers::adjustColumns(ui->entrypointTreeWidget, 0, 10);
|
||||
}
|
||||
|
||||
void EntrypointWidget::setScrollMode()
|
||||
{
|
||||
qhelpers::setVerticalScrollMode(ui->entrypointTreeWidget);
|
||||
}
|
||||
|
||||
void EntrypointWidget::on_entrypointTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int /* column */)
|
||||
{
|
||||
EntrypointDescription ep = item->data(0, Qt::UserRole).value<EntrypointDescription>();
|
||||
this->main->seek(ep.vaddr, ep.type, true);
|
||||
}
|
39
src/widgets/entrypointwidget.h
Normal file
39
src/widgets/entrypointwidget.h
Normal file
@ -0,0 +1,39 @@
|
||||
#ifndef ENTRYPOINTWIDGET_H
|
||||
#define ENTRYPOINTWIDGET_H
|
||||
|
||||
#include "dockwidget.h"
|
||||
#include <QStyledItemDelegate>
|
||||
#include <QTreeWidgetItem>
|
||||
|
||||
class MainWindow;
|
||||
class QTreeWidget;
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class EntrypointWidget;
|
||||
}
|
||||
|
||||
class EntrypointWidget : public DockWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit EntrypointWidget(MainWindow *main, QWidget *parent = 0);
|
||||
~EntrypointWidget();
|
||||
|
||||
void setup() override;
|
||||
|
||||
void refresh() override;
|
||||
|
||||
private slots:
|
||||
void on_entrypointTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column);
|
||||
|
||||
private:
|
||||
Ui::EntrypointWidget *ui;
|
||||
MainWindow *main;
|
||||
|
||||
void fillEntrypoint();
|
||||
void setScrollMode();
|
||||
};
|
||||
|
||||
#endif // ENTRYPOINTWIDGET_H
|
87
src/widgets/entrypointwidget.ui
Normal file
87
src/widgets/entrypointwidget.ui
Normal file
@ -0,0 +1,87 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>EntrypointWidget</class>
|
||||
<widget class="QDockWidget" name="EntrypointWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Entry Points</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="dockWidgetContents">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QTreeWidget" name="entrypointTreeWidget">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QTreeWidget::item
|
||||
{
|
||||
padding-left:10px;
|
||||
padding-top: 1px;
|
||||
padding-bottom: 1px;
|
||||
border-left: 10px;
|
||||
}
|
||||
|
||||
QTreeWidget::item:hover
|
||||
{
|
||||
background: rgb(242, 246, 248);
|
||||
color: black;
|
||||
}
|
||||
|
||||
QTreeWidget::item:selected
|
||||
{
|
||||
background: gray;
|
||||
color: white;
|
||||
}</string>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="lineWidth">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="columnCount">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string notr="true">1</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string notr="true">Address</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string notr="true">Type</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
Loading…
Reference in New Issue
Block a user