Add plugin information in 'About' window (#363)

* Add RBin plugin information in 'About' window
* Add RIO plugin information in 'About' window
* Add RCore plugin information in 'About' window
* Add RAsm plugin information in 'About' window
This commit is contained in:
Abdel-Rahman A 2018-03-09 17:05:40 +02:00 committed by xarkes
parent 051b95c69d
commit 4cc5e49a24
9 changed files with 337 additions and 13 deletions

View File

@ -910,6 +910,57 @@ QList<RBinPluginDescription> CutterCore::getRBinPluginDescriptions(const QString
return ret; return ret;
} }
QList<RIOPluginDescription> CutterCore::getRIOPluginDescriptions()
{
QList<RIOPluginDescription> ret;
QJsonArray plugins = cmdj("oLj").object()["IO_Plugins"].toArray();
for(QJsonValueRef pluginValue : plugins)
{
QJsonObject pluginObject = pluginValue.toObject();
RIOPluginDescription plugin;
plugin.name = pluginObject["Name"].toString();
plugin.description = pluginObject["Description"].toString();
plugin.license = pluginObject["License"].toString();
plugin.permissions = pluginObject["Permissions"].toString();
ret << plugin;
}
return ret;
}
QList<RCorePluginDescription> CutterCore::getRCorePluginDescriptions()
{
QList<RCorePluginDescription> ret;
QJsonArray plugins = cmdj("Lsj").array();
for(QJsonValueRef pluginValue : plugins)
{
QJsonObject pluginObject = pluginValue.toObject();
RCorePluginDescription plugin;
plugin.name = pluginObject["Name"].toString();
plugin.description = pluginObject["Description"].toString();
ret << plugin;
}
return ret;
}
QStringList CutterCore::getRAsmPlugins()
{
QStringList ret;
QJsonArray plugins = cmdj("evj asm.arch").array()[0].toObject()["options"].toArray();
for(QJsonValueRef pluginValue : plugins)
ret << pluginValue.toString();
return ret;
}
QList<FunctionDescription> CutterCore::getAllFunctions() QList<FunctionDescription> CutterCore::getAllFunctions()
{ {
CORE_LOCK(); CORE_LOCK();

View File

@ -186,6 +186,20 @@ struct RBinPluginDescription
QString type; QString type;
}; };
struct RIOPluginDescription
{
QString name;
QString description;
QString license;
QString permissions;
};
struct RCorePluginDescription
{
QString name;
QString description;
};
struct DisassemblyLine struct DisassemblyLine
{ {
RVA offset; RVA offset;
@ -241,6 +255,8 @@ Q_DECLARE_METATYPE(FlagDescription)
Q_DECLARE_METATYPE(XrefDescription) Q_DECLARE_METATYPE(XrefDescription)
Q_DECLARE_METATYPE(EntrypointDescription) Q_DECLARE_METATYPE(EntrypointDescription)
Q_DECLARE_METATYPE(RBinPluginDescription) Q_DECLARE_METATYPE(RBinPluginDescription)
Q_DECLARE_METATYPE(RIOPluginDescription)
Q_DECLARE_METATYPE(RCorePluginDescription)
Q_DECLARE_METATYPE(ClassMethodDescription) Q_DECLARE_METATYPE(ClassMethodDescription)
Q_DECLARE_METATYPE(ClassFieldDescription) Q_DECLARE_METATYPE(ClassFieldDescription)
Q_DECLARE_METATYPE(ClassDescription) Q_DECLARE_METATYPE(ClassDescription)
@ -371,6 +387,9 @@ public:
static bool isProjectNameValid(const QString &name); static bool isProjectNameValid(const QString &name);
QList<RBinPluginDescription> getRBinPluginDescriptions(const QString &type = nullptr); QList<RBinPluginDescription> getRBinPluginDescriptions(const QString &type = nullptr);
QList<RIOPluginDescription> getRIOPluginDescriptions();
QList<RCorePluginDescription> getRCorePluginDescriptions();
QStringList getRAsmPlugins();
QList<FunctionDescription> getAllFunctions(); QList<FunctionDescription> getAllFunctions();
QList<ImportDescription> getAllImports(); QList<ImportDescription> getAllImports();

View File

@ -140,7 +140,8 @@ SOURCES += \
utils/JupyterConnection.cpp \ utils/JupyterConnection.cpp \
widgets/JupyterWidget.cpp \ widgets/JupyterWidget.cpp \
utils/PythonAPI.cpp \ utils/PythonAPI.cpp \
utils/NestedIPyKernel.cpp utils/NestedIPyKernel.cpp \
dialogs/R2PluginsDialog.cpp
HEADERS += \ HEADERS += \
Cutter.h \ Cutter.h \
@ -206,7 +207,8 @@ HEADERS += \
utils/JupyterConnection.h \ utils/JupyterConnection.h \
widgets/JupyterWidget.h \ widgets/JupyterWidget.h \
utils/PythonAPI.h \ utils/PythonAPI.h \
utils/NestedIPyKernel.h utils/NestedIPyKernel.h \
dialogs/R2PluginsDialog.h
FORMS += \ FORMS += \
dialogs/AboutDialog.ui \ dialogs/AboutDialog.ui \
@ -245,7 +247,8 @@ FORMS += \
widgets/VTablesWidget.ui \ widgets/VTablesWidget.ui \
widgets/TypesWidget.ui \ widgets/TypesWidget.ui \
widgets/SearchWidget.ui \ widgets/SearchWidget.ui \
widgets/JupyterWidget.ui widgets/JupyterWidget.ui \
dialogs/R2PluginsDialog.ui
RESOURCES += \ RESOURCES += \
resources.qrc \ resources.qrc \

View File

@ -1,6 +1,7 @@
#include <Cutter.h> #include <Cutter.h>
#include "AboutDialog.h" #include "AboutDialog.h"
#include "ui_AboutDialog.h" #include "ui_AboutDialog.h"
#include "R2PluginsDialog.h"
#include "r_version.h" #include "r_version.h"
#include "utils/Configuration.h" #include "utils/Configuration.h"
@ -53,3 +54,9 @@ void AboutDialog::on_showVersionButton_clicked()
popup.setText(versionInformation); popup.setText(versionInformation);
popup.exec(); popup.exec();
} }
void AboutDialog::on_showPluginsButton_clicked()
{
R2PluginsDialog dialog(this);
dialog.exec();
}

View File

@ -20,6 +20,7 @@ public:
private slots: private slots:
void on_buttonBox_rejected(); void on_buttonBox_rejected();
void on_showVersionButton_clicked(); void on_showVersionButton_clicked();
void on_showPluginsButton_clicked();
private: private:
std::unique_ptr<Ui::AboutDialog> ui; std::unique_ptr<Ui::AboutDialog> ui;

View File

@ -33,17 +33,37 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="showVersionButton"> <layout class="QVBoxLayout" name="verticalLayout">
<property name="sizePolicy"> <property name="sizeConstraint">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum"> <enum>QLayout::SetDefaultConstraint</enum>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property> </property>
<property name="text"> <item>
<string>Show version information</string> <widget class="QPushButton" name="showVersionButton">
</property> <property name="sizePolicy">
</widget> <sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Show version information</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="showPluginsButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Show plugin information</string>
</property>
</widget>
</item>
</layout>
</item> </item>
</layout> </layout>
</item> </item>

View File

@ -0,0 +1,55 @@
#include "R2PluginsDialog.h"
#include "ui_R2PluginsDialog.h"
#include "Cutter.h"
#include "utils/Helpers.h"
R2PluginsDialog::R2PluginsDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::R2PluginsDialog)
{
ui->setupUi(this);
for(auto plugin : Core()->getRBinPluginDescriptions())
{
QTreeWidgetItem* item = new QTreeWidgetItem();
item->setText(0, plugin.name);
item->setText(1, plugin.description);
item->setText(2, plugin.license);
item->setText(3, plugin.type);
ui->RBinTreeWidget->addTopLevelItem(item);
}
qhelpers::adjustColumns(ui->RBinTreeWidget, 0);
for(auto plugin : Core()->getRIOPluginDescriptions())
{
QTreeWidgetItem* item = new QTreeWidgetItem();
item->setText(0, plugin.name);
item->setText(1, plugin.description);
item->setText(2, plugin.license);
item->setText(3, plugin.permissions);
ui->RIOTreeWidget->addTopLevelItem(item);
}
qhelpers::adjustColumns(ui->RIOTreeWidget, 0);
for(auto plugin : Core()->getRCorePluginDescriptions())
{
QTreeWidgetItem* item = new QTreeWidgetItem();
item->setText(0, plugin.name);
item->setText(1, plugin.description);
ui->RCoreTreeWidget->addTopLevelItem(item);
}
qhelpers::adjustColumns(ui->RCoreTreeWidget, 0);
for(auto plugin : Core()->getRAsmPlugins())
{
QTreeWidgetItem* item = new QTreeWidgetItem();
item->setText(0, plugin);
ui->RAsmTreeWidget->addTopLevelItem(item);
}
}
R2PluginsDialog::~R2PluginsDialog()
{
delete ui;
}

View File

@ -0,0 +1,26 @@
#ifndef PLUGINSDIALOG_H
#define PLUGINSDIALOG_H
#include <QDialog>
#include <QAbstractTableModel>
#include "Cutter.h"
namespace Ui
{
class R2PluginsDialog;
}
class R2PluginsDialog : public QDialog
{
Q_OBJECT
public:
explicit R2PluginsDialog(QWidget *parent = 0);
~R2PluginsDialog();
private:
Ui::R2PluginsDialog *ui;
};
#endif // PLUGINSDIALOG_H

View File

@ -0,0 +1,142 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>R2PluginsDialog</class>
<widget class="QDialog" name="R2PluginsDialog">
<property name="windowTitle">
<string>radare2 plugin information</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="1">
<widget class="QTreeWidget" name="RCoreTreeWidget">
<column>
<property name="text">
<string>Name</string>
</property>
</column>
<column>
<property name="text">
<string>Description</string>
</property>
</column>
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="RIOLabel">
<property name="text">
<string>RIO plugins</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="RAsmLabel">
<property name="text">
<string>RAsm plugins</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QTreeWidget" name="RAsmTreeWidget">
<column>
<property name="text">
<string>Name</string>
</property>
</column>
</widget>
</item>
<item row="1" column="0">
<widget class="QTreeWidget" name="RBinTreeWidget">
<property name="sortingEnabled">
<bool>true</bool>
</property>
<column>
<property name="text">
<string>Name</string>
</property>
</column>
<column>
<property name="text">
<string>Description</string>
</property>
</column>
<column>
<property name="text">
<string>License</string>
</property>
</column>
<column>
<property name="text">
<string>Type</string>
</property>
</column>
</widget>
</item>
<item row="3" column="0">
<widget class="QTreeWidget" name="RIOTreeWidget">
<column>
<property name="text">
<string>Name</string>
</property>
</column>
<column>
<property name="text">
<string>Description</string>
</property>
</column>
<column>
<property name="text">
<string>License</string>
</property>
</column>
<column>
<property name="text">
<string>Permissions</string>
</property>
</column>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="RCoreLabel">
<property name="text">
<string>RCore plugins</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="RBinLabel">
<property name="text">
<string>RBin plugins</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>R2PluginsDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>