2017-10-10 10:17:05 +00:00
|
|
|
#ifndef DISASSEMBLYCONTEXTMENU_H
|
|
|
|
#define DISASSEMBLYCONTEXTMENU_H
|
|
|
|
|
2019-02-22 16:50:45 +00:00
|
|
|
#include "core/Cutter.h"
|
2020-03-19 09:36:36 +00:00
|
|
|
#include "common/IOModesController.h"
|
2017-10-10 10:17:05 +00:00
|
|
|
#include <QMenu>
|
2017-11-03 11:31:20 +00:00
|
|
|
#include <QKeySequence>
|
2017-10-10 10:17:05 +00:00
|
|
|
|
2017-11-19 17:49:29 +00:00
|
|
|
class DisassemblyContextMenu : public QMenu
|
|
|
|
{
|
2018-03-21 20:32:32 +00:00
|
|
|
Q_OBJECT
|
2017-11-19 17:49:29 +00:00
|
|
|
|
2017-10-10 10:17:05 +00:00
|
|
|
public:
|
2019-08-14 18:47:30 +00:00
|
|
|
DisassemblyContextMenu(QWidget *parent, MainWindow *mainWindow);
|
2017-12-10 20:40:15 +00:00
|
|
|
~DisassemblyContextMenu();
|
2017-11-03 11:31:20 +00:00
|
|
|
|
2017-12-02 15:43:21 +00:00
|
|
|
signals:
|
|
|
|
void copy();
|
|
|
|
|
2017-11-03 11:31:20 +00:00
|
|
|
public slots:
|
|
|
|
void setOffset(RVA offset);
|
2017-12-02 15:43:21 +00:00
|
|
|
void setCanCopy(bool enabled);
|
2017-11-03 11:31:20 +00:00
|
|
|
|
2019-03-06 20:30:39 +00:00
|
|
|
/**
|
|
|
|
* @brief Sets the value of curHighlightedWord
|
|
|
|
* @param text The current highlighted word
|
2019-03-04 21:45:17 +00:00
|
|
|
*/
|
|
|
|
void setCurHighlightedWord(const QString &text);
|
|
|
|
|
2017-11-28 13:50:41 +00:00
|
|
|
private slots:
|
|
|
|
void aboutToShowSlot();
|
|
|
|
|
2018-10-22 09:16:56 +00:00
|
|
|
void on_actionEditFunction_triggered();
|
2018-02-12 20:12:13 +00:00
|
|
|
void on_actionEditInstruction_triggered();
|
2018-03-05 14:20:55 +00:00
|
|
|
void on_actionNopInstruction_triggered();
|
2018-03-10 07:27:09 +00:00
|
|
|
void on_actionJmpReverse_triggered();
|
2018-02-12 20:12:13 +00:00
|
|
|
void on_actionEditBytes_triggered();
|
2018-09-14 17:20:54 +00:00
|
|
|
void showReverseJmpQuery();
|
2018-02-12 20:12:13 +00:00
|
|
|
|
2017-12-02 15:43:21 +00:00
|
|
|
void on_actionCopy_triggered();
|
2018-05-03 07:53:01 +00:00
|
|
|
void on_actionCopyAddr_triggered();
|
2017-11-03 11:31:20 +00:00
|
|
|
void on_actionAddComment_triggered();
|
2018-08-18 19:28:04 +00:00
|
|
|
void on_actionAnalyzeFunction_triggered();
|
2017-11-03 11:31:20 +00:00
|
|
|
void on_actionAddFlag_triggered();
|
|
|
|
void on_actionRename_triggered();
|
2017-11-30 14:16:39 +00:00
|
|
|
void on_actionRenameUsedHere_triggered();
|
2018-10-03 20:10:53 +00:00
|
|
|
void on_actionSetFunctionVarTypes_triggered();
|
2017-11-03 11:31:20 +00:00
|
|
|
void on_actionXRefs_triggered();
|
|
|
|
void on_actionDisplayOptions_triggered();
|
2017-10-10 10:17:05 +00:00
|
|
|
|
2017-12-11 13:07:12 +00:00
|
|
|
void on_actionDeleteComment_triggered();
|
|
|
|
void on_actionDeleteFlag_triggered();
|
|
|
|
void on_actionDeleteFunction_triggered();
|
|
|
|
|
2018-06-12 08:43:14 +00:00
|
|
|
void on_actionAddBreakpoint_triggered();
|
2020-01-04 18:05:49 +00:00
|
|
|
void on_actionAdvancedBreakpoint_triggered();
|
2018-06-12 08:43:14 +00:00
|
|
|
void on_actionContinueUntil_triggered();
|
|
|
|
void on_actionSetPC_triggered();
|
2018-02-12 09:48:06 +00:00
|
|
|
|
2018-08-04 18:05:56 +00:00
|
|
|
void on_actionSetToCode_triggered();
|
2018-11-16 21:27:07 +00:00
|
|
|
void on_actionSetAsString_triggered();
|
2019-12-18 14:26:51 +00:00
|
|
|
void on_actionSetAsStringRemove_triggered();
|
|
|
|
void on_actionSetAsStringAdvanced_triggered();
|
2018-08-04 18:05:56 +00:00
|
|
|
void on_actionSetToData_triggered();
|
|
|
|
void on_actionSetToDataEx_triggered();
|
|
|
|
|
2019-03-06 20:30:39 +00:00
|
|
|
/**
|
|
|
|
* @brief Executed on selecting an offset from the structureOffsetMenu
|
2019-02-24 17:25:38 +00:00
|
|
|
* Uses the applyStructureOffset() function of CutterCore to apply the
|
|
|
|
* structure offset
|
|
|
|
* \param action The action which trigered the event
|
|
|
|
*/
|
|
|
|
void on_actionStructureOffsetMenu_triggered(QAction *action);
|
|
|
|
|
2019-03-06 20:30:39 +00:00
|
|
|
/**
|
|
|
|
* @brief Executed on selecting the "Link Type to Address" option
|
2019-03-04 21:45:17 +00:00
|
|
|
* Opens the LinkTypeDialog box from where the user can link the address
|
|
|
|
* to a type
|
|
|
|
*/
|
|
|
|
void on_actionLinkType_triggered();
|
|
|
|
|
2017-11-03 11:31:20 +00:00
|
|
|
private:
|
2017-12-02 15:43:21 +00:00
|
|
|
QKeySequence getCopySequence() const;
|
2017-11-03 11:31:20 +00:00
|
|
|
QKeySequence getCommentSequence() const;
|
2019-04-25 11:38:53 +00:00
|
|
|
QKeySequence getCopyAddressSequence() const;
|
2018-08-04 18:05:56 +00:00
|
|
|
QKeySequence getSetToCodeSequence() const;
|
2018-11-16 21:27:07 +00:00
|
|
|
QKeySequence getSetAsStringSequence() const;
|
2018-08-04 18:05:56 +00:00
|
|
|
QKeySequence getSetToDataSequence() const;
|
|
|
|
QKeySequence getSetToDataExSequence() const;
|
2017-11-03 11:31:20 +00:00
|
|
|
QKeySequence getAddFlagSequence() const;
|
|
|
|
QKeySequence getRenameSequence() const;
|
2017-11-30 14:16:39 +00:00
|
|
|
QKeySequence getRenameUsedHereSequence() const;
|
2018-10-03 20:10:53 +00:00
|
|
|
QKeySequence getRetypeSequence() const;
|
2017-11-03 11:31:20 +00:00
|
|
|
QKeySequence getXRefSequence() const;
|
|
|
|
QKeySequence getDisplayOptionsSequence() const;
|
2019-09-25 13:58:58 +00:00
|
|
|
QKeySequence getDefineNewFunctionSequence() const;
|
|
|
|
QKeySequence getUndefineFunctionSequence() const;
|
|
|
|
QKeySequence getEditFunctionSequence() const;
|
2018-07-17 07:26:20 +00:00
|
|
|
QList<QKeySequence> getAddBPSequence() const;
|
2017-11-19 17:49:29 +00:00
|
|
|
|
2019-03-06 20:30:39 +00:00
|
|
|
/**
|
|
|
|
* @return the shortcut key for "Link Type to Address" option
|
2019-03-04 21:45:17 +00:00
|
|
|
*/
|
|
|
|
QKeySequence getLinkTypeSequence() const;
|
|
|
|
|
|
|
|
|
2017-10-10 10:17:05 +00:00
|
|
|
RVA offset;
|
2017-12-02 15:43:21 +00:00
|
|
|
bool canCopy;
|
2019-03-04 21:45:17 +00:00
|
|
|
QString curHighlightedWord; // The current highlighted word
|
2019-08-14 18:47:30 +00:00
|
|
|
MainWindow *mainWindow;
|
2020-03-19 09:36:36 +00:00
|
|
|
IOModesController ioModesController;
|
2017-12-02 15:43:21 +00:00
|
|
|
|
2018-03-21 20:32:32 +00:00
|
|
|
QList<QAction *> anonymousActions;
|
2017-12-10 20:40:15 +00:00
|
|
|
|
2018-02-12 20:12:13 +00:00
|
|
|
QMenu *editMenu;
|
|
|
|
QAction actionEditInstruction;
|
2018-03-05 14:20:55 +00:00
|
|
|
QAction actionNopInstruction;
|
2018-03-10 07:27:09 +00:00
|
|
|
QAction actionJmpReverse;
|
2018-02-12 20:12:13 +00:00
|
|
|
QAction actionEditBytes;
|
|
|
|
|
2017-12-02 15:43:21 +00:00
|
|
|
QAction actionCopy;
|
|
|
|
QAction *copySeparator;
|
2018-05-03 07:53:01 +00:00
|
|
|
QAction actionCopyAddr;
|
2017-12-10 20:40:15 +00:00
|
|
|
|
|
|
|
|
2017-10-10 10:17:05 +00:00
|
|
|
QAction actionAddComment;
|
|
|
|
QAction actionAddFlag;
|
2018-08-18 19:28:04 +00:00
|
|
|
QAction actionAnalyzeFunction;
|
2018-10-22 09:16:56 +00:00
|
|
|
QAction actionEditFunction;
|
2017-10-10 10:17:05 +00:00
|
|
|
QAction actionRename;
|
2017-11-30 14:16:39 +00:00
|
|
|
QAction actionRenameUsedHere;
|
2018-10-03 20:10:53 +00:00
|
|
|
QAction actionSetFunctionVarTypes;
|
2017-10-10 10:17:05 +00:00
|
|
|
QAction actionXRefs;
|
|
|
|
QAction actionDisplayOptions;
|
2017-11-28 13:13:22 +00:00
|
|
|
|
2017-12-11 13:07:12 +00:00
|
|
|
QAction actionDeleteComment;
|
|
|
|
QAction actionDeleteFlag;
|
|
|
|
QAction actionDeleteFunction;
|
|
|
|
|
2019-02-24 17:25:38 +00:00
|
|
|
QMenu *structureOffsetMenu;
|
|
|
|
|
2019-03-04 21:45:17 +00:00
|
|
|
QAction actionLinkType;
|
|
|
|
|
2017-11-28 13:50:41 +00:00
|
|
|
QMenu *setBaseMenu;
|
2017-11-28 13:13:22 +00:00
|
|
|
QAction actionSetBaseBinary;
|
|
|
|
QAction actionSetBaseOctal;
|
|
|
|
QAction actionSetBaseDecimal;
|
|
|
|
QAction actionSetBaseHexadecimal;
|
|
|
|
QAction actionSetBasePort;
|
|
|
|
QAction actionSetBaseIPAddr;
|
|
|
|
QAction actionSetBaseSyscall;
|
|
|
|
QAction actionSetBaseString;
|
2017-12-10 20:40:15 +00:00
|
|
|
|
2018-02-12 09:48:06 +00:00
|
|
|
QMenu *setBitsMenu;
|
|
|
|
QAction actionSetBits16;
|
|
|
|
QAction actionSetBits32;
|
|
|
|
QAction actionSetBits64;
|
|
|
|
|
2018-06-12 08:43:14 +00:00
|
|
|
QMenu *debugMenu;
|
|
|
|
QAction actionContinueUntil;
|
2020-01-29 16:58:05 +00:00
|
|
|
QAction actionSetPC;
|
|
|
|
|
|
|
|
QMenu *breakpointMenu;
|
2018-06-12 08:43:14 +00:00
|
|
|
QAction actionAddBreakpoint;
|
2020-01-04 18:05:49 +00:00
|
|
|
QAction actionAdvancedBreakpoint;
|
2018-06-12 08:43:14 +00:00
|
|
|
|
2018-08-04 18:05:56 +00:00
|
|
|
QAction actionSetToCode;
|
2019-12-18 14:26:51 +00:00
|
|
|
|
|
|
|
QAction actionSetAsStringAuto;
|
|
|
|
QAction actionSetAsStringRemove;
|
|
|
|
QAction actionSetAsStringAdvanced;
|
2018-08-04 18:05:56 +00:00
|
|
|
|
|
|
|
QMenu *setToDataMenu;
|
2019-06-12 07:08:15 +00:00
|
|
|
QMenu *setAsMenu;
|
2019-12-18 14:26:51 +00:00
|
|
|
QMenu *setAsString;
|
2018-08-04 18:05:56 +00:00
|
|
|
QAction actionSetToDataEx;
|
|
|
|
QAction actionSetToDataByte;
|
|
|
|
QAction actionSetToDataWord;
|
|
|
|
QAction actionSetToDataDword;
|
|
|
|
QAction actionSetToDataQword;
|
|
|
|
|
2019-07-19 19:21:12 +00:00
|
|
|
QAction showInSubmenu;
|
2019-08-14 18:47:30 +00:00
|
|
|
QList<QAction*> showTargetMenuActions;
|
2020-02-04 09:02:34 +00:00
|
|
|
QMenu *pluginMenu = nullptr;
|
|
|
|
QAction *pluginActionMenuAction = nullptr;
|
2019-07-19 19:21:12 +00:00
|
|
|
|
2017-12-10 20:40:15 +00:00
|
|
|
// For creating anonymous entries (that are always visible)
|
2018-08-04 18:05:56 +00:00
|
|
|
QAction *addAnonymousAction(QString name, const char *slot, QKeySequence shortcut);
|
|
|
|
|
|
|
|
void initAction(QAction *action, QString name, const char *slot = nullptr);
|
|
|
|
void initAction(QAction *action, QString name, const char *slot, QKeySequence keySequence);
|
|
|
|
void initAction(QAction *action, QString name, const char *slot, QList<QKeySequence> keySequence);
|
|
|
|
|
|
|
|
void setBase(QString base);
|
|
|
|
void setToData(int size, int repeat = 1);
|
|
|
|
void setBits(int bits);
|
|
|
|
|
|
|
|
void addSetBaseMenu();
|
|
|
|
void addSetBitsMenu();
|
2019-06-12 07:08:15 +00:00
|
|
|
void addSetAsMenu();
|
2018-08-04 18:05:56 +00:00
|
|
|
void addSetToDataMenu();
|
|
|
|
void addEditMenu();
|
2020-01-29 16:58:05 +00:00
|
|
|
void addBreakpointMenu();
|
2018-08-04 18:05:56 +00:00
|
|
|
void addDebugMenu();
|
2019-08-14 18:47:30 +00:00
|
|
|
|
|
|
|
struct ThingUsedHere {
|
|
|
|
QString name;
|
|
|
|
RVA offset;
|
|
|
|
enum class Type {
|
|
|
|
Var,
|
|
|
|
Function,
|
|
|
|
Flag,
|
|
|
|
Address
|
|
|
|
};
|
|
|
|
Type type;
|
|
|
|
};
|
|
|
|
QVector<ThingUsedHere> getThingUsedHere(RVA offset);
|
|
|
|
|
|
|
|
void updateTargetMenuActions(const QVector<ThingUsedHere> &targets);
|
2017-10-10 10:17:05 +00:00
|
|
|
};
|
|
|
|
#endif // DISASSEMBLYCONTEXTMENU_H
|