2017-03-29 10:18:37 +00:00
|
|
|
#ifndef MAINWINDOW_H
|
|
|
|
#define MAINWINDOW_H
|
|
|
|
|
2019-02-22 16:50:45 +00:00
|
|
|
#include "core/Cutter.h" // only needed for ut64
|
2018-02-10 18:04:31 +00:00
|
|
|
#include "dialogs/NewFileDialog.h"
|
2019-01-19 20:54:02 +00:00
|
|
|
#include "dialogs/WelcomeDialog.h"
|
2018-10-17 07:55:53 +00:00
|
|
|
#include "common/Configuration.h"
|
|
|
|
#include "common/InitialOptions.h"
|
2020-05-23 11:41:12 +00:00
|
|
|
#include "common/IOModesController.h"
|
2020-05-23 22:12:32 +00:00
|
|
|
#include "common/CutterLayout.h"
|
2019-07-19 19:21:12 +00:00
|
|
|
#include "MemoryDockWidget.h"
|
2017-03-29 10:18:37 +00:00
|
|
|
|
2019-03-14 09:28:42 +00:00
|
|
|
#include <memory>
|
|
|
|
|
2017-10-22 10:21:44 +00:00
|
|
|
#include <QMainWindow>
|
|
|
|
#include <QList>
|
|
|
|
|
2017-09-25 12:55:41 +00:00
|
|
|
class CutterCore;
|
2017-04-13 15:36:20 +00:00
|
|
|
class Omnibar;
|
2018-06-24 19:12:02 +00:00
|
|
|
class ProgressIndicator;
|
2017-10-12 19:55:15 +00:00
|
|
|
class PreviewWidget;
|
2017-04-13 15:36:20 +00:00
|
|
|
class Highlighter;
|
|
|
|
class AsciiHighlighter;
|
2017-12-08 15:00:52 +00:00
|
|
|
class VisualNavbar;
|
2017-04-13 15:36:20 +00:00
|
|
|
class FunctionsWidget;
|
|
|
|
class ImportsWidget;
|
2017-05-19 07:45:26 +00:00
|
|
|
class ExportsWidget;
|
2017-04-13 15:36:20 +00:00
|
|
|
class SymbolsWidget;
|
|
|
|
class RelocsWidget;
|
|
|
|
class CommentsWidget;
|
|
|
|
class StringsWidget;
|
|
|
|
class FlagsWidget;
|
|
|
|
class Dashboard;
|
|
|
|
class QLineEdit;
|
2019-02-13 06:38:47 +00:00
|
|
|
class SdbWidget;
|
2017-04-13 15:36:20 +00:00
|
|
|
class QAction;
|
2018-05-03 07:52:30 +00:00
|
|
|
class SectionsWidget;
|
2018-10-20 18:20:06 +00:00
|
|
|
class SegmentsWidget;
|
2017-04-26 23:00:20 +00:00
|
|
|
class ConsoleWidget;
|
2017-07-13 18:49:12 +00:00
|
|
|
class EntrypointWidget;
|
2017-10-22 10:21:44 +00:00
|
|
|
class DisassemblerGraphView;
|
2017-12-23 16:42:42 +00:00
|
|
|
class ClassesWidget;
|
2018-02-04 14:32:18 +00:00
|
|
|
class ResourcesWidget;
|
2018-02-26 22:26:18 +00:00
|
|
|
class VTablesWidget;
|
2018-03-06 17:21:48 +00:00
|
|
|
class TypesWidget;
|
2018-05-21 17:34:41 +00:00
|
|
|
class HeadersWidget;
|
2022-01-21 08:39:56 +00:00
|
|
|
class FlirtWidget;
|
2018-03-08 12:24:15 +00:00
|
|
|
class SearchWidget;
|
2017-04-13 15:36:20 +00:00
|
|
|
class QDockWidget;
|
2019-03-14 09:28:42 +00:00
|
|
|
class DisassemblyWidget;
|
|
|
|
class GraphWidget;
|
|
|
|
class HexdumpWidget;
|
2019-09-06 05:40:20 +00:00
|
|
|
class DecompilerWidget;
|
2019-03-14 09:28:42 +00:00
|
|
|
class OverviewWidget;
|
2020-12-16 10:59:23 +00:00
|
|
|
class RizinGraphWidget;
|
2020-07-16 08:05:10 +00:00
|
|
|
class CallGraphWidget;
|
2021-06-27 20:21:06 +00:00
|
|
|
class HeapWidget;
|
2017-03-29 10:18:37 +00:00
|
|
|
|
2018-03-21 20:32:32 +00:00
|
|
|
namespace Ui {
|
|
|
|
class MainWindow;
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
|
2022-03-31 10:49:37 +00:00
|
|
|
class CUTTER_EXPORT MainWindow : public QMainWindow
|
2017-03-29 10:18:37 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
bool responsive;
|
|
|
|
|
2018-05-04 07:58:32 +00:00
|
|
|
explicit MainWindow(QWidget *parent = nullptr);
|
2018-09-30 20:00:44 +00:00
|
|
|
~MainWindow() override;
|
2017-04-01 01:56:35 +00:00
|
|
|
|
2019-05-17 11:40:50 +00:00
|
|
|
void openNewFile(InitialOptions &options, bool skipOptionsDialog = false);
|
2018-02-06 18:23:01 +00:00
|
|
|
void displayNewFileDialog();
|
2019-01-19 20:54:02 +00:00
|
|
|
void displayWelcomeDialog();
|
2018-02-10 18:04:31 +00:00
|
|
|
void closeNewFileDialog();
|
2020-12-01 11:45:26 +00:00
|
|
|
bool openProject(const QString &project_name);
|
2017-10-21 19:20:10 +00:00
|
|
|
|
2020-12-01 11:45:26 +00:00
|
|
|
RzProjectErr saveProject(bool *canceled);
|
|
|
|
RzProjectErr saveProjectAs(bool *canceled);
|
|
|
|
void showProjectSaveError(RzProjectErr err);
|
2017-05-13 18:09:36 +00:00
|
|
|
|
2017-10-12 19:55:15 +00:00
|
|
|
void closeEvent(QCloseEvent *event) override;
|
2019-03-18 06:44:14 +00:00
|
|
|
void paintEvent(QPaintEvent *event) override;
|
2020-05-22 11:49:34 +00:00
|
|
|
void readSettings();
|
2017-12-17 13:49:03 +00:00
|
|
|
void saveSettings();
|
2017-04-28 13:38:01 +00:00
|
|
|
void setFilename(const QString &fn);
|
2017-04-27 18:59:27 +00:00
|
|
|
void refreshOmniBar(const QStringList &flags);
|
2017-04-01 01:56:35 +00:00
|
|
|
|
2020-05-22 11:49:34 +00:00
|
|
|
void addWidget(CutterDockWidget *widget);
|
2019-07-19 19:21:12 +00:00
|
|
|
void addMemoryDockWidget(MemoryDockWidget *widget);
|
2020-05-22 11:49:34 +00:00
|
|
|
void removeWidget(CutterDockWidget *widget);
|
2019-04-27 09:46:29 +00:00
|
|
|
void addExtraWidget(CutterDockWidget *extraDock);
|
2021-01-24 14:50:13 +00:00
|
|
|
MemoryDockWidget *addNewMemoryWidget(MemoryWidgetType type, RVA address,
|
|
|
|
bool synchronized = true);
|
2019-07-19 19:21:12 +00:00
|
|
|
|
2020-05-22 11:49:34 +00:00
|
|
|
CUTTER_DEPRECATED("Action will be ignored. Use addPluginDockWidget(CutterDockWidget*) instead.")
|
2021-01-24 14:50:13 +00:00
|
|
|
void addPluginDockWidget(CutterDockWidget *dockWidget, QAction *)
|
|
|
|
{
|
|
|
|
addPluginDockWidget(dockWidget);
|
|
|
|
}
|
2020-05-22 11:49:34 +00:00
|
|
|
void addPluginDockWidget(CutterDockWidget *dockWidget);
|
2019-04-03 07:50:25 +00:00
|
|
|
enum class MenuType { File, Edit, View, Windows, Debug, Help, Plugins };
|
2020-01-24 09:49:52 +00:00
|
|
|
/**
|
|
|
|
* @brief Getter for MainWindow's different menus
|
|
|
|
* @param type The type which represents the desired menu
|
|
|
|
* @return The requested menu or nullptr if "type" is invalid
|
|
|
|
*/
|
2019-04-03 07:50:25 +00:00
|
|
|
QMenu *getMenuByType(MenuType type);
|
2019-02-11 19:05:53 +00:00
|
|
|
void addMenuFileAction(QAction *action);
|
2019-02-07 16:19:05 +00:00
|
|
|
|
2021-01-24 14:50:13 +00:00
|
|
|
QString getFilename() const { return filename; }
|
2019-02-11 19:05:53 +00:00
|
|
|
void messageBoxWarning(QString title, QString message);
|
2018-03-16 21:46:57 +00:00
|
|
|
|
2019-06-18 17:57:07 +00:00
|
|
|
QString getUniqueObjectName(const QString &widgetType) const;
|
2019-07-19 19:21:12 +00:00
|
|
|
void showMemoryWidget();
|
|
|
|
void showMemoryWidget(MemoryWidgetType type);
|
2020-07-30 08:41:23 +00:00
|
|
|
enum class AddressTypeHint { Function, Data, Unknown };
|
2021-01-24 14:50:13 +00:00
|
|
|
QMenu *createShowInMenu(QWidget *parent, RVA address,
|
|
|
|
AddressTypeHint addressType = AddressTypeHint::Unknown);
|
|
|
|
void setCurrentMemoryWidget(MemoryDockWidget *memoryWidget);
|
|
|
|
MemoryDockWidget *getLastMemoryWidget();
|
2019-06-18 17:57:07 +00:00
|
|
|
|
2020-01-31 10:13:28 +00:00
|
|
|
/* Context menu plugins */
|
|
|
|
enum class ContextMenuType { Disassembly, Addressable };
|
|
|
|
/**
|
|
|
|
* @brief Fetches the pointer to a context menu extension of type
|
|
|
|
* @param type - the type of the context menu
|
|
|
|
* @return plugins submenu of the selected context menu
|
|
|
|
*/
|
|
|
|
QMenu *getContextMenuExtensions(ContextMenuType type);
|
|
|
|
|
2017-03-29 10:18:37 +00:00
|
|
|
public slots:
|
2018-05-27 16:03:29 +00:00
|
|
|
void finalizeOpen();
|
2017-03-29 10:18:37 +00:00
|
|
|
|
2017-11-19 12:56:10 +00:00
|
|
|
void refreshAll();
|
2019-05-30 08:41:14 +00:00
|
|
|
void seekToFunctionLastInstruction();
|
|
|
|
void seekToFunctionStart();
|
2017-12-17 13:49:03 +00:00
|
|
|
void setTabLocation();
|
|
|
|
|
2017-03-29 10:18:37 +00:00
|
|
|
void on_actionTabs_triggered();
|
|
|
|
|
2020-08-10 16:12:38 +00:00
|
|
|
void on_actionAnalyze_triggered();
|
|
|
|
|
2020-11-30 07:42:13 +00:00
|
|
|
void lockDocks(bool lock);
|
2017-03-29 10:18:37 +00:00
|
|
|
|
|
|
|
void on_actionRun_Script_triggered();
|
|
|
|
|
|
|
|
void toggleResponsive(bool maybe);
|
|
|
|
|
2018-05-08 20:44:53 +00:00
|
|
|
void openNewFileFailed();
|
|
|
|
|
2019-02-19 15:56:50 +00:00
|
|
|
void toggleOverview(bool visibility, GraphWidget *targetGraph);
|
2017-03-29 10:18:37 +00:00
|
|
|
private slots:
|
|
|
|
void on_actionAbout_triggered();
|
2019-02-07 10:52:08 +00:00
|
|
|
void on_actionIssue_triggered();
|
2020-08-11 12:52:52 +00:00
|
|
|
void documentationClicked();
|
2019-06-18 13:02:41 +00:00
|
|
|
void addExtraGraph();
|
|
|
|
void addExtraHexdump();
|
|
|
|
void addExtraDisassembly();
|
2020-08-29 05:15:47 +00:00
|
|
|
void addExtraDecompiler();
|
2017-03-29 10:18:37 +00:00
|
|
|
|
|
|
|
void on_actionRefresh_Panels_triggered();
|
|
|
|
|
|
|
|
void on_actionDisasAdd_comment_triggered();
|
|
|
|
|
2018-01-16 14:09:51 +00:00
|
|
|
void on_actionDefault_triggered();
|
2017-03-29 10:18:37 +00:00
|
|
|
|
|
|
|
void on_actionNew_triggered();
|
|
|
|
|
|
|
|
void on_actionSave_triggered();
|
2017-11-03 17:22:54 +00:00
|
|
|
void on_actionSaveAs_triggered();
|
2017-03-29 10:18:37 +00:00
|
|
|
|
2018-03-08 09:11:19 +00:00
|
|
|
void on_actionBackward_triggered();
|
|
|
|
void on_actionForward_triggered();
|
2017-03-29 10:18:37 +00:00
|
|
|
|
2020-04-07 13:18:41 +00:00
|
|
|
void on_actionMap_triggered();
|
2017-03-29 10:18:37 +00:00
|
|
|
|
|
|
|
void on_actionTabs_on_Top_triggered();
|
|
|
|
|
|
|
|
void on_actionReset_settings_triggered();
|
|
|
|
|
2017-03-31 21:54:06 +00:00
|
|
|
void on_actionQuit_triggered();
|
|
|
|
|
2017-05-26 08:52:17 +00:00
|
|
|
void on_actionRefresh_contents_triggered();
|
2017-04-12 21:04:39 +00:00
|
|
|
|
2017-12-14 13:42:24 +00:00
|
|
|
void on_actionPreferences_triggered();
|
2017-09-02 08:17:48 +00:00
|
|
|
|
2018-01-16 14:09:51 +00:00
|
|
|
void on_actionImportPDB_triggered();
|
|
|
|
|
2018-08-24 22:36:15 +00:00
|
|
|
void on_actionExport_as_code_triggered();
|
|
|
|
|
2022-01-21 08:39:56 +00:00
|
|
|
void on_actionApplySigFromFile_triggered();
|
|
|
|
|
|
|
|
void on_actionCreateNewSig_triggered();
|
|
|
|
|
2019-05-08 11:38:25 +00:00
|
|
|
void on_actionGrouped_dock_dragging_triggered(bool checked);
|
|
|
|
|
2018-06-22 18:34:25 +00:00
|
|
|
void updateTasksIndicator();
|
|
|
|
|
2018-05-13 07:50:01 +00:00
|
|
|
void mousePressEvent(QMouseEvent *event) override;
|
2018-09-30 20:00:44 +00:00
|
|
|
bool eventFilter(QObject *object, QEvent *event) override;
|
2020-01-07 22:03:25 +00:00
|
|
|
bool event(QEvent *event) override;
|
2019-12-13 17:30:55 +00:00
|
|
|
void toggleDebugView();
|
2019-04-27 17:58:44 +00:00
|
|
|
void chooseThemeIcons();
|
2018-05-13 07:50:01 +00:00
|
|
|
|
2019-10-12 05:50:10 +00:00
|
|
|
void onZoomIn();
|
|
|
|
void onZoomOut();
|
|
|
|
void onZoomReset();
|
|
|
|
|
2020-05-23 11:41:12 +00:00
|
|
|
void setAvailableIOModeOptions();
|
2021-01-24 14:50:13 +00:00
|
|
|
|
2017-03-29 10:18:37 +00:00
|
|
|
private:
|
2018-02-04 14:32:18 +00:00
|
|
|
CutterCore *core;
|
2017-12-13 17:36:00 +00:00
|
|
|
|
2017-12-17 13:49:03 +00:00
|
|
|
bool tabsOnTop;
|
2017-03-29 10:18:37 +00:00
|
|
|
ut64 hexdumpTopOffset;
|
|
|
|
ut64 hexdumpBottomOffset;
|
|
|
|
QString filename;
|
2017-10-02 09:41:28 +00:00
|
|
|
std::unique_ptr<Ui::MainWindow> ui;
|
2018-02-04 14:32:18 +00:00
|
|
|
Highlighter *highlighter;
|
|
|
|
VisualNavbar *visualNavbar;
|
|
|
|
Omnibar *omnibar;
|
2018-06-24 19:12:02 +00:00
|
|
|
ProgressIndicator *tasksProgressIndicator;
|
2019-06-18 13:02:41 +00:00
|
|
|
QByteArray emptyState;
|
2020-05-23 11:41:12 +00:00
|
|
|
IOModesController ioModesController;
|
2018-06-22 18:34:25 +00:00
|
|
|
|
2018-02-04 14:32:18 +00:00
|
|
|
Configuration *configuration;
|
2017-04-28 13:09:40 +00:00
|
|
|
|
2020-05-22 11:49:34 +00:00
|
|
|
QList<CutterDockWidget *> dockWidgets;
|
|
|
|
QList<CutterDockWidget *> pluginDocks;
|
2021-01-24 14:50:13 +00:00
|
|
|
OverviewWidget *overviewDock = nullptr;
|
2020-05-22 11:49:34 +00:00
|
|
|
QAction *actionOverview = nullptr;
|
2021-01-24 14:50:13 +00:00
|
|
|
EntrypointWidget *entrypointDock = nullptr;
|
|
|
|
FunctionsWidget *functionsDock = nullptr;
|
|
|
|
ImportsWidget *importsDock = nullptr;
|
|
|
|
ExportsWidget *exportsDock = nullptr;
|
|
|
|
HeadersWidget *headersDock = nullptr;
|
|
|
|
TypesWidget *typesDock = nullptr;
|
|
|
|
SearchWidget *searchDock = nullptr;
|
|
|
|
SymbolsWidget *symbolsDock = nullptr;
|
|
|
|
RelocsWidget *relocsDock = nullptr;
|
|
|
|
CommentsWidget *commentsDock = nullptr;
|
|
|
|
StringsWidget *stringsDock = nullptr;
|
|
|
|
FlagsWidget *flagsDock = nullptr;
|
|
|
|
Dashboard *dashboardDock = nullptr;
|
|
|
|
SdbWidget *sdbDock = nullptr;
|
|
|
|
SectionsWidget *sectionsDock = nullptr;
|
|
|
|
SegmentsWidget *segmentsDock = nullptr;
|
2022-01-21 08:39:56 +00:00
|
|
|
FlirtWidget *flirtDock = nullptr;
|
2021-01-24 14:50:13 +00:00
|
|
|
ConsoleWidget *consoleDock = nullptr;
|
|
|
|
ClassesWidget *classesDock = nullptr;
|
|
|
|
ResourcesWidget *resourcesDock = nullptr;
|
|
|
|
VTablesWidget *vTablesDock = nullptr;
|
|
|
|
CutterDockWidget *stackDock = nullptr;
|
|
|
|
CutterDockWidget *threadsDock = nullptr;
|
|
|
|
CutterDockWidget *processesDock = nullptr;
|
|
|
|
CutterDockWidget *registersDock = nullptr;
|
|
|
|
CutterDockWidget *backtraceDock = nullptr;
|
|
|
|
CutterDockWidget *memoryMapDock = nullptr;
|
|
|
|
NewFileDialog *newFileDialog = nullptr;
|
|
|
|
CutterDockWidget *breakpointDock = nullptr;
|
|
|
|
CutterDockWidget *registerRefsDock = nullptr;
|
|
|
|
RizinGraphWidget *rzGraphDock = nullptr;
|
|
|
|
CallGraphWidget *callGraphDock = nullptr;
|
|
|
|
CallGraphWidget *globalCallGraphDock = nullptr;
|
2021-06-27 20:21:06 +00:00
|
|
|
CutterDockWidget *heapDock = nullptr;
|
2017-12-21 15:47:36 +00:00
|
|
|
|
2020-01-31 10:13:28 +00:00
|
|
|
QMenu *disassemblyContextMenuExtensions = nullptr;
|
|
|
|
QMenu *addressableContextMenuExtensions = nullptr;
|
|
|
|
|
2020-05-23 22:12:32 +00:00
|
|
|
QMap<QString, Cutter::CutterLayout> layouts;
|
2020-05-22 11:49:34 +00:00
|
|
|
|
2019-11-04 16:40:54 +00:00
|
|
|
void initUI();
|
2019-03-18 06:44:14 +00:00
|
|
|
void initToolBar();
|
|
|
|
void initDocks();
|
2019-12-10 07:34:21 +00:00
|
|
|
void initBackForwardMenu();
|
2021-01-24 14:50:13 +00:00
|
|
|
void displayInitialOptionsDialog(const InitialOptions &options = InitialOptions(),
|
|
|
|
bool skipOptionsDialog = false);
|
2018-08-18 16:04:45 +00:00
|
|
|
|
2020-05-23 22:12:32 +00:00
|
|
|
Cutter::CutterLayout getViewLayout();
|
|
|
|
Cutter::CutterLayout getViewLayout(const QString &name);
|
2020-05-22 11:49:34 +00:00
|
|
|
|
2020-05-23 22:12:32 +00:00
|
|
|
void setViewLayout(const Cutter::CutterLayout &layout);
|
2020-05-22 11:49:34 +00:00
|
|
|
void loadLayouts(QSettings &settings);
|
|
|
|
void saveLayouts(QSettings &settings);
|
|
|
|
|
2019-06-18 13:02:41 +00:00
|
|
|
void updateMemberPointers();
|
2017-11-03 17:22:54 +00:00
|
|
|
void restoreDocks();
|
2018-05-25 14:30:59 +00:00
|
|
|
void showZenDocks();
|
2018-06-12 15:42:38 +00:00
|
|
|
void showDebugDocks();
|
2020-05-22 11:49:34 +00:00
|
|
|
/**
|
|
|
|
* @brief Try to guess which is the "main" section of layout and dock there.
|
|
|
|
* @param widget that needs to be docked
|
|
|
|
*/
|
|
|
|
void dockOnMainArea(QDockWidget *widget);
|
2018-10-22 18:06:30 +00:00
|
|
|
void enableDebugWidgetsMenu(bool enable);
|
2019-12-10 07:34:21 +00:00
|
|
|
/**
|
|
|
|
* @brief Fill menu with seek history entries.
|
|
|
|
* @param menu
|
|
|
|
* @param redo set to false for undo history, true for redo.
|
|
|
|
*/
|
|
|
|
void updateHistoryMenu(QMenu *menu, bool redo = false);
|
2020-05-22 11:49:34 +00:00
|
|
|
void updateLayoutsMenu();
|
|
|
|
void saveNamedLayout();
|
2020-05-23 22:12:32 +00:00
|
|
|
void manageLayouts();
|
2017-11-03 17:22:54 +00:00
|
|
|
|
2019-02-19 15:56:50 +00:00
|
|
|
void setOverviewData();
|
2019-03-12 07:37:10 +00:00
|
|
|
bool isOverviewActive();
|
2019-12-20 06:19:44 +00:00
|
|
|
/**
|
|
|
|
* @brief Check if a widget is one of debug specific dock widgets.
|
|
|
|
* @param dock
|
|
|
|
* @return true for debug specific widgets, false for all other including common dock widgets.
|
|
|
|
*/
|
|
|
|
bool isDebugWidget(QDockWidget *dock) const;
|
2020-05-22 11:49:34 +00:00
|
|
|
bool isExtraMemoryWidget(QDockWidget *dock) const;
|
2019-06-18 13:02:41 +00:00
|
|
|
|
2019-07-19 19:21:12 +00:00
|
|
|
MemoryWidgetType getMemoryWidgetTypeToRestore();
|
|
|
|
|
2019-06-18 13:02:41 +00:00
|
|
|
/**
|
2021-01-24 14:50:13 +00:00
|
|
|
* @brief Map from a widget type (e.g. DisassemblyWidget::getWidgetType()) to the respective
|
|
|
|
* contructor of the widget
|
2019-06-18 13:02:41 +00:00
|
|
|
*/
|
2021-01-24 14:50:13 +00:00
|
|
|
QMap<QString, std::function<CutterDockWidget *(MainWindow *)>> widgetTypeToConstructorMap;
|
2019-07-19 19:21:12 +00:00
|
|
|
|
2021-01-24 14:50:13 +00:00
|
|
|
MemoryDockWidget *lastSyncMemoryWidget = nullptr;
|
|
|
|
MemoryDockWidget *lastMemoryWidget = nullptr;
|
2020-05-22 11:49:34 +00:00
|
|
|
int functionDockWidthToRestore = 0;
|
2017-03-29 10:18:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // MAINWINDOW_H
|