-
Notifications
You must be signed in to change notification settings - Fork 647
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update QHexView, build it as a library
- Loading branch information
1 parent
369f101
commit a0d8338
Showing
64 changed files
with
3,951 additions
and
2,632 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
CMAKE_MINIMUM_REQUIRED(VERSION 3.1.0 FATAL_ERROR) | ||
CMAKE_MINIMUM_REQUIRED(VERSION 3.22) | ||
|
||
PROJECT(UEFIExtract) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
CMAKE_MINIMUM_REQUIRED(VERSION 3.1.0 FATAL_ERROR) | ||
CMAKE_MINIMUM_REQUIRED(VERSION 3.22) | ||
|
||
PROJECT(UEFIFind) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
cmake_minimum_required(VERSION 3.16...3.21) | ||
|
||
# These are part of the public API. Projects should use them to provide a | ||
# consistent set of prefix-relative destinations. | ||
if(NOT QT_DEPLOY_BIN_DIR) | ||
set(QT_DEPLOY_BIN_DIR "bin") | ||
endif() | ||
if(NOT QT_DEPLOY_LIBEXEC_DIR) | ||
set(QT_DEPLOY_LIBEXEC_DIR "libexec") | ||
endif() | ||
if(NOT QT_DEPLOY_LIB_DIR) | ||
set(QT_DEPLOY_LIB_DIR "lib") | ||
endif() | ||
if(NOT QT_DEPLOY_PLUGINS_DIR) | ||
set(QT_DEPLOY_PLUGINS_DIR "plugins") | ||
endif() | ||
if(NOT QT_DEPLOY_QML_DIR) | ||
set(QT_DEPLOY_QML_DIR "qml") | ||
endif() | ||
if(NOT QT_DEPLOY_TRANSLATIONS_DIR) | ||
set(QT_DEPLOY_TRANSLATIONS_DIR "translations") | ||
endif() | ||
if(NOT QT_DEPLOY_PREFIX) | ||
set(QT_DEPLOY_PREFIX "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}") | ||
endif() | ||
if(QT_DEPLOY_PREFIX STREQUAL "") | ||
set(QT_DEPLOY_PREFIX .) | ||
endif() | ||
if(NOT QT_DEPLOY_IGNORED_LIB_DIRS) | ||
set(QT_DEPLOY_IGNORED_LIB_DIRS "") | ||
endif() | ||
|
||
# These are internal implementation details. They may be removed at any time. | ||
set(__QT_DEPLOY_SYSTEM_NAME "Darwin") | ||
set(__QT_DEPLOY_IS_SHARED_LIBS_BUILD "ON") | ||
set(__QT_DEPLOY_TOOL "/opt/homebrew/bin/macdeployqt") | ||
set(__QT_DEPLOY_IMPL_DIR "/Users/nschlej/UEFITool/UEFITool/qhexview5/.qt") | ||
set(__QT_DEPLOY_VERBOSE "") | ||
set(__QT_CMAKE_EXPORT_NAMESPACE "Qt6") | ||
set(__QT_DEPLOY_GENERATOR_IS_MULTI_CONFIG "0") | ||
set(__QT_DEPLOY_ACTIVE_CONFIG "") | ||
set(__QT_NO_CREATE_VERSIONLESS_FUNCTIONS "") | ||
set(__QT_DEFAULT_MAJOR_VERSION "6") | ||
set(__QT_DEPLOY_QT_ADDITIONAL_PACKAGES_PREFIX_PATH "") | ||
set(__QT_DEPLOY_QT_INSTALL_PREFIX "/opt/homebrew") | ||
set(__QT_DEPLOY_QT_INSTALL_BINS "bin") | ||
set(__QT_DEPLOY_QT_INSTALL_DATA "share/qt") | ||
set(__QT_DEPLOY_QT_INSTALL_LIBEXECS "share/qt/libexec") | ||
set(__QT_DEPLOY_QT_INSTALL_PLUGINS "share/qt/plugins") | ||
set(__QT_DEPLOY_QT_INSTALL_TRANSLATIONS "share/qt/translations") | ||
set(__QT_DEPLOY_TARGET_QT_PATHS_PATH "/opt/homebrew/bin/qtpaths6") | ||
set(__QT_DEPLOY_PLUGINS "") | ||
set(__QT_DEPLOY_MUST_ADJUST_PLUGINS_RPATH "") | ||
set(__QT_DEPLOY_USE_PATCHELF "") | ||
set(__QT_DEPLOY_PATCHELF_EXECUTABLE "") | ||
set(__QT_DEPLOY_QT_IS_MULTI_CONFIG_BUILD_WITH_DEBUG "FALSE") | ||
set(__QT_DEPLOY_QT_DEBUG_POSTFIX "") | ||
|
||
# Define the CMake commands to be made available during deployment. | ||
set(__qt_deploy_support_files | ||
"/Users/nschlej/UEFITool/UEFITool/qhexview5/.qt/QtDeployTargets.cmake" | ||
"/opt/homebrew/Cellar/qt/6.8.2/lib/cmake/Qt6Core/Qt6CoreDeploySupport.cmake" | ||
) | ||
foreach(__qt_deploy_support_file IN LISTS __qt_deploy_support_files) | ||
include("${__qt_deploy_support_file}") | ||
endforeach() | ||
|
||
unset(__qt_deploy_support_file) | ||
unset(__qt_deploy_support_files) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
set(__QT_DEPLOY_TARGET_QHexView_FILE /Users/nschlej/UEFITool/UEFITool/qhexview5/libQHexView.a) | ||
set(__QT_DEPLOY_TARGET_QHexView_TYPE STATIC_LIBRARY) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
cmake_minimum_required(VERSION 3.13) | ||
|
||
project(QHexView) | ||
|
||
option(QHEXVIEW_BUILD_EXAMPLE "Build Example Application" OFF) | ||
option(QHEXVIEW_USE_QT5 "Enable Qt5 build" OFF) | ||
option(QHEXVIEW_ENABLE_DIALOGS "BuiltIn dialogs" ON) | ||
|
||
if(QHEXVIEW_USE_QT5) | ||
find_package(Qt5 REQUIRED COMPONENTS Widgets) | ||
else() | ||
find_package(Qt6 COMPONENTS Widgets) | ||
|
||
if(NOT Qt6_FOUND) | ||
find_package(Qt5 REQUIRED COMPONENTS Widgets) | ||
endif() | ||
endif() | ||
|
||
add_library(${PROJECT_NAME} STATIC) | ||
|
||
set_target_properties(${PROJECT_NAME} | ||
PROPERTIES | ||
CXX_STANDARD_REQUIRED YES | ||
CXX_STANDARD 11 | ||
AUTOMOC ON | ||
) | ||
|
||
target_link_libraries(${PROJECT_NAME} | ||
PUBLIC | ||
Qt::Widgets | ||
) | ||
|
||
target_include_directories(${PROJECT_NAME} | ||
PUBLIC | ||
"${PROJECT_SOURCE_DIR}/include" | ||
) | ||
|
||
target_sources(${PROJECT_NAME} | ||
PRIVATE | ||
include/QHexView/model/buffer/qdevicebuffer.h | ||
include/QHexView/model/buffer/qhexbuffer.h | ||
include/QHexView/model/buffer/qmappedfilebuffer.h | ||
include/QHexView/model/buffer/qmemorybuffer.h | ||
include/QHexView/model/buffer/qmemoryrefbuffer.h | ||
include/QHexView/model/commands/hexcommand.h | ||
include/QHexView/model/commands/insertcommand.h | ||
include/QHexView/model/commands/removecommand.h | ||
include/QHexView/model/commands/replacecommand.h | ||
include/QHexView/model/commands/replacecommand.h | ||
include/QHexView/model/qhexcursor.h | ||
include/QHexView/model/qhexdelegate.h | ||
include/QHexView/model/qhexdocument.h | ||
include/QHexView/model/qhexmetadata.h | ||
include/QHexView/model/qhexoptions.h | ||
include/QHexView/model/qhexutils.h | ||
include/QHexView/qhexview.h | ||
|
||
PRIVATE | ||
src/model/commands/hexcommand.cpp | ||
src/model/commands/insertcommand.cpp | ||
src/model/commands/removecommand.cpp | ||
src/model/commands/replacecommand.cpp | ||
src/model/buffer/qdevicebuffer.cpp | ||
src/model/buffer/qhexbuffer.cpp | ||
src/model/buffer/qmemorybuffer.cpp | ||
src/model/buffer/qmemoryrefbuffer.cpp | ||
src/model/buffer/qmappedfilebuffer.cpp | ||
src/model/qhexdelegate.cpp | ||
src/model/qhexutils.cpp | ||
src/model/qhexcursor.cpp | ||
src/model/qhexmetadata.cpp | ||
src/model/qhexdocument.cpp | ||
src/qhexview.cpp | ||
) | ||
|
||
if(QHEXVIEW_ENABLE_DIALOGS) | ||
target_sources(${PROJECT_NAME} | ||
PRIVATE | ||
include/QHexView/dialogs/hexfinddialog.h | ||
src/dialogs/hexfinddialog.cpp | ||
) | ||
|
||
target_compile_definitions(${PROJECT_NAME} | ||
PUBLIC | ||
QHEXVIEW_ENABLE_DIALOGS | ||
) | ||
endif() | ||
|
||
if(QHEXVIEW_BUILD_EXAMPLE) | ||
add_subdirectory(example) | ||
endif() |
File renamed without changes.
56 changes: 56 additions & 0 deletions
56
UEFITool/QHexView/include/QHexView/dialogs/hexfinddialog.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#pragma once | ||
|
||
#include <QDialog> | ||
#include <QHexView/model/qhexutils.h> | ||
|
||
class QRegularExpressionValidator; | ||
class QDoubleValidator; | ||
class QIntValidator; | ||
class QHexView; | ||
|
||
class HexFindDialog: public QDialog { | ||
Q_OBJECT | ||
|
||
public: | ||
enum class Type { Find, Replace }; | ||
|
||
public: | ||
explicit HexFindDialog(HexFindDialog::Type type = Type::Find, | ||
QHexView* parent = nullptr); | ||
QHexView* hexView() const; | ||
|
||
private Q_SLOTS: | ||
void updateFindOptions(int); | ||
void validateActions(); | ||
void replace(); | ||
void find(); | ||
|
||
private: | ||
bool prepareOptions(QString& q, QHexFindMode& mode, QHexFindDirection& fd); | ||
bool validateIntRange(uint v) const; | ||
void checkResult(const QString& q, qint64 offset, QHexFindDirection fd); | ||
void prepareTextMode(QLayout* l); | ||
void prepareHexMode(QLayout* l); | ||
void prepareIntMode(QLayout* l); | ||
void prepareFloatMode(QLayout* l); | ||
|
||
private: | ||
QRegularExpressionValidator *m_hexvalidator, *m_hexpvalidator; | ||
QDoubleValidator* m_dblvalidator; | ||
QIntValidator* m_intvalidator; | ||
int m_oldidxbits{-1}, m_oldidxendian{-1}; | ||
unsigned int m_findoptions{0}; | ||
qint64 m_startoffset{-1}; | ||
Type m_type; | ||
|
||
private: | ||
static const QString BUTTONBOX; | ||
static const QString CBFINDMODE; | ||
static const QString LEFIND; | ||
static const QString LEREPLACE; | ||
static const QString HLAYOUT; | ||
static const QString GBOPTIONS; | ||
static const QString RBALL; | ||
static const QString RBFORWARD; | ||
static const QString RBBACKWARD; | ||
}; |
24 changes: 24 additions & 0 deletions
24
UEFITool/QHexView/include/QHexView/model/buffer/qdevicebuffer.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#pragma once | ||
|
||
#include <QHexView/model/buffer/qhexbuffer.h> | ||
|
||
class QDeviceBuffer: public QHexBuffer { | ||
Q_OBJECT | ||
|
||
public: | ||
explicit QDeviceBuffer(QObject* parent = nullptr); | ||
virtual ~QDeviceBuffer(); | ||
uchar at(qint64 idx) override; | ||
qint64 length() const override; | ||
void insert(qint64 offset, const QByteArray& data) override; | ||
void replace(qint64 offset, const QByteArray& data) override; | ||
void remove(qint64 offset, int length) override; | ||
QByteArray read(qint64 offset, int length) override; | ||
bool read(QIODevice* device) override; | ||
void write(QIODevice* device) override; | ||
qint64 indexOf(const QByteArray& ba, qint64 from) override; | ||
qint64 lastIndexOf(const QByteArray& ba, qint64 from) override; | ||
|
||
protected: | ||
QIODevice* m_device{nullptr}; | ||
}; |
29 changes: 29 additions & 0 deletions
29
UEFITool/QHexView/include/QHexView/model/buffer/qhexbuffer.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#pragma once | ||
|
||
#include <QIODevice> | ||
#include <QObject> | ||
|
||
class QHexBuffer: public QObject { | ||
Q_OBJECT | ||
|
||
public: | ||
explicit QHexBuffer(QObject* parent = nullptr); | ||
bool isEmpty() const; | ||
|
||
public: | ||
virtual uchar at(qint64 idx); | ||
virtual bool accept(qint64 idx) const; | ||
virtual void replace(qint64 offset, const QByteArray& data); | ||
virtual void read(char* data, int size); | ||
virtual void read(const QByteArray& ba); | ||
|
||
public: | ||
virtual qint64 length() const = 0; | ||
virtual void insert(qint64 offset, const QByteArray& data) = 0; | ||
virtual void remove(qint64 offset, int length) = 0; | ||
virtual QByteArray read(qint64 offset, int length) = 0; | ||
virtual bool read(QIODevice* iodevice) = 0; | ||
virtual void write(QIODevice* iodevice) = 0; | ||
virtual qint64 indexOf(const QByteArray& ba, qint64 from) = 0; | ||
virtual qint64 lastIndexOf(const QByteArray& ba, qint64 from) = 0; | ||
}; |
20 changes: 20 additions & 0 deletions
20
UEFITool/QHexView/include/QHexView/model/buffer/qmappedfilebuffer.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#pragma once | ||
|
||
#include <QHexView/model/buffer/qdevicebuffer.h> | ||
|
||
class QMappedFileBuffer: public QDeviceBuffer { | ||
public: | ||
explicit QMappedFileBuffer(QObject* parent = nullptr); | ||
virtual ~QMappedFileBuffer(); | ||
|
||
public: | ||
QByteArray read(qint64 offset, int length) override; | ||
bool read(QIODevice* iodevice) override; | ||
void write(QIODevice* iodevice) override; | ||
|
||
private: | ||
void remap(); | ||
|
||
private: | ||
uchar* m_mappeddata{nullptr}; | ||
}; |
22 changes: 22 additions & 0 deletions
22
UEFITool/QHexView/include/QHexView/model/buffer/qmemorybuffer.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#pragma once | ||
|
||
#include <QHexView/model/buffer/qhexbuffer.h> | ||
|
||
class QMemoryBuffer: public QHexBuffer { | ||
Q_OBJECT | ||
|
||
public: | ||
explicit QMemoryBuffer(QObject* parent = nullptr); | ||
uchar at(qint64 idx) override; | ||
qint64 length() const override; | ||
void insert(qint64 offset, const QByteArray& data) override; | ||
void remove(qint64 offset, int length) override; | ||
QByteArray read(qint64 offset, int length) override; | ||
bool read(QIODevice* device) override; | ||
void write(QIODevice* device) override; | ||
qint64 indexOf(const QByteArray& ba, qint64 from) override; | ||
qint64 lastIndexOf(const QByteArray& ba, qint64 from) override; | ||
|
||
private: | ||
QByteArray m_buffer; | ||
}; |
12 changes: 12 additions & 0 deletions
12
UEFITool/QHexView/include/QHexView/model/buffer/qmemoryrefbuffer.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#pragma once | ||
|
||
#include <QHexView/model/buffer/qdevicebuffer.h> | ||
|
||
class QMemoryRefBuffer: public QDeviceBuffer { | ||
Q_OBJECT | ||
|
||
public: | ||
explicit QMemoryRefBuffer(QObject* parent = nullptr); | ||
bool read(QIODevice* device) override; | ||
void write(QIODevice* device) override; | ||
}; |
Oops, something went wrong.