2018-10-17 07:55:53 +00:00
|
|
|
|
#include "common/AsyncTask.h"
|
2018-08-18 10:51:11 +00:00
|
|
|
|
#include "InitialOptionsDialog.h"
|
|
|
|
|
#include "ui_InitialOptionsDialog.h"
|
2019-03-14 09:28:42 +00:00
|
|
|
|
|
2019-02-22 16:50:45 +00:00
|
|
|
|
#include "core/MainWindow.h"
|
2017-10-02 09:41:28 +00:00
|
|
|
|
#include "dialogs/NewFileDialog.h"
|
2018-05-26 18:49:57 +00:00
|
|
|
|
#include "dialogs/AsyncTaskDialog.h"
|
2018-10-17 07:55:53 +00:00
|
|
|
|
#include "common/Helpers.h"
|
2017-03-29 10:18:37 +00:00
|
|
|
|
|
|
|
|
|
#include <QSettings>
|
2017-07-11 16:41:58 +00:00
|
|
|
|
#include <QFileInfo>
|
2017-09-27 20:23:18 +00:00
|
|
|
|
#include <QFileDialog>
|
2019-03-14 09:28:42 +00:00
|
|
|
|
#include <QCloseEvent>
|
2017-04-18 10:03:47 +00:00
|
|
|
|
|
2019-04-06 12:04:55 +00:00
|
|
|
|
#include "core/Cutter.h"
|
|
|
|
|
#include "common/AnalTask.h"
|
|
|
|
|
|
|
|
|
|
|
2018-08-18 10:51:11 +00:00
|
|
|
|
InitialOptionsDialog::InitialOptionsDialog(MainWindow *main):
|
2019-04-06 12:04:55 +00:00
|
|
|
|
QDialog(nullptr), // parent must not be main
|
2018-08-18 10:51:11 +00:00
|
|
|
|
ui(new Ui::InitialOptionsDialog),
|
2017-10-09 18:08:35 +00:00
|
|
|
|
main(main),
|
2018-08-18 18:45:49 +00:00
|
|
|
|
core(Core())
|
2017-03-29 10:18:37 +00:00
|
|
|
|
{
|
|
|
|
|
ui->setupUi(this);
|
2017-03-31 00:51:14 +00:00
|
|
|
|
setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint));
|
2018-02-12 12:22:53 +00:00
|
|
|
|
ui->logoSvgWidget->load(Config()->getLogoFile());
|
2017-04-10 12:22:18 +00:00
|
|
|
|
|
2017-03-29 10:18:37 +00:00
|
|
|
|
// Fill the plugins combo
|
2020-07-21 11:08:35 +00:00
|
|
|
|
asmPlugins = core->getRAsmPluginDescriptions();
|
|
|
|
|
for (const auto &plugin : asmPlugins) {
|
|
|
|
|
ui->archComboBox->addItem(plugin.name, plugin.name);
|
2019-04-14 09:36:13 +00:00
|
|
|
|
}
|
2020-03-08 16:27:47 +00:00
|
|
|
|
|
|
|
|
|
setTooltipWithConfigHelp(ui->archComboBox,"asm.arch");
|
2017-09-27 20:23:18 +00:00
|
|
|
|
|
|
|
|
|
// cpu combo box
|
|
|
|
|
ui->cpuComboBox->lineEdit()->setPlaceholderText(tr("Auto"));
|
2020-03-08 16:27:47 +00:00
|
|
|
|
setTooltipWithConfigHelp(ui->cpuComboBox, "asm.cpu");
|
|
|
|
|
|
2017-09-27 20:23:18 +00:00
|
|
|
|
updateCPUComboBox();
|
|
|
|
|
|
|
|
|
|
// os combo box
|
2019-04-14 09:36:13 +00:00
|
|
|
|
for (const auto &plugin : core->cmdList("e asm.os=?")) {
|
2017-09-27 20:23:18 +00:00
|
|
|
|
ui->kernelComboBox->addItem(plugin, plugin);
|
2019-04-14 09:36:13 +00:00
|
|
|
|
}
|
2017-09-27 20:23:18 +00:00
|
|
|
|
|
2020-03-08 16:27:47 +00:00
|
|
|
|
setTooltipWithConfigHelp(ui->kernelComboBox, "asm.os");
|
|
|
|
|
setTooltipWithConfigHelp(ui->bitsComboBox, "asm.bits");
|
2017-03-29 10:18:37 +00:00
|
|
|
|
|
2019-04-14 09:36:13 +00:00
|
|
|
|
for (const auto &plugin : core->getRBinPluginDescriptions("bin")) {
|
2017-09-29 11:32:53 +00:00
|
|
|
|
ui->formatComboBox->addItem(plugin.name, QVariant::fromValue(plugin));
|
2019-04-14 09:36:13 +00:00
|
|
|
|
}
|
2017-09-29 11:32:53 +00:00
|
|
|
|
|
2019-08-03 21:58:41 +00:00
|
|
|
|
analysisCommands = {
|
|
|
|
|
{ { "aa", tr("Analyze all symbols") }, new QCheckBox(), true },
|
|
|
|
|
{ { "aar", tr("Analyze instructions for references") }, new QCheckBox(), true },
|
|
|
|
|
{ { "aac", tr("Analyze function calls") }, new QCheckBox(), true },
|
|
|
|
|
{ { "aab", tr("Analyze all basic blocks") }, new QCheckBox(), false },
|
|
|
|
|
{ { "aao", tr("Analyze all objc references") }, new QCheckBox(), false },
|
|
|
|
|
{ { "avrr", tr("Recover class information from RTTI") }, new QCheckBox(), false },
|
|
|
|
|
{ { "aan", tr("Autoname functions based on context") }, new QCheckBox(), false },
|
|
|
|
|
{ { "aae", tr("Emulate code to find computed references") }, new QCheckBox(), false },
|
2019-09-15 11:41:12 +00:00
|
|
|
|
{ { "aafr", tr("Analyze all consecutive functions") }, new QCheckBox(), false },
|
2019-08-03 21:58:41 +00:00
|
|
|
|
{ { "aaft", tr("Type and Argument matching analysis") }, new QCheckBox(), false },
|
|
|
|
|
{ { "aaT", tr("Analyze code after trap-sleds") }, new QCheckBox(), false },
|
|
|
|
|
{ { "aap", tr("Analyze function preludes") }, new QCheckBox(), false },
|
|
|
|
|
{ { "e! anal.jmp.tbl", tr("Analyze jump tables in switch statements") }, new QCheckBox(), false },
|
|
|
|
|
{ { "e! anal.pushret", tr("Analyze PUSH+RET as JMP") }, new QCheckBox(), false },
|
|
|
|
|
{ { "e! anal.hasnext", tr("Continue analysis after each function") }, new QCheckBox(), false }};
|
|
|
|
|
|
|
|
|
|
// Per each checkbox, set a tooltip desccribing it
|
|
|
|
|
AnalysisCommands item;
|
|
|
|
|
foreach (item, analysisCommands){
|
|
|
|
|
item.checkbox->setText(item.commandDesc.description);
|
|
|
|
|
item.checkbox->setToolTip(item.commandDesc.command);
|
|
|
|
|
item.checkbox->setChecked(item.checked);
|
|
|
|
|
ui->verticalLayout_7->addWidget(item.checkbox);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2017-03-29 10:18:37 +00:00
|
|
|
|
ui->hideFrame->setVisible(false);
|
2017-07-24 11:05:28 +00:00
|
|
|
|
ui->analoptionsFrame->setVisible(false);
|
2019-08-03 21:58:41 +00:00
|
|
|
|
ui->advancedAnlysisLine->setVisible(false);
|
2017-03-29 10:18:37 +00:00
|
|
|
|
|
2017-09-27 20:23:18 +00:00
|
|
|
|
updatePDBLayout();
|
|
|
|
|
|
2020-08-03 09:13:39 +00:00
|
|
|
|
connect(ui->pdbCheckBox, &QCheckBox::stateChanged, this, &InitialOptionsDialog::updatePDBLayout);
|
2017-09-27 20:23:18 +00:00
|
|
|
|
|
2018-04-30 06:39:48 +00:00
|
|
|
|
updateScriptLayout();
|
2018-07-17 19:00:35 +00:00
|
|
|
|
|
2020-08-03 09:13:39 +00:00
|
|
|
|
connect(ui->scriptCheckBox, &QCheckBox::stateChanged, this, &InitialOptionsDialog::updateScriptLayout);
|
2018-04-30 06:39:48 +00:00
|
|
|
|
|
2020-08-07 14:18:42 +00:00
|
|
|
|
connect(ui->cancelButton, &QPushButton::clicked, this, &InitialOptionsDialog::reject);
|
2017-04-09 19:55:06 +00:00
|
|
|
|
|
2017-05-13 18:09:36 +00:00
|
|
|
|
ui->programLineEdit->setText(main->getFilename());
|
2017-03-29 10:18:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-08-18 10:51:11 +00:00
|
|
|
|
InitialOptionsDialog::~InitialOptionsDialog() {}
|
2017-03-29 10:18:37 +00:00
|
|
|
|
|
2018-08-18 10:51:11 +00:00
|
|
|
|
void InitialOptionsDialog::updateCPUComboBox()
|
2017-09-27 20:23:18 +00:00
|
|
|
|
{
|
|
|
|
|
QString currentText = ui->cpuComboBox->lineEdit()->text();
|
|
|
|
|
ui->cpuComboBox->clear();
|
|
|
|
|
|
|
|
|
|
QString arch = getSelectedArch();
|
2020-07-21 11:08:35 +00:00
|
|
|
|
QStringList cpus;
|
|
|
|
|
if (!arch.isEmpty()) {
|
|
|
|
|
auto pluginDescr = std::find_if(asmPlugins.begin(), asmPlugins.end(), [&](const RAsmPluginDescription &plugin) {
|
|
|
|
|
return plugin.name == arch;
|
|
|
|
|
});
|
|
|
|
|
if (pluginDescr != asmPlugins.end()) {
|
|
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(5,14,0)
|
|
|
|
|
cpus = pluginDescr->cpus.split(",", Qt::SkipEmptyParts);
|
|
|
|
|
#else
|
|
|
|
|
cpus = pluginDescr->cpus.split(",", QString::SkipEmptyParts);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
2019-04-14 09:36:13 +00:00
|
|
|
|
}
|
2017-09-27 20:23:18 +00:00
|
|
|
|
|
|
|
|
|
ui->cpuComboBox->addItem("");
|
2020-07-21 11:08:35 +00:00
|
|
|
|
ui->cpuComboBox->addItems(cpus);
|
2017-09-27 20:23:18 +00:00
|
|
|
|
|
|
|
|
|
ui->cpuComboBox->lineEdit()->setText(currentText);
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-03 21:58:41 +00:00
|
|
|
|
QList<QString> InitialOptionsDialog::getAnalysisCommands(const InitialOptions &options) {
|
|
|
|
|
QList<QString> commands;
|
|
|
|
|
for (auto& commandDesc: options.analCmd) {
|
|
|
|
|
commands << commandDesc.command;
|
|
|
|
|
}
|
|
|
|
|
return commands;
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-18 16:04:45 +00:00
|
|
|
|
void InitialOptionsDialog::loadOptions(const InitialOptions &options)
|
2018-07-24 16:49:52 +00:00
|
|
|
|
{
|
2018-08-18 16:04:45 +00:00
|
|
|
|
if (options.analCmd.isEmpty()) {
|
2018-08-18 18:45:49 +00:00
|
|
|
|
analLevel = 0;
|
2019-08-03 21:58:41 +00:00
|
|
|
|
} else if (options.analCmd.first().command == "aaa" ) {
|
2018-08-18 18:45:49 +00:00
|
|
|
|
analLevel = 1;
|
2019-08-03 21:58:41 +00:00
|
|
|
|
} else if (options.analCmd.first().command == "aaaa" ) {
|
2018-08-18 18:45:49 +00:00
|
|
|
|
analLevel = 2;
|
|
|
|
|
} else {
|
|
|
|
|
analLevel = 3;
|
2019-08-03 21:58:41 +00:00
|
|
|
|
AnalysisCommands item;
|
|
|
|
|
QList<QString> commands = getAnalysisCommands(options);
|
|
|
|
|
foreach (item, analysisCommands){
|
|
|
|
|
qInfo() << item.commandDesc.command;
|
|
|
|
|
item.checkbox->setChecked(commands.contains(item.commandDesc.command));
|
|
|
|
|
}
|
2018-07-24 16:49:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-08-18 16:04:45 +00:00
|
|
|
|
if (!options.script.isEmpty()) {
|
|
|
|
|
ui->scriptCheckBox->setChecked(true);
|
|
|
|
|
ui->scriptLineEdit->setText(options.script);
|
2018-08-18 18:45:49 +00:00
|
|
|
|
analLevel = 0;
|
2018-08-18 16:09:49 +00:00
|
|
|
|
} else {
|
|
|
|
|
ui->scriptCheckBox->setChecked(false);
|
|
|
|
|
ui->scriptLineEdit->setText("");
|
2018-08-18 16:04:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-08-18 18:45:49 +00:00
|
|
|
|
ui->analSlider->setValue(analLevel);
|
|
|
|
|
|
2018-08-18 16:04:45 +00:00
|
|
|
|
shellcode = options.shellcode;
|
|
|
|
|
|
2019-12-19 12:59:15 +00:00
|
|
|
|
if (!options.forceBinPlugin.isEmpty()) {
|
|
|
|
|
ui->formatComboBox->setCurrentText(options.forceBinPlugin);
|
|
|
|
|
} else {
|
|
|
|
|
ui->formatComboBox->setCurrentIndex(0);
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-27 19:12:50 +00:00
|
|
|
|
if (options.binLoadAddr != RVA_INVALID) {
|
|
|
|
|
ui->entry_loadOffset->setText(RAddressString(options.binLoadAddr));
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-28 11:33:19 +00:00
|
|
|
|
ui->writeCheckBox->setChecked(options.writeEnabled);
|
|
|
|
|
|
|
|
|
|
|
2018-08-18 16:04:45 +00:00
|
|
|
|
// TODO: all other options should also be applied to the ui
|
2018-08-10 17:12:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-03-08 16:27:47 +00:00
|
|
|
|
|
|
|
|
|
void InitialOptionsDialog::setTooltipWithConfigHelp(QWidget *w, const char *config) {
|
|
|
|
|
w->setToolTip(QString("%1 (%2)")
|
|
|
|
|
.arg(core->getConfigDescription(config))
|
|
|
|
|
.arg(config));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2019-04-06 12:04:55 +00:00
|
|
|
|
QString InitialOptionsDialog::getSelectedArch() const
|
2017-09-27 20:23:18 +00:00
|
|
|
|
{
|
|
|
|
|
QVariant archValue = ui->archComboBox->currentData();
|
|
|
|
|
return archValue.isValid() ? archValue.toString() : nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-06 12:04:55 +00:00
|
|
|
|
QString InitialOptionsDialog::getSelectedCPU() const
|
2017-09-27 20:23:18 +00:00
|
|
|
|
{
|
|
|
|
|
QString cpu = ui->cpuComboBox->currentText();
|
2019-04-14 09:36:13 +00:00
|
|
|
|
if (cpu.isNull() || cpu.isEmpty()) {
|
2017-09-27 20:23:18 +00:00
|
|
|
|
return nullptr;
|
2019-04-14 09:36:13 +00:00
|
|
|
|
}
|
2017-09-27 20:23:18 +00:00
|
|
|
|
return cpu;
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-06 12:04:55 +00:00
|
|
|
|
int InitialOptionsDialog::getSelectedBits() const
|
2017-09-27 20:23:18 +00:00
|
|
|
|
{
|
|
|
|
|
QString sel_bits = ui->bitsComboBox->currentText();
|
2018-03-21 20:32:32 +00:00
|
|
|
|
if (sel_bits != "Auto") {
|
2017-09-27 20:23:18 +00:00
|
|
|
|
return sel_bits.toInt();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-06 12:04:55 +00:00
|
|
|
|
InitialOptions::Endianness InitialOptionsDialog::getSelectedEndianness() const
|
2018-01-20 10:35:31 +00:00
|
|
|
|
{
|
2018-03-21 20:32:32 +00:00
|
|
|
|
switch (ui->endiannessComboBox->currentIndex()) {
|
2018-01-20 10:35:31 +00:00
|
|
|
|
case 1:
|
2018-05-27 16:03:29 +00:00
|
|
|
|
return InitialOptions::Endianness::Little;
|
2018-01-20 10:35:31 +00:00
|
|
|
|
case 2:
|
2018-05-27 16:03:29 +00:00
|
|
|
|
return InitialOptions::Endianness::Big;
|
2018-01-20 10:35:31 +00:00
|
|
|
|
default:
|
2018-05-27 16:03:29 +00:00
|
|
|
|
return InitialOptions::Endianness::Auto;
|
2018-01-20 10:35:31 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-06 12:04:55 +00:00
|
|
|
|
QString InitialOptionsDialog::getSelectedOS() const
|
2017-09-27 20:23:18 +00:00
|
|
|
|
{
|
|
|
|
|
QVariant os = ui->kernelComboBox->currentData();
|
|
|
|
|
return os.isValid() ? os.toString() : nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-03 21:58:41 +00:00
|
|
|
|
QList<CommandDescription> InitialOptionsDialog::getSelectedAdvancedAnalCmds() const
|
2018-05-27 19:38:19 +00:00
|
|
|
|
{
|
2019-08-03 21:58:41 +00:00
|
|
|
|
QList<CommandDescription> advanced = QList<CommandDescription>();
|
2018-05-27 19:38:19 +00:00
|
|
|
|
if (ui->analSlider->value() == 3) {
|
2019-08-03 21:58:41 +00:00
|
|
|
|
AnalysisCommands item;
|
|
|
|
|
foreach (item, analysisCommands){
|
|
|
|
|
if(item.checkbox->isChecked()) {
|
|
|
|
|
advanced << item.commandDesc;
|
|
|
|
|
}
|
2018-05-27 19:38:19 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return advanced;
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-18 16:04:45 +00:00
|
|
|
|
void InitialOptionsDialog::setupAndStartAnalysis(/*int level, QList<QString> advanced*/)
|
2017-03-29 10:18:37 +00:00
|
|
|
|
{
|
2018-05-27 16:03:29 +00:00
|
|
|
|
InitialOptions options;
|
2018-05-26 18:49:57 +00:00
|
|
|
|
|
2018-05-27 16:03:29 +00:00
|
|
|
|
options.filename = main->getFilename();
|
2018-09-27 11:16:07 +00:00
|
|
|
|
if (!options.filename.isEmpty()) {
|
|
|
|
|
main->setWindowTitle("Cutter – " + options.filename);
|
|
|
|
|
}
|
2018-08-10 17:12:00 +00:00
|
|
|
|
options.shellcode = this->shellcode;
|
2018-05-27 16:03:29 +00:00
|
|
|
|
|
|
|
|
|
// Where the bin header is located in the file (-B)
|
|
|
|
|
if (ui->entry_loadOffset->text().length() > 0) {
|
|
|
|
|
options.binLoadAddr = Core()->math(ui->entry_loadOffset->text());
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-30 20:00:53 +00:00
|
|
|
|
options.mapAddr = Core()->math(
|
|
|
|
|
ui->entry_mapOffset->text()); // Where to map the file once loaded (-m)
|
2018-05-27 16:03:29 +00:00
|
|
|
|
options.arch = getSelectedArch();
|
|
|
|
|
options.cpu = getSelectedCPU();
|
|
|
|
|
options.bits = getSelectedBits();
|
|
|
|
|
options.os = getSelectedOS();
|
|
|
|
|
options.writeEnabled = ui->writeCheckBox->isChecked();
|
|
|
|
|
options.loadBinInfo = !ui->binCheckBox->isChecked();
|
|
|
|
|
QVariant forceBinPluginData = ui->formatComboBox->currentData();
|
|
|
|
|
if (!forceBinPluginData.isNull()) {
|
|
|
|
|
RBinPluginDescription pluginDesc = forceBinPluginData.value<RBinPluginDescription>();
|
|
|
|
|
options.forceBinPlugin = pluginDesc.name;
|
|
|
|
|
}
|
|
|
|
|
options.demangle = ui->demangleCheckBox->isChecked();
|
|
|
|
|
if (ui->pdbCheckBox->isChecked()) {
|
|
|
|
|
options.pdbFile = ui->pdbLineEdit->text();
|
|
|
|
|
}
|
|
|
|
|
if (ui->scriptCheckBox->isChecked()) {
|
|
|
|
|
options.script = ui->scriptLineEdit->text();
|
|
|
|
|
}
|
2019-01-31 16:45:58 +00:00
|
|
|
|
|
|
|
|
|
|
2018-05-27 16:03:29 +00:00
|
|
|
|
options.endian = getSelectedEndianness();
|
|
|
|
|
|
2018-08-18 16:04:45 +00:00
|
|
|
|
int level = ui->analSlider->value();
|
2018-09-30 20:00:53 +00:00
|
|
|
|
switch (level) {
|
|
|
|
|
case 1:
|
2019-08-03 21:58:41 +00:00
|
|
|
|
options.analCmd = { {"aaa", "Auto analysis"} };
|
2018-09-30 20:00:53 +00:00
|
|
|
|
break;
|
|
|
|
|
case 2:
|
2020-06-04 03:41:55 +00:00
|
|
|
|
options.analCmd = { {"aaaa", "Auto analysis (experimental)"} };
|
2018-09-30 20:00:53 +00:00
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
options.analCmd = getSelectedAdvancedAnalCmds();
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
options.analCmd = {};
|
|
|
|
|
break;
|
2018-05-27 19:38:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2018-05-28 14:19:04 +00:00
|
|
|
|
AnalTask *analTask = new AnalTask();
|
2018-05-27 16:03:29 +00:00
|
|
|
|
analTask->setOptions(options);
|
|
|
|
|
|
2018-07-07 10:39:28 +00:00
|
|
|
|
MainWindow *main = this->main;
|
2018-05-27 16:03:29 +00:00
|
|
|
|
connect(analTask, &AnalTask::openFileFailed, main, &MainWindow::openNewFileFailed);
|
2018-07-07 10:39:28 +00:00
|
|
|
|
connect(analTask, &AsyncTask::finished, main, [analTask, main]() {
|
|
|
|
|
if (analTask->getOpenFileFailed()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
main->finalizeOpen();
|
|
|
|
|
});
|
2018-05-27 16:03:29 +00:00
|
|
|
|
|
2018-05-28 14:19:04 +00:00
|
|
|
|
AsyncTask::Ptr analTaskPtr(analTask);
|
|
|
|
|
|
|
|
|
|
AsyncTaskDialog *taskDialog = new AsyncTaskDialog(analTaskPtr);
|
2018-06-26 20:11:26 +00:00
|
|
|
|
taskDialog->setInterruptOnClose(true);
|
2018-05-27 16:03:29 +00:00
|
|
|
|
taskDialog->setAttribute(Qt::WA_DeleteOnClose);
|
2018-05-26 18:49:57 +00:00
|
|
|
|
taskDialog->show();
|
2018-05-27 16:03:29 +00:00
|
|
|
|
|
2018-07-07 10:32:51 +00:00
|
|
|
|
Core()->getAsyncTaskManager()->start(analTaskPtr);
|
|
|
|
|
|
2018-05-27 16:03:29 +00:00
|
|
|
|
done(0);
|
2017-09-28 22:04:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-08-18 10:51:11 +00:00
|
|
|
|
void InitialOptionsDialog::on_okButton_clicked()
|
2017-04-28 13:09:40 +00:00
|
|
|
|
{
|
2018-08-01 19:31:57 +00:00
|
|
|
|
ui->okButton->setEnabled(false);
|
2018-08-18 16:04:45 +00:00
|
|
|
|
setupAndStartAnalysis();
|
2017-03-29 10:18:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-08-18 10:51:11 +00:00
|
|
|
|
void InitialOptionsDialog::closeEvent(QCloseEvent *event)
|
2018-03-09 12:57:57 +00:00
|
|
|
|
{
|
|
|
|
|
event->accept();
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-18 10:51:11 +00:00
|
|
|
|
QString InitialOptionsDialog::analysisDescription(int level)
|
2017-04-10 12:22:18 +00:00
|
|
|
|
{
|
|
|
|
|
//TODO: replace this with meaningful descriptions
|
2018-03-21 20:32:32 +00:00
|
|
|
|
switch (level) {
|
2017-04-10 12:22:18 +00:00
|
|
|
|
case 0:
|
2017-07-24 11:05:28 +00:00
|
|
|
|
return tr("No analysis");
|
2017-04-10 12:22:18 +00:00
|
|
|
|
case 1:
|
2017-07-24 11:05:28 +00:00
|
|
|
|
return tr("Auto-Analysis (aaa)");
|
2017-04-10 12:22:18 +00:00
|
|
|
|
case 2:
|
2017-07-24 11:05:28 +00:00
|
|
|
|
return tr("Auto-Analysis Experimental (aaaa)");
|
2017-04-10 12:22:18 +00:00
|
|
|
|
case 3:
|
2017-07-24 11:05:28 +00:00
|
|
|
|
return tr("Advanced");
|
2017-04-10 12:22:18 +00:00
|
|
|
|
default:
|
|
|
|
|
return tr("Unknown");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-18 10:51:11 +00:00
|
|
|
|
void InitialOptionsDialog::on_analSlider_valueChanged(int value)
|
2017-03-29 10:18:37 +00:00
|
|
|
|
{
|
2017-04-12 15:02:35 +00:00
|
|
|
|
ui->analDescription->setText(tr("Level") + QString(": %1").arg(analysisDescription(value)));
|
2018-03-21 20:32:32 +00:00
|
|
|
|
if (value == 0) {
|
2017-03-29 10:18:37 +00:00
|
|
|
|
ui->analCheckBox->setChecked(false);
|
2017-09-09 09:36:15 +00:00
|
|
|
|
ui->analCheckBox->setText(tr("Analysis: Disabled"));
|
2018-03-21 20:32:32 +00:00
|
|
|
|
} else {
|
2017-03-29 10:18:37 +00:00
|
|
|
|
ui->analCheckBox->setChecked(true);
|
2017-09-09 09:36:15 +00:00
|
|
|
|
ui->analCheckBox->setText(tr("Analysis: Enabled"));
|
2018-03-21 20:32:32 +00:00
|
|
|
|
if (value == 3) {
|
2017-07-24 11:05:28 +00:00
|
|
|
|
ui->analoptionsFrame->setVisible(true);
|
2019-08-03 21:58:41 +00:00
|
|
|
|
ui->advancedAnlysisLine->setVisible(true);
|
2018-03-21 20:32:32 +00:00
|
|
|
|
} else {
|
2017-07-24 11:05:28 +00:00
|
|
|
|
ui->analoptionsFrame->setVisible(false);
|
2019-08-03 21:58:41 +00:00
|
|
|
|
ui->advancedAnlysisLine->setVisible(false);
|
2017-07-24 11:05:28 +00:00
|
|
|
|
}
|
2017-03-29 10:18:37 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-18 10:51:11 +00:00
|
|
|
|
void InitialOptionsDialog::on_AdvOptButton_clicked()
|
2017-03-29 10:18:37 +00:00
|
|
|
|
{
|
2018-03-21 20:32:32 +00:00
|
|
|
|
if (ui->AdvOptButton->isChecked()) {
|
2017-03-29 10:18:37 +00:00
|
|
|
|
ui->hideFrame->setVisible(true);
|
|
|
|
|
ui->AdvOptButton->setArrowType(Qt::DownArrow);
|
2018-03-21 20:32:32 +00:00
|
|
|
|
} else {
|
2017-03-29 10:18:37 +00:00
|
|
|
|
ui->hideFrame->setVisible(false);
|
|
|
|
|
ui->AdvOptButton->setArrowType(Qt::RightArrow);
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-04-10 12:22:18 +00:00
|
|
|
|
|
2018-08-18 10:51:11 +00:00
|
|
|
|
void InitialOptionsDialog::on_analCheckBox_clicked(bool checked)
|
2017-04-10 12:22:18 +00:00
|
|
|
|
{
|
2018-08-18 18:45:49 +00:00
|
|
|
|
if (!checked) {
|
|
|
|
|
analLevel = ui->analSlider->value();
|
|
|
|
|
}
|
|
|
|
|
ui->analSlider->setValue(checked ? analLevel : 0);
|
2017-04-10 12:22:18 +00:00
|
|
|
|
}
|
2017-09-27 20:23:18 +00:00
|
|
|
|
|
2018-08-18 10:51:11 +00:00
|
|
|
|
void InitialOptionsDialog::on_archComboBox_currentIndexChanged(int)
|
2017-09-27 20:23:18 +00:00
|
|
|
|
{
|
|
|
|
|
updateCPUComboBox();
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-18 10:51:11 +00:00
|
|
|
|
void InitialOptionsDialog::updatePDBLayout()
|
2017-09-27 20:23:18 +00:00
|
|
|
|
{
|
|
|
|
|
ui->pdbWidget->setEnabled(ui->pdbCheckBox->isChecked());
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-18 10:51:11 +00:00
|
|
|
|
void InitialOptionsDialog::on_pdbSelectButton_clicked()
|
2017-09-27 20:23:18 +00:00
|
|
|
|
{
|
|
|
|
|
QFileDialog dialog(this);
|
|
|
|
|
dialog.setWindowTitle(tr("Select PDB file"));
|
|
|
|
|
dialog.setNameFilters({ tr("PDB file (*.pdb)"), tr("All files (*)") });
|
|
|
|
|
|
2018-03-21 20:32:32 +00:00
|
|
|
|
if (!dialog.exec()) {
|
2017-09-27 20:23:18 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-02 06:48:17 +00:00
|
|
|
|
const QString &fileName = QDir::toNativeSeparators(dialog.selectedFiles().first());
|
2017-09-27 20:23:18 +00:00
|
|
|
|
|
2018-03-21 20:32:32 +00:00
|
|
|
|
if (!fileName.isEmpty()) {
|
2017-09-27 20:23:18 +00:00
|
|
|
|
ui->pdbLineEdit->setText(fileName);
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-12-06 12:32:35 +00:00
|
|
|
|
|
2018-04-30 06:39:48 +00:00
|
|
|
|
|
2018-08-18 10:51:11 +00:00
|
|
|
|
void InitialOptionsDialog::updateScriptLayout()
|
2018-04-30 06:39:48 +00:00
|
|
|
|
{
|
|
|
|
|
ui->scriptWidget->setEnabled(ui->scriptCheckBox->isChecked());
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-18 10:51:11 +00:00
|
|
|
|
void InitialOptionsDialog::on_scriptSelectButton_clicked()
|
2018-04-30 06:39:48 +00:00
|
|
|
|
{
|
|
|
|
|
QFileDialog dialog(this);
|
|
|
|
|
dialog.setWindowTitle(tr("Select radare2 script file"));
|
|
|
|
|
dialog.setNameFilters({ tr("Script file (*.r2)"), tr("All files (*)") });
|
|
|
|
|
|
|
|
|
|
if (!dialog.exec()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-02 06:48:17 +00:00
|
|
|
|
const QString &fileName = QDir::toNativeSeparators(dialog.selectedFiles().first());
|
2018-04-30 06:39:48 +00:00
|
|
|
|
|
|
|
|
|
if (!fileName.isEmpty()) {
|
|
|
|
|
ui->scriptLineEdit->setText(fileName);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2018-08-18 10:51:11 +00:00
|
|
|
|
void InitialOptionsDialog::reject()
|
2017-12-06 12:32:35 +00:00
|
|
|
|
{
|
|
|
|
|
done(0);
|
2019-03-10 22:26:25 +00:00
|
|
|
|
main->displayNewFileDialog();
|
2017-12-06 12:32:35 +00:00
|
|
|
|
}
|