mirror of
https://github.com/rizinorg/cutter
synced 2026-08-11 16:23:06 -04:00
RzAsm plugins info page enhancement (#3595)
* Limit CPU's width and add tooltips for it * Add columns displaying asm plugin capabilities * Handle number of bits of 27 and none * Fix: make sure that all the values coming to html are escaped * Use rz_analysis_get_plugins to get the plugin list
This commit is contained in:
parent
2ef6d65328
commit
013a76616b
8 changed files with 86 additions and 10 deletions
|
|
@ -49,10 +49,11 @@ bool DisassemblyPreview::showDisasPreviewAt(QWidget *parent, const QPoint &point
|
|||
QStringList disasmPreview = Core()->getDisassemblyPreview(offset, 10);
|
||||
if (!disasmPreview.isEmpty()) {
|
||||
const QFont &fnt = Config()->getFont();
|
||||
QString tooltip = QString { "<html><div style=\"font-family: %1; font-size: %2pt; "
|
||||
"white-space: nowrap;\"><div style=\"margin-bottom: "
|
||||
"10px;\"><strong>Disassembly Preview</strong>:<br>%3<div>" }
|
||||
.arg(fnt.family())
|
||||
QString tooltip = QString("<html><div style=\"font-family: '%1'; font-size: %2pt; "
|
||||
"white-space: nowrap;\"><div style=\"margin-bottom: "
|
||||
"10px;\"><strong>Disassembly Preview</strong>:</div>"
|
||||
"%3</div></html>")
|
||||
.arg(fnt.family().toHtmlEscaped())
|
||||
.arg(qMax(8, fnt.pointSize() - 1))
|
||||
.arg(disasmPreview.join("<br>"));
|
||||
|
||||
|
|
|
|||
|
|
@ -3169,7 +3169,7 @@ QList<RzAsmPluginDescription> CutterCore::getRAsmPluginDescriptions()
|
|||
QList<RzAsmPluginDescription> ret;
|
||||
|
||||
CutterHtSP<RzAsmPlugin>(rz_asm_get_plugins(core->rasm))
|
||||
.ForEach([&ret](const char *k, const RzAsmPlugin *ap) {
|
||||
.ForEach([&ret, &core, this](const char *k, const RzAsmPlugin *ap) {
|
||||
RzAsmPluginDescription plugin;
|
||||
|
||||
plugin.name = ap->name;
|
||||
|
|
@ -3180,6 +3180,39 @@ QList<RzAsmPluginDescription> CutterCore::getRAsmPluginDescriptions()
|
|||
plugin.description = ap->desc;
|
||||
plugin.license = ap->license;
|
||||
|
||||
// Bits
|
||||
QStringList bitsList;
|
||||
if (ap->bits == 27) {
|
||||
bitsList << "27";
|
||||
} else if (ap->bits == 0) {
|
||||
bitsList << "any";
|
||||
} else {
|
||||
for (int bits = 4; bits <= 64; bits *= 2) {
|
||||
if (ap->bits & bits) {
|
||||
bitsList << QString::number(bits);
|
||||
}
|
||||
}
|
||||
}
|
||||
plugin.bits = bitsList.join(" ");
|
||||
|
||||
// Capabilities
|
||||
QString caps;
|
||||
caps += ap->assemble ? "a" : "_";
|
||||
caps += ap->disassemble ? "d" : "_";
|
||||
|
||||
bool foundAnalysis = false;
|
||||
auto analysisPlugin =
|
||||
CutterHtSP<RzAnalysisPlugin>(rz_analysis_get_plugins(core->analysis))
|
||||
.Find(ap->name, &foundAnalysis);
|
||||
if (foundAnalysis && analysisPlugin) {
|
||||
caps += "A";
|
||||
caps += analysisPlugin->esil ? "e" : "_";
|
||||
caps += analysisPlugin->il_config ? "I" : "_";
|
||||
} else {
|
||||
caps += "__";
|
||||
}
|
||||
plugin.capabilities = caps;
|
||||
|
||||
ret << plugin;
|
||||
return true;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -207,6 +207,8 @@ struct RzAsmPluginDescription
|
|||
QString cpus;
|
||||
QString description;
|
||||
QString license;
|
||||
QString capabilities;
|
||||
QString bits;
|
||||
};
|
||||
|
||||
struct DisassemblyLine
|
||||
|
|
|
|||
|
|
@ -209,7 +209,11 @@ public:
|
|||
{ \
|
||||
ht_##xx##_foreach(ht, ForEachCb<F>, &f); \
|
||||
} \
|
||||
}
|
||||
const V *Find(K k, bool *found = nullptr) \
|
||||
{ \
|
||||
return reinterpret_cast<const V *>(ht_##xx##_find(ht, k, found)); \
|
||||
} \
|
||||
};
|
||||
|
||||
CutterHtDef(sp, SP, const char *, void *);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,15 @@
|
|||
#include "RizinPluginsDialog.h"
|
||||
#include "ui_RizinPluginsDialog.h"
|
||||
|
||||
#include "Configuration.h"
|
||||
#include "common/DisassemblyPreview.h"
|
||||
#include "core/Cutter.h"
|
||||
#include "common/Helpers.h"
|
||||
#include "plugins/PluginManager.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QTreeWidgetItem>
|
||||
|
||||
RizinPluginsDialog::RizinPluginsDialog(QWidget *parent)
|
||||
: QDialog(parent), ui(new Ui::RizinPluginsDialog)
|
||||
{
|
||||
|
|
@ -47,14 +52,35 @@ RizinPluginsDialog::RizinPluginsDialog(QWidget *parent)
|
|||
item->setText(0, plugin.name);
|
||||
item->setText(1, plugin.architecture);
|
||||
item->setText(2, plugin.cpus);
|
||||
if (!plugin.cpus.isEmpty()) {
|
||||
QString cpus = plugin.cpus;
|
||||
cpus.replace(",", ", ");
|
||||
|
||||
const QFont &fnt = Config()->getFont();
|
||||
const QString tooltip =
|
||||
QString("<html><div style='font-family:'%1';font-size:%2pt;'>%3</div></html>")
|
||||
.arg(fnt.family().toHtmlEscaped())
|
||||
.arg(qMax(8, fnt.pointSize() - 1))
|
||||
.arg(cpus.toHtmlEscaped());
|
||||
|
||||
item->setToolTip(2, tooltip);
|
||||
}
|
||||
item->setText(3, plugin.version);
|
||||
item->setText(4, plugin.description);
|
||||
item->setText(5, plugin.license);
|
||||
item->setText(6, plugin.author);
|
||||
item->setText(7, plugin.capabilities);
|
||||
item->setText(8, plugin.bits);
|
||||
ui->RzAsmTreeWidget->addTopLevelItem(item);
|
||||
}
|
||||
ui->RzAsmTreeWidget->sortByColumn(0, Qt::AscendingOrder);
|
||||
ui->RzAsmTreeWidget->setStyleSheet(DisassemblyPreview::getToolTipStyleSheet());
|
||||
qhelpers::adjustColumns(ui->RzAsmTreeWidget, 0);
|
||||
|
||||
int cpuCol = 2;
|
||||
if (ui->RzAsmTreeWidget->columnWidth(cpuCol) > 200) {
|
||||
ui->RzAsmTreeWidget->setColumnWidth(cpuCol, 200);
|
||||
}
|
||||
}
|
||||
|
||||
RizinPluginsDialog::~RizinPluginsDialog()
|
||||
|
|
|
|||
|
|
@ -189,6 +189,16 @@
|
|||
<string>Author</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Capabilities</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Bits</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
|
|
|||
|
|
@ -252,9 +252,9 @@ QVariant FunctionModel::data(const QModelIndex &index, int role) const
|
|||
return {};
|
||||
|
||||
QString toolTipContent =
|
||||
QString("<html><div style=\"font-family: %1; font-size: %2pt; white-space: "
|
||||
QString("<html><div style=\"font-family: '%1'; font-size: %2pt; white-space: "
|
||||
"nowrap;\">")
|
||||
.arg(fnt.family())
|
||||
.arg(fnt.family().toHtmlEscaped())
|
||||
.arg(qMax(6, fnt.pointSize() - 1)); // slightly decrease font size, to
|
||||
// keep more text in the same box
|
||||
|
||||
|
|
|
|||
|
|
@ -152,9 +152,9 @@ QVariant SearchModel::data(const QModelIndex &index, int role) const
|
|||
QFontMetrics fm { fnt };
|
||||
|
||||
QString toolTipContent =
|
||||
QString("<html><div style=\"font-family: %1; font-size: %2pt; white-space: "
|
||||
QString("<html><div style=\"font-family: '%1'; font-size: %2pt; white-space: "
|
||||
"nowrap;\">")
|
||||
.arg(fnt.family())
|
||||
.arg(fnt.family().toHtmlEscaped())
|
||||
.arg(qMax(6, fnt.pointSize() - 1)); // slightly decrease font size, to keep
|
||||
// more text in the same box
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue