2017-11-02 06:48:32 +00:00
|
|
|
#ifndef DISASSEMBLYWIDGET_H
|
|
|
|
#define DISASSEMBLYWIDGET_H
|
2017-10-11 21:07:32 +00:00
|
|
|
|
2018-03-04 17:42:02 +00:00
|
|
|
#include "Cutter.h"
|
2018-03-16 21:46:57 +00:00
|
|
|
#include "CutterDockWidget.h"
|
2019-01-13 14:20:07 +00:00
|
|
|
#include "CutterSeekable.h"
|
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;
|
2017-11-02 06:48:32 +00:00
|
|
|
|
2018-03-16 21:46:57 +00:00
|
|
|
class DisassemblyWidget : public CutterDockWidget
|
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
|
|
|
|
|
|
|
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();
|
2017-11-28 15:42:40 +00:00
|
|
|
void seekPrev();
|
2018-05-25 14:30:59 +00:00
|
|
|
void toggleSync();
|
2017-10-11 21:07:32 +00:00
|
|
|
|
2017-11-02 06:48:32 +00:00
|
|
|
private 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
|
|
|
void raisePrioritizedMemoryWidget(CutterCore::MemoryWidgetType type);
|
|
|
|
|
2017-11-02 06:48:32 +00:00
|
|
|
void scrollInstructions(int count);
|
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();
|
|
|
|
|
2017-10-11 21:07:32 +00:00
|
|
|
private:
|
2017-11-03 11:31:20 +00:00
|
|
|
DisassemblyContextMenu *mCtxMenu;
|
2017-11-02 06:48:32 +00:00
|
|
|
DisassemblyScrollArea *mDisasScrollArea;
|
|
|
|
DisassemblyTextEdit *mDisasTextEdit;
|
|
|
|
|
|
|
|
RVA topOffset;
|
|
|
|
RVA bottomOffset;
|
|
|
|
int maxLines;
|
2017-10-11 21:07:32 +00:00
|
|
|
|
2017-12-16 13:01:58 +00:00
|
|
|
/*!
|
|
|
|
* offset of lines below the first line of the current seek
|
|
|
|
*/
|
|
|
|
int cursorLineOffset;
|
|
|
|
bool seekFromCursor;
|
|
|
|
|
2019-01-12 18:01:43 +00:00
|
|
|
bool disasmDirty = false;
|
|
|
|
RVA disasmDirtyOffset = RVA_INVALID;
|
|
|
|
|
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;
|
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);
|
2018-05-25 14:30:59 +00:00
|
|
|
QAction syncIt;
|
2019-01-13 14:20:07 +00:00
|
|
|
CutterSeekable *seekable;
|
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
|
|
|
};
|
|
|
|
|
2017-11-02 06:48:32 +00:00
|
|
|
#endif // DISASSEMBLYWIDGET_H
|