2017-10-12 19:55:15 +00:00
|
|
|
#ifndef HEXDUMPWIDGET_H
|
|
|
|
#define HEXDUMPWIDGET_H
|
|
|
|
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QTextEdit>
|
|
|
|
#include <QMouseEvent>
|
2019-02-07 16:19:05 +00:00
|
|
|
#include <QAction>
|
2018-01-27 10:08:05 +00:00
|
|
|
|
|
|
|
#include <array>
|
2017-10-12 19:55:15 +00:00
|
|
|
#include <memory>
|
2018-01-27 10:08:05 +00:00
|
|
|
|
2019-02-22 16:50:45 +00:00
|
|
|
#include "core/Cutter.h"
|
2018-03-16 21:46:57 +00:00
|
|
|
#include "CutterDockWidget.h"
|
2019-01-14 18:43:44 +00:00
|
|
|
#include "common/CutterSeekable.h"
|
2018-12-18 17:26:38 +00:00
|
|
|
#include "dialogs/HexdumpRangeDialog.h"
|
2018-10-17 07:55:53 +00:00
|
|
|
#include "common/Highlighter.h"
|
|
|
|
#include "common/HexAsciiHighlighter.h"
|
|
|
|
#include "common/HexHighlighter.h"
|
|
|
|
#include "common/SvgIconEngine.h"
|
2017-10-12 19:55:15 +00:00
|
|
|
|
2018-01-27 10:08:05 +00:00
|
|
|
#include "Dashboard.h"
|
2017-10-12 19:55:15 +00:00
|
|
|
|
2019-02-07 16:19:05 +00:00
|
|
|
namespace Ui {
|
|
|
|
class HexdumpWidget;
|
|
|
|
}
|
2017-10-12 19:55:15 +00:00
|
|
|
|
2019-01-13 15:00:07 +00:00
|
|
|
class RefreshDeferrer;
|
|
|
|
|
2018-03-16 21:46:57 +00:00
|
|
|
class HexdumpWidget : public CutterDockWidget
|
2017-10-12 19:55:15 +00:00
|
|
|
{
|
2018-01-27 10:08:05 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
2017-10-12 19:55:15 +00:00
|
|
|
|
|
|
|
public:
|
2018-03-16 21:46:57 +00:00
|
|
|
explicit HexdumpWidget(MainWindow *main, QAction *action = nullptr);
|
2017-10-12 19:55:15 +00:00
|
|
|
~HexdumpWidget();
|
|
|
|
Highlighter *highlighter;
|
2018-01-27 10:08:05 +00:00
|
|
|
enum Format {
|
|
|
|
Hex,
|
|
|
|
Octal,
|
|
|
|
// TODO:
|
|
|
|
// HalfWord,
|
|
|
|
// Word,
|
|
|
|
// QuadWord,
|
|
|
|
// Emoji,
|
|
|
|
// SignedInt1,
|
|
|
|
// SignedInt2,
|
|
|
|
// SignedInt4,
|
|
|
|
};
|
2017-10-12 19:55:15 +00:00
|
|
|
|
|
|
|
public slots:
|
2017-12-03 10:50:14 +00:00
|
|
|
void initParsing();
|
2018-12-18 17:26:38 +00:00
|
|
|
void on_rangeDialogAccepted();
|
2017-10-12 19:55:15 +00:00
|
|
|
void showOffsets(bool show);
|
|
|
|
|
2017-11-08 13:17:24 +00:00
|
|
|
void zoomIn(int range = 1);
|
|
|
|
void zoomOut(int range = 1);
|
2018-05-25 14:30:59 +00:00
|
|
|
void toggleSync();
|
2017-11-08 13:17:24 +00:00
|
|
|
|
2017-10-12 19:55:15 +00:00
|
|
|
protected:
|
2017-11-08 13:17:24 +00:00
|
|
|
virtual void resizeEvent(QResizeEvent *event) override;
|
2018-03-21 20:32:32 +00:00
|
|
|
virtual void wheelEvent(QWheelEvent *event) override;
|
2017-10-12 19:55:15 +00:00
|
|
|
|
|
|
|
private:
|
2018-01-27 10:08:05 +00:00
|
|
|
static const int linesMarginMin = 32;
|
|
|
|
static const int linesMarginDefault = 48;
|
|
|
|
static const int linesMarginMax = 64;
|
|
|
|
|
|
|
|
enum Format format = Format::Hex;
|
2017-11-17 12:41:30 +00:00
|
|
|
|
2017-10-12 19:55:15 +00:00
|
|
|
std::unique_ptr<Ui::HexdumpWidget> ui;
|
|
|
|
|
2018-01-27 10:08:05 +00:00
|
|
|
bool sent_seek = false;
|
|
|
|
bool scroll_disabled = false;
|
|
|
|
|
|
|
|
RVA first_loaded_address = RVA_INVALID;
|
|
|
|
RVA last_loaded_address = RVA_INVALID;
|
2017-10-12 19:55:15 +00:00
|
|
|
|
2019-01-13 15:00:07 +00:00
|
|
|
RefreshDeferrer *refreshDeferrer;
|
2019-01-12 18:01:43 +00:00
|
|
|
|
2017-10-12 19:55:15 +00:00
|
|
|
void refresh(RVA addr = RVA_INVALID);
|
2017-12-03 01:44:12 +00:00
|
|
|
void selectHexPreview();
|
2018-01-27 10:08:05 +00:00
|
|
|
void updateHeaders();
|
2017-11-19 21:21:02 +00:00
|
|
|
|
2018-01-27 10:08:05 +00:00
|
|
|
std::array<QString, 3> fetchHexdump(RVA addr, int lines);
|
2017-11-15 21:56:10 +00:00
|
|
|
|
2018-01-27 10:08:05 +00:00
|
|
|
void connectScroll(bool disconnect_);
|
2017-11-18 14:33:52 +00:00
|
|
|
void setupScrollSync();
|
2017-11-17 12:41:30 +00:00
|
|
|
|
2017-11-20 10:10:31 +00:00
|
|
|
void setupFonts();
|
|
|
|
|
2018-01-27 10:08:05 +00:00
|
|
|
// If bottom = false gets the FIRST displayed line, otherwise the LAST displayed
|
|
|
|
// line.
|
|
|
|
int getDisplayedLined(QTextEdit *textEdit, bool bottom = false);
|
|
|
|
|
|
|
|
static void removeTopLinesWithoutScroll(QTextEdit *textEdit, int lines);
|
|
|
|
static void removeBottomLinesWithoutScroll(QTextEdit *textEdit, int lines);
|
|
|
|
static void prependWithoutScroll(QTextEdit *textEdit, QString text);
|
|
|
|
static void appendWithoutScroll(QTextEdit *textEdit, QString text);
|
|
|
|
static void setTextEditPosition(QTextEdit *textEdit, int position);
|
|
|
|
|
|
|
|
RVA hexPositionToAddress(int position);
|
|
|
|
RVA asciiPositionToAddress(int position);
|
|
|
|
int hexAddressToPosition(RVA address);
|
|
|
|
int asciiAddressToPosition(RVA address);
|
|
|
|
void updateWidths();
|
|
|
|
|
|
|
|
void updateParseWindow(RVA start_address, int size);
|
|
|
|
void clearParseWindow();
|
|
|
|
|
2018-06-26 20:28:51 +00:00
|
|
|
int bufferLines = 0;
|
|
|
|
int cols = 0;
|
2018-12-18 17:26:38 +00:00
|
|
|
ut64 requestedSelectionStartAddress=0;
|
|
|
|
ut64 requestedSelectionEndAddress=0;
|
|
|
|
HexdumpRangeDialog rangeDialog;
|
2018-05-25 14:30:59 +00:00
|
|
|
QAction syncAction;
|
2019-01-13 14:20:07 +00:00
|
|
|
CutterSeekable *seekable;
|
2018-01-27 10:08:05 +00:00
|
|
|
|
2017-10-12 19:55:15 +00:00
|
|
|
private slots:
|
2019-01-12 17:02:51 +00:00
|
|
|
void onSeekChanged(RVA addr);
|
2017-11-04 11:46:29 +00:00
|
|
|
void raisePrioritizedMemoryWidget(CutterCore::MemoryWidgetType type);
|
2017-10-12 19:55:15 +00:00
|
|
|
|
2018-01-27 10:08:05 +00:00
|
|
|
// Currently unused/untested
|
|
|
|
// void highlightHexCurrentLine();
|
|
|
|
// void highlightHexWords(const QString &str);
|
2017-10-12 19:55:15 +00:00
|
|
|
|
|
|
|
void on_actionHideHexdump_side_panel_triggered();
|
|
|
|
|
|
|
|
void showHexdumpContextMenu(const QPoint &pt);
|
|
|
|
void showHexASCIIContextMenu(const QPoint &pt);
|
|
|
|
|
2018-01-27 10:08:05 +00:00
|
|
|
void selectionChanged();
|
|
|
|
void scrollChanged();
|
2017-12-03 10:50:14 +00:00
|
|
|
|
|
|
|
void on_parseArchComboBox_currentTextChanged(const QString &arg1);
|
|
|
|
void on_parseBitsComboBox_currentTextChanged(const QString &arg1);
|
|
|
|
void on_parseTypeComboBox_currentTextChanged(const QString &arg1);
|
|
|
|
void on_parseEndianComboBox_currentTextChanged(const QString &arg1);
|
2017-10-12 19:55:15 +00:00
|
|
|
|
|
|
|
void on_action1column_triggered();
|
|
|
|
void on_action2columns_triggered();
|
|
|
|
void on_action4columns_triggered();
|
|
|
|
void on_action8columns_triggered();
|
|
|
|
void on_action16columns_triggered();
|
|
|
|
void on_action32columns_triggered();
|
|
|
|
void on_action64columns_triggered();
|
|
|
|
|
2018-01-27 10:08:05 +00:00
|
|
|
void on_actionFormatHex_triggered();
|
|
|
|
void on_actionFormatOctal_triggered();
|
2017-10-12 19:55:15 +00:00
|
|
|
|
2018-12-18 17:26:38 +00:00
|
|
|
void on_actionSelect_Block_triggered();
|
|
|
|
|
2017-11-20 10:10:31 +00:00
|
|
|
void fontsUpdated();
|
2017-11-20 16:38:10 +00:00
|
|
|
void colorsUpdatedSlot();
|
2017-11-20 10:10:31 +00:00
|
|
|
|
2017-10-12 19:55:15 +00:00
|
|
|
void on_hexSideTab_2_currentChanged(int index);
|
|
|
|
void on_copyMD5_clicked();
|
|
|
|
void on_copySHA1_clicked();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // HEXDUMPWIDGET_H
|