2017-11-02 06:48:32 +00:00
|
|
|
#ifndef DISASSEMBLYWIDGET_H
|
|
|
|
#define DISASSEMBLYWIDGET_H
|
2017-10-11 21:07:32 +00:00
|
|
|
|
2019-02-22 16:50:45 +00:00
|
|
|
#include "core/Cutter.h"
|
2019-03-27 08:24:54 +00:00
|
|
|
#include "MemoryDockWidget.h"
|
2019-01-14 18:43:44 +00:00
|
|
|
#include "common/CutterSeekable.h"
|
2019-01-12 19:25:43 +00:00
|
|
|
#include "common/RefreshDeferrer.h"
|
2019-06-26 07:12:39 +00:00
|
|
|
#include "common/CachedFontMetrics.h"
|
2019-01-12 19:25:43 +00:00
|
|
|
|
2017-11-03 11:31:20 +00:00
|
|
|
#include <QTextEdit>
|
2017-11-02 06:48:32 +00:00
|
|
|
#include <QPlainTextEdit>
|
2017-10-16 19:00:47 +00:00
|
|
|
#include <QShortcut>
|
2018-05-25 14:30:59 +00:00
|
|
|
#include <QAction>
|
2017-10-11 21:07:32 +00:00
|
|
|
|
2017-11-02 06:48:32 +00:00
|
|
|
|
|
|
|
class DisassemblyTextEdit;
|
|
|
|
class DisassemblyScrollArea;
|
2017-11-03 11:31:20 +00:00
|
|
|
class DisassemblyContextMenu;
|
2019-06-26 07:12:39 +00:00
|
|
|
class DisassemblyLeftPanel;
|
2017-11-02 06:48:32 +00:00
|
|
|
|
2019-03-27 08:24:54 +00:00
|
|
|
class DisassemblyWidget : public MemoryDockWidget
|
2017-10-11 21:07:32 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2018-03-16 21:46:57 +00:00
|
|
|
explicit DisassemblyWidget(MainWindow *main, QAction *action = nullptr);
|
2018-03-21 20:32:32 +00:00
|
|
|
QWidget *getTextWidget();
|
2017-10-11 21:07:32 +00:00
|
|
|
|
2019-06-18 13:02:41 +00:00
|
|
|
static QString getWidgetType();
|
|
|
|
|
2017-10-11 21:07:32 +00:00
|
|
|
public slots:
|
|
|
|
void highlightCurrentLine();
|
|
|
|
void showDisasContextMenu(const QPoint &pt);
|
2017-10-14 09:35:49 +00:00
|
|
|
void fontsUpdatedSlot();
|
2017-11-20 11:23:37 +00:00
|
|
|
void colorsUpdatedSlot();
|
2019-07-14 00:52:43 +00:00
|
|
|
void scrollInstructions(int count);
|
2017-11-28 15:42:40 +00:00
|
|
|
void seekPrev();
|
2019-05-01 16:15:33 +00:00
|
|
|
void setPreviewMode(bool previewMode);
|
2019-06-26 07:12:39 +00:00
|
|
|
QFontMetrics getFontMetrics();
|
|
|
|
QList<DisassemblyLine> getLines();
|
2017-10-11 21:07:32 +00:00
|
|
|
|
2019-05-01 16:15:33 +00:00
|
|
|
protected slots:
|
2017-11-04 11:46:29 +00:00
|
|
|
void on_seekChanged(RVA offset);
|
2019-01-12 17:02:51 +00:00
|
|
|
void refreshDisasm(RVA offset = RVA_INVALID);
|
2017-11-04 11:46:29 +00:00
|
|
|
|
2017-11-20 10:04:03 +00:00
|
|
|
bool updateMaxLines();
|
2017-11-02 06:48:32 +00:00
|
|
|
|
|
|
|
void cursorPositionChanged();
|
|
|
|
|
2018-06-15 00:03:22 +00:00
|
|
|
void zoomIn();
|
|
|
|
void zoomOut();
|
|
|
|
|
2019-05-01 16:15:33 +00:00
|
|
|
protected:
|
2017-11-03 11:31:20 +00:00
|
|
|
DisassemblyContextMenu *mCtxMenu;
|
2017-11-02 06:48:32 +00:00
|
|
|
DisassemblyScrollArea *mDisasScrollArea;
|
|
|
|
DisassemblyTextEdit *mDisasTextEdit;
|
2019-06-26 07:12:39 +00:00
|
|
|
DisassemblyLeftPanel *leftPanel;
|
|
|
|
QList<DisassemblyLine> lines;
|
2017-11-02 06:48:32 +00:00
|
|
|
|
2019-05-01 16:15:33 +00:00
|
|
|
private:
|
2017-11-02 06:48:32 +00:00
|
|
|
RVA topOffset;
|
|
|
|
RVA bottomOffset;
|
|
|
|
int maxLines;
|
2017-10-11 21:07:32 +00:00
|
|
|
|
2019-03-04 21:45:17 +00:00
|
|
|
QString curHighlightedWord;
|
|
|
|
|
2019-03-06 20:30:39 +00:00
|
|
|
/**
|
2017-12-16 13:01:58 +00:00
|
|
|
* offset of lines below the first line of the current seek
|
|
|
|
*/
|
|
|
|
int cursorLineOffset;
|
2019-04-22 08:48:06 +00:00
|
|
|
int cursorCharOffset;
|
2017-12-16 13:01:58 +00:00
|
|
|
bool seekFromCursor;
|
|
|
|
|
2019-01-13 11:40:54 +00:00
|
|
|
RefreshDeferrer *disasmRefresh;
|
2019-01-12 18:01:43 +00:00
|
|
|
|
2017-10-11 21:07:32 +00:00
|
|
|
RVA readCurrentDisassemblyOffset();
|
2017-11-28 11:56:38 +00:00
|
|
|
RVA readDisassemblyOffset(QTextCursor tc);
|
2019-01-12 17:02:51 +00:00
|
|
|
bool eventFilter(QObject *obj, QEvent *event) override;
|
2019-06-18 13:02:41 +00:00
|
|
|
QString getWindowTitle() const override;
|
2017-11-02 06:48:32 +00:00
|
|
|
|
2018-08-12 16:20:16 +00:00
|
|
|
QList<RVA> breakpoints;
|
|
|
|
|
2017-11-30 14:00:22 +00:00
|
|
|
void setupFonts();
|
|
|
|
void setupColors();
|
|
|
|
|
2017-11-02 06:48:32 +00:00
|
|
|
void updateCursorPosition();
|
|
|
|
|
|
|
|
void connectCursorPositionChanged(bool disconnect);
|
2017-12-16 13:01:58 +00:00
|
|
|
|
|
|
|
void moveCursorRelative(bool up, bool page);
|
2019-04-22 08:48:06 +00:00
|
|
|
|
2018-05-25 14:30:59 +00:00
|
|
|
QAction syncIt;
|
2017-11-02 06:48:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class DisassemblyScrollArea : public QAbstractScrollArea
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit DisassemblyScrollArea(QWidget *parent = nullptr);
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void scrollLines(int lines);
|
|
|
|
void disassemblyResized();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
bool viewportEvent(QEvent *event) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void resetScrollBars();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class DisassemblyTextEdit: public QPlainTextEdit
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit DisassemblyTextEdit(QWidget *parent = nullptr)
|
2018-03-21 20:32:32 +00:00
|
|
|
: QPlainTextEdit(parent),
|
|
|
|
lockScroll(false) {}
|
2017-11-02 06:48:32 +00:00
|
|
|
|
2018-03-21 20:32:32 +00:00
|
|
|
void setLockScroll(bool lock)
|
|
|
|
{
|
|
|
|
this->lockScroll = lock;
|
|
|
|
}
|
2017-11-02 06:48:32 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
bool viewportEvent(QEvent *event) override;
|
|
|
|
void scrollContentsBy(int dx, int dy) override;
|
2017-11-04 11:46:29 +00:00
|
|
|
void keyPressEvent(QKeyEvent *event) override;
|
2017-12-02 13:10:15 +00:00
|
|
|
void mousePressEvent(QMouseEvent *event) override;
|
2017-11-02 06:48:32 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
bool lockScroll;
|
2017-10-11 21:07:32 +00:00
|
|
|
};
|
|
|
|
|
2019-06-26 07:12:39 +00:00
|
|
|
/**
|
|
|
|
* @class This class is used to draw the left pane of the disassembly
|
|
|
|
* widget. Its goal is to draw proper arrows for the jumps of the disassembly.
|
|
|
|
*/
|
|
|
|
class DisassemblyLeftPanel: public QFrame
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DisassemblyLeftPanel(DisassemblyWidget *disas);
|
|
|
|
void paintEvent(QPaintEvent *event) override;
|
2019-07-14 00:52:43 +00:00
|
|
|
void wheelEvent(QWheelEvent *event) override;
|
2019-06-26 07:12:39 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
DisassemblyWidget *disas;
|
|
|
|
};
|
|
|
|
|
2017-11-02 06:48:32 +00:00
|
|
|
#endif // DISASSEMBLYWIDGET_H
|