mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-20 11:56:12 +00:00
Implement forcing format in OptionsDialog
This commit is contained in:
parent
bbf424a950
commit
97ee9f17b6
@ -8,8 +8,8 @@
|
|||||||
|
|
||||||
AnalThread::AnalThread(OptionsDialog *parent) :
|
AnalThread::AnalThread(OptionsDialog *parent) :
|
||||||
QThread(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
|
// options dialog should show the list of archs inside the given fatbin
|
||||||
int binidx = 0; // index of subbin
|
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.");
|
emit updateProgress("Analysis in progress.");
|
||||||
|
|
||||||
QString os = optionsDialog->getSelectedOS();
|
QString os = optionsDialog->getSelectedOS();
|
||||||
|
@ -208,7 +208,7 @@ QJsonDocument CutterCore::cmdj(const QString &str)
|
|||||||
return doc;
|
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(loadaddr);
|
||||||
CUTTERNOTUSED(idx);
|
CUTTERNOTUSED(idx);
|
||||||
@ -228,6 +228,11 @@ bool CutterCore::loadFile(QString path, uint64_t loadaddr, uint64_t mapaddr, boo
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!forceBinPlugin.isNull())
|
||||||
|
{
|
||||||
|
r_bin_force_plugin(r_core_get_bin(core_), forceBinPlugin.toUtf8().constData());
|
||||||
|
}
|
||||||
|
|
||||||
if (loadbin)
|
if (loadbin)
|
||||||
{
|
{
|
||||||
if (va == 1)
|
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()
|
QList<FunctionDescription> CutterCore::getAllFunctions()
|
||||||
{
|
{
|
||||||
CORE_LOCK();
|
CORE_LOCK();
|
||||||
|
13
src/cutter.h
13
src/cutter.h
@ -155,6 +155,14 @@ struct XrefDescription
|
|||||||
QString type;
|
QString type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct RBinPluginDescription
|
||||||
|
{
|
||||||
|
QString name;
|
||||||
|
QString description;
|
||||||
|
QString license;
|
||||||
|
QString type;
|
||||||
|
};
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(FunctionDescription)
|
Q_DECLARE_METATYPE(FunctionDescription)
|
||||||
Q_DECLARE_METATYPE(ImportDescription)
|
Q_DECLARE_METATYPE(ImportDescription)
|
||||||
Q_DECLARE_METATYPE(ExportDescription)
|
Q_DECLARE_METATYPE(ExportDescription)
|
||||||
@ -166,6 +174,7 @@ Q_DECLARE_METATYPE(FlagspaceDescription)
|
|||||||
Q_DECLARE_METATYPE(FlagDescription)
|
Q_DECLARE_METATYPE(FlagDescription)
|
||||||
Q_DECLARE_METATYPE(XrefDescription)
|
Q_DECLARE_METATYPE(XrefDescription)
|
||||||
Q_DECLARE_METATYPE(EntrypointDescription)
|
Q_DECLARE_METATYPE(EntrypointDescription)
|
||||||
|
Q_DECLARE_METATYPE(RBinPluginDescription)
|
||||||
|
|
||||||
class CutterCore: public QObject
|
class CutterCore: public QObject
|
||||||
{
|
{
|
||||||
@ -192,7 +201,7 @@ public:
|
|||||||
void delComment(ut64 addr);
|
void delComment(ut64 addr);
|
||||||
QMap<QString, QList<QList<QString>>> getNestedComments();
|
QMap<QString, QList<QList<QString>>> getNestedComments();
|
||||||
void setOptions(QString key);
|
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);
|
bool tryFile(QString path, bool rw);
|
||||||
void analyze(int level, QList<QString> advanced);
|
void analyze(int level, QList<QString> advanced);
|
||||||
void seek(QString addr);
|
void seek(QString addr);
|
||||||
@ -241,6 +250,8 @@ public:
|
|||||||
|
|
||||||
QStringList getProjectNames();
|
QStringList getProjectNames();
|
||||||
|
|
||||||
|
QList<RBinPluginDescription> getRBinPluginDescriptions(const QString &type = nullptr);
|
||||||
|
|
||||||
QList<FunctionDescription> getAllFunctions();
|
QList<FunctionDescription> getAllFunctions();
|
||||||
QList<ImportDescription> getAllImports();
|
QList<ImportDescription> getAllImports();
|
||||||
QList<ExportDescription> getAllExports();
|
QList<ExportDescription> getAllExports();
|
||||||
|
@ -77,7 +77,7 @@ NewFileDialog::NewFileDialog(QWidget *parent) :
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
while (it.hasNext())
|
while (it.hasNext())
|
||||||
{
|
{
|
||||||
const QString& file = it.next();
|
const QString &file = it.next();
|
||||||
// Get stored files
|
// Get stored files
|
||||||
|
|
||||||
// Remove all but the file name
|
// Remove all but the file name
|
||||||
@ -87,12 +87,15 @@ NewFileDialog::NewFileDialog(QWidget *parent) :
|
|||||||
|
|
||||||
// Get file info
|
// Get file info
|
||||||
QFileInfo info(file);
|
QFileInfo info(file);
|
||||||
if (!info.exists()) {
|
if (!info.exists())
|
||||||
|
{
|
||||||
it.remove();
|
it.remove();
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
QListWidgetItem *item = new QListWidgetItem(
|
QListWidgetItem *item = new QListWidgetItem(
|
||||||
getIconFor(name, i++),
|
getIconFor(name, i++),
|
||||||
file + "\nCreated: " + info.created().toString() + "\nSize: " + formatBytecount(info.size())
|
file + "\nCreated: " + info.created().toString() + "\nSize: " + formatBytecount(info.size())
|
||||||
);
|
);
|
||||||
//":/img/icons/target.svg"), name );
|
//":/img/icons/target.svg"), name );
|
||||||
item->setData(Qt::UserRole, file);
|
item->setData(Qt::UserRole, file);
|
||||||
|
@ -45,6 +45,10 @@ OptionsDialog::OptionsDialog(MainWindow *main):
|
|||||||
|
|
||||||
ui->bitsComboBox->setToolTip(main->core->cmd("e? asm.bits").trimmed());
|
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
|
// Restore settings
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
ui->bytesCheckBox->setChecked(settings.value("bytes").toBool());
|
ui->bytesCheckBox->setChecked(settings.value("bytes").toBool());
|
||||||
@ -228,16 +232,6 @@ void OptionsDialog::anal_finished()
|
|||||||
ui->statusLabel->setText(tr("Loading interface"));
|
ui->statusLabel->setText(tr("Loading interface"));
|
||||||
main->addOutput(tr(" > Analysis finished"));
|
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();
|
main->finalizeOpen();
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
@ -889,47 +889,13 @@ color: rgb(0, 0, 0);</string>
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<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">
|
<widget class="QCheckBox" name="pdbCheckBox">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Load PDB</string>
|
<string>Load PDB</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="1">
|
<item row="2" column="1">
|
||||||
<widget class="QWidget" name="pdbWidget" native="true">
|
<widget class="QWidget" name="pdbWidget" native="true">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
|
@ -183,7 +183,7 @@ void ConsoleWidget::on_inputLineEdit_returnPressed()
|
|||||||
QString input = ui->inputLineEdit->text();
|
QString input = ui->inputLineEdit->text();
|
||||||
if (!input.isEmpty() && core != nullptr)
|
if (!input.isEmpty() && core != nullptr)
|
||||||
{
|
{
|
||||||
if (true || !isForbidden(input))
|
if (!isForbidden(input))
|
||||||
{
|
{
|
||||||
ui->outputTextEdit->appendPlainText(this->core->cmd(input));
|
ui->outputTextEdit->appendPlainText(this->core->cmd(input));
|
||||||
scrollOutputToEnd();
|
scrollOutputToEnd();
|
||||||
|
Loading…
Reference in New Issue
Block a user