mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-19 19:36:11 +00:00
Implement forcing format in OptionsDialog
This commit is contained in:
parent
bbf424a950
commit
97ee9f17b6
@ -8,8 +8,8 @@
|
||||
|
||||
AnalThread::AnalThread(OptionsDialog *parent) :
|
||||
QThread(parent),
|
||||
main(nullptr),
|
||||
level(2)
|
||||
level(2),
|
||||
main(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
@ -69,7 +69,15 @@ void AnalThread::run()
|
||||
// options dialog should show the list of archs inside the given fatbin
|
||||
int binidx = 0; // index of subbin
|
||||
|
||||
main->core->loadFile(main->getFilename(), loadaddr, mapaddr, rw, va, binidx, load_bininfo);
|
||||
QString forceBinPlugin = nullptr;
|
||||
QVariant forceBinPluginData = ui->formatComboBox->currentData();
|
||||
if (!forceBinPluginData.isNull())
|
||||
{
|
||||
RBinPluginDescription pluginDesc = forceBinPluginData.value<RBinPluginDescription>();
|
||||
forceBinPlugin = pluginDesc.name;
|
||||
}
|
||||
|
||||
main->core->loadFile(main->getFilename(), loadaddr, mapaddr, rw, va, binidx, load_bininfo, forceBinPlugin);
|
||||
emit updateProgress("Analysis in progress.");
|
||||
|
||||
QString os = optionsDialog->getSelectedOS();
|
||||
|
@ -208,7 +208,7 @@ QJsonDocument CutterCore::cmdj(const QString &str)
|
||||
return doc;
|
||||
}
|
||||
|
||||
bool CutterCore::loadFile(QString path, uint64_t loadaddr, uint64_t mapaddr, bool rw, int va, int idx, bool loadbin)
|
||||
bool CutterCore::loadFile(QString path, uint64_t loadaddr, uint64_t mapaddr, bool rw, int va, int idx, bool loadbin, const QString &forceBinPlugin)
|
||||
{
|
||||
CUTTERNOTUSED(loadaddr);
|
||||
CUTTERNOTUSED(idx);
|
||||
@ -228,6 +228,11 @@ bool CutterCore::loadFile(QString path, uint64_t loadaddr, uint64_t mapaddr, boo
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!forceBinPlugin.isNull())
|
||||
{
|
||||
r_bin_force_plugin(r_core_get_bin(core_), forceBinPlugin.toUtf8().constData());
|
||||
}
|
||||
|
||||
if (loadbin)
|
||||
{
|
||||
if (va == 1)
|
||||
@ -813,6 +818,34 @@ QStringList CutterCore::getProjectNames()
|
||||
}
|
||||
|
||||
|
||||
QList<RBinPluginDescription> CutterCore::getRBinPluginDescriptions(const QString &type)
|
||||
{
|
||||
QList<RBinPluginDescription> ret;
|
||||
|
||||
QJsonObject jsonRoot = cmdj("iLj").object();
|
||||
for (const QString &key : jsonRoot.keys())
|
||||
{
|
||||
if (!type.isNull() && key != type)
|
||||
continue;
|
||||
|
||||
QJsonArray pluginArray = jsonRoot[key].toArray();
|
||||
|
||||
for (const auto &pluginValue : pluginArray)
|
||||
{
|
||||
QJsonObject pluginObject = pluginValue.toObject();
|
||||
RBinPluginDescription desc;
|
||||
desc.name = pluginObject["name"].toString();
|
||||
desc.description = pluginObject["description"].toString();
|
||||
desc.license = pluginObject["license"].toString();
|
||||
desc.type = key;
|
||||
ret.append(desc);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
QList<FunctionDescription> CutterCore::getAllFunctions()
|
||||
{
|
||||
CORE_LOCK();
|
||||
|
13
src/cutter.h
13
src/cutter.h
@ -155,6 +155,14 @@ struct XrefDescription
|
||||
QString type;
|
||||
};
|
||||
|
||||
struct RBinPluginDescription
|
||||
{
|
||||
QString name;
|
||||
QString description;
|
||||
QString license;
|
||||
QString type;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(FunctionDescription)
|
||||
Q_DECLARE_METATYPE(ImportDescription)
|
||||
Q_DECLARE_METATYPE(ExportDescription)
|
||||
@ -166,6 +174,7 @@ Q_DECLARE_METATYPE(FlagspaceDescription)
|
||||
Q_DECLARE_METATYPE(FlagDescription)
|
||||
Q_DECLARE_METATYPE(XrefDescription)
|
||||
Q_DECLARE_METATYPE(EntrypointDescription)
|
||||
Q_DECLARE_METATYPE(RBinPluginDescription)
|
||||
|
||||
class CutterCore: public QObject
|
||||
{
|
||||
@ -192,7 +201,7 @@ public:
|
||||
void delComment(ut64 addr);
|
||||
QMap<QString, QList<QList<QString>>> getNestedComments();
|
||||
void setOptions(QString key);
|
||||
bool loadFile(QString path, uint64_t loadaddr = 0LL, uint64_t mapaddr = 0LL, bool rw = false, int va = 0, int idx = 0, bool loadbin = false);
|
||||
bool loadFile(QString path, uint64_t loadaddr = 0LL, uint64_t mapaddr = 0LL, bool rw = false, int va = 0, int idx = 0, bool loadbin = false, const QString &forceBinPlugin = nullptr);
|
||||
bool tryFile(QString path, bool rw);
|
||||
void analyze(int level, QList<QString> advanced);
|
||||
void seek(QString addr);
|
||||
@ -241,6 +250,8 @@ public:
|
||||
|
||||
QStringList getProjectNames();
|
||||
|
||||
QList<RBinPluginDescription> getRBinPluginDescriptions(const QString &type = nullptr);
|
||||
|
||||
QList<FunctionDescription> getAllFunctions();
|
||||
QList<ImportDescription> getAllImports();
|
||||
QList<ExportDescription> getAllExports();
|
||||
|
@ -77,7 +77,7 @@ NewFileDialog::NewFileDialog(QWidget *parent) :
|
||||
int i = 0;
|
||||
while (it.hasNext())
|
||||
{
|
||||
const QString& file = it.next();
|
||||
const QString &file = it.next();
|
||||
// Get stored files
|
||||
|
||||
// Remove all but the file name
|
||||
@ -87,12 +87,15 @@ NewFileDialog::NewFileDialog(QWidget *parent) :
|
||||
|
||||
// Get file info
|
||||
QFileInfo info(file);
|
||||
if (!info.exists()) {
|
||||
if (!info.exists())
|
||||
{
|
||||
it.remove();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
QListWidgetItem *item = new QListWidgetItem(
|
||||
getIconFor(name, i++),
|
||||
file + "\nCreated: " + info.created().toString() + "\nSize: " + formatBytecount(info.size())
|
||||
getIconFor(name, i++),
|
||||
file + "\nCreated: " + info.created().toString() + "\nSize: " + formatBytecount(info.size())
|
||||
);
|
||||
//":/img/icons/target.svg"), name );
|
||||
item->setData(Qt::UserRole, file);
|
||||
|
@ -45,6 +45,10 @@ OptionsDialog::OptionsDialog(MainWindow *main):
|
||||
|
||||
ui->bitsComboBox->setToolTip(main->core->cmd("e? asm.bits").trimmed());
|
||||
|
||||
|
||||
for (auto plugin : main->core->getRBinPluginDescriptions("bin"))
|
||||
ui->formatComboBox->addItem(plugin.name, QVariant::fromValue(plugin));
|
||||
|
||||
// Restore settings
|
||||
QSettings settings;
|
||||
ui->bytesCheckBox->setChecked(settings.value("bytes").toBool());
|
||||
@ -228,16 +232,6 @@ void OptionsDialog::anal_finished()
|
||||
ui->statusLabel->setText(tr("Loading interface"));
|
||||
main->addOutput(tr(" > Analysis finished"));
|
||||
|
||||
QString initial_seek = ui->entry_initialSeek->text();
|
||||
if (initial_seek.length() > 0)
|
||||
{
|
||||
main->core->seek(initial_seek);
|
||||
}
|
||||
else
|
||||
{
|
||||
main->core->seek("entry0");
|
||||
}
|
||||
|
||||
main->finalizeOpen();
|
||||
close();
|
||||
}
|
||||
|
@ -889,47 +889,13 @@ color: rgb(0, 0, 0);</string>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="seekLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Initial seek:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="entry_initialSeek">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="inputMask">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="frame">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QCheckBox" name="pdbCheckBox">
|
||||
<property name="text">
|
||||
<string>Load PDB</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<item row="2" column="1">
|
||||
<widget class="QWidget" name="pdbWidget" native="true">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
|
@ -183,7 +183,7 @@ void ConsoleWidget::on_inputLineEdit_returnPressed()
|
||||
QString input = ui->inputLineEdit->text();
|
||||
if (!input.isEmpty() && core != nullptr)
|
||||
{
|
||||
if (true || !isForbidden(input))
|
||||
if (!isForbidden(input))
|
||||
{
|
||||
ui->outputTextEdit->appendPlainText(this->core->cmd(input));
|
||||
scrollOutputToEnd();
|
||||
|
Loading…
Reference in New Issue
Block a user