2017-03-29 10:18:37 +00:00
|
|
|
#include "mainwindow.h"
|
|
|
|
#include "ui_mainwindow.h"
|
|
|
|
#include "createnewdialog.h"
|
|
|
|
#include "dialogs/commentsdialog.h"
|
|
|
|
#include "dialogs/aboutdialog.h"
|
|
|
|
#include "dialogs/renamedialog.h"
|
2017-04-18 10:03:47 +00:00
|
|
|
#include "helpers.h"
|
2017-03-29 10:18:37 +00:00
|
|
|
|
2017-05-14 16:21:54 +00:00
|
|
|
#include <QComboBox>
|
|
|
|
#include <QCompleter>
|
2017-03-29 10:18:37 +00:00
|
|
|
#include <QDebug>
|
|
|
|
#include <QDesktopServices>
|
2017-05-14 16:21:54 +00:00
|
|
|
#include <QDir>
|
|
|
|
#include <QDockWidget>
|
|
|
|
#include <QFile>
|
2017-03-29 10:18:37 +00:00
|
|
|
#include <QFileDialog>
|
2017-05-14 16:21:54 +00:00
|
|
|
#include <QFont>
|
|
|
|
#include <QFontDialog>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QLineEdit>
|
|
|
|
#include <QList>
|
|
|
|
#include <QMessageBox>
|
|
|
|
#include <QProcess>
|
2017-03-29 10:18:37 +00:00
|
|
|
#include <QPropertyAnimation>
|
2017-05-14 16:21:54 +00:00
|
|
|
#include <QScrollBar>
|
|
|
|
#include <QSettings>
|
|
|
|
#include <QShortcut>
|
|
|
|
#include <QStringListModel>
|
2017-03-29 10:18:37 +00:00
|
|
|
#include <QStyledItemDelegate>
|
2017-05-14 16:21:54 +00:00
|
|
|
#include <QStyleFactory>
|
|
|
|
#include <QTextCursor>
|
2017-03-29 10:18:37 +00:00
|
|
|
#include <QtGlobal>
|
2017-05-14 16:21:54 +00:00
|
|
|
#include <QToolButton>
|
2017-03-29 10:18:37 +00:00
|
|
|
#include <QToolTip>
|
2017-04-13 15:36:20 +00:00
|
|
|
#include <QTreeWidgetItem>
|
2017-05-14 16:21:54 +00:00
|
|
|
|
2017-04-13 15:36:20 +00:00
|
|
|
|
|
|
|
#include "highlighter.h"
|
|
|
|
#include "hexascii_highlighter.h"
|
|
|
|
#include "newfiledialog.h"
|
|
|
|
#include "helpers.h"
|
|
|
|
|
|
|
|
#include "widgets/memorywidget.h"
|
|
|
|
#include "widgets/functionswidget.h"
|
|
|
|
#include "widgets/sectionswidget.h"
|
|
|
|
#include "widgets/commentswidget.h"
|
|
|
|
#include "widgets/importswidget.h"
|
2017-05-19 07:45:26 +00:00
|
|
|
#include "widgets/exportswidget.h"
|
2017-04-13 15:36:20 +00:00
|
|
|
#include "widgets/symbolswidget.h"
|
|
|
|
#include "widgets/stringswidget.h"
|
|
|
|
#include "widgets/sectionsdock.h"
|
|
|
|
#include "widgets/relocswidget.h"
|
|
|
|
#include "widgets/flagswidget.h"
|
|
|
|
#include "widgets/codegraphic.h"
|
|
|
|
#include "widgets/dashboard.h"
|
|
|
|
#include "widgets/notepad.h"
|
|
|
|
#include "widgets/sidebar.h"
|
|
|
|
#include "widgets/sdbdock.h"
|
|
|
|
#include "widgets/omnibar.h"
|
2017-04-26 23:00:20 +00:00
|
|
|
#include "widgets/consolewidget.h"
|
2017-05-13 18:09:36 +00:00
|
|
|
#include "settings.h"
|
|
|
|
#include "optionsdialog.h"
|
2017-07-13 18:49:12 +00:00
|
|
|
#include "widgets/entrypointwidget.h"
|
2017-04-13 15:36:20 +00:00
|
|
|
|
2017-03-29 10:18:37 +00:00
|
|
|
// graphics
|
|
|
|
#include <QGraphicsEllipseItem>
|
|
|
|
#include <QGraphicsScene>
|
|
|
|
#include <QGraphicsView>
|
|
|
|
|
2017-04-05 08:56:59 +00:00
|
|
|
#include <cassert>
|
|
|
|
|
2017-04-09 17:09:35 +00:00
|
|
|
static void registerCustomFonts()
|
2017-04-05 08:56:59 +00:00
|
|
|
{
|
2017-06-15 09:53:10 +00:00
|
|
|
int ret = QFontDatabase::addApplicationFont(":/fonts/Anonymous Pro.ttf");
|
2017-04-09 17:09:35 +00:00
|
|
|
assert(-1 != ret && "unable to register Anonymous Pro.ttf");
|
2017-04-05 08:56:59 +00:00
|
|
|
|
2017-06-15 09:53:10 +00:00
|
|
|
ret = QFontDatabase::addApplicationFont(":/fonts/Inconsolata-Regular.ttf");
|
2017-04-09 17:09:35 +00:00
|
|
|
assert(-1 != ret && "unable to register Inconsolata-Regular.ttf");
|
2017-04-05 08:56:59 +00:00
|
|
|
|
2017-04-09 17:09:35 +00:00
|
|
|
// do not issue a warning in release
|
|
|
|
Q_UNUSED(ret)
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
|
2017-05-13 18:09:36 +00:00
|
|
|
MainWindow::MainWindow(QWidget *parent) :
|
2017-03-29 10:18:37 +00:00
|
|
|
QMainWindow(parent),
|
2017-07-02 11:11:02 +00:00
|
|
|
core(new IaitoRCore()),
|
2017-04-13 15:36:20 +00:00
|
|
|
memoryDock(nullptr),
|
|
|
|
notepadDock(nullptr),
|
2017-04-12 21:04:39 +00:00
|
|
|
asmDock(nullptr),
|
|
|
|
calcDock(nullptr),
|
|
|
|
omnibar(nullptr),
|
|
|
|
sideBar(nullptr),
|
2017-04-01 01:56:35 +00:00
|
|
|
ui(new Ui::MainWindow),
|
2017-04-12 21:04:39 +00:00
|
|
|
highlighter(nullptr),
|
|
|
|
hex_highlighter(nullptr),
|
|
|
|
graphicsBar(nullptr),
|
|
|
|
functionsDock(nullptr),
|
|
|
|
importsDock(nullptr),
|
2017-05-19 07:45:26 +00:00
|
|
|
exportsDock(nullptr),
|
2017-04-12 21:04:39 +00:00
|
|
|
symbolsDock(nullptr),
|
|
|
|
relocsDock(nullptr),
|
|
|
|
commentsDock(nullptr),
|
|
|
|
stringsDock(nullptr),
|
|
|
|
flagsDock(nullptr),
|
|
|
|
dashboardDock(nullptr),
|
|
|
|
gotoEntry(nullptr),
|
|
|
|
sdbDock(nullptr),
|
|
|
|
sidebar_action(nullptr),
|
|
|
|
sectionsDock(nullptr),
|
2017-04-26 23:00:20 +00:00
|
|
|
consoleWidget(nullptr),
|
2017-07-13 18:49:12 +00:00
|
|
|
entrypointDock(nullptr),
|
2017-05-13 16:39:37 +00:00
|
|
|
webserver(core)
|
2017-03-29 10:18:37 +00:00
|
|
|
{
|
|
|
|
doLock = false;
|
2017-04-28 13:09:40 +00:00
|
|
|
this->cursor_address = core->getOffset();
|
2017-05-13 18:09:36 +00:00
|
|
|
}
|
2017-03-29 10:18:37 +00:00
|
|
|
|
2017-05-13 18:09:36 +00:00
|
|
|
MainWindow::~MainWindow()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
delete core;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::initUI()
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
2017-04-05 08:56:59 +00:00
|
|
|
|
2017-05-13 18:09:36 +00:00
|
|
|
registerCustomFonts();
|
2017-03-29 10:18:37 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Toolbar
|
|
|
|
*/
|
|
|
|
// Hide central tab widget tabs
|
|
|
|
QTabBar *centralbar = ui->centralTabWidget->tabBar();
|
|
|
|
centralbar->setVisible(false);
|
2017-04-26 23:00:20 +00:00
|
|
|
consoleWidget = new ConsoleWidget(core, this);
|
|
|
|
ui->tabVerticalLayout->addWidget(consoleWidget);
|
2017-03-29 10:18:37 +00:00
|
|
|
|
|
|
|
// Sepparator between back/forward and undo/redo buttons
|
2017-04-09 19:55:06 +00:00
|
|
|
QWidget *spacer4 = new QWidget();
|
2017-03-29 10:18:37 +00:00
|
|
|
spacer4->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
|
|
|
|
spacer4->setMinimumSize(10, 10);
|
|
|
|
ui->mainToolBar->insertWidget(ui->actionForward, spacer4);
|
|
|
|
|
|
|
|
// Popup menu on theme toolbar button
|
|
|
|
QToolButton *backButton = new QToolButton(this);
|
2017-06-15 09:53:10 +00:00
|
|
|
backButton->setIcon(QIcon(":/img/icons/arrow_left.svg"));
|
2017-03-29 10:18:37 +00:00
|
|
|
//backButton->setPopupMode(QToolButton::DelayedPopup);
|
|
|
|
ui->mainToolBar->insertWidget(ui->actionForward, backButton);
|
2017-04-01 12:43:57 +00:00
|
|
|
connect(backButton, SIGNAL(clicked()), this, SLOT(on_backButton_clicked()));
|
2017-03-29 10:18:37 +00:00
|
|
|
|
|
|
|
// Sepparator between undo/redo and goto lineEdit
|
2017-04-09 19:55:06 +00:00
|
|
|
QWidget *spacer3 = new QWidget();
|
2017-03-29 10:18:37 +00:00
|
|
|
spacer3->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
|
|
|
spacer3->setMinimumSize(20, 20);
|
|
|
|
spacer3->setMaximumWidth(300);
|
|
|
|
ui->mainToolBar->insertWidget(ui->actionShow_Hide_mainsidebar, spacer3);
|
|
|
|
|
|
|
|
// Omnibar LineEdit
|
|
|
|
this->omnibar = new Omnibar(this);
|
|
|
|
ui->mainToolBar->insertWidget(ui->actionShow_Hide_mainsidebar, this->omnibar);
|
|
|
|
|
2017-09-01 13:03:35 +00:00
|
|
|
// Add special separators to the toolbar that expand to separate groups of elements
|
2017-04-09 19:55:06 +00:00
|
|
|
QWidget *spacer2 = new QWidget();
|
2017-03-29 10:18:37 +00:00
|
|
|
spacer2->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
|
|
|
spacer2->setMinimumSize(10, 10);
|
|
|
|
spacer2->setMaximumWidth(300);
|
|
|
|
ui->mainToolBar->insertWidget(ui->actionShow_Hide_mainsidebar, spacer2);
|
|
|
|
|
2017-09-01 13:03:35 +00:00
|
|
|
// Separator between back/forward and undo/redo buttons
|
2017-04-09 19:55:06 +00:00
|
|
|
QWidget *spacer = new QWidget();
|
2017-03-29 10:18:37 +00:00
|
|
|
spacer->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
|
|
|
|
spacer->setMinimumSize(20, 20);
|
|
|
|
ui->mainToolBar->addWidget(spacer);
|
|
|
|
|
|
|
|
// codeGraphics tool bar
|
|
|
|
this->graphicsBar = new GraphicsBar(this);
|
|
|
|
this->graphicsBar->setMovable(false);
|
|
|
|
addToolBarBreak(Qt::TopToolBarArea);
|
|
|
|
addToolBar(graphicsBar);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Dock Widgets
|
|
|
|
*/
|
2017-04-13 15:36:20 +00:00
|
|
|
dockWidgets.reserve(11);
|
|
|
|
|
2017-03-29 10:18:37 +00:00
|
|
|
// Add Memory DockWidget
|
|
|
|
this->memoryDock = new MemoryWidget(this);
|
2017-04-13 15:36:20 +00:00
|
|
|
dockWidgets.push_back(memoryDock);
|
2017-03-29 10:18:37 +00:00
|
|
|
// To use in the future when we handle more than one memory views
|
|
|
|
// this->memoryDock->setAttribute(Qt::WA_DeleteOnClose);
|
|
|
|
// this->add_debug_output( QString::number(this->dockList.length()) );
|
|
|
|
|
|
|
|
// Add Sections dock panel
|
2017-04-12 10:16:43 +00:00
|
|
|
this->sectionsDock = new SectionsDock(this);
|
2017-04-13 15:36:20 +00:00
|
|
|
dockWidgets.push_back(sectionsDock);
|
2017-03-29 10:18:37 +00:00
|
|
|
|
2017-07-13 18:49:12 +00:00
|
|
|
// Add entrypoint DockWidget
|
|
|
|
this->entrypointDock = new EntrypointWidget(this);
|
|
|
|
dockWidgets.push_back(entrypointDock);
|
|
|
|
|
2017-03-29 10:18:37 +00:00
|
|
|
// Add functions DockWidget
|
|
|
|
this->functionsDock = new FunctionsWidget(this);
|
2017-04-13 15:36:20 +00:00
|
|
|
dockWidgets.push_back(functionsDock);
|
2017-03-29 10:18:37 +00:00
|
|
|
|
|
|
|
// Add imports DockWidget
|
|
|
|
this->importsDock = new ImportsWidget(this);
|
2017-04-13 15:36:20 +00:00
|
|
|
dockWidgets.push_back(importsDock);
|
2017-03-29 10:18:37 +00:00
|
|
|
|
2017-05-19 07:45:26 +00:00
|
|
|
// Add exports DockWidget
|
|
|
|
this->exportsDock = new ExportsWidget(this);
|
|
|
|
dockWidgets.push_back(exportsDock);
|
|
|
|
|
2017-03-29 10:18:37 +00:00
|
|
|
// Add symbols DockWidget
|
|
|
|
this->symbolsDock = new SymbolsWidget(this);
|
2017-04-13 15:36:20 +00:00
|
|
|
dockWidgets.push_back(symbolsDock);
|
2017-03-29 10:18:37 +00:00
|
|
|
|
|
|
|
// Add relocs DockWidget
|
|
|
|
this->relocsDock = new RelocsWidget(this);
|
2017-04-13 15:36:20 +00:00
|
|
|
dockWidgets.push_back(relocsDock);
|
2017-03-29 10:18:37 +00:00
|
|
|
|
|
|
|
// Add comments DockWidget
|
|
|
|
this->commentsDock = new CommentsWidget(this);
|
2017-04-13 15:36:20 +00:00
|
|
|
dockWidgets.push_back(commentsDock);
|
2017-03-29 10:18:37 +00:00
|
|
|
|
|
|
|
// Add strings DockWidget
|
|
|
|
this->stringsDock = new StringsWidget(this);
|
2017-04-13 15:36:20 +00:00
|
|
|
dockWidgets.push_back(stringsDock);
|
2017-03-29 10:18:37 +00:00
|
|
|
|
|
|
|
// Add flags DockWidget
|
|
|
|
this->flagsDock = new FlagsWidget(this);
|
2017-04-13 15:36:20 +00:00
|
|
|
dockWidgets.push_back(flagsDock);
|
2017-03-29 10:18:37 +00:00
|
|
|
|
|
|
|
// Add Notepad Dock panel
|
|
|
|
this->notepadDock = new Notepad(this);
|
2017-04-13 15:36:20 +00:00
|
|
|
dockWidgets.push_back(notepadDock);
|
|
|
|
connect(memoryDock, SIGNAL(fontChanged(QFont)), notepadDock, SLOT(setFonts(QFont)));
|
2017-03-29 10:18:37 +00:00
|
|
|
|
|
|
|
//Add Dashboard Dock panel
|
|
|
|
this->dashboardDock = new Dashboard(this);
|
2017-04-13 15:36:20 +00:00
|
|
|
dockWidgets.push_back(dashboardDock);
|
2017-03-29 10:18:37 +00:00
|
|
|
|
|
|
|
// Set up dock widgets default layout
|
|
|
|
restoreDocks();
|
|
|
|
hideAllDocks();
|
|
|
|
showDefaultDocks();
|
|
|
|
|
|
|
|
// Restore saved settings
|
|
|
|
this->readSettings();
|
|
|
|
// TODO: Allow the user to select this option visually in the GUI settings
|
|
|
|
// Adjust the DockWidget areas
|
2017-04-09 19:55:06 +00:00
|
|
|
setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea);
|
2017-03-29 10:18:37 +00:00
|
|
|
//setCorner( Qt::TopRightCorner, Qt::RightDockWidgetArea );
|
2017-04-09 19:55:06 +00:00
|
|
|
setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
|
2017-03-29 10:18:37 +00:00
|
|
|
//setCorner( Qt::BottomRightCorner, Qt::RightDockWidgetArea );
|
|
|
|
|
|
|
|
// Setup and hide sidebar by default
|
|
|
|
this->sideBar = new SideBar(this);
|
|
|
|
this->sidebar_action = ui->sideToolBar->addWidget(this->sideBar);
|
|
|
|
ui->sideToolBar->hide();
|
|
|
|
|
|
|
|
// Show dashboard by default
|
|
|
|
this->dashboardDock->raise();
|
|
|
|
|
|
|
|
//qDebug() << "FOLDER: " << QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);
|
|
|
|
/*
|
|
|
|
* Some global shortcuts
|
|
|
|
*/
|
|
|
|
// Period goes to command entry
|
2017-04-09 19:55:06 +00:00
|
|
|
QShortcut *cmd_shortcut = new QShortcut(QKeySequence(Qt::Key_Period), this);
|
2017-04-26 23:00:20 +00:00
|
|
|
connect(cmd_shortcut, SIGNAL(activated()), consoleWidget, SLOT(focusInputLineEdit()));
|
2017-03-29 10:18:37 +00:00
|
|
|
|
|
|
|
// G and S goes to goto entry
|
2017-04-09 19:55:06 +00:00
|
|
|
QShortcut *goto_shortcut = new QShortcut(QKeySequence(Qt::Key_G), this);
|
2017-03-29 10:18:37 +00:00
|
|
|
connect(goto_shortcut, SIGNAL(activated()), this->omnibar, SLOT(setFocus()));
|
2017-04-09 19:55:06 +00:00
|
|
|
QShortcut *seek_shortcut = new QShortcut(QKeySequence(Qt::Key_S), this);
|
2017-03-29 10:18:37 +00:00
|
|
|
connect(seek_shortcut, SIGNAL(activated()), this->omnibar, SLOT(setFocus()));
|
|
|
|
|
|
|
|
// : goes to goto entry
|
2017-04-09 19:55:06 +00:00
|
|
|
QShortcut *commands_shortcut = new QShortcut(QKeySequence(Qt::Key_Colon), this);
|
2017-03-29 10:18:37 +00:00
|
|
|
connect(commands_shortcut, SIGNAL(activated()), this->omnibar, SLOT(showCommands()));
|
|
|
|
|
2017-04-12 21:04:39 +00:00
|
|
|
QShortcut *refresh_shortcut = new QShortcut(QKeySequence(QKeySequence::Refresh), this);
|
|
|
|
connect(refresh_shortcut, SIGNAL(activated()), this, SLOT(refreshVisibleDockWidgets()));
|
2017-04-01 01:56:35 +00:00
|
|
|
}
|
|
|
|
|
2017-07-24 11:05:28 +00:00
|
|
|
void MainWindow::openFile(const QString &fn, int anal_level, QList<QString> advanced)
|
2017-04-09 19:55:06 +00:00
|
|
|
{
|
2017-05-13 18:09:36 +00:00
|
|
|
QString project_name = qhelpers::uniqueProjectName(fn);
|
|
|
|
|
2017-06-03 12:27:23 +00:00
|
|
|
if (core->getProjectNames().contains(project_name))
|
2017-05-13 18:09:36 +00:00
|
|
|
openProject(project_name);
|
|
|
|
else
|
2017-07-24 11:05:28 +00:00
|
|
|
openNewFile(fn, anal_level, advanced);
|
2017-05-13 18:09:36 +00:00
|
|
|
}
|
|
|
|
|
2017-07-24 11:05:28 +00:00
|
|
|
void MainWindow::openNewFile(const QString &fn, int anal_level, QList<QString> advanced)
|
2017-05-13 18:09:36 +00:00
|
|
|
{
|
|
|
|
setFilename(fn);
|
|
|
|
|
|
|
|
OptionsDialog *o = new OptionsDialog(this);
|
|
|
|
o->setAttribute(Qt::WA_DeleteOnClose);
|
|
|
|
o->show();
|
|
|
|
|
2017-06-03 12:27:23 +00:00
|
|
|
if (anal_level >= 0)
|
2017-07-24 11:05:28 +00:00
|
|
|
o->setupAndStartAnalysis(anal_level, advanced);
|
2017-05-13 18:09:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::openProject(const QString &project_name)
|
|
|
|
{
|
|
|
|
QString filename = core->cmd("Pi " + project_name);
|
|
|
|
setFilename(filename.trimmed());
|
|
|
|
|
|
|
|
core->cmd("Po " + project_name);
|
|
|
|
|
|
|
|
initUI();
|
|
|
|
finalizeOpen();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::finalizeOpen()
|
|
|
|
{
|
|
|
|
core->getOpcodes();
|
|
|
|
|
|
|
|
// Set settings to override any incorrect saved in the project
|
|
|
|
core->setSettings();
|
|
|
|
|
|
|
|
|
|
|
|
addOutput(" > Populating UI");
|
|
|
|
// FIXME: initialization order frakup. the next line is needed so that the
|
|
|
|
// comments widget displays the function names.
|
|
|
|
core->cmd("fs sections");
|
|
|
|
updateFrames();
|
|
|
|
|
|
|
|
memoryDock->selectHexPreview();
|
|
|
|
|
|
|
|
// Restore project notes
|
|
|
|
QString notes = this->core->cmd("Pnj");
|
|
|
|
//qDebug() << "Notes:" << notes;
|
|
|
|
if (notes != "")
|
|
|
|
{
|
|
|
|
QByteArray ba;
|
|
|
|
ba.append(notes);
|
|
|
|
notepadDock->setText(QByteArray::fromBase64(ba));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
addOutput(" > Adding binary information to notepad");
|
|
|
|
|
|
|
|
notepadDock->setText("# Binary information\n\n" + core->cmd("i") +
|
2017-06-03 12:27:23 +00:00
|
|
|
"\n" + core->cmd("ie") + "\n" + core->cmd("iM") + "\n");
|
2017-05-13 18:09:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//Get binary beginning/end addresses
|
|
|
|
this->core->binStart = this->core->cmd("?v $M");
|
|
|
|
this->core->binEnd = this->core->cmd("?v $M+$s");
|
|
|
|
|
|
|
|
addOutput(" > Finished, happy reversing :)");
|
|
|
|
// Add fortune message
|
|
|
|
addOutput("\n" + core->cmd("fo"));
|
|
|
|
memoryDock->setWindowTitle("entry0");
|
|
|
|
start_web_server();
|
|
|
|
showMaximized();
|
|
|
|
// Initialize syntax highlighters
|
|
|
|
memoryDock->highlightDisasms();
|
|
|
|
notepadDock->highlightPreview();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::applySettings()
|
|
|
|
{
|
|
|
|
Settings settings;
|
|
|
|
|
|
|
|
// Show asm bytes
|
|
|
|
if (settings.getAsmBytes())
|
|
|
|
{
|
|
|
|
core->config("asm.bytes", "true");
|
|
|
|
core->config("asm.cmtcol", "100");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
core->config("asm.bytes", "false");
|
|
|
|
core->config("asm.cmtcol", "70");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Show AT&T syntax
|
|
|
|
if (settings.getATnTSyntax())
|
|
|
|
core->config("asm.syntax", "att");
|
|
|
|
else
|
|
|
|
core->config("asm.syntax", "intel");
|
|
|
|
|
|
|
|
// Show opcode description
|
|
|
|
if (settings.getOpcodeDescription())
|
|
|
|
{
|
|
|
|
core->config("asm.describe", "true");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
core->config("asm.describe", "false");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Show stack pointer
|
|
|
|
if (settings.getStackPointer())
|
|
|
|
{
|
|
|
|
core->config("asm.stackptr", "true");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
core->config("asm.stackptr", "false");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Show uppercase dasm
|
|
|
|
if (settings.getUppercaseDisas())
|
|
|
|
{
|
|
|
|
core->config("asm.ucase", "true");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
core->config("asm.ucase", "false");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Show spaces in dasm
|
|
|
|
if (settings.getSpacy())
|
|
|
|
{
|
2017-05-19 13:25:48 +00:00
|
|
|
core->config("asm.bbline", "true");
|
2017-05-13 18:09:36 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-05-19 13:25:48 +00:00
|
|
|
core->config("asm.bbline", "false");
|
2017-05-13 18:09:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::saveProject()
|
|
|
|
{
|
|
|
|
QString project_name = qhelpers::uniqueProjectName(filename);
|
|
|
|
core->cmd("Ps " + project_name);
|
|
|
|
QString notes = this->notepadDock->textToBase64();
|
|
|
|
//this->add_debug_output(notes);
|
|
|
|
this->core->cmd("Pnj " + notes);
|
|
|
|
this->addOutput("Project saved: " + project_name);
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
|
2017-04-09 19:55:06 +00:00
|
|
|
void MainWindow::start_web_server()
|
|
|
|
{
|
2017-03-29 10:18:37 +00:00
|
|
|
// Start web server
|
2017-05-13 16:39:37 +00:00
|
|
|
webserver.start();
|
2017-04-01 01:56:35 +00:00
|
|
|
}
|
|
|
|
|
2017-03-29 10:18:37 +00:00
|
|
|
|
2017-04-01 01:56:35 +00:00
|
|
|
void MainWindow::setWebServerState(bool start)
|
|
|
|
{
|
2017-04-09 19:55:06 +00:00
|
|
|
if (start)
|
|
|
|
{
|
2017-05-13 16:39:37 +00:00
|
|
|
webserver.start();
|
2017-04-01 01:56:35 +00:00
|
|
|
|
|
|
|
// Open web interface on default browser
|
|
|
|
// ballessay: well isn't this possible with =H&
|
|
|
|
//QString link = "http://localhost:9090/";
|
|
|
|
//QDesktopServices::openUrl(QUrl(link));
|
2017-04-09 19:55:06 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-05-13 16:39:37 +00:00
|
|
|
webserver.stop();
|
2017-04-01 01:56:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-13 15:36:20 +00:00
|
|
|
void MainWindow::raiseMemoryDock()
|
2017-04-09 19:55:06 +00:00
|
|
|
{
|
2017-04-13 15:36:20 +00:00
|
|
|
memoryDock->raise();
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
|
2017-04-13 15:36:20 +00:00
|
|
|
void MainWindow::toggleSideBarTheme()
|
2017-04-09 19:55:06 +00:00
|
|
|
{
|
2017-04-13 15:36:20 +00:00
|
|
|
sideBar->themesButtonToggle();
|
|
|
|
}
|
2017-03-29 10:18:37 +00:00
|
|
|
|
2017-04-27 18:59:27 +00:00
|
|
|
void MainWindow::refreshOmniBar(const QStringList &flags)
|
|
|
|
{
|
|
|
|
omnibar->refresh(flags);
|
|
|
|
}
|
|
|
|
|
2017-04-28 13:38:01 +00:00
|
|
|
void MainWindow::setFilename(const QString &fn)
|
2017-04-13 15:36:20 +00:00
|
|
|
{
|
2017-03-29 10:18:37 +00:00
|
|
|
// Add file name to window title
|
|
|
|
this->filename = fn;
|
|
|
|
this->setWindowTitle("Iaito - " + fn);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::closeEvent(QCloseEvent *event)
|
|
|
|
{
|
|
|
|
QMessageBox::StandardButton ret = QMessageBox::question(this, "Iaito",
|
2017-04-09 19:55:06 +00:00
|
|
|
"Do you really want to exit?\nSave your project before closing!",
|
2017-05-19 07:45:26 +00:00
|
|
|
(QMessageBox::StandardButtons)(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel));
|
2017-03-29 10:18:37 +00:00
|
|
|
//qDebug() << ret;
|
2017-04-09 19:55:06 +00:00
|
|
|
if (ret == QMessageBox::Save)
|
|
|
|
{
|
2017-04-03 00:18:09 +00:00
|
|
|
QSettings settings;
|
2017-03-29 10:18:37 +00:00
|
|
|
settings.setValue("geometry", saveGeometry());
|
|
|
|
settings.setValue("size", size());
|
|
|
|
settings.setValue("pos", pos());
|
|
|
|
settings.setValue("state", saveState());
|
2017-05-13 18:09:36 +00:00
|
|
|
saveProject();
|
2017-03-29 10:18:37 +00:00
|
|
|
QMainWindow::closeEvent(event);
|
2017-04-09 19:55:06 +00:00
|
|
|
}
|
|
|
|
else if (ret == QMessageBox::Discard)
|
|
|
|
{
|
2017-04-03 00:18:09 +00:00
|
|
|
QSettings settings;
|
2017-03-31 10:13:33 +00:00
|
|
|
settings.setValue("geometry", saveGeometry());
|
|
|
|
settings.setValue("size", size());
|
|
|
|
settings.setValue("pos", pos());
|
|
|
|
settings.setValue("state", saveState());
|
2017-04-09 19:55:06 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-03-29 10:18:37 +00:00
|
|
|
event->ignore();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::readSettings()
|
|
|
|
{
|
2017-04-03 00:18:09 +00:00
|
|
|
QSettings settings;
|
2017-03-29 10:18:37 +00:00
|
|
|
QByteArray geo = settings.value("geometry", QByteArray()).toByteArray();
|
|
|
|
restoreGeometry(geo);
|
|
|
|
QByteArray state = settings.value("state", QByteArray()).toByteArray();
|
|
|
|
restoreState(state);
|
2017-04-09 19:55:06 +00:00
|
|
|
if (settings.value("dark").toBool())
|
|
|
|
{
|
2017-03-29 10:18:37 +00:00
|
|
|
this->dark();
|
|
|
|
}
|
|
|
|
this->responsive = settings.value("responsive").toBool();
|
|
|
|
}
|
|
|
|
|
2017-04-09 19:55:06 +00:00
|
|
|
void MainWindow::dark()
|
|
|
|
{
|
2017-03-29 10:18:37 +00:00
|
|
|
qApp->setStyleSheet("QPlainTextEdit { background-color: rgb(64, 64, 64); color: rgb(222, 222, 222);} QTextEdit { background-color: rgb(64, 64, 64); color: rgb(222, 222, 222);} ");
|
|
|
|
this->memoryDock->switchTheme(true);
|
2017-04-03 00:18:09 +00:00
|
|
|
QSettings settings;
|
2017-03-29 10:18:37 +00:00
|
|
|
settings.setValue("dark", true);
|
|
|
|
}
|
|
|
|
|
2017-04-09 19:55:06 +00:00
|
|
|
void MainWindow::def_theme()
|
|
|
|
{
|
2017-03-29 10:18:37 +00:00
|
|
|
qApp->setStyleSheet("");
|
|
|
|
this->memoryDock->switchTheme(false);
|
2017-04-03 00:18:09 +00:00
|
|
|
QSettings settings;
|
2017-03-29 10:18:37 +00:00
|
|
|
settings.setValue("dark", false);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Refresh widget functions
|
|
|
|
*/
|
|
|
|
|
2017-04-09 19:55:06 +00:00
|
|
|
void MainWindow::refreshFunctions()
|
|
|
|
{
|
2017-04-13 15:36:20 +00:00
|
|
|
functionsDock->refresh();
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
|
2017-04-09 19:55:06 +00:00
|
|
|
void MainWindow::refreshComments()
|
|
|
|
{
|
2017-04-13 15:36:20 +00:00
|
|
|
commentsDock->refresh();
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
|
2017-04-09 19:55:06 +00:00
|
|
|
void MainWindow::updateFrames()
|
|
|
|
{
|
2017-03-29 10:18:37 +00:00
|
|
|
if (core == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
static bool first_time = true;
|
2017-04-13 15:36:20 +00:00
|
|
|
|
2017-04-09 19:55:06 +00:00
|
|
|
if (first_time)
|
|
|
|
{
|
2017-04-13 15:36:20 +00:00
|
|
|
for (auto w : dockWidgets)
|
|
|
|
{
|
|
|
|
w->setup();
|
|
|
|
}
|
2017-03-29 10:18:37 +00:00
|
|
|
|
2017-04-13 15:36:20 +00:00
|
|
|
first_time = false;
|
2017-04-09 19:55:06 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-04-13 15:36:20 +00:00
|
|
|
for (auto w : dockWidgets)
|
2017-04-09 19:55:06 +00:00
|
|
|
{
|
2017-04-13 15:36:20 +00:00
|
|
|
w->refresh();
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-13 15:36:20 +00:00
|
|
|
// graphicsBar->refreshColorBar();
|
|
|
|
graphicsBar->fillData();
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionLock_triggered()
|
|
|
|
{
|
|
|
|
doLock = !doLock;
|
2017-04-09 19:55:06 +00:00
|
|
|
if (doLock)
|
|
|
|
{
|
|
|
|
foreach (QDockWidget *dockWidget, findChildren<QDockWidget *>())
|
|
|
|
{
|
|
|
|
dockWidget->setFeatures(QDockWidget::NoDockWidgetFeatures);
|
|
|
|
}
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
2017-04-09 19:55:06 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
foreach (QDockWidget *dockWidget, findChildren<QDockWidget *>())
|
|
|
|
{
|
|
|
|
dockWidget->setFeatures(QDockWidget::AllDockWidgetFeatures);
|
|
|
|
}
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::lockUnlock_Docks(bool what)
|
|
|
|
{
|
2017-04-09 19:55:06 +00:00
|
|
|
if (what)
|
|
|
|
{
|
|
|
|
foreach (QDockWidget *dockWidget, findChildren<QDockWidget *>())
|
|
|
|
{
|
2017-03-29 10:18:37 +00:00
|
|
|
dockWidget->setFeatures(QDockWidget::NoDockWidgetFeatures);
|
|
|
|
}
|
2017-04-09 19:55:06 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
foreach (QDockWidget *dockWidget, findChildren<QDockWidget *>())
|
|
|
|
{
|
2017-03-29 10:18:37 +00:00
|
|
|
dockWidget->setFeatures(QDockWidget::AllDockWidgetFeatures);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionLockUnlock_triggered()
|
|
|
|
{
|
2017-04-09 19:55:06 +00:00
|
|
|
if (ui->actionLockUnlock->isChecked())
|
2017-03-29 10:18:37 +00:00
|
|
|
{
|
2017-04-09 19:55:06 +00:00
|
|
|
foreach (QDockWidget *dockWidget, findChildren<QDockWidget *>())
|
|
|
|
{
|
2017-03-29 10:18:37 +00:00
|
|
|
dockWidget->setFeatures(QDockWidget::NoDockWidgetFeatures);
|
|
|
|
}
|
2017-06-15 09:53:10 +00:00
|
|
|
ui->actionLockUnlock->setIcon(QIcon(":/lock"));
|
2017-04-09 19:55:06 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
foreach (QDockWidget *dockWidget, findChildren<QDockWidget *>())
|
|
|
|
{
|
2017-03-29 10:18:37 +00:00
|
|
|
dockWidget->setFeatures(QDockWidget::AllDockWidgetFeatures);
|
|
|
|
}
|
2017-06-15 09:53:10 +00:00
|
|
|
ui->actionLockUnlock->setIcon(QIcon(":/unlock"));
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionTabs_triggered()
|
|
|
|
{
|
2017-04-09 19:55:06 +00:00
|
|
|
if (ui->centralTabWidget->tabPosition() == QTabWidget::South)
|
|
|
|
{
|
2017-03-29 10:18:37 +00:00
|
|
|
ui->centralTabWidget->setTabPosition(QTabWidget::North);
|
|
|
|
this->memoryDock->memTabWidget->setTabPosition(QTabWidget::North);
|
|
|
|
this->setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::North);
|
2017-04-09 19:55:06 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-03-29 10:18:37 +00:00
|
|
|
ui->centralTabWidget->setTabPosition(QTabWidget::South);
|
|
|
|
this->memoryDock->memTabWidget->setTabPosition(QTabWidget::South);
|
|
|
|
this->setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::South);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionMem_triggered()
|
|
|
|
{
|
|
|
|
//this->memoryDock->show();
|
|
|
|
//this->memoryDock->raise();
|
2017-04-09 19:55:06 +00:00
|
|
|
MemoryWidget *newMemDock = new MemoryWidget(this);
|
2017-04-13 15:36:20 +00:00
|
|
|
this->dockWidgets << newMemDock;
|
2017-03-29 10:18:37 +00:00
|
|
|
newMemDock->setAttribute(Qt::WA_DeleteOnClose);
|
|
|
|
this->tabifyDockWidget(this->memoryDock, newMemDock);
|
2017-04-12 21:04:39 +00:00
|
|
|
newMemDock->refreshDisasm();
|
|
|
|
newMemDock->refreshHexdump();
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
|
2017-07-13 18:49:12 +00:00
|
|
|
void MainWindow::on_actionEntry_points_triggered()
|
|
|
|
{
|
|
|
|
toggleDockWidget(entrypointDock);
|
|
|
|
}
|
|
|
|
|
2017-03-29 10:18:37 +00:00
|
|
|
void MainWindow::on_actionFunctions_triggered()
|
|
|
|
{
|
2017-05-19 07:45:26 +00:00
|
|
|
toggleDockWidget(functionsDock);
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionImports_triggered()
|
|
|
|
{
|
2017-05-19 07:45:26 +00:00
|
|
|
toggleDockWidget(importsDock);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionExports_triggered()
|
|
|
|
{
|
|
|
|
toggleDockWidget(exportsDock);
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionSymbols_triggered()
|
|
|
|
{
|
2017-05-19 07:45:26 +00:00
|
|
|
toggleDockWidget(symbolsDock);
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionReloc_triggered()
|
|
|
|
{
|
2017-05-19 07:45:26 +00:00
|
|
|
toggleDockWidget(relocsDock);
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionStrings_triggered()
|
|
|
|
{
|
2017-05-19 07:45:26 +00:00
|
|
|
toggleDockWidget(stringsDock);
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionSections_triggered()
|
|
|
|
{
|
2017-05-19 07:45:26 +00:00
|
|
|
toggleDockWidget(sectionsDock);
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionFlags_triggered()
|
|
|
|
{
|
2017-05-19 07:45:26 +00:00
|
|
|
toggleDockWidget(flagsDock);
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionComents_triggered()
|
|
|
|
{
|
2017-05-19 07:45:26 +00:00
|
|
|
toggleDockWidget(commentsDock);
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionNotepad_triggered()
|
|
|
|
{
|
2017-05-19 07:45:26 +00:00
|
|
|
toggleDockWidget(notepadDock);
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionAbout_triggered()
|
|
|
|
{
|
2017-04-09 19:55:06 +00:00
|
|
|
AboutDialog *a = new AboutDialog(this);
|
2017-03-29 10:18:37 +00:00
|
|
|
a->open();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionRefresh_Panels_triggered()
|
|
|
|
{
|
|
|
|
this->updateFrames();
|
|
|
|
}
|
|
|
|
|
2017-05-19 07:45:26 +00:00
|
|
|
void MainWindow::toggleDockWidget(DockWidget *dock_widget)
|
|
|
|
{
|
|
|
|
if (dock_widget->isVisible())
|
|
|
|
{
|
|
|
|
dock_widget->close();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dock_widget->show();
|
|
|
|
dock_widget->raise();
|
|
|
|
}
|
|
|
|
}
|
2017-04-28 13:09:40 +00:00
|
|
|
|
|
|
|
void MainWindow::seek(const QString &offset, const QString &name, bool raise_memory_dock)
|
2017-04-09 19:55:06 +00:00
|
|
|
{
|
2017-04-28 13:09:40 +00:00
|
|
|
// TODO: remove this method and use the one with RVA only!
|
|
|
|
|
2017-04-28 13:38:01 +00:00
|
|
|
if (offset.length() < 2)
|
2017-04-28 13:09:40 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
bool ok;
|
|
|
|
RVA addr = offset.mid(2).toULongLong(&ok, 16);
|
2017-04-28 13:38:01 +00:00
|
|
|
if (!ok)
|
2017-03-29 10:18:37 +00:00
|
|
|
return;
|
2017-04-28 13:09:40 +00:00
|
|
|
|
|
|
|
seek(addr, name, raise_memory_dock);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::seek(const RVA offset, const QString &name, bool raise_memory_dock)
|
|
|
|
{
|
2017-04-13 15:51:58 +00:00
|
|
|
{
|
2017-03-29 10:18:37 +00:00
|
|
|
this->memoryDock->setWindowTitle(name);
|
2017-04-28 13:09:40 +00:00
|
|
|
//this->current_address = name;
|
2017-04-11 11:41:44 +00:00
|
|
|
}
|
2017-03-29 10:18:37 +00:00
|
|
|
this->hexdumpTopOffset = 0;
|
|
|
|
this->hexdumpBottomOffset = 0;
|
2017-04-09 19:55:06 +00:00
|
|
|
core->seek(offset);
|
2017-07-11 11:05:42 +00:00
|
|
|
emit globalSeekTo(offset);
|
2017-04-28 13:09:40 +00:00
|
|
|
setCursorAddress(offset);
|
2017-03-29 10:18:37 +00:00
|
|
|
|
2017-07-11 11:05:42 +00:00
|
|
|
//refreshMem();
|
2017-04-05 10:10:22 +00:00
|
|
|
this->memoryDock->disasTextEdit->setFocus();
|
2017-04-28 13:09:40 +00:00
|
|
|
|
|
|
|
// Rise and shine baby!
|
2017-04-28 13:38:01 +00:00
|
|
|
if (raise_memory_dock)
|
2017-04-28 13:09:40 +00:00
|
|
|
this->memoryDock->raise();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::refreshMem()
|
|
|
|
{
|
|
|
|
this->memoryDock->updateViews();
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_backButton_clicked()
|
|
|
|
{
|
2017-04-28 13:09:40 +00:00
|
|
|
QList<RVA> seek_history = core->getSeekHistory();
|
2017-03-29 10:18:37 +00:00
|
|
|
this->core->cmd("s-");
|
2017-04-28 13:09:40 +00:00
|
|
|
RVA offset = this->core->getOffset();
|
|
|
|
QString fcn = this->core->cmdFunctionAt(QString::number(offset));
|
|
|
|
this->seek(offset, fcn);
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionCalculator_triggered()
|
|
|
|
{
|
2017-04-09 19:55:06 +00:00
|
|
|
if (!this->sideBar->isVisible())
|
|
|
|
{
|
2017-03-29 10:18:37 +00:00
|
|
|
this->on_actionShow_Hide_mainsidebar_triggered();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionCreate_File_triggered()
|
|
|
|
{
|
2017-04-09 19:55:06 +00:00
|
|
|
createNewDialog *n = new createNewDialog(this);
|
2017-03-29 10:18:37 +00:00
|
|
|
n->exec();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionAssembler_triggered()
|
|
|
|
{
|
2017-04-09 19:55:06 +00:00
|
|
|
if (!this->sideBar->isVisible())
|
|
|
|
{
|
2017-03-29 10:18:37 +00:00
|
|
|
this->on_actionShow_Hide_mainsidebar_triggered();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionStart_Web_Server_triggered()
|
|
|
|
{
|
2017-04-01 01:56:35 +00:00
|
|
|
setWebServerState(ui->actionStart_Web_Server->isChecked());
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionDisasAdd_comment_triggered()
|
|
|
|
{
|
2017-04-09 19:55:06 +00:00
|
|
|
CommentsDialog *c = new CommentsDialog(this);
|
2017-03-29 10:18:37 +00:00
|
|
|
c->exec();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::restoreDocks()
|
|
|
|
{
|
|
|
|
addDockWidget(Qt::RightDockWidgetArea, sectionsDock);
|
|
|
|
addDockWidget(Qt::TopDockWidgetArea, this->dashboardDock);
|
|
|
|
this->tabifyDockWidget(sectionsDock, this->commentsDock);
|
|
|
|
this->tabifyDockWidget(this->dashboardDock, this->memoryDock);
|
2017-07-13 18:49:12 +00:00
|
|
|
this->tabifyDockWidget(this->dashboardDock, this->entrypointDock);
|
2017-03-29 10:18:37 +00:00
|
|
|
this->tabifyDockWidget(this->dashboardDock, this->functionsDock);
|
|
|
|
this->tabifyDockWidget(this->dashboardDock, this->flagsDock);
|
|
|
|
this->tabifyDockWidget(this->dashboardDock, this->stringsDock);
|
|
|
|
this->tabifyDockWidget(this->dashboardDock, this->relocsDock);
|
|
|
|
this->tabifyDockWidget(this->dashboardDock, this->importsDock);
|
2017-05-19 07:45:26 +00:00
|
|
|
this->tabifyDockWidget(this->dashboardDock, this->exportsDock);
|
2017-03-29 10:18:37 +00:00
|
|
|
this->tabifyDockWidget(this->dashboardDock, this->symbolsDock);
|
|
|
|
this->tabifyDockWidget(this->dashboardDock, this->notepadDock);
|
|
|
|
this->dashboardDock->raise();
|
|
|
|
sectionsDock->raise();
|
|
|
|
this->functionsDock->raise();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionDefaut_triggered()
|
|
|
|
{
|
|
|
|
hideAllDocks();
|
|
|
|
restoreDocks();
|
|
|
|
showDefaultDocks();
|
|
|
|
this->dashboardDock->raise();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::hideAllDocks()
|
|
|
|
{
|
2017-04-13 15:36:20 +00:00
|
|
|
for (auto w : dockWidgets)
|
|
|
|
{
|
|
|
|
w->hide();
|
|
|
|
}
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::showDefaultDocks()
|
|
|
|
{
|
2017-04-13 15:51:58 +00:00
|
|
|
const QList<DockWidget *> defaultDocks = { sectionsDock,
|
2017-07-13 18:49:12 +00:00
|
|
|
entrypointDock,
|
2017-04-13 15:51:58 +00:00
|
|
|
functionsDock,
|
|
|
|
memoryDock,
|
|
|
|
commentsDock,
|
|
|
|
stringsDock,
|
|
|
|
importsDock,
|
|
|
|
symbolsDock,
|
|
|
|
notepadDock,
|
|
|
|
dashboardDock
|
|
|
|
};
|
2017-04-13 15:36:20 +00:00
|
|
|
|
|
|
|
for (auto w : dockWidgets)
|
|
|
|
{
|
|
|
|
if (defaultDocks.contains(w))
|
|
|
|
{
|
|
|
|
w->show();
|
|
|
|
}
|
|
|
|
}
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionhide_bottomPannel_triggered()
|
|
|
|
{
|
2017-04-09 19:55:06 +00:00
|
|
|
if (ui->centralWidget->isVisible())
|
|
|
|
{
|
2017-03-29 10:18:37 +00:00
|
|
|
ui->centralWidget->hide();
|
2017-04-09 19:55:06 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-03-29 10:18:37 +00:00
|
|
|
ui->centralWidget->show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-26 23:00:20 +00:00
|
|
|
void MainWindow::sendToNotepad(const QString &txt)
|
2017-03-29 10:18:37 +00:00
|
|
|
{
|
2017-04-13 15:36:20 +00:00
|
|
|
this->notepadDock->appendPlainText("```\n" + txt + "\n```");
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionFunctionsRename_triggered()
|
|
|
|
{
|
2017-04-09 19:55:06 +00:00
|
|
|
RenameDialog *r = new RenameDialog(this);
|
2017-03-29 10:18:37 +00:00
|
|
|
// Get function based on click position
|
|
|
|
//r->setFunctionName(fcn_name);
|
|
|
|
r->open();
|
|
|
|
}
|
|
|
|
|
2017-04-26 23:00:20 +00:00
|
|
|
void MainWindow::addOutput(const QString &msg)
|
2017-03-29 10:18:37 +00:00
|
|
|
{
|
2017-04-26 23:00:20 +00:00
|
|
|
consoleWidget->addOutput(msg);
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
|
2017-04-26 23:00:20 +00:00
|
|
|
void MainWindow::addDebugOutput(const QString &msg)
|
2017-03-29 10:18:37 +00:00
|
|
|
{
|
2017-04-28 13:09:40 +00:00
|
|
|
printf("debug output: %s\n", msg.toLocal8Bit().constData());
|
2017-04-26 23:00:20 +00:00
|
|
|
consoleWidget->addDebugOutput(msg);
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionNew_triggered()
|
|
|
|
{
|
2017-04-13 15:51:58 +00:00
|
|
|
if (close())
|
2017-04-09 20:36:17 +00:00
|
|
|
on_actionLoad_triggered();
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionSave_triggered()
|
|
|
|
{
|
2017-05-13 18:09:36 +00:00
|
|
|
saveProject();
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionRun_Script_triggered()
|
|
|
|
{
|
|
|
|
QFileDialog dialog(this);
|
|
|
|
dialog.setFileMode(QFileDialog::ExistingFile);
|
|
|
|
dialog.setViewMode(QFileDialog::Detail);
|
|
|
|
dialog.setDirectory(QDir::home());
|
|
|
|
|
|
|
|
QString fileName;
|
|
|
|
fileName = dialog.getOpenFileName(this, "Select radare2 script");
|
2017-04-13 15:51:58 +00:00
|
|
|
if (!fileName.length()) //cancel was pressed
|
2017-04-09 20:36:17 +00:00
|
|
|
return;
|
2017-03-29 10:18:37 +00:00
|
|
|
|
|
|
|
qDebug() << "Meow: " + fileName;
|
|
|
|
this->core->cmd(". " + fileName);
|
2017-04-12 21:04:39 +00:00
|
|
|
this->refreshMem();
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionDark_Theme_triggered()
|
|
|
|
{
|
|
|
|
this->dark();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionWhite_Theme_triggered()
|
|
|
|
{
|
|
|
|
this->def_theme();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionSDB_browser_triggered()
|
|
|
|
{
|
|
|
|
this->sdbDock = new SdbDock(this);
|
|
|
|
this->tabifyDockWidget(this->memoryDock, this->sdbDock);
|
|
|
|
this->sdbDock->setFloating(true);
|
|
|
|
this->sdbDock->show();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionLoad_triggered()
|
|
|
|
{
|
2017-04-01 01:56:35 +00:00
|
|
|
QProcess process(this);
|
|
|
|
process.setEnvironment(QProcess::systemEnvironment());
|
|
|
|
process.startDetached(qApp->applicationFilePath());
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionShow_Hide_mainsidebar_triggered()
|
|
|
|
{
|
2017-04-09 19:55:06 +00:00
|
|
|
if (ui->sideToolBar->isVisible())
|
|
|
|
{
|
2017-03-29 10:18:37 +00:00
|
|
|
ui->sideToolBar->hide();
|
2017-04-09 19:55:06 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-03-29 10:18:37 +00:00
|
|
|
ui->sideToolBar->show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionDashboard_triggered()
|
|
|
|
{
|
2017-04-09 19:55:06 +00:00
|
|
|
if (this->dashboardDock->isVisible())
|
|
|
|
{
|
2017-03-29 10:18:37 +00:00
|
|
|
this->dashboardDock->close();
|
2017-04-09 19:55:06 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-03-29 10:18:37 +00:00
|
|
|
this->dashboardDock->show();
|
|
|
|
this->dashboardDock->raise();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionForward_triggered()
|
|
|
|
{
|
|
|
|
this->core->cmd("s+");
|
2017-04-28 13:09:40 +00:00
|
|
|
RVA offset = core->getOffset();
|
2017-04-26 23:00:20 +00:00
|
|
|
this->addDebugOutput(QString::number(offset));
|
2017-04-28 13:09:40 +00:00
|
|
|
this->seek(offset);
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
|
2017-04-09 19:55:06 +00:00
|
|
|
void MainWindow::toggleResponsive(bool maybe)
|
|
|
|
{
|
2017-03-29 10:18:37 +00:00
|
|
|
this->responsive = maybe;
|
|
|
|
// Save options in settings
|
2017-04-03 00:18:09 +00:00
|
|
|
QSettings settings;
|
2017-03-29 10:18:37 +00:00
|
|
|
settings.setValue("responsive", this->responsive);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionTabs_on_Top_triggered()
|
|
|
|
{
|
|
|
|
this->on_actionTabs_triggered();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionReset_settings_triggered()
|
|
|
|
{
|
2017-05-19 07:45:26 +00:00
|
|
|
QMessageBox::StandardButton ret =
|
2017-06-03 12:27:23 +00:00
|
|
|
(QMessageBox::StandardButton)QMessageBox::question(this, "Iaito",
|
|
|
|
"Do you really want to clear all settings?",
|
|
|
|
QMessageBox::Ok | QMessageBox::Cancel);
|
2017-04-09 19:55:06 +00:00
|
|
|
if (ret == QMessageBox::Ok)
|
|
|
|
{
|
2017-03-29 10:18:37 +00:00
|
|
|
// Save options in settings
|
2017-04-03 00:18:09 +00:00
|
|
|
QSettings settings;
|
2017-03-29 10:18:37 +00:00
|
|
|
settings.clear();
|
|
|
|
}
|
|
|
|
}
|
2017-03-31 21:54:06 +00:00
|
|
|
|
|
|
|
void MainWindow::on_actionQuit_triggered()
|
|
|
|
{
|
|
|
|
close();
|
|
|
|
}
|
2017-04-12 21:04:39 +00:00
|
|
|
|
2017-04-28 13:09:40 +00:00
|
|
|
void MainWindow::setCursorAddress(RVA addr)
|
|
|
|
{
|
|
|
|
this->cursor_address = addr;
|
|
|
|
emit cursorAddressChanged(addr);
|
|
|
|
}
|
|
|
|
|
2017-04-12 21:04:39 +00:00
|
|
|
void MainWindow::refreshVisibleDockWidgets()
|
|
|
|
{
|
|
|
|
// There seems to be no convenience function to check if a QDockWidget
|
|
|
|
// is really visible or hidden in a tabbed dock. So:
|
2017-04-13 15:51:58 +00:00
|
|
|
auto isDockVisible = [](const QDockWidget * const pWidget)
|
|
|
|
{
|
2017-04-12 21:04:39 +00:00
|
|
|
return pWidget != nullptr && !pWidget->visibleRegion().isEmpty();
|
|
|
|
};
|
|
|
|
|
2017-04-13 15:36:20 +00:00
|
|
|
for (auto w : dockWidgets)
|
|
|
|
{
|
|
|
|
if (isDockVisible(w))
|
|
|
|
{
|
|
|
|
w->refresh();
|
|
|
|
}
|
|
|
|
}
|
2017-04-12 21:04:39 +00:00
|
|
|
}
|
2017-05-26 08:52:17 +00:00
|
|
|
|
|
|
|
void MainWindow::on_actionRefresh_contents_triggered()
|
|
|
|
{
|
2017-09-01 13:03:35 +00:00
|
|
|
refreshVisibleDockWidgets();
|
2017-05-26 08:52:17 +00:00
|
|
|
}
|
2017-08-31 17:43:46 +00:00
|
|
|
|
|
|
|
void MainWindow::on_actionDisplay_Esil_triggered()
|
|
|
|
{
|
|
|
|
int esil = this->core->getConfig("asm.esil");
|
2017-09-01 13:03:35 +00:00
|
|
|
core->config("asm.esil", !esil);
|
|
|
|
refreshVisibleDockWidgets();
|
2017-08-31 17:43:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionDisplay_Pseudocode_triggered()
|
|
|
|
{
|
|
|
|
int pseudo = this->core->getConfig("asm.pseudo");
|
2017-09-01 13:03:35 +00:00
|
|
|
core->config("asm.pseudo", !pseudo);
|
|
|
|
refreshVisibleDockWidgets();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionDisplay_Offsets_triggered()
|
|
|
|
{
|
|
|
|
bool checked = ui->actionDisplay_Offsets->isChecked();
|
|
|
|
memoryDock->showOffsets(checked);
|
|
|
|
refreshVisibleDockWidgets();
|
2017-08-31 17:43:46 +00:00
|
|
|
}
|