1
0
Fork 0

Move ReleaseNotesDialog to x64dbg::widgets

This commit is contained in:
Duncan Ogilvie 2025-08-18 21:43:26 +02:00
parent 28178084c6
commit 5c84c5230d
20 changed files with 106 additions and 87 deletions

63
CMakeLists.txt generated
View File

@ -33,6 +33,7 @@ endif()
# Options
option(X64DBG_BUILD_IN_TREE "" ON)
option(X64DBG_RELEASE "" OFF)
# Variables
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
@ -53,32 +54,25 @@ find_package(Qt5 REQUIRED
WinExtras
)
# Target: zydis_wrapper
set(zydis_wrapper_SOURCES
cmake.toml
"src/zydis_wrapper/Zydis/Zydis.c"
"src/zydis_wrapper/Zydis/Zydis.h"
"src/zydis_wrapper/zydis_wrapper.cpp"
"src/zydis_wrapper/zydis_wrapper.h"
)
# Subdirectory: src/zydis_wrapper
set(CMKR_CMAKE_FOLDER ${CMAKE_FOLDER})
if(CMAKE_FOLDER)
set(CMAKE_FOLDER "${CMAKE_FOLDER}/src/zydis_wrapper")
else()
set(CMAKE_FOLDER "src/zydis_wrapper")
endif()
add_subdirectory("src/zydis_wrapper")
set(CMAKE_FOLDER ${CMKR_CMAKE_FOLDER})
add_library(zydis_wrapper STATIC)
target_sources(zydis_wrapper PRIVATE ${zydis_wrapper_SOURCES})
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${zydis_wrapper_SOURCES})
target_compile_definitions(zydis_wrapper PUBLIC
ZYCORE_STATIC_BUILD
ZYDIS_STATIC_BUILD
)
target_include_directories(zydis_wrapper PUBLIC
"src/zydis_wrapper"
)
target_include_directories(zydis_wrapper PRIVATE
"src/zydis_wrapper/Zydis"
)
# Subdirectory: src/gui/Src/ThirdPartyLibs/md4c
set(CMKR_CMAKE_FOLDER ${CMAKE_FOLDER})
if(CMAKE_FOLDER)
set(CMAKE_FOLDER "${CMAKE_FOLDER}/src/gui/Src/ThirdPartyLibs/md4c")
else()
set(CMAKE_FOLDER "src/gui/Src/ThirdPartyLibs/md4c")
endif()
add_subdirectory("src/gui/Src/ThirdPartyLibs/md4c")
set(CMAKE_FOLDER ${CMKR_CMAKE_FOLDER})
# Target: bridge
set(bridge_SOURCES
@ -629,6 +623,8 @@ set(gui_SOURCES
"src/gui/Src/Gui/HexLineEdit.cpp"
"src/gui/Src/Gui/HexLineEdit.h"
"src/gui/Src/Gui/HexLineEdit.ui"
"src/gui/Src/Gui/ImageTextBrowser.cpp"
"src/gui/Src/Gui/ImageTextBrowser.h"
"src/gui/Src/Gui/LineEditDialog.cpp"
"src/gui/Src/Gui/LineEditDialog.h"
"src/gui/Src/Gui/LineEditDialog.ui"
@ -665,6 +661,9 @@ set(gui_SOURCES
"src/gui/Src/Gui/ReferenceManager.h"
"src/gui/Src/Gui/RegistersView.cpp"
"src/gui/Src/Gui/RegistersView.h"
"src/gui/Src/Gui/ReleaseNotesDialog.cpp"
"src/gui/Src/Gui/ReleaseNotesDialog.h"
"src/gui/Src/Gui/ReleaseNotesDialog.ui"
"src/gui/Src/Gui/RichTextItemDelegate.cpp"
"src/gui/Src/Gui/RichTextItemDelegate.h"
"src/gui/Src/Gui/SEHChainView.cpp"
@ -731,6 +730,9 @@ set(gui_SOURCES
"src/gui/Src/QHexEdit/XByteArray.cpp"
"src/gui/Src/QHexEdit/XByteArray.h"
"src/gui/Src/ThirdPartyLibs/ldconvert/ldconvert.h"
"src/gui/Src/ThirdPartyLibs/md4c/md4c-entity.h"
"src/gui/Src/ThirdPartyLibs/md4c/md4c-html.h"
"src/gui/Src/ThirdPartyLibs/md4c/md4c.h"
"src/gui/Src/Tracer/TraceBrowser.cpp"
"src/gui/Src/Tracer/TraceBrowser.h"
"src/gui/Src/Tracer/TraceDump.cpp"
@ -806,6 +808,12 @@ add_library(gui SHARED)
target_sources(gui PRIVATE ${gui_SOURCES})
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${gui_SOURCES})
if(X64DBG_RELEASE) # X64DBG_RELEASE
target_compile_definitions(gui PUBLIC
X64DBG_RELEASE
)
endif()
target_compile_definitions(gui PRIVATE
BUILD_LIB
NOMINMAX
@ -833,11 +841,16 @@ if(NOT TARGET bridge)
message(FATAL_ERROR "Target \"bridge\" referenced by \"gui\" does not exist!")
endif()
if(NOT TARGET md4c-html)
message(FATAL_ERROR "Target \"md4c-html\" referenced by \"gui\" does not exist!")
endif()
target_link_libraries(gui PRIVATE
Qt5::Widgets
Qt5::WinExtras
zydis_wrapper
bridge
md4c-html
winmm
wininet
)

View File

@ -4,6 +4,7 @@ cmkr-include = "cmake/cmkr.cmake"
[options]
X64DBG_BUILD_IN_TREE = true
X64DBG_RELEASE = false
[variables]
CMAKE_MODULE_PATH = "${CMAKE_SOURCE_DIR}/cmake"
@ -26,24 +27,8 @@ x64 = "CMAKE_SIZEOF_VOID_P EQUAL 8"
[find-package]
Qt5 = { components = ["Widgets", "WinExtras"] }
[target.zydis_wrapper]
type = "static"
sources = [
"src/zydis_wrapper/*.cpp",
"src/zydis_wrapper/*.h",
"src/zydis_wrapper/Zydis/Zydis.h",
"src/zydis_wrapper/Zydis/Zydis.c",
]
include-directories = [
"src/zydis_wrapper",
]
private-include-directories = [
"src/zydis_wrapper/Zydis",
]
compile-definitions = [
"ZYCORE_STATIC_BUILD",
"ZYDIS_STATIC_BUILD",
]
[subdir."src/zydis_wrapper"]
[subdir."src/gui/Src/ThirdPartyLibs/md4c"]
[target.bridge]
type = "shared"
@ -160,6 +145,7 @@ private-link-libraries = [
"Qt5::WinExtras",
"::zydis_wrapper",
"::bridge",
"::md4c-html",
"winmm",
"wininet",
]
@ -186,6 +172,7 @@ private-compile-definitions = [
"NOMINMAX",
"X64DBG",
]
X64DBG_RELEASE.compile-definitions = ["X64DBG_RELEASE"]
include-after = ["cmake/deps.cmake"]
[target.gui.properties]

View File

@ -143,11 +143,6 @@ endif()
# Target: release_notes
set(release_notes_SOURCES
cmake.toml
"release_notes/ImageTextBrowser.cpp"
"release_notes/ImageTextBrowser.h"
"release_notes/ReleaseNotesDialog.cpp"
"release_notes/ReleaseNotesDialog.h"
"release_notes/ReleaseNotesDialog.ui"
"release_notes/main.cpp"
)
@ -162,12 +157,8 @@ target_include_directories(release_notes PRIVATE
release_notes
)
if(NOT TARGET md4c-html)
message(FATAL_ERROR "Target \"md4c-html\" referenced by \"release_notes\" does not exist!")
endif()
target_link_libraries(release_notes PRIVATE
md4c-html
x64dbg::widgets
)
get_directory_property(CMKR_VS_STARTUP_PROJECT DIRECTORY ${PROJECT_SOURCE_DIR} DEFINITION VS_STARTUP_PROJECT)

View File

@ -59,7 +59,7 @@ sources = [
]
include-directories = ["release_notes"]
link-libraries = [
"::md4c-html",
"x64dbg::widgets",
]
[target.hex_viewer]

View File

@ -1,7 +1,7 @@
#include <QApplication>
#include <QFile>
#include "ReleaseNotesDialog.h"
#include <Gui/ReleaseNotesDialog.h>
int main(int argc, char* argv[])
{

20
src/cross/vendor/CMakeLists.txt generated vendored
View File

@ -66,23 +66,3 @@ FetchContent_Declare(udmp-parser
src
)
FetchContent_MakeAvailable(udmp-parser)
# Target: md4c-html
set(md4c-html_SOURCES
cmake.toml
"md4c/md4c-entity.c"
"md4c/md4c-entity.h"
"md4c/md4c-html.c"
"md4c/md4c-html.h"
"md4c/md4c.c"
"md4c/md4c.h"
)
add_library(md4c-html STATIC)
target_sources(md4c-html PRIVATE ${md4c-html_SOURCES})
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${md4c-html_SOURCES})
target_include_directories(md4c-html PUBLIC
md4c
)

View File

@ -26,9 +26,3 @@ tag = "3e98b047c52c07bb1816bd0936f561ce7797469d"
git = "https://github.com/mrexodia/udmp-parser"
tag = "bc5952eda39ba0b1a07fc57f57d166292f1e9563"
subdir = "src"
# https://github.com/mity/md4c/commit/481fbfbdf72daab2912380d62bb5f2187d438408
[target.md4c-html]
type = "static"
sources = ["md4c/*.c", "md4c/*.h"]
include-directories = ["md4c"]

View File

@ -5,6 +5,11 @@ add_subdirectory(
${CMAKE_CURRENT_BINARY_DIR}/zydis_wrapper
)
add_subdirectory(
${widgets_SOURCE_DIR}/ThirdPartyLibs/md4c
${CMAKE_CURRENT_BINARY_DIR}/md4c
)
include(Qt.cmake)
set(hook_SOURCES
@ -58,6 +63,10 @@ set(widgets_SOURCES
${widgets_SOURCE_DIR}/Gui/TypeWidget.h
${widgets_SOURCE_DIR}/Gui/RichTextItemDelegate.cpp
${widgets_SOURCE_DIR}/Gui/RichTextItemDelegate.h
${widgets_SOURCE_DIR}/Gui/ReleaseNotesDialog.cpp
${widgets_SOURCE_DIR}/Gui/ReleaseNotesDialog.h
${widgets_SOURCE_DIR}/Gui/ImageTextBrowser.cpp
${widgets_SOURCE_DIR}/Gui/ImageTextBrowser.h
${widgets_SOURCE_DIR}/Memory/MemoryPage.cpp
${widgets_SOURCE_DIR}/Memory/MemoryPage.h
${widgets_SOURCE_DIR}/Utils/ActionHelpers.h
@ -98,6 +107,7 @@ target_compile_definitions(x64dbg_widgets PRIVATE
target_link_libraries(x64dbg_widgets PUBLIC
${QT_LIBRARIES}
zydis_wrapper
md4c-html
)
# https://doc.qt.io/qt-6/wasm.html#asyncify

View File

@ -33,7 +33,10 @@ QVariant ImageTextBrowser::loadResource(int type, const QUrl & name)
auto url = name.toString();
if(url.startsWith("http"))
{
// TODO: download
if(mDownloadFn)
{
image = mDownloadFn(url);
}
}
else if(url.startsWith("data:"))
{

View File

@ -4,6 +4,8 @@
#include <QTextCursor>
#include <QTimer>
#include <functional>
class ImageTextBrowser : public QTextBrowser
{
Q_OBJECT
@ -11,10 +13,18 @@ public:
explicit ImageTextBrowser(QWidget* parent = nullptr);
void resizeImages();
using DownloadFn = std::function<QImage(const QString &)>;
void setDownloadFn(DownloadFn fn)
{
mDownloadFn = std::move(fn);
}
protected:
QVariant loadResource(int type, const QUrl & name) override;
private:
qreal mSavedScrollPercentage = 0.0;
QTimer* mResizeTimer = nullptr;
DownloadFn mDownloadFn;
};

View File

@ -194,12 +194,13 @@ static void markdownGithubLinks(QString & markdown, const QString & issueUrl)
}
}
ReleaseNotesDialog::ReleaseNotesDialog(QWidget* parent)
ReleaseNotesDialog::ReleaseNotesDialog(ImageTextBrowser::DownloadFn downloadFn, QWidget* parent)
: QDialog(parent)
, ui(new Ui::ReleaseNotesDialog)
{
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
ui->setupUi(this);
ui->textBrowser->setDownloadFn(std::move(downloadFn));
#ifdef Q_OS_WINDOWS
QFont font("Segoe UI");
@ -254,6 +255,11 @@ bool ReleaseNotesDialog::setMarkdown(QString markdown, const QString & issueUrl)
return !html.isEmpty();
}
void ReleaseNotesDialog::setLabel(const QString & text)
{
ui->label->setText(text);
}
void ReleaseNotesDialog::resizeEvent(QResizeEvent* event)
{
QDialog::resizeEvent(event);

View File

@ -1,6 +1,8 @@
#pragma once
#include <QDialog>
#include <functional>
#include "ImageTextBrowser.h"
namespace Ui
{
@ -12,9 +14,10 @@ class ReleaseNotesDialog : public QDialog
Q_OBJECT
public:
explicit ReleaseNotesDialog(QWidget* parent = nullptr);
~ReleaseNotesDialog();
explicit ReleaseNotesDialog(ImageTextBrowser::DownloadFn downloadFn, QWidget* parent = nullptr);
~ReleaseNotesDialog() override;
bool setMarkdown(QString markdown, const QString & issueUrl);
void setLabel(const QString & text);
protected:
void resizeEvent(QResizeEvent* event) override;

View File

@ -35,10 +35,10 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>4</number>
<number>8</number>
</property>
<property name="rightMargin">
<number>4</number>
<number>0</number>
</property>
<item>
<spacer name="horizontalSpacer">
@ -53,6 +53,16 @@
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string/>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">

View File

@ -0,0 +1,12 @@
# https://github.com/mity/md4c/commit/481fbfbdf72daab2912380d62bb5f2187d438408
add_library(md4c-html STATIC
md4c.c
md4c.h
md4c-entity.c
md4c-entity.h
md4c-html.c
md4c-html.h
)
target_include_directories(md4c-html PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
)