2017-10-12 19:55:15 +00:00
|
|
|
#ifndef HEXDUMPWIDGET_H
|
|
|
|
#define HEXDUMPWIDGET_H
|
|
|
|
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QTextEdit>
|
|
|
|
#include <QMouseEvent>
|
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
|
|
|
|
2018-03-04 17:42:02 +00:00
|
|
|
#include "Cutter.h"
|
2018-03-16 21:46:57 +00:00
|
|
|
#include "CutterDockWidget.h"
|
2017-10-12 19:55:15 +00:00
|
|
|
#include "utils/Highlighter.h"
|
|
|
|
#include "utils/HexAsciiHighlighter.h"
|
|
|
|
#include "utils/HexHighlighter.h"
|
2018-01-27 10:08:05 +00:00
|
|
|
#include "utils/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
|
|
|
|
2018-01-27 10:08:05 +00:00
|
|
|
#include "ui_HexdumpWidget.h"
|
2017-10-12 19:55:15 +00:00
|
|
|
|
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();
|
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);
|
|
|
|
|
2017-10-12 19:55:15 +00:00
|
|
|
protected:
|
2017-11-08 13:17:24 +00:00
|
|
|
virtual void resizeEvent(QResizeEvent *event) override;
|
|
|
|
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
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
int bufferLines;
|
2018-02-07 20:15:33 +00:00
|
|
|
int cols;
|
2018-01-27 10:08:05 +00:00
|
|
|
|
2017-10-12 19:55:15 +00:00
|
|
|
private slots:
|
|
|
|
void on_seekChanged(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
|
|
|
|
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
|