Compare commits

..

18 Commits

Author SHA1 Message Date
WerWolv
f112123d39 build: Bumped version to 1.37.1 2025-02-18 10:47:51 +01:00
WerWolv
1a1ef9e7e0 fix: Pattern Editor losing focus during auto evaluation
Fixes #2122
2025-02-18 10:27:10 +01:00
WerWolv
39543fbda8 build: Updated dependencies 2025-02-18 10:26:54 +01:00
WerWolv
835863523b build: Get rid of unused Toolchain file warning 2025-02-17 13:19:41 +01:00
WerWolv
e6c8c69fda fix: Remove unused event unsubscribes in disassembler 2025-02-17 13:07:22 +01:00
WerWolv
e2d30eeba2 fix: Crash when setting invalid font 2025-02-17 13:07:15 +01:00
WerWolv
1da82d1403 impr: Added missing ellipsis on Edit options 2025-02-17 11:21:43 +01:00
WerWolv
73b9df24cf fix: Closing one view breaking all other views 2025-02-17 10:17:23 +01:00
WerWolv
f93e1194d6 fix: Crash when loading process memory provider from project 2025-02-17 10:17:13 +01:00
WerWolv
677cff244d fix: Make sure fps counter values are initialized to zero 2025-02-16 23:46:20 +01:00
WerWolv
8d88e328fa fix: Don't execute EventDPIChanged multiple times 2025-02-16 22:53:35 +01:00
WerWolv
acb5ef561d fix: Wrong native scaling on Wayland 2025-02-16 21:55:38 +01:00
WerWolv
444b5219e2 fix: Crash when custom disassembler returns no bytes 2025-02-16 21:11:19 +01:00
WerWolv
a4c7e0db90 patterns: Updated pattern language 2025-02-16 21:06:14 +01:00
WerWolv
f4e1824b7b fix: Pattern editor being shifted to the left on evaluate 2025-02-16 20:53:29 +01:00
WerWolv
fcb5e18102 fix: Pattern console log logic 2025-02-16 20:53:20 +01:00
WerWolv
70d4e21c4b fix: Don't parse version string on every call 2025-02-16 20:53:12 +01:00
WerWolv
2e2d5d31bc build: Updated libwolv 2025-02-16 20:52:57 +01:00
854 changed files with 42835 additions and 96480 deletions

View File

@@ -1,97 +1,69 @@
# All rules should have a comment associated
# Directives that do not have any effect (e.g. disabling a rule that is not enabled) can be done to add an explanation comment.
# Or at least an empty comment # to show they were put here explicitely,
# and not as part of the historical CLion-generated rules
# Note: `- -X` means disable X
# CLI usage: go to the build directory and run: `run-clang-tidy -allow-no-checks -source-filter ".*/lib/.*" -fix -j`
Checks:
- -*
- mpi-*
- bugprone-*
- -bugprone-signal-handler
- -bugprone-narrowing-conversions
- -bugprone-redundant-branch-condition
- -bugprone-exception-escape
- -bugprone-shared-ptr-array-mismatch
- -bugprone-implicit-widening-of-multiplication-result
- -bugprone-signed-char-misuse
- -bugprone-unhandled-exception-at-new
- -bugprone-infinite-loop
- -bugprone-easily-swappable-parameters
- -bugprone-float-loop-counter #
- -bugprone-unchecked-string-to-number-conversion # Unfortunately no alternative
- -bugprone-branch-clone # Mostly warns about one-line duplicates
- cert-err52-cpp
- cert-err60-cpp
- cert-str34-c
- cert-dcl21-cpp
- cert-msc50-cpp
- cert-msc51-cpp
- cert-dcl58-cpp
- cppcoreguidelines-avoid-const-or-ref-data-members
- cppcoreguidelines-pro-type-member-init # We want to use default member initializers
- cppcoreguidelines-slicing
- cppcoreguidelines-interfaces-global-init
- -cppcoreguidelines-pro-type-static-cast-downcast # dynamic_cast has a runtime overhead
- -cppcoreguidelines-narrowing-conversions #
- google-runtime-operator
- google-explicit-constructor
- -google-default-arguments # Provider and ViewProvider read() is a good example of why this is useful
- hicpp-multiway-paths-covered
- hicpp-exception-baseclass
- misc-*
- -misc-definitions-in-headers
- -misc-unused-parameters
- -misc-unused-alias-decls
- -misc-use-anonymous-namespace
- -misc-misleading-identifier
- -misc-confusable-identifiers
- -misc-misleading-bidirectional
- -misc-static-assert
- -misc-no-recursion
- -misc-const-correctness
- -misc-use-internal-linkage # False positives if header where function is defined is not included
- -misc-include-cleaner # Allow indirect includes
- -misc-non-private-member-variables-in-classes #
- modernize-*
- -modernize-use-trailing-return-type
- -modernize-use-std-print # We want to use fmt::print instead
- -modernize-use-integer-sign-comparison # Too much occurrences to change
- openmp-use-default-none
- performance-*
- -performance-no-int-to-ptr
- portability-*
- -portability-restrict-system-includes
- readability-*
- -readability-redundant-preprocessor
- -readability-named-parameter
- -readability-function-size
- -readability-use-anyofallof
- -readability-identifier-length
- -readability-magic-numbers
- -readability-braces-around-statements
- -readability-suspicious-call-argument
- -readability-isolate-declaration
- -readability-else-after-return
- -readability-redundant-access-specifiers
- -readability-function-cognitive-complexity
- -readability-identifier-naming
- -readability-qualified-auto
- -readability-use-std-min-max # Less readable imo
- -readability-math-missing-parentheses # Basic math
- -readability-implicit-bool-conversion # Not much of a problem ?
- -readability-convert-member-functions-to-static #
- -readability-use-concise-preprocessor-directives # We do not use #ifdef
- -readability-uppercase-literal-suffix # Not important enough
- -readability-redundant-string-cstr # Sometimes used to stop at first null byte
- -readability-static-accessed-through-instance #
- -readability-ambiguous-smartptr-reset-call # Fix is hard to read
# Will fix later
- -modernize-avoid-c-arrays
- -readability-make-member-function-const # idk + lots of occurences
- -readability-misleading-indentation # We need to handle cases with #if defined()
- -bugprone-unchecked-optional-access
- -performance-unnecessary-value-param # idk
- -readability-avoid-nested-conditional-operator
# Generated from CLion Inspection settings
---
Checks: '-*,
mpi-*,
bugprone-*,
-bugprone-signal-handler,
-bugprone-narrowing-conversions,
-bugprone-redundant-branch-condition,
-bugprone-exception-escape,
-bugprone-shared-ptr-array-mismatch,
-bugprone-implicit-widening-of-multiplication-result,
-bugprone-signed-char-misuse,
-bugprone-unhandled-exception-at-new,
-bugprone-infinite-loop,
-bugprone-easily-swappable-parameters,
cert-err52-cpp,
cert-err60-cpp,
cert-err34-c,
cert-str34-c,
cert-dcl21-cpp,
cert-msc50-cpp,
cert-msc51-cpp,
cert-dcl58-cpp,
cert-flp30-c,
cppcoreguidelines-avoid-const-or-ref-data-members,
cppcoreguidelines-pro-type-member-init,
cppcoreguidelines-slicing,
cppcoreguidelines-interfaces-global-init,
cppcoreguidelines-pro-type-static-cast-downcast,
cppcoreguidelines-narrowing-conversions,
google-default-arguments,
google-runtime-operator,
google-explicit-constructor,
hicpp-multiway-paths-covered,
hicpp-exception-baseclass,
misc-*,
-misc-definitions-in-headers,
-misc-unused-parameters,
-misc-unused-alias-decls,
-misc-use-anonymous-namespace,
-misc-misleading-identifier,
-misc-confusable-identifiers,
-misc-misleading-bidirectional,
-misc-static-assert,
-misc-no-recursion,
-misc-const-correctness,
modernize-*,
-modernize-use-trailing-return-type,
openmp-use-default-none,
performance-*,
-performance-no-int-to-ptr,
portability-*,
-portability-restrict-system-includes,
readability-*,
-readability-redundant-preprocessor,
-readability-named-parameter,
-readability-function-size,
-readability-use-anyofallof,
-readability-identifier-length,
-readability-magic-numbers,
-readability-braces-around-statements,
-readability-suspicious-call-argument,
-readability-isolate-declaration,
-readability-else-after-return,
-readability-redundant-access-specifiers,
-readability-function-cognitive-complexity,
-readability-identifier-naming,
*-include-cleaner,
-readability-qualified-auto'

View File

@@ -7,7 +7,6 @@ skip -rfu ^ImGui::
# Trigger breakpoint when execution reaches triggerSafeShutdown()
break triggerSafeShutdown
break __glibcxx_assert_fail
# Print backtrace after execution jumped to an invalid address
define fixbt

4
.github/FUNDING.yml vendored
View File

@@ -1,5 +1,5 @@
# Sponsor links
patreon: werwolv
custom: https://werwolv.net/donate
github: WerWolv
ko_fi: WerWolv
custom: "https://werwolv.net/donate"

View File

@@ -1,7 +0,0 @@
#!/bin/sh
set -xe
ARTIFACT_NAME="$1"
ARTIFACT_ID=$(gh api repos/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID/artifacts --jq ".artifacts[] | select(.name==\"$ARTIFACT_NAME\") | .id")
gh api -X DELETE repos/$GITHUB_REPOSITORY/actions/artifacts/$ARTIFACT_ID
echo "Deleted artifact $ARTIFACT_NAME with ID $ARTIFACT_ID"

View File

@@ -49,16 +49,15 @@ jobs:
set -x
mkdir -p build
cd build
CC=gcc-14 CXX=g++-14 cmake \
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
-DCMAKE_INSTALL_PREFIX="$PWD/install" \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_C_FLAGS="-fuse-ld=lld" \
-DCMAKE_CXX_FLAGS="-fuse-ld=lld" \
-DIMHEX_PATTERNS_PULL_MASTER=ON \
-DIMHEX_EXCLUDE_PLUGINS="script_loader" \
-G Ninja \
CC=gcc-14 CXX=g++-14 cmake \
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
-DCMAKE_INSTALL_PREFIX="$PWD/install" \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_C_FLAGS="-fuse-ld=lld" \
-DCMAKE_CXX_FLAGS="-fuse-ld=lld" \
-DIMHEX_PATTERNS_PULL_MASTER=ON \
-G Ninja \
..
ninja install

View File

@@ -1,9 +1,5 @@
name: Build
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
on:
push:
branches:
@@ -21,19 +17,8 @@ jobs:
# Windows MINGW build
win_mingw:
strategy:
fail-fast: false
matrix:
include:
- architecture_name: "x86_64"
msystem: "mingw64"
runner_os: "windows-2025"
- architecture_name: "arm64"
msystem: "clangarm64"
runner_os: "windows-11-arm"
runs-on: ${{ matrix.runner_os }}
name: 🪟 Windows MSYS2 ${{ matrix.architecture_name }}
runs-on: windows-2022
name: 🪟 Windows MINGW64
defaults:
run:
@@ -63,7 +48,7 @@ jobs:
- name: 🟦 Install msys2
uses: msys2/setup-msys2@v2
with:
msystem: ${{ matrix.msystem }}
msystem: mingw64
- name: ⬇️ Install dependencies
run: |
@@ -86,20 +71,18 @@ jobs:
mkdir -p build
cd build
cmake -G "Ninja" \
-DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \
-DCMAKE_INSTALL_PREFIX="$PWD/install" \
-DIMHEX_GENERATE_PACKAGE=ON \
-DIMHEX_USE_DEFAULT_BUILD_SETTINGS=ON \
-DIMHEX_PATTERNS_PULL_MASTER=ON \
-DIMHEX_COMMIT_HASH_LONG="${GITHUB_SHA}" \
-DIMHEX_COMMIT_BRANCH="${GITHUB_REF##*/}" \
-DUSE_SYSTEM_CAPSTONE=ON \
-DUSE_SYSTEM_MD4C=ON \
-DIMHEX_GENERATE_PDBS=ON \
-DIMHEX_REPLACE_DWARF_WITH_PDB=ON \
-DDOTNET_EXECUTABLE="C:/Program Files/dotnet/dotnet.exe" \
-DCPACK_WIX_ROOT="$(echo "$USERPROFILE" | tr '\\' '/')/.dotnet/tools" \
cmake -G "Ninja" \
-DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \
-DCMAKE_INSTALL_PREFIX="$PWD/install" \
-DIMHEX_GENERATE_PACKAGE=ON \
-DIMHEX_USE_DEFAULT_BUILD_SETTINGS=ON \
-DIMHEX_PATTERNS_PULL_MASTER=ON \
-DIMHEX_COMMIT_HASH_LONG="${GITHUB_SHA}" \
-DIMHEX_COMMIT_BRANCH="${GITHUB_REF##*/}" \
-DUSE_SYSTEM_CAPSTONE=ON \
-DIMHEX_GENERATE_PDBS=ON \
-DIMHEX_REPLACE_DWARF_WITH_PDB=ON \
-DDOTNET_EXECUTABLE="C:/Program Files/dotnet/dotnet.exe" \
..
- name: 🛠️ Build
@@ -107,11 +90,6 @@ jobs:
cd build
ninja install
- name: 🕯️ Install WiX Toolkit
run: |
"C:/Program Files/dotnet/dotnet.exe" tool install --global wix
"$(echo "$USERPROFILE" | tr '\\' '/')/.dotnet/tools/wix" extension add -g WixToolset.UI.wixext
- name: 🪲 Create PDBs for MSI
run: |
cd build
@@ -136,7 +114,7 @@ jobs:
run: |
cd build
cpack
mv ImHex-*.msi ../imhex-${{ env.IMHEX_VERSION }}-Windows-${{ matrix.architecture_name }}.msi
mv ImHex-*.msi ../imhex-${{ env.IMHEX_VERSION }}-Windows-x86_64.msi
echo "ImHex checks for the existence of this file to determine if it is running in portable mode. You should not delete this file" > $PWD/install/PORTABLE
@@ -169,10 +147,9 @@ jobs:
- name: ⬆️ Upload Windows Installer
uses: actions/upload-artifact@v4
id: upload-installer
with:
if-no-files-found: error
name: Windows Installer ${{ matrix.architecture_name }}
name: Windows Installer x86_64
path: |
imhex-*.msi
@@ -180,43 +157,30 @@ jobs:
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: Windows Portable ${{ matrix.architecture_name }}
name: Windows Portable x86_64
path: |
build/install/*
- name: ⬇️ Download Mesa3D for NoGPU version
if: ${{ matrix.architecture_name == 'x86_64' }}
shell: bash
run: |
set -x
echo "NoGPU version Powered by Mesa 3D : https://fdossena.com/?p=mesa%2Findex.frag" > build/install/MESA.md
curl --connect-timeout 30 --retry 5 --retry-delay 0 --retry-max-time 30 https://downloads.fdossena.com/geth.php?r=mesa64-latest -L -o mesa.7z
curl https://downloads.fdossena.com/geth.php?r=mesa64-latest -L -o mesa.7z
7z e mesa.7z
mv opengl32.dll build/install
- name: ⬆️ Upload NoGPU Portable ZIP
if: ${{ matrix.architecture_name == 'x86_64' }}
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: Windows Portable NoGPU ${{ matrix.architecture_name }}
name: Windows Portable NoGPU x86_64
path: |
build/install/*
win_msvc:
strategy:
fail-fast: false
matrix:
include:
- architecture_name: "x86_64"
vs_arch: "amd64"
runner_os: "windows-2025"
- architecture_name: "arm64"
vs_arch: "amd64_arm64"
runner_os: "windows-11-arm"
runs-on: ${{ matrix.runner_os }}
name: 🪟 Windows MSVC ${{ matrix.architecture_name }}
runs-on: windows-2022
name: 🪟 Windows MSVC
env:
CCACHE_DIR: "${{ github.workspace }}/.ccache"
@@ -234,19 +198,19 @@ jobs:
- name: 🫧 Setup Visual Studio Dev Environment
uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ matrix.vs_arch }}
arch: amd64
- name: 📜 Setup ccache
uses: hendrikmuhs/ccache-action@v1
id: cache-ccache
with:
key: ${{ runner.os }}-msvc-${{ matrix.vs_arch }}-ccache-${{ github.run_id }}
restore-keys: ${{ runner.os }}-msvc-${{ matrix.vs_arch }}-ccache
key: ${{ runner.os }}-msvc-ccache-${{ github.run_id }}
restore-keys: ${{ runner.os }}-msvc-ccache
max-size: 1G
- name: 📦 Install vcpkg
uses: friendlyanon/setup-vcpkg@v1
with: { committish: ef7dbf94b9198bc58f45951adcf1f041fcbc5ea0 }
with: { committish: 7e21420f775f72ae938bdeb5e6068f722088f06a }
- name: ⬇️ Install dependencies
run: |
@@ -272,51 +236,21 @@ jobs:
cmake -G "Ninja" -B build `
--preset vs2022 `
-DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake" `
-DCMAKE_C_COMPILER="$($(Get-Command cl.exe).Path)" `
-DCMAKE_CXX_COMPILER="$($(Get-Command cl.exe).Path)" `
-DCMAKE_C_COMPILER="$($(Get-Command cl.exe).Path)" `
-DCMAKE_CXX_COMPILER="$($(Get-Command cl.exe).Path)" `
-DCMAKE_C_COMPILER_LAUNCHER=ccache `
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache `
-DCMAKE_INSTALL_PREFIX="$(Join-Path $PWD 'install')" `
-DIMHEX_GENERATE_PACKAGE=ON `
-DCMAKE_BUILD_TYPE="$env:BUILD_TYPE" `
-DIMHEX_PATTERNS_PULL_MASTER=ON `
-DIMHEX_COMMIT_HASH_LONG="$env:GITHUB_SHA" `
-DIMHEX_COMMIT_BRANCH="$($env:GITHUB_REF -replace '.*/', '')" `
-DDOTNET_EXECUTABLE="C:/Program Files/dotnet/dotnet.exe" `
-DCPACK_WIX_ROOT="$($env:USERPROFILE -replace '\\','/')/.dotnet/tools" `
.
- name: 🛠️ Build
run: |
cd build
ninja install
- name: 🕯️ Install WiX Toolkit
run: |
& "C:/Program Files/dotnet/dotnet.exe" tool install --global wix
& "$($env:USERPROFILE -replace '\\','/')/.dotnet/tools/wix" extension add -g WixToolset.UI.wixext
- name: 📦 Bundle MSI
run: |
cd build
cpack
mv ImHex-*.msi ../imhex-${{ env.IMHEX_VERSION }}-Windows-MSVC-${{ matrix.architecture_name }}.msi
- name: 🗝️ Generate build provenance attestations
uses: actions/attest-build-provenance@v2
if: ${{ github.event.repository.fork == false && github.event_name != 'pull_request' }}
with:
subject-path: |
imhex-*.msi
- name: ⬆️ Upload Windows Installer
uses: actions/upload-artifact@v4
if: false # The MSVC builds should not really be used, they're still packaged for testings sake though
with:
if-no-files-found: error
name: Windows Installer MSVC ${{ matrix.architecture_name }}
path: |
imhex-*.msi
ninja
win-plugin-template-test:
runs-on: windows-2022
@@ -371,25 +305,28 @@ jobs:
-DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \
-DIMHEX_USE_DEFAULT_BUILD_SETTINGS=ON \
-DUSE_SYSTEM_CAPSTONE=ON \
-DUSE_SYSTEM_MD4C=ON \
..
ninja
- name: 🧪 Test if plugin can be loaded
run: |
export WORKSPACE=$(echo "${{ github.workspace }}" | tr '\\' '/')
${WORKSPACE}/out/imhex.exe --validate-plugin ${WORKSPACE}/template/build/example_plugin.hexplug
# MacOS build
macos-x86:
runs-on: macos-15-intel
runs-on: macos-13
permissions:
id-token: write
attestations: write
name: 🍎 macOS 10.15 x86_64
strategy:
fail-fast: false
matrix:
include:
- suffix: "-NoGPU"
custom_glfw: true
- suffix: ""
custom_glfw: false
name: 🍎 macOS 13${{ matrix.suffix }}
steps:
- name: 🧰 Checkout
@@ -404,40 +341,58 @@ jobs:
- name: 📜 Setup ccache
uses: hendrikmuhs/ccache-action@v1
with:
key: ${{ runner.os }}-ccache-${{ github.run_id }}
restore-keys: ${{ runner.os }}-ccache
key: ${{ runner.os }}${{ matrix.suffix }}-ccache-${{ github.run_id }}
restore-keys: ${{ runner.os }}${{ matrix.suffix }}-ccache
max-size: 1G
- name: Set Xcode version
run: |
sudo xcode-select --install || true
sudo xcode-select -s /Library/Developer/CommandLineTools
- name: 📦 Install MacPorts
run: |
wget https://github.com/macports/macports-base/releases/download/v2.11.6/MacPorts-2.11.6-15-Sequoia.pkg
sudo installer -pkg MacPorts-2.11.6-15-Sequoia.pkg -target /
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
echo "PATH=/opt/local/bin:/opt/local/sbin:$PATH" >> $GITHUB_ENV
echo "MACOSX_DEPLOYMENT_TARGET=10.15" >> $GITHUB_ENV
echo "universal_target 10.15" | sudo tee -a /opt/local/etc/macports/macports.conf
echo "macos_deployment_target 10.15" | sudo tee -a /opt/local/etc/macports/macports.conf
echo "macosx_sdk_version 10.15" | sudo tee -a /opt/local/etc/macports/macports.conf
sudo port selfupdate
- name: ⬇️ Install dependencies
env:
# Make brew not display useless errors
HOMEBREW_TESTS: 1
run: |
brew install llvm automake
sudo -E port install mbedtls3 nlohmann-json ccache freetype libmagic pkgconfig curl glfw ninja zlib xz bzip2 zstd libssh2 md4c
brew reinstall python --quiet || true
brew link --overwrite --quiet python 2>/dev/null || true
brew bundle --no-lock --quiet --file dist/macOS/Brewfile || true
rm -rf /usr/local/Cellar/capstone
- name: ⬇️ Install classic glfw
if: ${{! matrix.custom_glfw }}
run: |
brew install --quiet glfw || true
- name: ⬇️ Install .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.100'
- name: 🧰 Checkout glfw
if: ${{ matrix.custom_glfw }}
uses: actions/checkout@v4
with:
repository: glfw/glfw
path: glfw
# GLFW custom build (to allow software rendering)
- name: ⬇️ Patch and install custom glfw
if: ${{ matrix.custom_glfw }}
run: |
set -x
cd glfw
git apply ../dist/macOS/0001-glfw-SW.patch
mkdir build
cd build
cmake -G "Ninja" \
-DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_OBJC_COMPILER_LAUNCHER=ccache \
-DCMAKE_OBJCXX_COMPILER_LAUNCHER=ccache \
..
ninja install
# MacOS cmake build
- name: 🛠️ Configure CMake
run: |
@@ -448,8 +403,8 @@ jobs:
CXX=$(brew --prefix llvm)/bin/clang++ \
OBJC=$(brew --prefix llvm)/bin/clang \
OBJCXX=$(brew --prefix llvm)/bin/clang++ \
PKG_CONFIG_PATH="$(brew --prefix openssl)/lib/pkgconfig":"$(brew --prefix)/lib/pkgconfig" \
cmake -G "Ninja" \
-DCMAKE_OSX_DEPLOYMENT_TARGET=10.15 \
-DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \
-DIMHEX_GENERATE_PACKAGE=ON \
-DIMHEX_SYSTEM_LIBRARY_PATH="$(brew --prefix llvm)/lib;$(brew --prefix llvm)/lib/unwind;$(brew --prefix llvm)/lib/c++;$(brew --prefix)/lib" \
@@ -470,6 +425,7 @@ jobs:
run: |
set -x
cd build/install
mv imhex.app ImHex.app
codesign --remove-signature ImHex.app
codesign --force --deep --sign - ImHex.app
@@ -498,7 +454,7 @@ jobs:
break;
fi
done
mv *.dmg ../../imhex-${{ env.IMHEX_VERSION }}-macOS-x86_64.dmg
mv *.dmg ../../imhex-${{ env.IMHEX_VERSION }}-macOS${{ matrix.suffix }}-x86_64.dmg
- name: 🗝️ Generate build provenance attestations
uses: actions/attest-build-provenance@v2
@@ -511,12 +467,12 @@ jobs:
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: macOS DMG x86_64
name: macOS DMG${{ matrix.suffix }} x86_64
path: ./*.dmg
macos-arm64:
runs-on: ubuntu-24.04
name: 🍎 macOS 11 arm64
name: 🍎 macOS 13 arm64
outputs:
IMHEX_VERSION: ${{ steps.build.outputs.IMHEX_VERSION }}
@@ -531,8 +487,7 @@ jobs:
uses: actions/cache@v4
with:
path: cache
key: macos-arm64-cache-${{ github.run_id }}
restore-keys: macos-arm64-cache
key: build-macos-arm64-cache
- name: 🐳 Inject /cache into docker
uses: reproducible-containers/buildkit-cache-dance@v2
@@ -560,11 +515,11 @@ jobs:
GH_TOKEN: ${{ github.token }}
run: |
gh extension install actions/gh-actions-cache
gh cache delete "macos-arm64-cache" --confirm || true
gh actions-cache delete "build-macos-arm64-cache" --confirm || true
macos-arm64-package:
runs-on: macos-15-intel
name: 🍎 macOS 11 arm64 Packaging
runs-on: macos-13
name: 🍎 macOS 13 arm64 Packaging
needs: macos-arm64
env:
@@ -590,6 +545,7 @@ jobs:
run: |
set -x
cd out
mv imhex.app ImHex.app
codesign --remove-signature ImHex.app
codesign --force --deep --entitlements Entitlements.plist --sign - ImHex.app
@@ -618,7 +574,7 @@ jobs:
break;
fi
done
mv *.dmg ../imhex-${{ env.IMHEX_VERSION }}-macOS${{ matrix.file_suffix }}-arm64.dmg
mv *.dmg ../imhex-${{ env.IMHEX_VERSION }}-macOS${{ matrix.suffix }}-arm64.dmg
- name: 🗝️ Generate build provenance attestations
uses: actions/attest-build-provenance@v2
@@ -640,21 +596,14 @@ jobs:
fail-fast: false
matrix:
include:
- name: "Ubuntu"
release_num: "24.04"
image: "ubuntu:24.04"
- name: "Ubuntu"
release_num: "25.10"
image: "ubuntu:25.10"
- name: "Debian"
release_num: "13"
image: "debian:13"
- release_num: "24.04"
- release_num: "24.10"
name: 🐧 ${{ matrix.name }} ${{ matrix.release_num }} x86_64
name: 🐧 Ubuntu ${{ matrix.release_num }}
runs-on: ubuntu-24.04
container:
image: "${{ matrix.image }}"
image: "ubuntu:${{ matrix.release_num }}"
options: --privileged
permissions:
@@ -673,8 +622,8 @@ jobs:
- name: 📜 Setup ccache
uses: hendrikmuhs/ccache-action@v1
with:
key: ${{ matrix.image }}-ccache-${{ github.run_id }}
restore-keys: ${{ matrix.image }}-ccache
key: Ubuntu-${{ matrix.release_num }}-ccache-${{ github.run_id }}
restore-keys: Ubuntu-${{ matrix.release_num }}-ccache
max-size: 1G
- name: ⬇️ Install dependencies
@@ -719,7 +668,7 @@ jobs:
run: |
cp -r build/DEBIAN build/DebDir
dpkg-deb -Zzstd --build build/DebDir
mv build/DebDir.deb imhex-${{ env.IMHEX_VERSION }}-${{ matrix.name }}-${{ matrix.release_num }}-x86_64.deb
mv build/DebDir.deb imhex-${{ env.IMHEX_VERSION }}-Ubuntu-${{ matrix.release_num }}-x86_64.deb
- name: 🗝️ Generate build provenance attestations
uses: actions/attest-build-provenance@v2
@@ -732,7 +681,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: ${{ matrix.name }} ${{ matrix.release_num }} DEB x86_64
name: Ubuntu ${{ matrix.release_num }} DEB x86_64
path: '*.deb'
# AppImage build
@@ -807,7 +756,7 @@ jobs:
# ArchLinux build
archlinux-build:
name: 🐧 ArchLinux x86_64
name: 🐧 ArchLinux
runs-on: ubuntu-24.04
container:
@@ -862,7 +811,6 @@ jobs:
-DUSE_SYSTEM_YARA=ON \
-DUSE_SYSTEM_NLOHMANN_JSON=ON \
-DUSE_SYSTEM_CAPSTONE=OFF \
-DUSE_SYSTEM_MD4C=ON \
-DIMHEX_PATTERNS_PULL_MASTER=ON \
-DIMHEX_COMMIT_HASH_LONG="${GITHUB_SHA}" \
-DIMHEX_COMMIT_BRANCH="${GITHUB_REF##*/}" \
@@ -923,14 +871,27 @@ jobs:
matrix:
include:
- name: Fedora
release_num: 43
mock_config: fedora-43
mock_release: rawhide
release_num: rawhide
mock_config: fedora-rawhide
- name: Fedora
mock_release: f41
release_num: 41
mock_config: fedora-41
- name: Fedora
mock_release: f40
release_num: 40
mock_config: fedora-40
- name: RHEL-AlmaLinux
mock_release: epel9
release_num: 9
mock_config: "alma+epel-9"
name: 🐧 ${{ matrix.name }} ${{ matrix.release_num }} x86_64
name: 🐧 ${{ matrix.name }} ${{ matrix.release_num }}
runs-on: ubuntu-24.04
container:
image: "almalinux:10"
image: "almalinux:9"
options: --privileged --pid=host --security-opt apparmor=unconfined
permissions:
@@ -939,10 +900,10 @@ jobs:
steps:
# This, together with the `--pid=host --security-opt apparmor=unconfined` docker options is required to allow
# mock to work inside a Docker container running on Ubuntu again.
# fedpkg to work inside a Docker container running on Ubuntu again.
# GitHub seems to have enabled AppArmor on their Ubuntu CI runners which limits Docker in ways that cause
# programs inside it to fail.
# Without this, mock will throw the unhelpful error message 'Insufficient Rights'
# Without this, fedpkg will throw the unhelpful error message 'Insufficient Rights'
# This step uses nsenter to execute commands on the host that disable AppArmor entirely.
- name: 🛡️ Disable AppArmor on Host
run: |
@@ -961,19 +922,19 @@ jobs:
submodules: recursive
- name: 📜 Setup DNF Cache
if: false # Disabled for now since it fills up the cache very quickly
uses: actions/cache@v4
with:
path: /var/cache/dnf
key: dnf-ccache-${{ matrix.mock_config }}-${{ github.run_id }}
restore-keys: dnf-ccache-${{ matrix.mock_config }}
key: ${{ matrix.mock_release }}-dnf-${{ github.run_id }}
restore-keys: |
${{ matrix.mock_release }}-dnf-
- name: ⬇️ Update all packages and install dependencies
run: |
set -x
dnf upgrade -y
dnf install -y \
mock \
fedpkg \
ccache
- name: ⬇️ Install .NET
@@ -984,8 +945,8 @@ jobs:
- name: 📜 Setup ccache
uses: hendrikmuhs/ccache-action@v1
with:
key: ${{ matrix.mock_config }}-rpm-${{ github.run_id }}
restore-keys: ${{ matrix.mock_config }}-rpm
key: ${{ matrix.mock_release }}-rpm-${{ github.run_id }}
restore-keys: ${{ matrix.mock_release }}-rpm
max-size: 1G
- name: 📜 Set version variable
@@ -1002,33 +963,34 @@ jobs:
-e 's/IMHEX_OFFLINE_BUILD=ON/IMHEX_OFFLINE_BUILD=OFF/g' \
-e '/IMHEX_OFFLINE_BUILD=OFF/a -D IMHEX_PATTERNS_PULL_MASTER=ON \\' \
-e '/BuildRequires: cmake/a BuildRequires: git-core' \
-e '/%files/a %{_datadir}/imhex/' \
-e '/%files/a %{_datadir}/%{name}/' \
$GITHUB_WORKSPACE/ImHex/dist/rpm/imhex.spec
- name: 📜 Fix ccache on EL9
if: matrix.mock_config == 'alma+epel-9'
if: matrix.mock_release == 'epel9'
run: sed -i '/\. \/opt\/rh\/gcc-toolset-14\/enable/a PATH=/usr/lib64/ccache:$PATH' $GITHUB_WORKSPACE/ImHex/dist/rpm/imhex.spec
- name: 🟩 Copy spec file to build root
run: mv $GITHUB_WORKSPACE/ImHex/dist/rpm/imhex.spec $GITHUB_WORKSPACE/imhex.spec
- name: 📜 Enable ccache for mock
run: |
cat <<EOT > $GITHUB_WORKSPACE/mock.cfg
include('${{ matrix.mock_config }}-x86_64.cfg')
config_opts['plugin_conf']['ccache_enable'] = True
config_opts['plugin_conf']['ccache_opts']['max_cache_size'] = '1G'
config_opts['plugin_conf']['ccache_opts']['compress'] = True
config_opts['plugin_conf']['ccache_opts']['dir'] = "$GITHUB_WORKSPACE/.ccache"
EOT
# Fedora cmake build (in imhex.spec)
- name: 📦 Build RPM
run: |
mock -r ${{ matrix.mock_config }}-x86_64 \
--define 'debug_package %{nil}' \
--enable-network -N -v \
--enable-plugin=ccache \
--plugin-option=ccache:compress=True \
--plugin-option=ccache:max_cache_size=200M \
--plugin-option=ccache:dir=$GITHUB_WORKSPACE/.ccache \
--spec $GITHUB_WORKSPACE/imhex.spec \
--sources $GITHUB_WORKSPACE \
--resultdir $GITHUB_WORKSPACE/results
fedpkg --path $GITHUB_WORKSPACE --release ${{ matrix.mock_release }} mockbuild --enable-network -N --root $GITHUB_WORKSPACE/mock.cfg extra_args -- -v
- name: 🟩 Move and rename finished RPM
run: |
mv $GITHUB_WORKSPACE/results/imhex-${{ env.IMHEX_VERSION }}-0.*.x86_64.rpm \
mv $GITHUB_WORKSPACE/results_imhex/${{ env.IMHEX_VERSION }}/*/imhex-${{ env.IMHEX_VERSION }}-0.*.x86_64.rpm \
$GITHUB_WORKSPACE/imhex-${{ env.IMHEX_VERSION }}-${{ matrix.name }}-${{ matrix.release_num }}-x86_64.rpm
- name: 🗝️ Generate build provenance attestations
@@ -1046,149 +1008,13 @@ jobs:
path: |
imhex-${{ env.IMHEX_VERSION }}-${{ matrix.name }}-${{ matrix.release_num }}-x86_64.rpm
snap-build:
strategy:
fail-fast: false
matrix:
include:
- architecture: "x86_64"
image: ubuntu-24.04
- architecture: "arm64"
image: ubuntu-24.04-arm
name: 🐧 Snap ${{ matrix.architecture }}
runs-on: ${{ matrix.image }}
permissions:
id-token: write
attestations: write
steps:
- name: ⬇️ Install setup dependencies
run: |
sudo apt update && sudo apt install -y git curl snapd ccache
for i in $(seq 1 5); do
if sudo snap install snapcraft --classic; then
break;
fi
echo "Retrying snap install..."
sleep 10
done
- name: 🧰 Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: 📜 Set version variable
run: |
export IMHEX_VERSION=$(cat VERSION)
echo "IMHEX_VERSION=$IMHEX_VERSION" >> $GITHUB_ENV
if [[ "$IMHEX_VERSION" == *.WIP ]]; then
echo "IMHEX_VERSION_STRING=$IMHEX_VERSION-${GITHUB_RUN_NUMBER}" >> $GITHUB_ENV
else
echo "IMHEX_VERSION_STRING=$IMHEX_VERSION" >> $GITHUB_ENV
fi
echo "CCACHE=ccache" >> $GITHUB_ENV
- name: 📜 Move snap directory to root
run: |
mkdir -p ./snap
envsubst '${IMHEX_VERSION_STRING},${CCACHE}' < ./dist/snap/snapcraft.yaml > ./snap/snapcraft.yaml
- name: 📜 Setup ccache
uses: hendrikmuhs/ccache-action@v1
with:
key: ${{ matrix.architecture }}-snap-${{ github.run_id }}
restore-keys: ${{ matrix.architecture }}-snap
max-size: 1G
- name: 🛠️ Build
run: |
sudo snapcraft --destructive-mode
- name: 🟩 Rename Snap
run: |
mv *.snap imhex-${{ env.IMHEX_VERSION }}-${{ matrix.architecture }}.snap
- name: 🗝️ Generate build provenance attestations
uses: actions/attest-build-provenance@v2
if: ${{ github.event.repository.fork == false && github.event_name != 'pull_request' }}
with:
subject-path: |
*.snap
- name: ⬆️ Upload Snap
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: Snap ${{ matrix.architecture }}
path: |
*.snap
flatpak-build:
strategy:
fail-fast: false
matrix:
include:
- architecture: "x86_64"
flatpak_arch: "x86_64"
image: ubuntu-24.04
- architecture: "arm64"
flatpak_arch: "aarch64"
image: ubuntu-24.04-arm
name: 🐧 Flatpak ${{ matrix.architecture }}
runs-on: ${{ matrix.image }}
permissions:
id-token: write
attestations: write
steps:
- name: ⬇️ Install setup dependencies
run: |
sudo apt update && sudo apt install -y git curl flatpak-builder
sudo flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
sudo flatpak remote-modify --enable flathub
sudo flatpak install --noninteractive --system flathub org.freedesktop.Platform//24.08 org.freedesktop.Sdk//24.08
- name: 🧰 Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: 📜 Set version variable
run: |
echo "IMHEX_VERSION=`cat VERSION`" >> $GITHUB_ENV
- name: 🛠️ Build
uses: flatpak/flatpak-github-actions/flatpak-builder@v6
with:
bundle: imhex-${{ env.IMHEX_VERSION }}-${{ matrix.architecture }}.flatpak
manifest-path: dist/flatpak/net.werwolv.ImHex.yaml
cache-key: flatpak-builder-${{ matrix.architecture }}
arch: ${{ matrix.flatpak_arch }}
upload-artifact: false
- name: 🗝️ Generate build provenance attestations
uses: actions/attest-build-provenance@v2
if: ${{ github.event.repository.fork == false && github.event_name != 'pull_request' }}
with:
subject-path: |
imhex-${{ env.IMHEX_VERSION }}-${{ matrix.architecture }}.flatpak
- name: ⬆️ Upload Flatpak
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: Flatpak ${{ matrix.architecture }}
path: |
imhex-${{ env.IMHEX_VERSION }}-${{ matrix.architecture }}.flatpak
webassembly-build:
runs-on: ubuntu-24.04
name: 🌍 Web
permissions:
pages: write
id-token: write
actions: write
steps:
- name: 🧰 Checkout
uses: actions/checkout@v4
@@ -1199,8 +1025,7 @@ jobs:
uses: actions/cache@v4
with:
path: cache
key: webassembly-ccache-${{ github.run_id }}
restore-keys: webassembly-ccache
key: web-cache-${{ hashFiles('**/CMakeLists.txt') }}
- name: 🐳 Inject /cache into docker
uses: reproducible-containers/buildkit-cache-dance@v2
@@ -1208,25 +1033,12 @@ jobs:
cache-source: cache
cache-target: /cache
- name: 🔨 Copy necessary files
run: |
mkdir -p out/nightly
cp dist/web/serve.py out/nightly/start_imhex_web.py
- name: 🛠️ Build using docker
run: |
docker buildx build . -f dist/web/Dockerfile --progress=plain --build-arg 'JOBS=4' --output out/nightly --target raw
- name: ⬇️ Download Release artifact
if: ${{ github.event.repository.fork == false }}
env:
GH_TOKEN: ${{ github.token }}
run: gh --repo $GITHUB_REPOSITORY release download --pattern "imhex-*-Web.zip"
docker buildx build . -f dist/web/Dockerfile --progress=plain --build-arg 'JOBS=4' --output out --target raw
- name: 🔨 Fix permissions
if: ${{ github.event.repository.fork == false }}
run: |
unzip imhex-*-Web.zip -d out
chmod -c -R +rX "out/"
- name: ⬆️ Upload artifacts
@@ -1234,12 +1046,16 @@ jobs:
with:
path: out/
- name: 🔨 Copy necessary files
run: |
cp dist/web/serve.py out/start_imhex_web.py
- name: ⬆️ Upload package
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: ImHex Web
path: out/nightly/*
path: out/*
# See https://github.com/actions/cache/issues/342#issuecomment-1711054115
- name: 🗑️ Delete old cache
@@ -1252,7 +1068,7 @@ jobs:
webassembly-deploy:
environment:
name: ImHex Web
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
permissions:
pages: write
@@ -1265,64 +1081,11 @@ jobs:
needs: webassembly-build
steps:
- name: 🧰 Checkout
uses: actions/checkout@v4
- name: 🌍 Deploy WebAssembly Build to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
- name: 🗑️ Delete artifact
env:
GH_TOKEN: ${{ github.token }}
run: |
.github/scripts/delete-artifact.sh "github-pages"
webassembly-docker-image-deploy:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
needs: webassembly-build
name: 🐋 Deploy to ghcr.io
permissions:
contents: read
packages: write
steps:
- name: 🧰 Checkout
uses: actions/checkout@v4
- name: ⬇️ Download artifact
uses: actions/download-artifact@v4
uses: geekyeggo/delete-artifact@v5
with:
name: ImHex Web
path: out
- name: 📜 Login to ghcr.io
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: ⛓️ Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}/imhex-web
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha
- name: 🔨 Build and push Docker image
uses: docker/build-push-action@v6
env:
DOCKER_BUILD_RECORD_UPLOAD: false
with:
context: .
file: dist/web/Host.Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
name: github-pages

View File

@@ -1,47 +0,0 @@
# https://gist.github.com/iTrooz/d5bacca32c0974edc6c1ac3ad3ee82f3
# See https://github.com/cli/cli/issues/9125
# Extract archive with `tar -xf cache.tzst --transform 's@\.\./@#@g' -P` to avoid ../ errors
name: Download cache key
on:
workflow_dispatch:
inputs:
cache_key:
description: 'Cache key'
required: true
type: string
jobs:
cache-download:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Query cache version
id: version
env:
GH_TOKEN: ${{ github.token }}
run: |
VERSION=$(gh api repos/$GITHUB_REPOSITORY/actions/caches \
--jq "
.actions_caches[]
| select(.ref == \"refs/heads/$GITHUB_REF_NAME\")
| select(.key == \"${{ github.event.inputs.cache_key }}\")
| .version
")
echo "version=$VERSION" | tee $GITHUB_OUTPUT
- name: Restore cache
uses: iTrooz/cache/restore@restore_with_version
with:
# Path won't be actually used, we will match by 'version'.
path: .
key: ${{ github.event.inputs.cache_key }}
version: ${{ steps.version.outputs.version }}
- name: Upload cached folder as artifact
uses: actions/upload-artifact@v4
with:
name: cache-artifact
path: |
/home/runner/work/**/*.tzst

View File

@@ -1,144 +0,0 @@
permissions:
contents: write
name: Nightly Release
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
jobs:
nightly-release:
runs-on: ubuntu-24.04
name: 🌃 Update Nightly Release
steps:
- name: 🧰 Checkout
uses: actions/checkout@v4
with:
path: ImHex
fetch-depth: 0
fetch-tags: true
- name: 🌃 Check for new commits
id: check_commits
run: |
cd ImHex
git config --global --add safe.directory $(pwd)
if [ -z "$(git log nightly..HEAD --oneline)" ]; then
echo "No new commits since last nightly. Exiting."
echo "::set-output name=should_run::false"
else
echo "::set-output name=should_run::true"
fi
- name: 📜 Set version variable
if: ${{ steps.check_commits.outputs.should_run == 'true' }}
run: |
project_version=`cat ImHex/VERSION`
echo "IMHEX_VERSION=$project_version" >> $GITHUB_ENV
# TODO: Replace by Github CLI when github.com/cli/cli/pull/12435 is closed
- name: ⬇️ Download artifacts from latest workflow
uses: dawidd6/action-download-artifact@v6
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
workflow: build.yml
branch: master
workflow_conclusion: success
skip_unpack: true
- name: 🗜️ Unzip files when needed
if: ${{ steps.check_commits.outputs.should_run == 'true' }}
run: |
set -x
for zipfile in ./*.zip
do
if [ `zipinfo -1 "$zipfile" | wc -l` -eq 1 ];
then
echo "unzipping $zipfile"
unzip "$zipfile"
rm "$zipfile"
else
echo "keeping $zipfile zipped"
fi
done
- name: 🟩 Rename artifacts when needed
if: ${{ steps.check_commits.outputs.should_run == 'true' }}
run: |
mv "Windows Portable x86_64.zip" imhex-${{ env.IMHEX_VERSION }}-Windows-Portable-x86_64.zip
mv "Windows Portable arm64.zip" imhex-${{ env.IMHEX_VERSION }}-Windows-Portable-arm64.zip
mv "Windows Portable NoGPU x86_64.zip" imhex-${{ env.IMHEX_VERSION }}-Windows-Portable-NoGPU-x86_64.zip
mv "ImHex Web.zip" imhex-${{ env.IMHEX_VERSION }}-Web.zip
rm artifact.tar || true
- name: 📖 Generate Release Notes
if: ${{ steps.check_commits.outputs.should_run == 'true' }}
id: release_notes
continue-on-error: true
run: |
cd ImHex
echo "## Nightly ${GITHUB_SHA::7} Changelog" > changelog.md
git fetch --tags --recurse-submodules=no
git log nightly..origin/master --oneline --no-merges --pretty=format:'* %s' >> changelog.md
- name: 📦 Update Pre-Release
if: ${{ steps.check_commits.outputs.should_run == 'true' }}
run: |
set -e
cd ImHex
# Move nightly tag to latest commit
git tag -f nightly origin/master
git push origin nightly --force
# Auth for GitHub CLI
echo "${{ github.token }}" | gh auth login --with-token
# Delete existing assets
for asset in $(gh release view nightly --json assets --jq '.assets[].name'); do
gh release delete-asset nightly "$asset" --yes
done
# Update release notes
gh release edit nightly --notes-file changelog.md
# Upload new assets
gh release upload nightly ../*.* --clobber
- name: ⬆️ Publish x86_64 Snap package
if: ${{ steps.check_commits.outputs.should_run == 'true' }}
continue-on-error: true
uses: snapcore/action-publish@v1
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAP_STORE_LOGIN }}
with:
snap: imhex-${{ env.IMHEX_VERSION }}-x86_64.snap
release: edge
- name: ⬆️ Publish arm64 Snap package
if: ${{ steps.check_commits.outputs.should_run == 'true' }}
continue-on-error: true
uses: snapcore/action-publish@v1
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAP_STORE_LOGIN }}
with:
snap: imhex-${{ env.IMHEX_VERSION }}-arm64.snap
release: edge
website_update:
name: 🌍 Update ImHex Landing Website
needs: nightly-release
runs-on: ubuntu-24.04
env:
WEBSITE_DISPATCH_TOKEN: ${{ secrets.WEBSITE_DISPATCH_TOKEN }}
steps:
- name: ✉️ Dispatch Landing page update
if: ${{ env.WEBSITE_DISPATCH_TOKEN != '' }}
uses: peter-evans/repository-dispatch@v4
with:
token: ${{ secrets.WEBSITE_DISPATCH_TOKEN }}
repository: WerWolv/ImHexWebsite
event-type: update_page

View File

@@ -7,12 +7,6 @@ on:
release:
types: [published]
workflow_dispatch:
inputs:
commit_hash:
type: string
description: 'The commit hash to build (defaults to the latest commit on the default branch)'
required: false
default: ''
jobs:
release-update-repos:
@@ -31,7 +25,7 @@ jobs:
project_version=`cat ImHex/VERSION`
tag_version="${{github.event.release.tag_name}}"
tag_version="${tag_version:1}"
if [ "$project_version" != "$tag_version" ] && [ ! -z "$tag_version" ]; then
if [ "$project_version" != "$tag_version" ]; then
echo "::warning::$project_version and $tag_version are not the same ! Refusing to populate release"
exit 1
fi
@@ -47,7 +41,6 @@ jobs:
tag: ImHex-v${{ env.IMHEX_VERSION }}
repo: PatternLanguage
token: ${{ secrets.RELEASE_TOKEN }}
skipIfReleaseExists: true
- name: 🎫 Create ImHex-Patterns release
uses: ncipollo/release-action@v1
@@ -58,7 +51,6 @@ jobs:
tag: ImHex-v${{ env.IMHEX_VERSION }}
repo: ImHex-Patterns
token: ${{ secrets.RELEASE_TOKEN }}
skipIfReleaseExists: true
- name: 🎫 Create imhex-download-sdk release
uses: ncipollo/release-action@v1
@@ -69,13 +61,11 @@ jobs:
tag: v${{ env.IMHEX_VERSION }}
repo: imhex-download-sdk
token: ${{ secrets.RELEASE_TOKEN }}
skipIfReleaseExists: true
release-upload-artifacts:
runs-on: ubuntu-24.04
name: Release Upload Artifacts
outputs:
IMHEX_VERSION: ${{ steps.verify_version.outputs.IMHEX_VERSION }}
steps:
- name: 🧰 Checkout
uses: actions/checkout@v4
@@ -84,19 +74,17 @@ jobs:
submodules: recursive
- name: 📜 Verify version and set version variable
id: verify_version
run: |
set -x
project_version=`cat ImHex/VERSION`
tag_version="${{github.event.release.tag_name}}"
tag_version="${tag_version:1}"
if [ "$project_version" != "$tag_version" ] && [ ! -z "$tag_version" ]; then
if [ "$project_version" != "$tag_version" ]; then
echo "::warning::$project_version and $tag_version are not the same ! Refusing to populate release"
exit 1
fi
echo "IMHEX_VERSION=$project_version" >> $GITHUB_ENV
echo "IMHEX_VERSION=$project_version" >> $GITHUB_OUTPUT
- name: 🗜️ Create tarball from sources with dependencies
run: tar --exclude-vcs -czvf Full.Sources.tar.gz ImHex
@@ -104,12 +92,11 @@ jobs:
- name: ⬇️ Download artifacts from latest workflow
uses: dawidd6/action-download-artifact@v6
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
github_token: ${{secrets.GITHUB_TOKEN}}
workflow: build.yml
branch: ${{ github.event.release.target_commitish }}
workflow_conclusion: success
skip_unpack: true
commit: ${{ github.event.inputs.commit_hash }}
- name: 🗜️ Unzip files when needed
run: |
@@ -128,87 +115,23 @@ jobs:
- name: 🟩 Rename artifacts when needed
run: |
mv "Windows Portable x86_64.zip" imhex-${{ env.IMHEX_VERSION }}-Windows-Portable-x86_64.zip || true
mv "Windows Portable arm64.zip" imhex-${{ env.IMHEX_VERSION }}-Windows-Portable-arm64.zip || true
mv "Windows Portable NoGPU x86_64.zip" imhex-${{ env.IMHEX_VERSION }}-Windows-Portable-NoGPU-x86_64.zip || true
mv "ImHex Web.zip" imhex-${{ env.IMHEX_VERSION }}-Web.zip || true
rm artifact.tar || true
- name: ⬆️ Upload Unsigned x86_64 Windows Installer
uses: actions/upload-artifact@v4
id: upload-installer-x86_64
with:
if-no-files-found: error
name: Windows Installer x86_64
path: |
imhex-*-x86_64.msi
- name: ⬆️ Upload Unsigned ARM64 Windows Installer
if: false
uses: actions/upload-artifact@v4
id: upload-installer-arm64
with:
if-no-files-found: error
name: Windows Installer ARM64
path: |
imhex-*-arm64.msi
- name: 🗑️ Delete unsigned installers
run: |
rm imhex-*-x86_64.msi
- name: 🗝️ Sign x86_64 Installer
uses: signpath/github-action-submit-signing-request@v1
with:
api-token: '${{ secrets.SIGNPATH_API_TOKEN }}'
organization-id: 'f605a0e8-86cd-411c-bb6f-e05025afcc33'
project-slug: 'ImHex'
signing-policy-slug: 'release-signing'
github-artifact-id: '${{ steps.upload-installer-x86_64.outputs.artifact-id }}'
wait-for-completion: true
output-artifact-directory: '.'
- name: 🗝️ Sign ARM64 Installer
if: false
uses: signpath/github-action-submit-signing-request@v1
with:
api-token: '${{ secrets.SIGNPATH_API_TOKEN }}'
organization-id: 'f605a0e8-86cd-411c-bb6f-e05025afcc33'
project-slug: 'ImHex'
signing-policy-slug: 'release-signing'
github-artifact-id: '${{ steps.upload-installer-arm64.outputs.artifact-id }}'
wait-for-completion: true
output-artifact-directory: '.'
mv "Windows Portable x86_64.zip" imhex-${{ env.IMHEX_VERSION }}-Windows-Portable-x86_64.zip
mv "Windows Portable NoGPU x86_64.zip" imhex-${{ env.IMHEX_VERSION }}-Windows-Portable-NoGPU-x86_64.zip
mv "ImHex Web.zip" imhex-${{ env.IMHEX_VERSION }}-web.zip
- name: ⬆️ Upload everything to release
uses: softprops/action-gh-release@4634c16e79c963813287e889244c50009e7f0981
with:
files: '*'
release-update-aur:
name: Release update AUR package
needs: release-upload-artifacts
runs-on: ubuntu-24.04
steps:
- name: 🧰 Checkout
uses: actions/checkout@v4
with:
path: ImHex
- name: ⬇️ Download artifacts
run: |
tagname=${GITHUB_REF#refs/tags/}
version=${tagname#v}
wget https://github.com/WerWolv/ImHex/releases/download/${tagname}/imhex-${version}-ArchLinux-x86_64.pkg.tar.zst
- name: ✒️ Prepare PKGBUILD
run: |
set -x
cp ImHex/dist/Arch/PKGBUILD .
hash=`md5sum imhex-${{ needs.release-upload-artifacts.outputs.IMHEX_VERSION }}-ArchLinux-x86_64.pkg.tar.zst | cut -d ' ' -f 1`
hash=`md5sum imhex-${{ env.IMHEX_VERSION }}-ArchLinux-x86_64.pkg.tar.zst | cut -d ' ' -f 1`
sed -i 's/%version%/${{ needs.release-upload-artifacts.outputs.IMHEX_VERSION }}/g' PKGBUILD
sed -i 's/%version%/${{ env.IMHEX_VERSION }}/g' PKGBUILD
sed -i "s/(SKIP)/($hash)/g" PKGBUILD
- name: ⬆️ Publish AUR package
@@ -222,9 +145,9 @@ jobs:
pkgname: imhex-bin
pkgbuild: ./PKGBUILD
commit_username: iTrooz
commit_email: hey@itrooz.fr
commit_email: itrooz@protonmail.com
ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
commit_message: Bump to version ${{ needs.release-upload-artifacts.outputs.IMHEX_VERSION }}
commit_message: Bump to version ${{ env.IMHEX_VERSION }}
ssh_keyscan_types: rsa,ecdsa,ed25519
release-update-winget:
@@ -236,7 +159,6 @@ jobs:
shell: pwsh
run: |
iwr https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe
- name: ⬆️ Update winget manifest
shell: pwsh
env:
@@ -250,33 +172,3 @@ jobs:
if ($version -notmatch "-") {
.\wingetcreate.exe submit .\manifests\w\WerWolv\ImHex\${version}\ --token $env:WINGET_GITHUB_TOKEN
}
release-update-snapstore:
name: Release update snapstore package
needs: release-upload-artifacts
runs-on: ubuntu-24.04
steps:
- name: ⬇️ Download artifacts
run: |
tagname=${GITHUB_REF#refs/tags/}
version=${tagname#v}
wget https://github.com/WerWolv/ImHex/releases/download/${tagname}/imhex-${version}-x86_64.snap
wget https://github.com/WerWolv/ImHex/releases/download/${tagname}/imhex-${version}-arm64.snap
- name: ⬆️ Publish x86_64 Snap package
continue-on-error: true
uses: snapcore/action-publish@v1
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAP_STORE_LOGIN }}
with:
snap: imhex-${{ needs.release-upload-artifacts.outputs.IMHEX_VERSION }}-x86_64.snap
release: stable
- name: ⬆️ Publish arm64 Snap package
continue-on-error: true
uses: snapcore/action-publish@v1
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAP_STORE_LOGIN }}
with:
snap: imhex-${{ needs.release-upload-artifacts.outputs.IMHEX_VERSION }}-arm64.snap
release: stable

View File

@@ -6,7 +6,6 @@ on:
jobs:
close-issues:
if: false # Disabled for now until I actually have time to take care of all these issues
runs-on: ubuntu-24.04
permissions:
issues: write

23
.gitignore vendored
View File

@@ -1,18 +1,12 @@
/.vscode/
/.idea/
/.kdev4/
/.vs/
.venv/
.vscode/
.idea/
.kdev4/
/cmake-build-*/
/build*/
/local/
/venv/
/.cache/
/install/
/out/
/dist/ImHex.run.xml
cmake-build-*/
build*/
local/
venv/
.cache/
*.mgc
*.kdev4
@@ -21,4 +15,5 @@ imgui.ini
CMakeUserPresets.json
Brewfile.lock.json
.vs/
vcpkg.json

7
.gitmodules vendored
View File

@@ -18,6 +18,10 @@
path = lib/third_party/capstone
url = https://github.com/capstone-engine/capstone
ignore = dirty
[submodule "lib/third_party/jthread/jthread"]
path = lib/third_party/jthread/jthread
url = https://github.com/josuttis/jthread
ignore = dirty
[submodule "lib/third_party/edlib"]
path = lib/third_party/edlib
url = https://github.com/Martinsos/edlib
@@ -43,6 +47,3 @@
[submodule "lib/external/disassembler"]
path = lib/external/disassembler
url = https://github.com/WerWolv/Disassembler
[submodule "lib/third_party/md4c"]
path = lib/third_party/md4c
url = https://github.com/mity/md4c

View File

@@ -1,39 +1,27 @@
cmake_minimum_required(VERSION 3.25)
cmake_minimum_required(VERSION 3.20)
# Options
## General
option(IMHEX_PLUGINS_IN_SHARE "Put the plugins in share/imhex/plugins instead of lib[..]/imhex/plugins (Linux only)" OFF)
option(IMHEX_STRIP_RELEASE "Strip the release builds" ON )
option(IMHEX_OFFLINE_BUILD "Enable offline build" OFF)
option(IMHEX_IGNORE_BAD_CLONE "Disable the bad clone prevention checks" OFF)
option(IMHEX_PATTERNS_PULL_MASTER "Download latest files from master branch of the ImHex-Patterns repo" OFF)
option(IMHEX_IGNORE_BAD_COMPILER "Allow compiling with an unsupported compiler" OFF)
option(IMHEX_USE_GTK_FILE_PICKER "Use GTK file picker instead of xdg-desktop-portals (Linux only)" OFF)
option(IMHEX_DISABLE_STACKTRACE "Disables support for printing stack traces" OFF)
option(IMHEX_BUNDLE_DOTNET "Bundle .NET runtime" ON )
option(IMHEX_ENABLE_LTO "Enables Link Time Optimizations if possible" OFF)
option(IMHEX_USE_DEFAULT_BUILD_SETTINGS "Use default build settings" OFF)
option(IMHEX_BUILD_HARDENING "Enable hardening flags for build" ON )
option(IMHEX_GENERATE_PACKAGE "Specify if a cpack package should be built. (Windows only)" OFF)
option(IMHEX_MACOS_CREATE_BUNDLE "Creates a macOS .app bundle when building (macOS only)" ON )
option(IMHEX_STRICT_WARNINGS "Enable most available warnings and treat them as errors" ON )
option(IMHEX_STATIC_LINK_PLUGINS "Statically link all plugins into the main executable" OFF)
option(IMHEX_GENERATE_PACKAGE "Specify if a native package should be built. (Windows and MacOS only)" OFF)
option(IMHEX_ENABLE_UNITY_BUILD "Enables building ImHex as a unity build." OFF)
option(IMHEX_ENABLE_PRECOMPILED_HEADERS "Enable precompiled headers" OFF)
option(IMHEX_ENABLE_CXX_MODULES "Enable C++20 Module compilation. Testing only!" OFF)
option(IMHEX_ENABLE_CPPCHECK "Enable cppcheck static analysis" OFF)
option(IMHEX_BUNDLE_PLUGIN_SDK "Enable bundling of Plugin SDK into install package" ON )
## Testing
option(IMHEX_ENABLE_UNIT_TESTS "Enable building unit tests" ON )
option(IMHEX_ENABLE_IMGUI_TEST_ENGINE "Enable the ImGui Test Engine" OFF)
option(IMHEX_ENABLE_STD_ASSERTS "Enable debug asserts in the C++ std library. (Breaks Plugin ABI!)" OFF)
## Debug info
option(IMHEX_COMPRESS_DEBUG_INFO "Compress debug information" ON )
option(IMHEX_GENERATE_PDBS "Enable generating PDB files in non-debug builds (Windows only)" OFF)
option(IMHEX_REPLACE_DWARF_WITH_PDB "Remove DWARF information from binaries when generating PDBS (Windows only)" OFF)
option(IMHEX_STRICT_WARNINGS "Enable most available warnings and treat them as errors" ON )
option(IMHEX_DISABLE_STACKTRACE "Disables support for printing stack traces" OFF)
## Plugins
option(IMHEX_STATIC_LINK_PLUGINS "Statically link all plugins into the main executable" OFF)
option(IMHEX_ENABLE_PLUGIN_TESTS "Enable building plugin tests" ON )
option(IMHEX_INCLUDE_PLUGINS "Semicolon-separated list of plugins to include in the build (empty = build all)" "" )
option(IMHEX_EXCLUDE_PLUGINS "Semicolon-separated list of plugins to exclude from the build" "" )
option(IMHEX_ENABLE_STD_ASSERTS "Enable debug asserts in the C++ std library. (Breaks Plugin ABI!)" OFF)
option(IMHEX_ENABLE_UNIT_TESTS "Enable building unit tests" OFF)
option(IMHEX_ENABLE_PRECOMPILED_HEADERS "Enable precompiled headers" OFF)
option(IMHEX_COMPRESS_DEBUG_INFO "Compress debug information" ON )
set(IMHEX_BASE_FOLDER "${CMAKE_CURRENT_SOURCE_DIR}")
set(CMAKE_MODULE_PATH "${IMHEX_BASE_FOLDER}/cmake/modules")
@@ -43,7 +31,6 @@ include("${IMHEX_BASE_FOLDER}/cmake/ide_helpers.cmake")
# Basic compiler and cmake configurations
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_SCAN_FOR_MODULES ${IMHEX_ENABLE_CXX_MODULES})
set(CMAKE_INCLUDE_DIRECTORIES_BEFORE ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
include("${IMHEX_BASE_FOLDER}/cmake/build_helpers.cmake")
@@ -53,7 +40,7 @@ loadVersion(IMHEX_VERSION IMHEX_VERSION_PLAIN)
setVariableInParent(IMHEX_VERSION ${IMHEX_VERSION})
configureCMake()
project(ImHex
project(imhex
LANGUAGES C CXX
VERSION ${IMHEX_VERSION_PLAIN}
DESCRIPTION "The ImHex Hex Editor"
@@ -83,7 +70,6 @@ addBundledLibraries()
add_subdirectory(lib/libimhex)
add_subdirectory(main)
addPluginDirectories()
add_subdirectory(lib/trace)
# Add unit tests
if (IMHEX_ENABLE_UNIT_TESTS)
@@ -95,9 +81,7 @@ if (IMHEX_ENABLE_UNIT_TESTS)
endif ()
# Configure more resources that will be added to the install package
if (IMHEX_BUNDLE_PLUGIN_SDK)
generateSDKDirectory()
endif()
generateSDKDirectory()
# Handle package generation
createPackage()

View File

@@ -52,23 +52,9 @@
"generator": "Ninja",
"binaryDir": "${sourceDir}/build/${presetName}",
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
"VCPKG_MANIFEST_DIR": "${sourceDir}/dist"
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
}
},
{
"name": "vs2022-x86",
"displayName": "Visual Studio 2022 x86",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build/${presetName}",
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
"VCPKG_MANIFEST_DIR": "${sourceDir}/dist"
},
"environment": {
"VSCMD_ARG_TGT_ARCH": "x86"
}
}
}
],
"buildPresets": [
{

View File

@@ -10,7 +10,9 @@ This document is a guide for developers who want to contribute to ImHex in any w
If you'd like to add new features, the best way to start is by joining our Discord and telling us about your idea. We can then discuss the best way to implement it and how it should be integrated into ImHex or if it should be done in a separate plugin.
There are standalone plugin templates that use ImHex as a submodule. You can find them located in the README's [Plugin Development](README.md#plugin-development) section.
There are standalone plugin templates that use ImHex as a submodule. You can find them here:
- https://github.com/WerWolv/ImHex-Cpp-Plugin-Template
- https://github.com/WerWolv/ImHex-Rust-Plugin-Template
### Adding a new language
@@ -30,18 +32,18 @@ ImHex is written in C++ and usually uses the latest compiler and standard librar
### Structure
- `main`: Contains the main application code
- Important to understand here is that the main ImHex application is basically just an empty shell.
- Important to understand here is that the main ImHex application is basically just an empty shell.
- All it does is create a Window and a OpenGL context using GLFW, load all available plugins, properly configure ImGui and render it to the screen.
- Everything else is done inside of plugins. ImHex comes with a few plugins by default, most notably the `builtin` plugin which contains the majority of the application code.
- In most cases, this code doesn't need to be modified. Most features should be self-contained inside a plugin.
- `lib`
- `libimhex`: Contains all helper utilities as well as various APIs for plugins to interact with ImHex.
- The library's main purpose is for Dependency Inversion. The ImHex main application as well as libimhex do not know about the existence of plugins at build time. Plugins and the main application instead link against libimhex and use it as a common API to interact with each other.
- Since libimhex itself doesn't know about the existence of plugins, it cannot depend on any of them. This includes localizations and things that get registered by plugins after launch.
- Since libimhex is a doesn't know about the existence of plugins, it cannot depend on any of them. This includes localizations and things that get registered by plugins after launch.
- Even if the builtin plugin is technically always available, it is still a plugin and should be treated that way.
- All important APIs can be found in the `hex/api` include directory and are documented in the respective header file.
- `external`: All libraries that need custom patches or aren't typically available in package managers go into here.
- If you'd like to add new features to the Pattern language, please make a PR to https://github.com/WerWolv/PatternLanguage instead. ImHex usually depends on the latest commit of the master branch of this repo.
- If you'd like to add new features to the Pattern language, please make a PR to https://github.com/WerWolv/PatternLanguage instead. ImHex usually depends on the latest commit of the master branch of this repo.
- `plugins`
- `builtin`: The builtin plugin. Contains the majority of the application code.
- It's the heart of ImHex's functionality. It contains most of the default views, providers, etc. so if you want to add new functionality to ImHex, this is the place to start.

View File

@@ -27,18 +27,16 @@ chmod +x imhex-*.AppImage
./imhex-*.AppImage
```
If you're experiencing glib / libgtk assertion failures, you might need to setup your `XDG_DATA_DIRS` env var correctly. In this case, run the following command before executing the AppImage. (See issue [ImHex/#2038](https://github.com/WerWolv/ImHex/issues/2038))
```bash
export XDG_DATA_DIRS="/usr/local/share:/usr/share"
```
#### Flatpak
To install the Flatpak, make sure you have the Flathub repository added to your system. Then simply run the following command:
```bash
flatpak install flathub net.werwolv.ImHex
# or install the file directly
flatpak install ./imhex-*.flatpak
```
#### Snap
```bash
snap install ./imhex-*.snap
```
#### Ubuntu DEB Package

View File

@@ -1,8 +0,0 @@
# Privacy Policy
ImHex collects **anonymous** user statistics based on the user's preferences which are set on first launch and can be opted in or out at any moment through the settings interface.
These statistics contain basic system information such as: ImHex Version, System Architecture, OS, OS Version or Linux Distro version of the GPU in use. This information is linked to a randomly generated ID which cannot be used to identify a specific user.
Additionally, we allow uploading of anonymized crash log files in case of an error. These are never uploaded automatically but only after explicit consent by the user. This decision is not saved so logs can be uploaded on a per-error basis.
Information collected may be analyzed by members of our development team and will never be shared with third parties outside of the team. We may occasionally share general usage statistics publically in a summarized manner (For example a graph stating 70% of users are using a specific OS). We will never share information about individual users, even if they are anonymous.

View File

@@ -29,23 +29,14 @@
## Supporting
If you like my work, please consider supporting me on GitHub Sponsors, Ko-Fi or PayPal. Thanks a lot!
If you like my work, please consider supporting me on GitHub Sponsors, Patreon or PayPal. Thanks a lot!
<p align="center">
<a href="https://github.com/sponsors/WerWolv"><img src="https://werwolv.net/assets/github_banner.png" alt="GitHub donate button" /></a>
<a href="https://ko-fi.com/WerWolv"><img src="https://werwolv.net/assets/kofi_banner.png" alt="Ko-Fi donate button" /></a>
<a href="https://www.patreon.com/werwolv"><img src="https://c5.patreon.com/external/logo/become_a_patron_button.png" alt="Patreon donate button" /></a>
<a href="https://werwolv.net/donate"><img src="https://werwolv.net/assets/paypal_banner.png" alt="PayPal donate button" /></a>
</p>
### Notable Sponsors
| | |
|:---------------------------------------------------------------------------------------------------:|-----------------------------------------------------------------------------------|
| [![JetBrains logo](https://avatars.githubusercontent.com/u/878437?s=48)](https://www.jetbrains.com) | JetBrains, providing us with free All Products Pack licenses for development |
| [![SignPath logo](https://avatars.githubusercontent.com/u/34448643?s=48)](https://signpath.io/) | SignPath, providing us with free Code Signing Certificates for our Windows builds |
| [![AWS logo](https://avatars.githubusercontent.com/u/2232217?s=48)](https://aws.amazon.com) | Amazon, providing us with free AWS Cloud Credits for our CI |
Would you like to appear here as well? Contact us at [imhex@werwolv.net](mailto:imhex@werwolv.net)!
## Screenshots
![Hex editor, patterns and data information](https://github.com/user-attachments/assets/902a7c4c-410d-490f-999e-14c856fec027)
![Bookmarks, data information, find view and data processor](https://github.com/user-attachments/assets/58eefa1f-31c9-4bb8-a1c1-8cdd8ddbd29f)
@@ -116,7 +107,6 @@ Would you like to appear here as well? Contact us at [imhex@werwolv.net](mailto:
- Base64 files
- IPS and IPS32 patches
- Markdown reports
- Binary arrays for various programming languages
</details>
<details>
<summary><strong>Data Inspector</strong></summary>
@@ -150,13 +140,8 @@ Would you like to appear here as well? Contact us at [imhex@werwolv.net](mailto:
- GDB Server
- Access the RAM of a running process or embedded devices through GDB
- Intel Hex and Motorola SREC data
- Base64 encoded data
- UDP Packets
- Support for displaying raw data received over UDP
- Process Memory
- Inspect the entire address space of a running process
- Remote Files over SSH with SFTP
- Support for loading files from remote servers using SSH and SFTP
</details>
<details>
<summary><strong>Data searching</strong></summary>
@@ -227,7 +212,6 @@ Would you like to appear here as well? Contact us at [imhex@werwolv.net](mailto:
- WebAssembly
- MOS65XX
- Berkeley Packet Filter
- Support for writing custom disassemblers for your own architectures
</details>
<details>
<summary><strong>Bookmarks</strong></summary>
@@ -277,7 +261,6 @@ Would you like to appear here as well? Contact us at [imhex@werwolv.net](mailto:
- Division by invariant multiplication calculator
- TCP Client/Server
- Euclidean algorithm calculator
- HTTP Requests
</details>
<details>
<summary><strong>Built-in Content updater</strong></summary>
@@ -336,23 +319,21 @@ To use ImHex, the following minimal system requirements need to be met.
- **OS**:
- **Windows**: Windows 7 or higher (Windows 10/11 recommended)
- **macOS**: macOS 15 (Sequoia) or higher,
- Lower versions should still work too, but you'll need to compile ImHex yourself. The release binaries will NOT work due to GitHub not having any macOS 15 or lower CI runners available.
- **macOS**: macOS 13 (Ventura) or higher,
- Lower versions should still work too, but you'll need to compile ImHex yourself. The release binaries will NOT work.
- The macOS build is not signed and will require you to manually allow them in the Security & Privacy settings.
- **Linux**: "Modern" Linux. The following distributions have official releases available. Other distros are supported through the AppImage, Flatpak and Snap releases.
- **Linux**: "Modern" Linux. The following distributions have official releases available. Other distros are supported through the AppImage and Flatpak releases.
- Ubuntu and Debian
- Fedora
- RHEL/AlmaLinux
- Arch Linux
- Basically any other distro will work as well when compiling ImHex from sources.
- **FreeBSD**: Tested on FreeBSD 14.3
- Other versions will most likely work too but are untested
- **CPU**: Officially supported are x86, AMD64 and ARM64, though any Little Endian CPU should work.
- **CPU**: Officially supported are x86_64 and ARM64, though any Little Endian 64 bit CPU should work.
- **GPU**: OpenGL 3.0 or higher
- Integrated Intel HD iGPUs are supported, however certain drivers are known to cause various graphical artifacts, especially on Windows. Use at your own risk.
- In case you don't have a GPU available, there are software rendered releases available for Windows and macOS
- **RAM**: ~50MiB, more is required for more complex analysis
- **Storage**: ~100MiB
- **RAM**: ~150MiB, more is required for more complex analysis
- **Storage**: 150MiB
## Installing
@@ -375,20 +356,9 @@ For more information, check out the [Compiling](/dist/compiling) guide.
## Contributing
See [Contributing](/CONTRIBUTING.md)
## Plugin development
To develop plugins for ImHex, use the following template project to get started. You then have access to the entirety of libimhex as well as the ImHex API and the Content Registry to interact with ImHex or to add new content.
To build a plugin, you will need to use our SDK
### Getting the SDK locally
You can build the SDK by compiling ImHex like this:
- `cmake -G Ninja -DIMHEX_BUNDLE_PLUGIN_SDK=ON -B build`
- `cd build`
- `DESTDIR=install ninja install`
The SDK will then be available at `install/usr/local/share/imhex/sdk`. You will need to set the variable `IMHEX_SDK_PATH` to that (absolute) path.
### Getting the SDK in a Github Actions CI
You can use [this action](https://github.com/WerWolv/imhex-download-sdk) to automatically download the SDK to your Github Runner
- [ImHex Plugin Template](https://github.com/WerWolv/ImHex-Plugin-Template)
@@ -396,10 +366,9 @@ You can use [this action](https://github.com/WerWolv/imhex-download-sdk) to auto
### Contributors
- [AxCut](https://github.com/paxcut) for a gigantic amount of contributions to the Pattern Text Editor and tons of other parts of ImHex
- [iTrooz](https://github.com/iTrooz) for getting ImHex onto the Web as well as hundreds of contributions in every part of the project
- [jumanji144](https://github.com/jumanji144) for huge contributions to the Pattern Language and ImHex's infrastructure
- [Mary](https://github.com/marysaka) for her immense help porting ImHex to macOS and help during development
- [Mary](https://github.com/marysaka) for her immense help porting ImHex to MacOS and help during development
- [Roblabla](https://github.com/Roblabla) for adding MSI Installer support to ImHex
- [Mailaender](https://github.com/Mailaender) for getting ImHex onto Flathub
- Everybody else who has reported issues on Discord or GitHub that I had great conversations with :)
@@ -430,18 +399,3 @@ Notable exceptions to this are the following parts which are under the LGPLv2.1
- **/plugins/ui**: The UI plugin library that contains some common UI elements that can be used by other plugins
The reason for this is to allow for proprietary plugins to be developed for ImHex.
### Code Signing Policy
Free code signing provided by [SignPath.io](https://about.signpath.io/),
certificate by [SignPath Foundation](https://signpath.org/).
This program will not transfer any information to other networked systems
unless specifically requested by the user or the person installing or
operating it.
#### People with direct push access
- [WerWolv](https://github.com/WerWolv)
- [iTrooz](https://github.com/iTrooz)
- [jumanji144](https://github.com/jumanji144)
- [AxCut](https://github.com/paxcut)

View File

@@ -1 +1 @@
1.39.0.WIP
1.37.1

View File

View File

@@ -4,7 +4,6 @@
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
set(CMAKE_POLICY_DEFAULT_CMP0063 NEW)
set(CMAKE_POLICY_DEFAULT_CMP0141 NEW)
if (POLICY CMP0177)
set(CMAKE_POLICY_DEFAULT_CMP0177 OLD)
@@ -67,32 +66,6 @@ function(addCommonFlag)
addObjCFlag(${ARGV0} ${ARGV1})
endfunction()
function(addCppCheck target)
if (NOT IMHEX_ENABLE_CPPCHECK)
return()
endif()
find_program(cppcheck_exe NAMES cppcheck REQUIRED)
if (NOT cppcheck_exe)
return()
endif()
set(target_build_dir $<TARGET_FILE_DIR:${target}>)
set(cppcheck_opts
--enable=all
--inline-suppr
--quiet
--std=c++23
--check-level=exhaustive
--error-exitcode=10
--suppressions-list=${CMAKE_SOURCE_DIR}/dist/cppcheck.supp
--checkers-report=${target_build_dir}/cppcheck-report.txt
)
set_target_properties(${target} PROPERTIES
CXX_CPPCHECK "${cppcheck_exe};${cppcheck_opts}"
)
endfunction()
set(CMAKE_WARN_DEPRECATED OFF CACHE BOOL "Disable deprecated warnings" FORCE)
include(FetchContent)
@@ -175,11 +148,15 @@ macro(detectOS)
endif()
include(GNUInstallDirs)
set(PLUGINS_INSTALL_LOCATION "${CMAKE_INSTALL_LIBDIR}/imhex/plugins")
if(IMHEX_PLUGINS_IN_SHARE)
set(PLUGINS_INSTALL_LOCATION "share/imhex/plugins")
else()
set(PLUGINS_INSTALL_LOCATION "${CMAKE_INSTALL_LIBDIR}/imhex/plugins")
# Add System plugin location for plugins to be loaded from
# IMPORTANT: This does not work for Sandboxed or portable builds such as the Flatpak or AppImage release
add_compile_definitions(SYSTEM_PLUGINS_LOCATION="${CMAKE_INSTALL_FULL_LIBDIR}/imhex")
# Add System plugin location for plugins to be loaded from
# IMPORTANT: This does not work for Sandboxed or portable builds such as the Flatpak or AppImage release
add_compile_definitions(SYSTEM_PLUGINS_LOCATION="${CMAKE_INSTALL_FULL_LIBDIR}/imhex")
endif()
else ()
message(FATAL_ERROR "Unknown / unsupported system!")
@@ -201,18 +178,11 @@ macro(configurePackingResources)
set(CPACK_GENERATOR "WIX")
set(CPACK_PACKAGE_NAME "ImHex")
set(CPACK_PACKAGE_VENDOR "WerWolv")
set(CPACK_WIX_VERSION 4)
set(CPACK_WIX_PRODUCT_GUID "*")
set(CPACK_WIX_UPGRADE_GUID "05000E99-9659-42FD-A1CF-05C554B39285")
set(CPACK_WIX_PRODUCT_ICON "${PROJECT_SOURCE_DIR}/resources/dist/windows/icon.ico")
set(CPACK_WIX_UI_BANNER "${PROJECT_SOURCE_DIR}/resources/dist/windows/wix_banner.png")
set(CPACK_WIX_UI_DIALOG "${PROJECT_SOURCE_DIR}/resources/dist/windows/wix_dialog.png")
set(CPACK_WIX_CULTURES "en-US;de-DE;ja-JP;it-IT;pt-BR;zh-CN;zh-TW;ru-RU")
set(CPACK_WIX_TEMPLATE "${PROJECT_SOURCE_DIR}/resources/dist/windows/WIX.template.in")
set(CPACK_WIX_EXTENSIONS "WixToolset.UI.wixext")
file(GLOB_RECURSE CPACK_WIX_EXTRA_SOURCES "${PROJECT_SOURCE_DIR}/resources/dist/windows/wix/*.wxs")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "ImHex")
set_property(INSTALL "$<TARGET_FILE_NAME:main>"
PROPERTY CPACK_START_MENU_SHORTCUTS "ImHex"
@@ -221,9 +191,9 @@ macro(configurePackingResources)
endif()
elseif (APPLE OR ${CMAKE_HOST_SYSTEM_NAME} MATCHES "Darwin")
set(IMHEX_ICON "${IMHEX_BASE_FOLDER}/resources/dist/macos/AppIcon.icns")
set(BUNDLE_NAME "ImHex.app")
set(BUNDLE_NAME "imhex.app")
if (IMHEX_MACOS_CREATE_BUNDLE)
if (IMHEX_GENERATE_PACKAGE)
set(APPLICATION_TYPE MACOSX_BUNDLE)
set_source_files_properties(${IMHEX_ICON} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
set(MACOSX_BUNDLE_ICON_FILE "AppIcon.icns")
@@ -239,9 +209,9 @@ macro(configurePackingResources)
string(TIMESTAMP CURR_YEAR "%Y")
set(MACOSX_BUNDLE_COPYRIGHT "Copyright © 2020 - ${CURR_YEAR} WerWolv. All rights reserved." )
if ("${CMAKE_GENERATOR}" STREQUAL "Xcode")
set(IMHEX_BUNDLE_PATH "${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/${BUNDLE_NAME}")
set (IMHEX_BUNDLE_PATH "${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/${BUNDLE_NAME}")
else ()
set(IMHEX_BUNDLE_PATH "${CMAKE_BINARY_DIR}/${BUNDLE_NAME}")
set (IMHEX_BUNDLE_PATH "${CMAKE_BINARY_DIR}/${BUNDLE_NAME}")
endif()
set(PLUGINS_INSTALL_LOCATION "${IMHEX_BUNDLE_PATH}/Contents/MacOS/plugins")
@@ -259,7 +229,7 @@ macro(addPluginDirectories)
set_target_properties(${plugin} PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${IMHEX_MAIN_OUTPUT_DIRECTORY}/plugins")
if (APPLE)
if (IMHEX_MACOS_CREATE_BUNDLE)
if (IMHEX_GENERATE_PACKAGE)
set_target_properties(${plugin} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PLUGINS_INSTALL_LOCATION})
endif ()
else ()
@@ -291,17 +261,6 @@ macro(createPackage)
list(APPEND PLUGIN_TARGET_FILES "$<TARGET_FILE:${plugin}>")
endforeach ()
if (DEFINED VCPKG_TARGET_TRIPLET)
set(VCPKG_DEPS_FOLDER "")
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(VCPKG_DEPS_FOLDER "${CMAKE_BINARY_DIR}/vcpkg_installed/${VCPKG_TARGET_TRIPLET}/debug/bin")
else()
set(VCPKG_DEPS_FOLDER "${CMAKE_BINARY_DIR}/vcpkg_installed/${VCPKG_TARGET_TRIPLET}/bin")
endif()
install(CODE "set(VCPKG_DEPS_FOLDER \"${VCPKG_DEPS_FOLDER}\")")
endif()
# Grab all dynamically linked dependencies.
install(CODE "set(CMAKE_INSTALL_BINDIR \"${CMAKE_INSTALL_BINDIR}\")")
install(CODE "set(PLUGIN_TARGET_FILES \"${PLUGIN_TARGET_FILES}\")")
@@ -315,15 +274,10 @@ macro(createPackage)
POST_EXCLUDE_REGEXES ".*system32/.*\\.dll"
)
if(_c_deps_FILENAMES AND _c_deps AND NOT (_c_deps STREQUAL ""))
if(_c_deps_FILENAMES)
message(WARNING "Conflicting dependencies for library: \"${_c_deps}\"!")
endif()
if (DEFINED VCPKG_DEPS_FOLDER)
file(GLOB VCPKG_DEPS "${VCPKG_DEPS_FOLDER}/*.dll")
list(APPEND _r_deps ${VCPKG_DEPS})
endif()
foreach(_file ${_r_deps})
file(INSTALL
DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}"
@@ -334,49 +288,47 @@ macro(createPackage)
endforeach()
]])
downloadImHexPatternsFiles(".")
downloadImHexPatternsFiles("./")
elseif(UNIX AND NOT APPLE)
set_target_properties(libimhex PROPERTIES SOVERSION ${IMHEX_VERSION})
configure_file(${IMHEX_BASE_FOLDER}/dist/DEBIAN/control.in ${CMAKE_BINARY_DIR}/DEBIAN/control)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/dist/DEBIAN/control.in ${CMAKE_BINARY_DIR}/DEBIAN/control)
install(FILES ${IMHEX_BASE_FOLDER}/LICENSE DESTINATION ${CMAKE_INSTALL_PREFIX}/share/licenses/imhex)
install(FILES ${IMHEX_BASE_FOLDER}/dist/imhex.desktop DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications)
install(FILES ${IMHEX_BASE_FOLDER}/dist/imhex.mime.xml DESTINATION ${CMAKE_INSTALL_PREFIX}/share/mime/packages RENAME imhex.xml)
install(FILES ${IMHEX_BASE_FOLDER}/resources/icon.svg DESTINATION ${CMAKE_INSTALL_PREFIX}/share/pixmaps RENAME imhex.svg)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE DESTINATION ${CMAKE_INSTALL_PREFIX}/share/licenses/imhex)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/dist/imhex.desktop DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/dist/imhex.mime.xml DESTINATION ${CMAKE_INSTALL_PREFIX}/share/mime/packages RENAME imhex.xml)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/resources/icon.svg DESTINATION ${CMAKE_INSTALL_PREFIX}/share/pixmaps RENAME imhex.svg)
downloadImHexPatternsFiles("./share/imhex")
# install AppStream file
install(FILES ${IMHEX_BASE_FOLDER}/dist/net.werwolv.ImHex.metainfo.xml DESTINATION ${CMAKE_INSTALL_PREFIX}/share/metainfo)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/dist/net.werwolv.imhex.metainfo.xml DESTINATION ${CMAKE_INSTALL_PREFIX}/share/metainfo)
# install symlink for the old standard name
file(CREATE_LINK net.werwolv.imhex.metainfo.xml ${CMAKE_CURRENT_BINARY_DIR}/net.werwolv.imhex.appdata.xml SYMBOLIC)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/net.werwolv.imhex.appdata.xml DESTINATION ${CMAKE_INSTALL_PREFIX}/share/metainfo)
endif()
if (APPLE)
if (IMHEX_MACOS_CREATE_BUNDLE)
if (IMHEX_GENERATE_PACKAGE)
set(EXTRA_BUNDLE_LIBRARY_PATHS ${EXTRA_BUNDLE_LIBRARY_PATHS} "${IMHEX_SYSTEM_LIBRARY_PATH}")
include(PostprocessBundle)
set_target_properties(libimhex PROPERTIES SOVERSION ${IMHEX_VERSION})
set_property(TARGET main PROPERTY MACOSX_BUNDLE_INFO_PLIST ${MACOSX_BUNDLE_INFO_PLIST})
set_property(TARGET main PROPERTY MACOSX_BUNDLE_BUNDLE_NAME "${MACOSX_BUNDLE_BUNDLE_NAME}")
# Fix rpath
install(CODE "execute_process(COMMAND ${CMAKE_INSTALL_NAME_TOOL} -add_rpath \"@executable_path/../Frameworks/\" $<TARGET_FILE:main>)")
install(CODE "execute_process(COMMAND ${CMAKE_INSTALL_NAME_TOOL} -add_rpath \"@executable_path/../Frameworks/\" $<TARGET_FILE:updater>)")
add_custom_target(build-time-make-plugins-directory ALL COMMAND ${CMAKE_COMMAND} -E make_directory "${IMHEX_BUNDLE_PATH}/Contents/MacOS/plugins")
add_custom_target(build-time-make-resources-directory ALL COMMAND ${CMAKE_COMMAND} -E make_directory "${IMHEX_BUNDLE_PATH}/Contents/Resources")
downloadImHexPatternsFiles("${CMAKE_INSTALL_PREFIX}/${BUNDLE_NAME}/Contents/MacOS")
install(FILES ${IMHEX_ICON} DESTINATION "${CMAKE_INSTALL_PREFIX}/${BUNDLE_NAME}/Contents/Resources")
install(TARGETS main BUNDLE DESTINATION ".")
install(TARGETS updater DESTINATION "${CMAKE_INSTALL_PREFIX}/${BUNDLE_NAME}/Contents/MacOS")
install(
FILES ${IMHEX_BASE_FOLDER}/dist/cli/imhex.sh
DESTINATION "${CMAKE_INSTALL_PREFIX}/${BUNDLE_NAME}/Contents/MacOS/cli"
RENAME imhex
PERMISSIONS
OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE
)
# Update library references to make the bundle portable
postprocess_bundle(imhex_all main)
@@ -407,31 +359,9 @@ macro(createPackage)
if (TARGET main-forwarder)
install(TARGETS main-forwarder BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
if (WIN32)
install(
FILES ${IMHEX_BASE_FOLDER}/dist/cli/imhex.bat
DESTINATION ${CMAKE_INSTALL_BINDIR}/cli
RENAME imhex.bat
PERMISSIONS
OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE
)
else()
install(
FILES ${IMHEX_BASE_FOLDER}/dist/cli/imhex.sh
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/imhex
RENAME imhex
PERMISSIONS
OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE
)
endif()
endif()
if (IMHEX_MACOS_CREATE_BUNDLE)
if (IMHEX_GENERATE_PACKAGE)
set(CPACK_BUNDLE_NAME "ImHex")
include(CPack)
@@ -457,8 +387,6 @@ macro(configureCMake)
set(CMAKE_POSITION_INDEPENDENT_CODE ON CACHE BOOL "Enable position independent code for all targets" FORCE)
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<$<CONFIG:Debug,RelWithDebInfo>:Embedded>")
# Configure use of recommended build tools
if (IMHEX_USE_DEFAULT_BUILD_SETTINGS)
message(STATUS "Configuring CMake to use recommended build tools...")
@@ -492,8 +420,8 @@ macro(configureCMake)
set(CMAKE_LINKER ${LD_LLD_PATH})
if (NOT XCODE AND NOT MSVC)
add_link_options("-fuse-ld=lld")
add_link_options("-fuse-ld=lld")
set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -fuse-ld=lld)
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -fuse-ld=lld)
endif()
else ()
message(WARNING "lld not found, using default linker!")
@@ -505,6 +433,19 @@ macro(configureCMake)
message(WARNING "ninja not found, using default generator!")
endif ()
endif()
# Enable LTO if desired and supported
if (IMHEX_ENABLE_LTO)
include(CheckIPOSupported)
check_ipo_supported(RESULT result OUTPUT output_error)
if (result)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
message(STATUS "LTO enabled!")
else ()
message(WARNING "LTO is not supported: ${output_error}")
endif ()
endif ()
endmacro()
function(configureProject)
@@ -517,19 +458,6 @@ function(configureProject)
else()
set(IMHEX_MAIN_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" PARENT_SCOPE)
endif()
# Enable LTO if desired and supported
if (IMHEX_ENABLE_LTO)
include(CheckIPOSupported)
check_ipo_supported(RESULT result OUTPUT output_error)
if (result OR WIN32)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION $<$<CONFIG:Release,RelWithDebInfo,MinSizeRel>:ON>)
message(STATUS "LTO enabled!")
else ()
message(WARNING "LTO is not supported: ${output_error}")
endif ()
endif ()
endfunction()
macro(setDefaultBuiltTypeIfUnset)
@@ -547,10 +475,6 @@ function(loadVersion version plain_version)
string(REPLACE ".WIP" "" read_version_plain ${read_version})
set(${version} ${read_version} PARENT_SCOPE)
set(${plain_version} ${read_version_plain} PARENT_SCOPE)
if (read_version MATCHES ".+\.WIP")
set(IMHEX_PATTERNS_PULL_MASTER ON PARENT_SCOPE)
endif()
endfunction()
function(detectBadClone)
@@ -560,9 +484,6 @@ function(detectBadClone)
file (GLOB EXTERNAL_DIRS "lib/external/*" "lib/third_party/*")
foreach (EXTERNAL_DIR ${EXTERNAL_DIRS})
if(NOT IS_DIRECTORY "${EXTERNAL_DIR}")
continue()
endif()
file(GLOB_RECURSE RESULT "${EXTERNAL_DIR}/*")
list(LENGTH RESULT ENTRY_COUNT)
if(ENTRY_COUNT LESS_EQUAL 1)
@@ -590,9 +511,7 @@ endfunction()
macro(detectBundledPlugins)
file(GLOB PLUGINS_DIRS "plugins/*")
if (IMHEX_INCLUDE_PLUGINS)
set(PLUGINS ${IMHEX_INCLUDE_PLUGINS})
else()
if (NOT DEFINED IMHEX_INCLUDE_PLUGINS)
foreach(PLUGIN_DIR ${PLUGINS_DIRS})
if (EXISTS "${PLUGIN_DIR}/CMakeLists.txt")
get_filename_component(PLUGIN_NAME ${PLUGIN_DIR} NAME)
@@ -601,6 +520,8 @@ macro(detectBundledPlugins)
endif ()
endif()
endforeach()
else()
set(PLUGINS ${IMHEX_INCLUDE_PLUGINS})
endif()
foreach(PLUGIN_NAME ${PLUGINS})
@@ -611,13 +532,9 @@ macro(detectBundledPlugins)
message(FATAL_ERROR "No bundled plugins enabled")
endif()
set(REQUIRED_PLUGINS builtin fonts ui)
foreach(PLUGIN ${REQUIRED_PLUGINS})
list(FIND PLUGINS ${PLUGIN} PLUGIN_INDEX)
if (PLUGIN_INDEX EQUAL -1)
message(FATAL_ERROR "Required plugin '${PLUGIN}' is not enabled!")
endif()
endforeach()
if (NOT ("builtin" IN_LIST PLUGINS))
message(FATAL_ERROR "The 'builtin' plugin is required for ImHex to work!")
endif ()
endmacro()
macro(setVariableInParent variable value)
@@ -638,21 +555,16 @@ function(downloadImHexPatternsFiles dest)
set(PATTERNS_BRANCH ImHex-v${IMHEX_VERSION})
endif ()
set(imhex_patterns_SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/ImHex-Patterns")
install(CODE "set(PATTERNS_BRANCH \"${PATTERNS_BRANCH}\")")
install(CODE "set(imhex_patterns_SOURCE_DIR \"${imhex_patterns_SOURCE_DIR}\")")
install(CODE [[
message(STATUS "Downloading ImHex patterns from branch '${PATTERNS_BRANCH}'...")
if (NOT EXISTS "${imhex_patterns_SOURCE_DIR}")
file(MAKE_DIRECTORY "${imhex_patterns_SOURCE_DIR}")
execute_process(
COMMAND
git clone --recurse-submodules --branch ${PATTERNS_BRANCH} https://github.com/WerWolv/ImHex-Patterns.git "${imhex_patterns_SOURCE_DIR}"
COMMAND_ERROR_IS_FATAL ANY
)
endif()
]])
FetchContent_Declare(
imhex_patterns
GIT_REPOSITORY https://github.com/WerWolv/ImHex-Patterns.git
GIT_TAG origin/master
)
message(STATUS "Downloading ImHex-Patterns repo branch ${PATTERNS_BRANCH}...")
FetchContent_MakeAvailable(imhex_patterns)
message(STATUS "Finished downloading ImHex-Patterns")
else ()
set(imhex_patterns_SOURCE_DIR "")
@@ -667,32 +579,28 @@ function(downloadImHexPatternsFiles dest)
endif()
endif ()
install(CODE "set(imhex_patterns_SOURCE_DIR \"${imhex_patterns_SOURCE_DIR}\")")
if (NOT EXISTS ${imhex_patterns_SOURCE_DIR})
message(WARNING "Failed to locate ImHex-Patterns repository, some resources will be missing during install!")
elseif(XCODE)
# The Xcode build has multiple configurations, which each need a copy of these files
file(GLOB_RECURSE sourceFilePaths LIST_DIRECTORIES NO CONFIGURE_DEPENDS RELATIVE "${imhex_patterns_SOURCE_DIR}"
"${imhex_patterns_SOURCE_DIR}/constants/*"
"${imhex_patterns_SOURCE_DIR}/encodings/*"
"${imhex_patterns_SOURCE_DIR}/includes/*"
"${imhex_patterns_SOURCE_DIR}/patterns/*"
"${imhex_patterns_SOURCE_DIR}/magic/*"
"${imhex_patterns_SOURCE_DIR}/nodes/*"
)
list(FILTER sourceFilePaths EXCLUDE REGEX "_schema.json$")
if(XCODE)
install(CODE [[
# The Xcode build has multiple configurations, which each need a copy of these files
file(GLOB_RECURSE sourceFilePaths LIST_DIRECTORIES NO CONFIGURE_DEPENDS RELATIVE "${imhex_patterns_SOURCE_DIR}"
"${imhex_patterns_SOURCE_DIR}/constants/*"
"${imhex_patterns_SOURCE_DIR}/encodings/*"
"${imhex_patterns_SOURCE_DIR}/includes/*"
"${imhex_patterns_SOURCE_DIR}/patterns/*"
"${imhex_patterns_SOURCE_DIR}/magic/*"
"${imhex_patterns_SOURCE_DIR}/nodes/*"
)
list(FILTER sourceFilePaths EXCLUDE REGEX "_schema.json$")
foreach(relativePath IN LISTS sourceFilePaths)
file(GENERATE OUTPUT "${dest}/${relativePath}" INPUT "${imhex_patterns_SOURCE_DIR}/${relativePath}")
endforeach()
]])
foreach(relativePath IN LISTS sourceFilePaths)
file(GENERATE OUTPUT "${dest}/${relativePath}" INPUT "${imhex_patterns_SOURCE_DIR}/${relativePath}")
endforeach()
else()
if (NOT (imhex_patterns_SOURCE_DIR STREQUAL ""))
set(PATTERNS_FOLDERS_TO_INSTALL constants encodings includes patterns magic nodes)
foreach (FOLDER ${PATTERNS_FOLDERS_TO_INSTALL})
install(DIRECTORY "${imhex_patterns_SOURCE_DIR}/${FOLDER}" DESTINATION "${dest}" PATTERN "**/_schema.json" EXCLUDE)
endforeach ()
endif()
set(PATTERNS_FOLDERS_TO_INSTALL constants encodings includes patterns magic nodes)
foreach (FOLDER ${PATTERNS_FOLDERS_TO_INSTALL})
install(DIRECTORY "${imhex_patterns_SOURCE_DIR}/${FOLDER}" DESTINATION "${dest}" PATTERN "**/_schema.json" EXCLUDE)
endforeach ()
endif ()
endfunction()
@@ -731,7 +639,6 @@ macro(setupCompilerFlags target)
addCommonFlag("/wd4267" ${target}) # 'var': conversion from 'size_t' to 'type', possible loss of data
addCommonFlag("/wd4305" ${target}) # truncation from 'double' to 'float'
addCommonFlag("/wd4996" ${target}) # 'function': was declared deprecated
addCommonFlag("/wd5244" ${target}) # 'include' in the purview of module 'module' appears erroneous
if (IMHEX_STRICT_WARNINGS)
addCommonFlag("/WX" ${target})
@@ -752,26 +659,19 @@ macro(setupCompilerFlags target)
addCXXFlag("-fexceptions" ${target})
addCXXFlag("-frtti" ${target})
addCommonFlag("-fno-omit-frame-pointer" ${target})
# Disable some warnings
addCCXXFlag("-Wno-array-bounds" ${target})
addCCXXFlag("-Wno-deprecated-declarations" ${target})
addCCXXFlag("-Wno-unknown-pragmas" ${target})
addCXXFlag("-Wno-include-angled-in-module-purview" ${target})
# Enable hardening flags
if (IMHEX_BUILD_HARDENING)
if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
addCommonFlag("-U_FORTIFY_SOURCE" ${target})
addCommonFlag("-D_FORTIFY_SOURCE=3" ${target})
addCommonFlag("-U_FORTIFY_SOURCE" ${target})
addCommonFlag("-D_FORTIFY_SOURCE=3" ${target})
if (NOT EMSCRIPTEN)
addCommonFlag("-fstack-protector-strong" ${target})
endif()
endif()
if (NOT EMSCRIPTEN)
addCommonFlag("-fstack-protector-strong" ${target})
endif()
endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
@@ -781,19 +681,15 @@ macro(setupCompilerFlags target)
endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND APPLE)
addCCXXFlag("-Wno-unknown-warning-option" ${target})
# On macOS, when using clang from Homebrew, properly setup the libc++ library path so
# it's using the one from Homebrew instead of the system one.
execute_process(COMMAND brew --prefix llvm OUTPUT_VARIABLE LLVM_PREFIX OUTPUT_STRIP_TRAILING_WHITESPACE)
if (NOT LLVM_PREFIX STREQUAL "" AND ${CMAKE_CXX_COMPILER} STREQUAL "${LLVM_PREFIX}/bin/clang++")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L${LLVM_PREFIX}/lib/c++")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -L${LLVM_PREFIX}/lib/c++")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -L${LLVM_PREFIX}/lib/c++")
endif()
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L${LLVM_PREFIX}/lib/c++")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L${LLVM_PREFIX}/lib/c++")
addCCXXFlag("-Wno-unknown-warning-option" ${target})
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
add_compile_definitions(_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG)
else()
add_compile_definitions(_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE)
endif()
endif()
@@ -850,16 +746,11 @@ macro(setUninstallTarget)
endmacro()
macro(addBundledLibraries)
# Make sure the build is using vcpkg on Windows and Emscripten, otherwise none of these dependencies will be found
if (MSVC OR EMSCRIPTEN)
if (NOT (CMAKE_TOOLCHAIN_FILE MATCHES "vcpkg"))
message(AUTHOR_WARNING "Your current environment probably needs to be setup to use vcpkg, otherwise none of the dependencies will be found!")
endif()
endif()
set(EXTERNAL_LIBS_FOLDER "${CMAKE_CURRENT_SOURCE_DIR}/lib/external")
set(THIRD_PARTY_LIBS_FOLDER "${CMAKE_CURRENT_SOURCE_DIR}/lib/third_party")
set(BUILD_SHARED_LIBS OFF)
add_subdirectory(${THIRD_PARTY_LIBS_FOLDER}/imgui)
add_subdirectory(${THIRD_PARTY_LIBS_FOLDER}/microtar EXCLUDE_FROM_ALL)
@@ -909,19 +800,8 @@ macro(addBundledLibraries)
add_subdirectory(${THIRD_PARTY_LIBS_FOLDER}/lunasvg EXCLUDE_FROM_ALL)
set(LUNASVG_LIBRARIES lunasvg)
else()
find_package(lunasvg REQUIRED)
set(LUNASVG_LIBRARIES lunasvg::lunasvg)
endif()
if (NOT USE_SYSTEM_MD4C)
set(BUILD_MD2HTML_EXECUTABLE OFF CACHE BOOL "Disable md2html executable" FORCE)
add_subdirectory(${THIRD_PARTY_LIBS_FOLDER}/md4c EXCLUDE_FROM_ALL)
add_library(md4c_lib INTERFACE)
add_library(md4c::md4c ALIAS md4c_lib)
target_include_directories(md4c_lib INTERFACE ${THIRD_PARTY_LIBS_FOLDER}/md4c/src)
target_link_libraries(md4c_lib INTERFACE md4c)
else()
find_package(md4c REQUIRED)
find_package(LunaSVG REQUIRED)
set(LUNASVG_LIBRARIES lunasvg)
endif()
if (NOT USE_SYSTEM_LLVM)
@@ -930,8 +810,20 @@ macro(addBundledLibraries)
find_package(LLVM REQUIRED Demangle)
endif()
if (NOT USE_SYSTEM_JTHREAD)
add_subdirectory(${THIRD_PARTY_LIBS_FOLDER}/jthread EXCLUDE_FROM_ALL)
set(JTHREAD_LIBRARIES jthread)
else()
find_path(JOSUTTIS_JTHREAD_INCLUDE_DIRS "condition_variable_any2.hpp")
include_directories(${JOSUTTIS_JTHREAD_INCLUDE_DIRS})
add_library(jthread INTERFACE)
target_include_directories(jthread INTERFACE ${JOSUTTIS_JTHREAD_INCLUDE_DIRS})
set(JTHREAD_LIBRARIES jthread)
endif()
if (USE_SYSTEM_BOOST)
find_package(Boost REQUIRED CONFIG COMPONENTS regex)
find_package(Boost REQUIRED)
set(BOOST_LIBRARIES Boost::regex)
else()
add_subdirectory(${THIRD_PARTY_LIBS_FOLDER}/boost ${CMAKE_CURRENT_BINARY_DIR}/boost EXCLUDE_FROM_ALL)
@@ -946,8 +838,6 @@ macro(addBundledLibraries)
add_subdirectory(${EXTERNAL_LIBS_FOLDER}/pattern_language EXCLUDE_FROM_ALL)
add_subdirectory(${EXTERNAL_LIBS_FOLDER}/disassembler EXCLUDE_FROM_ALL)
add_subdirectory(${THIRD_PARTY_LIBS_FOLDER}/imgui)
if (LIBPL_SHARED_LIBRARY)
install(
TARGETS
@@ -971,6 +861,30 @@ macro(addBundledLibraries)
find_package(mbedTLS 3.4.0 REQUIRED)
find_package(Magic 5.39 REQUIRED)
if (NOT IMHEX_DISABLE_STACKTRACE)
if (WIN32)
message(STATUS "StackWalk enabled!")
set(LIBBACKTRACE_LIBRARIES DbgHelp.lib)
else ()
find_package(Backtrace)
if (${Backtrace_FOUND})
message(STATUS "Backtrace enabled! Header: ${Backtrace_HEADER}")
if (Backtrace_HEADER STREQUAL "backtrace.h")
set(LIBBACKTRACE_LIBRARIES ${Backtrace_LIBRARY})
set(LIBBACKTRACE_INCLUDE_DIRS ${Backtrace_INCLUDE_DIR})
add_compile_definitions(BACKTRACE_HEADER=<${Backtrace_HEADER}>)
add_compile_definitions(HEX_HAS_BACKTRACE)
elseif (Backtrace_HEADER STREQUAL "execinfo.h")
set(LIBBACKTRACE_LIBRARIES ${Backtrace_LIBRARY})
set(LIBBACKTRACE_INCLUDE_DIRS ${Backtrace_INCLUDE_DIR})
add_compile_definitions(BACKTRACE_HEADER=<${Backtrace_HEADER}>)
add_compile_definitions(HEX_HAS_EXECINFO)
endif()
endif()
endif()
endif()
endmacro()
function(enableUnityBuild TARGET)
@@ -994,7 +908,6 @@ endfunction()
function(generateSDKDirectory)
setSDKPaths()
install(DIRECTORY ${CMAKE_SOURCE_DIR}/lib/libimhex DESTINATION "${SDK_PATH}/lib" PATTERN "**/source/*" EXCLUDE)
install(DIRECTORY ${CMAKE_SOURCE_DIR}/lib/trace DESTINATION "${SDK_PATH}/lib" PATTERN "**/source/*" EXCLUDE)
install(DIRECTORY ${CMAKE_SOURCE_DIR}/lib/external DESTINATION "${SDK_PATH}/lib")
install(DIRECTORY ${CMAKE_SOURCE_DIR}/lib/third_party/imgui DESTINATION "${SDK_PATH}/lib/third_party" PATTERN "**/source/*" EXCLUDE)
if (NOT USE_SYSTEM_FMT)
@@ -1011,19 +924,12 @@ function(generateSDKDirectory)
install(FILES ${CMAKE_SOURCE_DIR}/cmake/build_helpers.cmake DESTINATION "${SDK_PATH}/cmake")
install(DIRECTORY ${CMAKE_SOURCE_DIR}/cmake/sdk/ DESTINATION "${SDK_PATH}")
install(TARGETS libimhex ARCHIVE DESTINATION "${SDK_PATH}/lib")
install(TARGETS tracing ARCHIVE DESTINATION "${SDK_PATH}/lib")
install(DIRECTORY ${CMAKE_SOURCE_DIR}/plugins/ui/include DESTINATION "${SDK_PATH}/lib/ui/include")
install(FILES ${CMAKE_SOURCE_DIR}/plugins/ui/CMakeLists.txt DESTINATION "${SDK_PATH}/lib/ui/")
if (WIN32)
install(TARGETS ui ARCHIVE DESTINATION "${SDK_PATH}/lib")
endif()
install(DIRECTORY ${CMAKE_SOURCE_DIR}/plugins/ui DESTINATION "${SDK_PATH}/lib" PATTERN "**/source/*" EXCLUDE)
install(TARGETS ui ARCHIVE DESTINATION "${SDK_PATH}/lib")
install(DIRECTORY ${CMAKE_SOURCE_DIR}/plugins/fonts/include DESTINATION "${SDK_PATH}/lib/fonts/include")
install(FILES ${CMAKE_SOURCE_DIR}/plugins/fonts/CMakeLists.txt DESTINATION "${SDK_PATH}/lib/fonts/")
if (WIN32)
install(TARGETS fonts ARCHIVE DESTINATION "${SDK_PATH}/lib")
endif()
install(DIRECTORY ${CMAKE_SOURCE_DIR}/plugins/fonts DESTINATION "${SDK_PATH}/lib" PATTERN "**/source/*" EXCLUDE)
install(TARGETS fonts ARCHIVE DESTINATION "${SDK_PATH}/lib")
endfunction()
function(addIncludesFromLibrary target library)
@@ -1037,9 +943,8 @@ function(precompileHeaders target includeFolder)
endif()
file(GLOB_RECURSE TARGET_INCLUDES "${includeFolder}/**/*.hpp")
file(GLOB_RECURSE LIBIMHEX_INCLUDES "${CMAKE_SOURCE_DIR}/lib/libimhex/include/**/*.hpp")
set(SYSTEM_INCLUDES "<algorithm>;<array>;<atomic>;<chrono>;<cmath>;<cstddef>;<cstdint>;<cstdio>;<cstdlib>;<cstring>;<exception>;<filesystem>;<functional>;<iterator>;<limits>;<list>;<map>;<memory>;<optional>;<ranges>;<set>;<stdexcept>;<string>;<string_view>;<thread>;<tuple>;<type_traits>;<unordered_map>;<unordered_set>;<utility>;<variant>;<vector>")
set(INCLUDES "${SYSTEM_INCLUDES};${TARGET_INCLUDES};${LIBIMHEX_INCLUDES}")
set(INCLUDES "${SYSTEM_INCLUDES};${TARGET_INCLUDES}")
string(REPLACE ">" "$<ANGLE-R>" INCLUDES "${INCLUDES}")
target_precompile_headers(${target}
PUBLIC

View File

@@ -2,7 +2,11 @@ find_path(LIBMAGIC_INCLUDE_DIR magic.h)
find_library(LIBMAGIC_LIBRARY NAMES magic)
find_package_handle_standard_args(Magic DEFAULT_MSG
if (LIBMAGIC_INCLUDE_DIR AND LIBMAGIC_LIBRARY)
set(LIBMAGIC_FOUND TRUE)
endif (LIBMAGIC_INCLUDE_DIR AND LIBMAGIC_LIBRARY)
find_package_handle_standard_args("libmagic" DEFAULT_MSG
LIBMAGIC_LIBRARY
LIBMAGIC_INCLUDE_DIR
)
@@ -10,5 +14,5 @@ find_package_handle_standard_args(Magic DEFAULT_MSG
mark_as_advanced(
LIBMAGIC_INCLUDE_DIR
LIBMAGIC_LIBRARY
Magic_FOUND
)
LIBMAGIC_FOUND
)

View File

@@ -1,15 +0,0 @@
find_path(LIBSSH2_INCLUDE_DIR libssh2.h)
find_library(LIBSSH2_LIBRARY NAMES ssh2 libssh2)
if(LIBSSH2_INCLUDE_DIR)
file(STRINGS "${LIBSSH2_INCLUDE_DIR}/libssh2.h" libssh2_version_str REGEX "^#define[\t ]+LIBSSH2_VERSION[\t ]+\"(.*)\"")
string(REGEX REPLACE "^.*\"([^\"]+)\"" "\\1" LIBSSH2_VERSION "${libssh2_version_str}")
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LibSSH2
REQUIRED_VARS LIBSSH2_LIBRARY LIBSSH2_INCLUDE_DIR
VERSION_VAR LIBSSH2_VERSION)
mark_as_advanced(LIBSSH2_INCLUDE_DIR LIBSSH2_LIBRARY)

View File

@@ -26,9 +26,8 @@ SET(MBEDTLS_FIND_QUIETLY TRUE)
FIND_LIBRARY(MBEDTLS_LIBRARY NAMES mbedtls libmbedtls libmbedx509)
FIND_LIBRARY(MBEDX509_LIBRARY NAMES mbedx509 libmbedx509)
FIND_LIBRARY(MBEDCRYPTO_LIBRARY NAMES mbedcrypto libmbedcrypto)
FIND_LIBRARY(TFPSACRYPTO_LIBRARY NAMES libtfpsacrypto tfpsacrypto)
IF(MBEDTLS_INCLUDE_DIR AND MBEDTLS_LIBRARY AND MBEDX509_LIBRARY AND (MBEDCRYPTO_LIBRARY OR TFPSACRYPTO_LIBRARY))
IF(MBEDTLS_INCLUDE_DIR AND MBEDTLS_LIBRARY AND MBEDX509_LIBRARY AND MBEDCRYPTO_LIBRARY)
SET(MBEDTLS_FOUND TRUE)
ENDIF()
@@ -38,24 +37,14 @@ IF(MBEDTLS_FOUND)
GET_FILENAME_COMPONENT(MBEDTLS_LIBRARY_FILE ${MBEDTLS_LIBRARY} NAME_WE)
GET_FILENAME_COMPONENT(MBEDX509_LIBRARY_FILE ${MBEDX509_LIBRARY} NAME_WE)
GET_FILENAME_COMPONENT(MBEDCRYPTO_LIBRARY_FILE ${MBEDCRYPTO_LIBRARY} NAME_WE)
GET_FILENAME_COMPONENT(TFPSACRYPTO_LIBRARY_FILE ${TFPSACRYPTO_LIBRARY} NAME_WE)
STRING(REGEX REPLACE "^lib" "" MBEDTLS_LIBRARY_FILE ${MBEDTLS_LIBRARY_FILE})
STRING(REGEX REPLACE "^lib" "" MBEDX509_LIBRARY_FILE ${MBEDX509_LIBRARY_FILE})
STRING(REGEX REPLACE "^lib" "" MBEDCRYPTO_LIBRARY_FILE ${MBEDCRYPTO_LIBRARY_FILE})
STRING(REGEX REPLACE "^lib" "" TFPSACRYPTO_LIBRARY_FILE ${TFPSACRYPTO_LIBRARY_FILE})
if (TFPSACRYPTO_LIBRARY)
SET(MBEDTLS_CRYPTO_LIBRARY_FILE ${TFPSACRYPTO_LIBRARY_FILE})
elseif (MBEDCRYPTO_LIBRARY)
SET(MBEDTLS_CRYPTO_LIBRARY_FILE ${MBEDCRYPTO_LIBRARY_FILE})
else ()
MESSAGE(FATAL_ERROR "Could not find mbedTLS Crypto library")
endif()
if (MSVC)
SET(MBEDTLS_LIBRARIES ${MBEDTLS_LIBRARY_FILE}.lib ${MBEDX509_LIBRARY_FILE}.lib ${MBEDTLS_CRYPTO_LIBRARY_FILE}.lib)
SET(MBEDTLS_LIBRARIES ${MBEDTLS_LIBRARY_FILE}.lib ${MBEDX509_LIBRARY_FILE}.lib ${MBEDCRYPTO_LIBRARY_FILE}.lib)
else()
SET(MBEDTLS_LIBRARIES "-L${MBEDTLS_LIBRARY_DIR} -l${MBEDTLS_LIBRARY_FILE} -l${MBEDX509_LIBRARY_FILE} -l${MBEDTLS_CRYPTO_LIBRARY_FILE}")
SET(MBEDTLS_LIBRARIES "-L${MBEDTLS_LIBRARY_DIR} -l${MBEDTLS_LIBRARY_FILE} -l${MBEDX509_LIBRARY_FILE} -l${MBEDCRYPTO_LIBRARY_FILE}")
endif()
IF(NOT MBEDTLS_FIND_QUIETLY)

View File

@@ -36,125 +36,105 @@ macro(add_imhex_plugin)
# Define new project for plugin
project(${IMHEX_PLUGIN_NAME})
if (IMHEX_PLUGIN_IMPORTED)
add_library(${IMHEX_PLUGIN_NAME} SHARED IMPORTED GLOBAL)
# Create a new shared library for the plugin source code
add_library(${IMHEX_PLUGIN_NAME} ${IMHEX_PLUGIN_LIBRARY_TYPE} ${IMHEX_PLUGIN_SOURCES})
if (WIN32)
set_target_properties(${IMHEX_PLUGIN_NAME} PROPERTIES
IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/../../../plugins/${IMHEX_PLUGIN_NAME}${IMHEX_PLUGIN_SUFFIX}"
IMPORTED_IMPLIB "${CMAKE_CURRENT_SOURCE_DIR}/../lib${IMHEX_PLUGIN_NAME}.dll.a"
INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/include/include")
elseif (APPLE)
set_target_properties(${IMHEX_PLUGIN_NAME} PROPERTIES
IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/../../../../MacOS/plugins/${IMHEX_PLUGIN_NAME}${IMHEX_PLUGIN_SUFFIX}"
INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/include/include")
else()
set_target_properties(${IMHEX_PLUGIN_NAME} PROPERTIES
IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/../../../plugins/${IMHEX_PLUGIN_NAME}${IMHEX_PLUGIN_SUFFIX}"
INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/include/include")
# Add include directories and link libraries
target_include_directories(${IMHEX_PLUGIN_NAME} PUBLIC ${IMHEX_PLUGIN_INCLUDES})
target_link_libraries(${IMHEX_PLUGIN_NAME} PUBLIC ${IMHEX_PLUGIN_LIBRARIES})
target_link_libraries(${IMHEX_PLUGIN_NAME} PRIVATE libimhex ${FMT_LIBRARIES} imgui_all_includes libwolv)
addIncludesFromLibrary(${IMHEX_PLUGIN_NAME} libpl)
addIncludesFromLibrary(${IMHEX_PLUGIN_NAME} libpl-gen)
precompileHeaders(${IMHEX_PLUGIN_NAME} "${CMAKE_CURRENT_SOURCE_DIR}/include")
# Add IMHEX_PROJECT_NAME and IMHEX_VERSION define
target_compile_definitions(${IMHEX_PLUGIN_NAME} PRIVATE IMHEX_PROJECT_NAME="${IMHEX_PLUGIN_NAME}")
target_compile_definitions(${IMHEX_PLUGIN_NAME} PRIVATE IMHEX_VERSION="${IMHEX_VERSION_STRING}")
target_compile_definitions(${IMHEX_PLUGIN_NAME} PRIVATE IMHEX_PLUGIN_NAME=${IMHEX_PLUGIN_NAME})
# Enable required compiler flags
enableUnityBuild(${IMHEX_PLUGIN_NAME})
setupCompilerFlags(${IMHEX_PLUGIN_NAME})
# Configure build properties
set_target_properties(${IMHEX_PLUGIN_NAME}
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${IMHEX_MAIN_OUTPUT_DIRECTORY}/plugins"
CXX_STANDARD 23
PREFIX ""
SUFFIX ${IMHEX_PLUGIN_SUFFIX}
)
# Set rpath of plugin libraries to the plugins folder
if (WIN32)
if (IMHEX_PLUGIN_LIBRARY_PLUGIN)
set_target_properties(${IMHEX_PLUGIN_NAME} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
endif()
else()
# Create a new shared library for the plugin source code
add_library(${IMHEX_PLUGIN_NAME} ${IMHEX_PLUGIN_LIBRARY_TYPE} ${IMHEX_PLUGIN_SOURCES})
elseif (APPLE)
set_target_properties(${IMHEX_PLUGIN_NAME} PROPERTIES BUILD_RPATH "@executable_path/../Frameworks;@executable_path/plugins")
endif()
# Add include directories and link libraries
target_include_directories(${IMHEX_PLUGIN_NAME} PUBLIC ${IMHEX_PLUGIN_INCLUDES})
target_link_libraries(${IMHEX_PLUGIN_NAME} PUBLIC ${IMHEX_PLUGIN_LIBRARIES})
target_link_libraries(${IMHEX_PLUGIN_NAME} PRIVATE libimhex ${FMT_LIBRARIES} imgui_all_includes libwolv)
addIncludesFromLibrary(${IMHEX_PLUGIN_NAME} libpl)
addIncludesFromLibrary(${IMHEX_PLUGIN_NAME} libpl-gen)
# Setup a romfs for the plugin
list(APPEND LIBROMFS_RESOURCE_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/romfs)
set(LIBROMFS_PROJECT_NAME ${IMHEX_PLUGIN_NAME})
add_subdirectory(${IMHEX_BASE_FOLDER}/lib/external/libromfs ${CMAKE_CURRENT_BINARY_DIR}/libromfs)
target_link_libraries(${IMHEX_PLUGIN_NAME} PRIVATE ${LIBROMFS_LIBRARY})
precompileHeaders(${IMHEX_PLUGIN_NAME} "${CMAKE_CURRENT_SOURCE_DIR}/include")
set(FEATURE_DEFINE_CONTENT)
# Add IMHEX_PROJECT_NAME and IMHEX_VERSION define
target_compile_definitions(${IMHEX_PLUGIN_NAME} PRIVATE IMHEX_PROJECT_NAME="${IMHEX_PLUGIN_NAME}")
target_compile_definitions(${IMHEX_PLUGIN_NAME} PRIVATE IMHEX_VERSION="${IMHEX_VERSION_STRING}")
target_compile_definitions(${IMHEX_PLUGIN_NAME} PRIVATE IMHEX_PLUGIN_NAME=${IMHEX_PLUGIN_NAME})
if (IMHEX_PLUGIN_FEATURES)
list(LENGTH IMHEX_PLUGIN_FEATURES IMHEX_FEATURE_COUNT)
math(EXPR IMHEX_FEATURE_COUNT "${IMHEX_FEATURE_COUNT} - 1" OUTPUT_FORMAT DECIMAL)
foreach(index RANGE 0 ${IMHEX_FEATURE_COUNT} 2)
list(SUBLIST IMHEX_PLUGIN_FEATURES ${index} 2 IMHEX_PLUGIN_FEATURE)
list(GET IMHEX_PLUGIN_FEATURE 0 feature_define)
list(GET IMHEX_PLUGIN_FEATURE 1 feature_description)
# Enable required compiler flags
enableUnityBuild(${IMHEX_PLUGIN_NAME})
setupCompilerFlags(${IMHEX_PLUGIN_NAME})
addCppCheck(${IMHEX_PLUGIN_NAME})
string(TOUPPER ${feature_define} feature_define)
add_definitions(-DIMHEX_PLUGIN_${IMHEX_PLUGIN_NAME}_FEATURE_${feature_define}=0)
set(FEATURE_DEFINE_CONTENT "${FEATURE_DEFINE_CONTENT}{ \"${feature_description}\", IMHEX_FEATURE_ENABLED(${feature_define}) },")
endforeach()
endif()
# Configure build properties
set_target_properties(${IMHEX_PLUGIN_NAME}
target_compile_options(${IMHEX_PLUGIN_NAME} PRIVATE -DIMHEX_PLUGIN_FEATURES_CONTENT=${FEATURE_DEFINE_CONTENT})
# Add the new plugin to the main dependency list so it gets built by default
if (TARGET imhex_all)
add_dependencies(imhex_all ${IMHEX_PLUGIN_NAME})
endif()
if (IMHEX_EXTERNAL_PLUGIN_BUILD)
install(TARGETS ${IMHEX_PLUGIN_NAME} DESTINATION ".")
endif()
# Fix rpath
if (APPLE)
set_target_properties(
${IMHEX_PLUGIN_NAME}
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${IMHEX_MAIN_OUTPUT_DIRECTORY}/plugins"
CXX_STANDARD 23
PREFIX ""
SUFFIX ${IMHEX_PLUGIN_SUFFIX}
)
# Set rpath of plugin libraries to the plugins folder
if (WIN32)
if (IMHEX_PLUGIN_LIBRARY_PLUGIN)
set_target_properties(${IMHEX_PLUGIN_NAME} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
endif()
elseif (APPLE)
set_target_properties(${IMHEX_PLUGIN_NAME} PROPERTIES BUILD_RPATH "@executable_path/../Frameworks;@executable_path/plugins")
endif()
# Setup a romfs for the plugin
list(APPEND LIBROMFS_RESOURCE_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/romfs)
set(LIBROMFS_PROJECT_NAME ${IMHEX_PLUGIN_NAME})
add_subdirectory(${IMHEX_BASE_FOLDER}/lib/external/libromfs ${CMAKE_CURRENT_BINARY_DIR}/libromfs)
target_link_libraries(${IMHEX_PLUGIN_NAME} PRIVATE ${LIBROMFS_LIBRARY})
set(FEATURE_DEFINE_CONTENT)
if (IMHEX_PLUGIN_FEATURES)
list(LENGTH IMHEX_PLUGIN_FEATURES IMHEX_FEATURE_COUNT)
math(EXPR IMHEX_FEATURE_COUNT "${IMHEX_FEATURE_COUNT} - 1" OUTPUT_FORMAT DECIMAL)
foreach(index RANGE 0 ${IMHEX_FEATURE_COUNT} 2)
list(SUBLIST IMHEX_PLUGIN_FEATURES ${index} 2 IMHEX_PLUGIN_FEATURE)
list(GET IMHEX_PLUGIN_FEATURE 0 feature_define)
list(GET IMHEX_PLUGIN_FEATURE 1 feature_description)
string(TOUPPER ${feature_define} feature_define)
add_definitions(-DIMHEX_PLUGIN_${IMHEX_PLUGIN_NAME}_FEATURE_${feature_define}=0)
set(FEATURE_DEFINE_CONTENT "${FEATURE_DEFINE_CONTENT}{ \"${feature_description}\", IMHEX_FEATURE_ENABLED(${feature_define}) },")
endforeach()
endif()
target_compile_options(${IMHEX_PLUGIN_NAME} PRIVATE -DIMHEX_PLUGIN_FEATURES_CONTENT=${FEATURE_DEFINE_CONTENT})
# Add the new plugin to the main dependency list so it gets built by default
if (TARGET imhex_all)
add_dependencies(imhex_all ${IMHEX_PLUGIN_NAME})
endif()
if (IMHEX_EXTERNAL_PLUGIN_BUILD)
install(TARGETS ${IMHEX_PLUGIN_NAME} DESTINATION ".")
endif()
# Fix rpath
if (APPLE)
set_target_properties(
${IMHEX_PLUGIN_NAME}
PROPERTIES
INSTALL_RPATH "@executable_path/../Frameworks;@executable_path/plugins"
)
elseif (UNIX)
set(PLUGIN_RPATH "")
list(APPEND PLUGIN_RPATH "$ORIGIN")
)
elseif (UNIX)
set(PLUGIN_RPATH "")
list(APPEND PLUGIN_RPATH "$ORIGIN")
if (IMHEX_PLUGIN_ADD_INSTALL_PREFIX_TO_RPATH)
list(APPEND PLUGIN_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
endif()
if (IMHEX_PLUGIN_ADD_INSTALL_PREFIX_TO_RPATH)
list(APPEND PLUGIN_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
endif()
set_target_properties(
${IMHEX_PLUGIN_NAME}
PROPERTIES
set_target_properties(
${IMHEX_PLUGIN_NAME}
PROPERTIES
INSTALL_RPATH_USE_ORIGIN ON
INSTALL_RPATH "${PLUGIN_RPATH}"
)
endif()
)
endif()
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/tests/CMakeLists.txt AND IMHEX_ENABLE_UNIT_TESTS AND IMHEX_ENABLE_PLUGIN_TESTS)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tests)
target_link_libraries(${IMHEX_PLUGIN_NAME} PUBLIC ${IMHEX_PLUGIN_NAME}_tests)
target_compile_definitions(${IMHEX_PLUGIN_NAME}_tests PRIVATE IMHEX_PROJECT_NAME="${IMHEX_PLUGIN_NAME}-tests")
endif()
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/tests/CMakeLists.txt AND IMHEX_ENABLE_UNIT_TESTS AND IMHEX_ENABLE_PLUGIN_TESTS)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tests)
target_link_libraries(${IMHEX_PLUGIN_NAME} PUBLIC ${IMHEX_PLUGIN_NAME}_tests)
target_compile_definitions(${IMHEX_PLUGIN_NAME}_tests PRIVATE IMHEX_PROJECT_NAME="${IMHEX_PLUGIN_NAME}-tests")
endif()
endmacro()

View File

@@ -38,36 +38,20 @@ add_subdirectory(lib/external/libwolv EXCLUDE_FROM_ALL)
set(LIBPL_ENABLE_CLI OFF CACHE BOOL "" FORCE)
add_subdirectory(lib/external/pattern_language EXCLUDE_FROM_ALL)
set(IMHEX_PLUGIN_IMPORTED ON)
add_subdirectory(lib/libimhex)
add_subdirectory(lib/trace)
add_subdirectory(lib/fonts)
add_subdirectory(lib/ui)
set(IMHEX_PLUGIN_IMPORTED OFF)
if (WIN32)
set_target_properties(libimhex PROPERTIES
IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/../libimhex.dll"
IMPORTED_IMPLIB "${CMAKE_CURRENT_SOURCE_DIR}/lib/liblibimhex.dll.a"
INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/lib/libimhex/include")
set_target_properties(tracing PROPERTIES
IMPORTED_IMPLIB "${CMAKE_CURRENT_SOURCE_DIR}/lib/libtracing.a"
INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/lib/trace/include")
elseif (APPLE)
file(GLOB LIBIMHEX_DYLIB "${CMAKE_CURRENT_SOURCE_DIR}/../../Frameworks/libimhex.*.dylib")
set_target_properties(libimhex PROPERTIES
IMPORTED_LOCATION "${LIBIMHEX_DYLIB}"
INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/lib/libimhex/include")
set_target_properties(tracing PROPERTIES
IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/../libtracing.a"
INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/lib/trace/include")
else()
set_target_properties(libimhex PROPERTIES
IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/../../../lib/libimhex.so"
IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/../libimhex.so"
INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/lib/libimhex/include")
set_target_properties(tracing PROPERTIES
IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/lib/libtracing.a"
INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/lib/trace/include")
endif()

View File

@@ -1,7 +1,7 @@
#include <hex/plugin.hpp>
// Browse through the headers in lib/libimhex/include/hex/api/ to see what you can do with the API.
// Most important ones are the things under imhex_api and content_registry
// Most important ones are <hex/api/imhex_api.hpp> and <hex/api/content_registry.hpp>
// This is the main entry point of your plugin. The code in the body of this construct will be executed
// when ImHex starts up and loads the plugin.

View File

@@ -11,16 +11,12 @@ AppDir:
exec_args: $@
apt:
arch:
- all
- "{{ARCHITECTURE_PACKAGE}}"
allow_unauthenticated: true
sources:
- sourceline: 'deb [arch=amd64] https://us.archive.ubuntu.com/ubuntu/ noble main restricted universe multiverse'
- sourceline: 'deb [arch=arm64] https://ports.ubuntu.com/ubuntu-ports/ noble main restricted universe multiverse'
- sourceline: 'deb [arch=amd64] http://us.archive.ubuntu.com/ubuntu/ oracular main restricted universe multiverse'
- sourceline: 'deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ oracular main restricted universe multiverse'
include:
- libgdk-pixbuf2.0-0
- libgdk-pixbuf2.0-common
- shared-mime-info
- librsvg2-common
- libbz2-1.0
- libcap2
@@ -32,115 +28,102 @@ AppDir:
- libpcre3
- libselinux1
- libtinfo6
- libmd4c-dev
- libmd4c-html0-dev
files:
include:
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libLLVM-13.so.1"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libOpenGL.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libX11.so.6"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libXau.so.6"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libXcomposite.so.1"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libXcursor.so.1"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libXdamage.so.1"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libXdmcp.so.6"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libXext.so.6"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libXfixes.so.3"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libXi.so.6"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libXinerama.so.1"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libXrandr.so.2"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libXrender.so.1"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libXxf86vm.so.1"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libatk-1.0.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libatk-bridge-2.0.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libatspi.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libblkid.so.1"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libbrotlicommon.so.1"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libbrotlidec.so.1"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libbsd.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libcairo-gobject.so.2"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libcairo.so.2"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libcurl-gnutls.so.4"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libdatrie.so.1"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libedit.so.2"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libelf.so.1"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libepoxy.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libffi.so.8"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libfontconfig.so.1"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libfreetype.so.6"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libfribidi.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libgcrypt.so.20"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libgdk-3.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libgdk_pixbuf-2.0.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libgio-2.0.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libglfw.so.3"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libglib-2.0.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libgmodule-2.0.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libgmp.so.10"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libgnutls.so.30"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libgobject-2.0.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libgraphite2.so.3"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libharfbuzz.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libhogweed.so.6"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libicudata.so.70"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libicuuc.so.70"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libidn2.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libjpeg.so.8"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/liblber-2.5.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libldap-2.5.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/liblz4.so.1"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libmagic.so.1"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libmbedcrypto.so.7"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libmbedtls.so.14"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libmbedx509.so.1"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libmd.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libmount.so.1"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libnettle.so.8"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libp11-kit.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libpango-1.0.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libpangocairo-1.0.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libpangoft2-1.0.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libpcre2-8.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libpixman-1.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libpng16.so.16"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libsasl2.so.2"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libsensors.so.5"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libstdc++.so.6"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libsystemd.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libtasn1.so.6"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libthai.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libunistring.so.2"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libuuid.so.1"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libvulkan.so.1"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libwayland-client.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libwayland-cursor.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libwayland-egl.so.1"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libxcb-dri2.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libxcb-dri3.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libxcb-present.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libxcb-sync.so.1"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libxkbcommon.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libxml2.so.2"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libxshmfence.so.1"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libzstd.so.1"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libmd4c.so"
- /lib/x86_64-linux-gnu/libLLVM-13.so.1
- /lib/x86_64-linux-gnu/libOpenGL.so.0
- /lib/x86_64-linux-gnu/libX11.so.6
- /lib/x86_64-linux-gnu/libXau.so.6
- /lib/x86_64-linux-gnu/libXcomposite.so.1
- /lib/x86_64-linux-gnu/libXcursor.so.1
- /lib/x86_64-linux-gnu/libXdamage.so.1
- /lib/x86_64-linux-gnu/libXdmcp.so.6
- /lib/x86_64-linux-gnu/libXext.so.6
- /lib/x86_64-linux-gnu/libXfixes.so.3
- /lib/x86_64-linux-gnu/libXi.so.6
- /lib/x86_64-linux-gnu/libXinerama.so.1
- /lib/x86_64-linux-gnu/libXrandr.so.2
- /lib/x86_64-linux-gnu/libXrender.so.1
- /lib/x86_64-linux-gnu/libXxf86vm.so.1
- /lib/x86_64-linux-gnu/libatk-1.0.so.0
- /lib/x86_64-linux-gnu/libatk-bridge-2.0.so.0
- /lib/x86_64-linux-gnu/libatspi.so.0
- /lib/x86_64-linux-gnu/libblkid.so.1
- /lib/x86_64-linux-gnu/libbrotlicommon.so.1
- /lib/x86_64-linux-gnu/libbrotlidec.so.1
- /lib/x86_64-linux-gnu/libbsd.so.0
- /lib/x86_64-linux-gnu/libcairo-gobject.so.2
- /lib/x86_64-linux-gnu/libcairo.so.2
- /lib/x86_64-linux-gnu/libcurl-gnutls.so.4
- /lib/x86_64-linux-gnu/libdatrie.so.1
- /lib/x86_64-linux-gnu/libedit.so.2
- /lib/x86_64-linux-gnu/libelf.so.1
- /lib/x86_64-linux-gnu/libepoxy.so.0
- /lib/x86_64-linux-gnu/libffi.so.8
- /lib/x86_64-linux-gnu/libfontconfig.so.1
- /lib/x86_64-linux-gnu/libfreetype.so.6
- /lib/x86_64-linux-gnu/libfribidi.so.0
- /lib/x86_64-linux-gnu/libgcrypt.so.20
- /lib/x86_64-linux-gnu/libgdk-3.so.0
- /lib/x86_64-linux-gnu/libgdk_pixbuf-2.0.so.0
- /lib/x86_64-linux-gnu/libgio-2.0.so.0
- /lib/x86_64-linux-gnu/libglfw.so.3
- /lib/x86_64-linux-gnu/libglib-2.0.so.0
- /lib/x86_64-linux-gnu/libgmodule-2.0.so.0
- /lib/x86_64-linux-gnu/libgmp.so.10
- /lib/x86_64-linux-gnu/libgnutls.so.30
- /lib/x86_64-linux-gnu/libgobject-2.0.so.0
- /lib/x86_64-linux-gnu/libgraphite2.so.3
- /lib/x86_64-linux-gnu/libharfbuzz.so.0
- /lib/x86_64-linux-gnu/libhogweed.so.6
- /lib/x86_64-linux-gnu/libicudata.so.70
- /lib/x86_64-linux-gnu/libicuuc.so.70
- /lib/x86_64-linux-gnu/libidn2.so.0
- /lib/x86_64-linux-gnu/libjpeg.so.8
- /lib/x86_64-linux-gnu/liblber-2.5.so.0
- /lib/x86_64-linux-gnu/libldap-2.5.so.0
- /lib/x86_64-linux-gnu/liblz4.so.1
- /lib/x86_64-linux-gnu/libmagic.so.1
- /lib/x86_64-linux-gnu/libmbedcrypto.so.7
- /lib/x86_64-linux-gnu/libmbedtls.so.14
- /lib/x86_64-linux-gnu/libmbedx509.so.1
- /lib/x86_64-linux-gnu/libmd.so.0
- /lib/x86_64-linux-gnu/libmount.so.1
- /lib/x86_64-linux-gnu/libnettle.so.8
- /lib/x86_64-linux-gnu/libp11-kit.so.0
- /lib/x86_64-linux-gnu/libpango-1.0.so.0
- /lib/x86_64-linux-gnu/libpangocairo-1.0.so.0
- /lib/x86_64-linux-gnu/libpangoft2-1.0.so.0
- /lib/x86_64-linux-gnu/libpcre2-8.so.0
- /lib/x86_64-linux-gnu/libpixman-1.so.0
- /lib/x86_64-linux-gnu/libpng16.so.16
- /lib/x86_64-linux-gnu/libsasl2.so.2
- /lib/x86_64-linux-gnu/libsensors.so.5
- /lib/x86_64-linux-gnu/libstdc++.so.6
- /lib/x86_64-linux-gnu/libsystemd.so.0
- /lib/x86_64-linux-gnu/libtasn1.so.6
- /lib/x86_64-linux-gnu/libthai.so.0
- /lib/x86_64-linux-gnu/libunistring.so.2
- /lib/x86_64-linux-gnu/libuuid.so.1
- /lib/x86_64-linux-gnu/libvulkan.so.1
- /lib/x86_64-linux-gnu/libwayland-client.so.0
- /lib/x86_64-linux-gnu/libwayland-cursor.so.0
- /lib/x86_64-linux-gnu/libwayland-egl.so.1
- /lib/x86_64-linux-gnu/libxcb-dri2.so.0
- /lib/x86_64-linux-gnu/libxcb-dri3.so.0
- /lib/x86_64-linux-gnu/libxcb-present.so.0
- /lib/x86_64-linux-gnu/libxcb-sync.so.1
- /lib/x86_64-linux-gnu/libxkbcommon.so.0
- /lib/x86_64-linux-gnu/libxml2.so.2
- /lib/x86_64-linux-gnu/libxshmfence.so.1
- /lib/x86_64-linux-gnu/libzstd.so.1
exclude:
- usr/share/man
- usr/share/doc/*/README.*
- usr/share/doc/*/changelog.*
- usr/share/doc/*/NEWS.*
- usr/share/doc/*/TODO.*
runtime:
env:
APPDIR_LIBRARY_PATH: '$APPDIR/usr/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu:$APPDIR/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu:$APPDIR/usr/lib:$APPDIR/usr/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/gdk-pixbuf-2.0/2.10.0/loaders'
GTK_EXE_PREFIX: $APPDIR/usr
GTK_DATA_PREFIX: $APPDIR
XDG_DATA_DIRS: '/usr/local/share:/usr/share:$APPDIR/usr/share:$XDG_DATA_DIRS:$APPDIR/usr/local/share:$APPDIR/usr/local/lib:$APPDIR/usr/local/share'
XDG_CONFIG_DIRS: '$XDG_CONFIG_DIRS:$APPDIR/usr/local/share'
AppImage:
arch: "{{ARCHITECTURE_APPIMAGE_BUILDER}}"
comp: zstd
update-information: gh-releases-zsync|WerWolv|ImHex|latest|imhex-*-{{ARCHITECTURE_FILE_NAME}}.AppImage.zsync
file_name: imhex-{{VERSION}}-{{ARCHITECTURE_FILE_NAME}}.AppImage

View File

@@ -1,4 +1,4 @@
FROM ubuntu:24.04 as build
FROM ubuntu:24.10 as build
# Used to invalidate layer cache but not mount cache
# See https://github.com/moby/moby/issues/41715#issuecomment-733976493
@@ -30,9 +30,9 @@ ARG LTO=ON
ARG BUILD_TYPE=RelWithDebInfo
ARG GIT_COMMIT_HASH
ARG GIT_BRANCH
ARG ARCHITECTURE_PACKAGE=x86_64
ARG ARCHITECTURE_FILE_NAME=amd64
ARG ARCHITECTURE_APPIMAGE_BUILDER=x86_64
ARG ARCHITECTURE_PACKAGE
ARG ARCHITECTURE_FILE_NAME
ARG ARCHITECTURE_APPIMAGE_BUILDER
WORKDIR /build
# Ubuntu sh doesnt support string substitution
@@ -42,18 +42,16 @@ RUN <<EOF
# Prepare ImHex build
set -xe
CC=gcc-14 CXX=g++-14 cmake -G "Ninja" \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
-DCMAKE_INSTALL_PREFIX="/usr" \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DIMHEX_PATTERNS_PULL_MASTER=ON \
-DIMHEX_COMMIT_HASH_LONG="${GIT_COMMIT_HASH}" \
-DIMHEX_COMMIT_BRANCH="${GIT_BRANCH}" \
-DIMHEX_ENABLE_LTO=${LTO} \
-DIMHEX_BUNDLE_PLUGIN_SDK=OFF \
`# To prevent using a libdir with an architecture-specific name` \
-DCMAKE_INSTALL_LIBDIR="lib" \
CC=gcc-14 CXX=g++-14 cmake -G "Ninja" \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
-DCMAKE_INSTALL_PREFIX="/usr" \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DIMHEX_PATTERNS_PULL_MASTER=ON \
-DIMHEX_COMMIT_HASH_LONG="${GIT_COMMIT_HASH}" \
-DIMHEX_COMMIT_BRANCH="${GIT_BRANCH}" \
-DIMHEX_ENABLE_LTO=${LTO} \
-DIMHEX_PLUGINS_IN_SHARE=ON \
/imhex
EOF
@@ -72,12 +70,12 @@ RUN <<EOF
set -xe
mkdir -p /cache/bin
wget -nc https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage -O /cache/bin/appimagetool || true
wget -nc https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage -O /cache/bin/appimagetool || true
chmod +x /cache/bin/appimagetool
python3 -m venv venv
. venv/bin/activate
pip3 install git+https://github.com/AppImageCrafters/appimage-builder@e995e8e
pip3 install git+https://github.com/AppImageCrafters/appimage-builder@f38699e
# Package ImHex as AppImage
export VERSION=$(cat /imhex/VERSION)

View File

@@ -17,9 +17,7 @@ RUN pacman -S --needed --noconfirm \
freetype2 \
curl \
dbus \
xdg-desktop-portal \
libssh2 \
md4c
xdg-desktop-portal
# Clone ImHex
RUN git clone https://github.com/WerWolv/ImHex --recurse-submodules /root/ImHex

4
dist/Arch/PKGBUILD vendored
View File

@@ -8,8 +8,8 @@ pkgdesc="A Hex Editor for Reverse Engineers, Programmers and people who value th
arch=("x86_64")
url="https://github.com/WerWolv/ImHex"
license=('GPL2')
depends=(glfw mbedtls fontconfig freetype2 libglvnd dbus gtk3 curl fmt yara zlib bzip2 xz zstd libssh2)
makedepends=(git nlohmann-json)
depends=(glfw mbedtls fontconfig freetype2 libglvnd dbus gtk3 curl fmt yara nlohmann-json zlib bzip2 xz zstd)
makedepends=(git)
provides=(imhex)
conflicts=(imhex)
source=("$url/releases/download/v$pkgver/imhex-$pkgver-ArchLinux-x86_64.pkg.tar.zst")

View File

@@ -4,7 +4,7 @@ Section: editors
Priority: optional
Architecture: amd64
License: GNU GPL-2
Depends: libfontconfig1, libglfw3 | libglfw3-wayland, libmagic1, libmbedtls14, libfreetype6, libopengl0, libdbus-1-3, xdg-desktop-portal, libssh2-1, libmd4c0
Depends: libfontconfig1, libglfw3 | libglfw3-wayland, libmagic1, libmbedtls14, libfreetype6, libopengl0, libdbus-1-3, xdg-desktop-portal
Maintainer: WerWolv <hey@werwolv.net>
Description: ImHex Hex Editor
A Hex Editor for Reverse Engineers, Programmers and

View File

@@ -21,6 +21,7 @@ RDEPEND="${DEPEND}
media-libs/glfw
sys-apps/file
net-libs/mbedtls
dev-cpp/nlohmann_json
sys-apps/dbus
sys-apps/xdg-desktop-portal
sys-libs/zlib
@@ -28,9 +29,5 @@ RDEPEND="${DEPEND}
app-arch/lzma
app-arch/zstd
app-arch/lz4
net-libs/libssh2
dev-libs/md4c
"
BDEPEND="${DEPEND}
dev-cpp/nlohmann_json
"
BDEPEND="${DEPEND}"

13
dist/ImHex.run.xml vendored
View File

@@ -1,13 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="ImHex" type="CMakeRunConfiguration" factoryName="Application" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" EMULATE_TERMINAL="false" WORKING_DIR="file://$CMakeCurrentBuildDir$" PASS_PARENT_ENVS_2="true" PROJECT_NAME="ImHex" TARGET_NAME="imhex_all" CONFIG_NAME="Debug" RUN_TARGET_PROJECT_NAME="ImHex" RUN_TARGET_NAME="main">
<envs>
<env name="NO_DEBUG_BANNER" value="1" />
</envs>
<method v="2">
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
</method>
</configuration>
<configuration default="false" name="CMake Debug" type="CMakeListConfigurationType" factoryName="CMakeListConfigurationFactory">
<method v="2" />
</configuration>
</component>

3
dist/cli/imhex.bat vendored
View File

@@ -1,3 +0,0 @@
@echo off
start "" "%~dp0..\imhex.exe" %*

5
dist/cli/imhex.sh vendored
View File

@@ -1,5 +0,0 @@
#!/bin/sh
script_path=$(readlink -f "$0")
script_dir=$(dirname "${script_path}")
"${script_dir}/../imhex" "$@" > /dev/null 2>&1 &

View File

@@ -9,7 +9,7 @@ On Linux, ImHex is built through regular GCC (or optionally Clang).
cd ImHex
mkdir -p build
cd build
CC=gcc-14 CXX=g++-14 \
CC=gcc-12 CXX=g++-12 \
cmake -G "Ninja" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX="/usr" \

View File

@@ -3,7 +3,7 @@
On macOS, ImHex is built through regular GCC and LLVM clang.
1. Clone the repo using `git clone https://github.com/WerWolv/ImHex --recurse-submodules`
2. Install all the dependencies using `brew bundle --file dist/macOS/Brewfile`
2. Install all the dependencies using `brew bundle --no-lock --file dist/macOS/Brewfile`
3. Build ImHex itself using the following commands:
```sh
cd ImHex
@@ -20,5 +20,3 @@ cmake -G "Ninja" \
..
ninja install
```
If your MacOS installation doesn't have graphic acceleration, you can check the [MacOS NoGPU guide](./macos_nogpu.md)

View File

@@ -1,10 +0,0 @@
### Compiling and running ImHex on macOS without a GPU
In order to run ImHex on a macOS installation without a GPU, you need a custom build of GLFW. You can build it this way:
Note: only tested on macOS x86
1. `git clone --depth 1 https://github.com/glfw/glfw`
2. `git apply {IMHEX_DIR}/dist/macOS/0001-glfw-SW.patch` (file is [here](../macOS/0001-glfw-SW.patch) in the ImHex repository. [Source](https://github.com/glfw/glfw/issues/2080).)
3. `cmake -G "Ninja" -DBUILD_SHARED_LIBS=ON ..`
4. `ninja install`, or `ninja` and figure out how to make ImHex detect the shared library

20
dist/cppcheck.supp vendored
View File

@@ -1,20 +0,0 @@
missingIncludeSystem
constParameter
unusedFunction
preprocessorErrorDirective
checkersReport
noExplicitConstructor
unmatchedSuppression
useInitializationList
useStlAlgorithm
knownConditionTrueFalse
internalAstError
unsignedPositive
variableScope
unusedPrivateFunction
constParameterCallback
*:*/lib/third_party/*
*:*/external/pattern_language/external/*
*:*/external/disassembler/external/*
*:*/lib/libimhex/source/ui/imgui_imhex_extensions.cpp

54
dist/flake.nix vendored
View File

@@ -1,54 +0,0 @@
{
description = "ImHex";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs = { self, nixpkgs }:
let
supportedSystems = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin" ];
forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems (system: f system);
in {
devShells = forAllSystems (system:
let
pkgs = import nixpkgs { inherit system; };
in
{
default = pkgs.mkShell {
buildInputs = [
pkgs.cmake
pkgs.clang
pkgs.lld
pkgs.nghttp3
pkgs.pkg-config
pkgs.glfw
pkgs.fontconfig
pkgs.file
pkgs.mbedtls
pkgs.freetype
pkgs.dbus
pkgs.gtk3
pkgs.curl
pkgs.fmt
pkgs.yara
pkgs.nlohmann_json
pkgs.ninja
pkgs.zlib
pkgs.bzip2
pkgs.xz
pkgs.zstd
pkgs.lz4
pkgs.libssh2
pkgs.md4c
];
shellHook = ''
export CC=${pkgs.clang}/bin/clang
export CXX=${pkgs.clang}/bin/clang++
'';
};
});
};
}

View File

@@ -1,139 +0,0 @@
app-id: net.werwolv.ImHex
runtime: org.freedesktop.Platform
runtime-version: '24.08'
sdk: org.freedesktop.Sdk
command: imhex
rename-desktop-file: imhex.desktop
finish-args:
- --share=ipc
- --share=network
- --socket=wayland
- --socket=fallback-x11
- --filesystem=host
- --device=dri
modules:
- name: glfw
buildsystem: cmake-ninja
builddir: true
config-opts:
- -DBUILD_SHARED_LIBS=ON
- -DGLFW_BUILD_EXAMPLES=OFF
- -DGLFW_BUILD_TESTS=OFF
- -DGLFW_BUILD_DOCS=OFF
sources:
- type: archive
url: https://github.com/glfw/glfw/releases/download/3.4/glfw-3.4.zip
sha256: b5ec004b2712fd08e8861dc271428f048775200a2df719ccf575143ba749a3e9
cleanup:
- /include
- /lib/pkgconfig
- /lib/pkgconfig
- /lib64/pkgconfig
- /lib/cmake
- /lib64/cmake
- name: mbedtls
buildsystem: cmake-ninja
config-opts:
- -DCMAKE_C_FLAGS=-fPIC
- -DENABLE_TESTING=OFF
- -DENABLE_PROGRAMS=OFF
sources:
- type: archive
url: https://github.com/ARMmbed/mbedtls/archive/refs/tags/v3.4.0.tar.gz
sha256: 1b899f355022e8d02c4d313196a0a16af86c5a692456fa99d302915b8cf0320a
cleanup:
- /include
- /lib/pkgconfig
- /lib64/pkgconfig
- /lib/cmake
- /lib64/cmake
- name: fmt
buildsystem: cmake-ninja
config-opts:
- -DBUILD_SHARED_LIBS=ON
- -DFMT_TEST=OFF
sources:
- type: archive
url: https://github.com/fmtlib/fmt/releases/download/10.0.0/fmt-10.0.0.zip
sha256: 4943cb165f3f587f26da834d3056ee8733c397e024145ca7d2a8a96bb71ac281
cleanup:
- /include
- /lib/pkgconfig
- /lib64/pkgconfig
- /lib/cmake
- /lib64/cmake
- name: yara
buildsystem: autotools
sources:
- type: git
url: https://github.com/VirusTotal/yara.git
tag: v4.3.1
commit: a6f6ce1d6d74a03c396660db25765f2a794d9e30
cleanup:
- /include
- /lib/pkgconfig
- /lib64/pkgconfig
- /lib/cmake
- /lib64/cmake
- name: libssh2
buildsystem: cmake-ninja
config-opts:
- -DBUILD_SHARED_LIBS=ON
- -DENABLE_ZLIB_COMPRESSION=OFF
- -DENABLE_MANUAL=OFF
- -DENABLE_EXAMPLES=OFF
- -DENABLE_TESTING=OFF
sources:
- type: git
url: https://github.com/libssh2/libssh2.git
tag: libssh2-1.11.1
cleanup:
- /include
- /lib/pkgconfig
- /lib64/pkgconfig
- /lib/cmake
- /lib64/cmake
- name: md4c
buildsystem: cmake-ninja
config-opts:
- -DBUILD_SHARED_LIBS=ON
- -DMD4C_BUILD_TESTS=OFF
- -DMD4C_BUILD_EXAMPLES=OFF
- -DMD4C_BUILD_DOCS=OFF
sources:
- type: git
url: https://github.com/mity/md4c.git
tag: release-0.5.2
- name: imhex
buildsystem: cmake-ninja
builddir: true
config-opts:
- -DUSE_SYSTEM_CURL=ON
- -DUSE_SYSTEM_FMT=ON
- -DUSE_SYSTEM_YARA=ON
- -DIMHEX_OFFLINE_BUILD=ON
- -DIMHEX_BUNDLE_PLUGIN_SDK=OFF
- -DCMAKE_INSTALL_LIBDIR=lib
- -DCMAKE_INSTALL_RPATH='$ORIGIN/../lib:$ORIGIN/../lib64'
sources:
- type: dir
path: ../..
- type: git
url: https://github.com/WerWolv/ImHex-Patterns.git
tag: master
dest: ImHex-Patterns
x-checker-data:
type: git
tag-pattern: ^ImHex-v([\d.]+)$
post-install:
- mkdir -p ${FLATPAK_DEST}/share/icons/hicolor/scalable/apps
- cp ${FLATPAK_DEST}/share/pixmaps/imhex.svg ${FLATPAK_DEST}/share/icons/hicolor/scalable/apps/${FLATPAK_ID}.svg
- desktop-file-edit --set-key="Icon" --set-value="${FLATPAK_ID}" "${FLATPAK_DEST}/share/applications/imhex.desktop"

View File

@@ -1,69 +0,0 @@
from fontTools.ttLib import TTFont
from fontTools.ttLib.tables._c_m_a_p import CmapSubtable
import argparse
# Default PUAs
SOURCE_PUA_START = 0xEA00
SOURCE_PUA_END = 0x100F2
TARGET_PUA_START = 0xF0000
def move_pua_glyphs(input_font_path, output_font_path):
font = TTFont(input_font_path)
cmap_table = font['cmap']
glyph_set = font.getGlyphSet()
# Track moved glyphs
moved = 0
new_mapping = {}
# Collect original mappings in the PUA
for cmap in cmap_table.tables:
if cmap.isUnicode():
for codepoint, glyph_name in cmap.cmap.items():
if SOURCE_PUA_START <= codepoint <= SOURCE_PUA_END:
offset = codepoint - SOURCE_PUA_START
new_codepoint = TARGET_PUA_START + offset
new_mapping[new_codepoint] = glyph_name
moved += 1
if moved == 0:
print("No glyphs found in the source Private Use Area.")
return
# Remove old PUA entries from existing cmap subtables
for cmap in cmap_table.tables:
if cmap.isUnicode():
cmap.cmap = {
cp: gn for cp, gn in cmap.cmap.items()
if not (SOURCE_PUA_START <= cp <= SOURCE_PUA_END)
}
# Create or update a format 12 cmap subtable
found_format12 = False
for cmap in cmap_table.tables:
if cmap.format == 12 and cmap.platformID == 3 and cmap.platEncID in (10, 1):
cmap.cmap.update(new_mapping)
found_format12 = True
break
if not found_format12:
# Create a new format 12 subtable
cmap12 = CmapSubtable.newSubtable(12)
cmap12.platformID = 3
cmap12.platEncID = 10 # UCS-4
cmap12.language = 0
cmap12.cmap = new_mapping
cmap_table.tables.append(cmap12)
print(f"Moved {moved} glyphs from U+{SOURCE_PUA_START:X}U+{SOURCE_PUA_END:X} to U+{TARGET_PUA_START:X}+")
font.save(output_font_path)
print(f"Saved modified font to {output_font_path}")
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Move PUA glyphs in a TTF file to another Unicode range.")
parser.add_argument("input", help="Input TTF file path")
parser.add_argument("output", help="Output TTF file path")
args = parser.parse_args()
move_pua_glyphs(args.input, args.output)

View File

@@ -1,60 +0,0 @@
import argparse
from fontTools.ttLib import TTFont
import os
def unicode_to_utf8_escape(codepoint):
return ''.join([f'\\x{b:02x}' for b in chr(codepoint).encode('utf-8')])
def format_macro_name(prefix, glyph_name):
# Convert names like 'repo-forked' -> 'ICON_VS_REPO_FORKED'
return "ICON_" + prefix + "_" + glyph_name.upper().replace('-', '_')
def generate_font_header(font_path, output_path, font_macro_name, font_file_macro):
font = TTFont(font_path)
# Use cmap to get Unicode to glyph mapping
codepoint_to_names = {}
for table in font["cmap"].tables:
if table.isUnicode():
for codepoint, glyph_name in table.cmap.items():
codepoint_to_names.setdefault(codepoint, []).append(glyph_name)
if not codepoint_to_names:
print("No Unicode-mapped glyphs found in the font.")
return
# Remove any glyph that is lower than 0xFF
codepoint_to_names = {cp: names for cp, names in codepoint_to_names.items() if cp >= 0xFF}
min_cp = min(codepoint_to_names)
max_cp = max(codepoint_to_names)
with open(output_path, "w", encoding="utf-8") as out:
out.write("#pragma once\n\n")
out.write(f'#define FONT_ICON_FILE_NAME_{font_macro_name} "{font_file_macro}"\n\n')
out.write(f"#define ICON_MIN_{font_macro_name} 0x{min_cp:04x}\n")
out.write(f"#define ICON_MAX_16_{font_macro_name} 0x{max_cp:04x}\n")
out.write(f"#define ICON_MAX_{font_macro_name} 0x{max_cp:04x}\n")
written = set()
for codepoint in sorted(codepoint_to_names):
utf8 = unicode_to_utf8_escape(codepoint)
comment = f"// U+{codepoint:04X}"
glyph_names = sorted(set(codepoint_to_names[codepoint]))
for i, glyph_name in enumerate(glyph_names):
macro = format_macro_name(font_macro_name, glyph_name)
if macro in written:
continue
out.write(f"#define {macro} \"{utf8}\"\t{comment}\n")
written.add(macro)
print(f"Header generated at {output_path}")
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Generate C header file from TTF glyphs.")
parser.add_argument("font", help="Input .ttf font file")
parser.add_argument("output", help="Output .h file")
parser.add_argument("macro_name", help="Macro prefix")
args = parser.parse_args()
generate_font_header(args.font, args.output, args.macro_name, os.path.basename(args.font))

View File

@@ -32,17 +32,11 @@ def main(args: list) -> int:
sorted_commits = {}
for commit in master_commits:
if commit == "":
continue
category, commit_name = commit.split(":", 1)
try:
category, commit_name = commit.split(":", 1)
if category not in sorted_commits:
sorted_commits[category] = []
sorted_commits[category].append(commit_name)
except:
print(f"Failed to parse commit: {commit}")
if category not in sorted_commits:
sorted_commits[category] = []
sorted_commits[category].append(commit_name)
for category in sorted_commits:
print(f"## {category}\n")

View File

@@ -20,6 +20,4 @@ pacman -S $@ --needed \
bzip2 \
xz \
zstd \
lz4 \
libssh2 \
md4c
lz4

View File

@@ -28,7 +28,4 @@ apt install -y \
libbz2-dev \
liblzma-dev \
libzstd-dev \
liblz4-dev \
libssh2-1-dev \
libmd4c-dev \
libmd4c-html0-dev
liblz4-dev

View File

@@ -18,5 +18,4 @@ dnf install -y \
zlib-devel \
bzip2-devel \
xz-devel \
lz4-devel \
libssh2-devel
lz4-devel

View File

@@ -1,23 +1,21 @@
#!/usr/bin/env sh
pacman -S --needed --noconfirm pactoys unzip git
pacman -S --needed --noconfirm pactoys unzip
pacboy -S --needed --noconfirm \
gcc:p \
lld:p \
cmake:p \
ccache:p \
glfw:p \
file:p \
curl-winssl:p \
mbedtls:p \
freetype:p \
dlfcn:p \
ninja:p \
capstone:p \
zlib:p \
bzip2:p \
xz:p \
zstd:p \
lz4:p \
libssh2-wincng:p \
md4c:p
gcc:p \
lld:p \
cmake:p \
ccache:p \
glfw:p \
file:p \
curl-winssl:p \
mbedtls:p \
freetype:p \
dlfcn:p \
ninja:p \
capstone:p \
zlib:p \
bzip2:p \
xz:p \
zstd:p \
lz4:p

View File

@@ -18,6 +18,4 @@ zypper install \
zlib-devel \
bzip3-devel \
xz-devel \
lz4-dev \
libssh2-devel \
md4c-devel
lz4-dev

47
dist/langtool.py vendored
View File

@@ -92,7 +92,18 @@ def main():
with lang_file_path.open("w", encoding="utf-8") as new_lang_file:
new_lang_data = {
"code": lang,
"language": (
exist_lang_data["language"]
if exist_lang_data
else input("Enter language name: ")
),
"country": (
exist_lang_data["country"]
if exist_lang_data
else input("Enter country name: ")
),
"translations": {},
}
json.dump(new_lang_data, new_lang_file, indent=4, ensure_ascii=False)
@@ -113,10 +124,10 @@ def main():
with lang_file_path.open("r+", encoding="utf-8") as target_lang_file:
lang_data = json.load(target_lang_file)
for key, value in default_lang_data.items():
for key, value in default_lang_data["translations"].items():
has_translation = (
key in lang_data
and lang_data[key] != INVALID_TRANSLATION
key in lang_data["translations"]
and lang_data["translations"][key] != INVALID_TRANSLATION
)
if (
has_translation
@@ -129,7 +140,7 @@ def main():
continue
if command == "check":
print(
f"Error: Translation {lang_file_path} is missing translation for key '{key}'"
f"Error: Translation {lang_data['code']} is missing translation for key '{key}'"
)
elif (
command == "translate"
@@ -139,45 +150,45 @@ def main():
if command == "untranslate" and not has_translation:
continue
reference_tranlsation = (
" '%s'" % reference_lang_data[key]
" '%s'" % reference_lang_data["translations"][key]
if (
reference_lang_data
and key in reference_lang_data
and key in reference_lang_data["translations"]
)
else ""
)
print(
f"\033[1m'{key}' '{value}'{reference_tranlsation}\033[0m => ",
f"\033[1m'{key}' '{value}'{reference_tranlsation}\033[0m => {lang_data['language']}",
end="",
)
if has_translation:
translation = lang_data[key]
translation = lang_data["translations"][key]
print(f" <= \033[1m'{translation}'\033[0m")
print() # for a new line
if command == "untranslate":
lang_data[key] = INVALID_TRANSLATION
lang_data["translations"][key] = INVALID_TRANSLATION
continue
try:
new_value = input("=> ")
lang_data[key] = new_value
lang_data["translations"][key] = new_value
except KeyboardInterrupt:
break
elif command == "update" or command == "create":
lang_data[key] = INVALID_TRANSLATION
lang_data["translations"][key] = INVALID_TRANSLATION
elif command == "fmtzh":
if has_translation:
lang_data[key] = fmtzh(
lang_data[key]
lang_data["translations"][key] = fmtzh(
lang_data["translations"][key]
)
keys_to_remove = []
for key, value in lang_data.items():
if key not in default_lang_data:
for key, value in lang_data["translations"].items():
if key not in default_lang_data["translations"]:
keys_to_remove.append(key)
for key in keys_to_remove:
lang_data.pop(key)
lang_data["translations"].pop(key)
print(
f"Removed unused key '{key}' from translation '{lang_file_path}'"
f"Removed unused key '{key}' from translation '{lang_data['code']}'"
)
target_lang_file.seek(0)

View File

@@ -1,5 +1,5 @@
From 9c8665af4c2e2ce66555c15c05c72027bfdf0cb6 Mon Sep 17 00:00:00 2001
From: iTrooz <hey@itrooz.fr>
From: iTrooz <itrooz@protonmail.com>
Date: Mon, 29 Aug 2022 17:29:38 +0200
Subject: [PATCH] Use software rendering on MacOS

4
dist/macOS/Brewfile vendored
View File

@@ -12,6 +12,4 @@ brew "ninja"
brew "zlib"
brew "xz"
brew "bzip2"
brew "zstd"
brew "libssh2"
brew "md4c"
brew "zstd"

View File

@@ -1,7 +1,7 @@
# This base image is also known as "crosscompile". See arm64.crosscompile.Dockerfile
FROM ghcr.io/werwolv/macos-crosscompile:6d89b20ac5ebedb6f680f94637591c94cb36f40b as build
FROM ghcr.io/itrooz/macos-crosscompile:clang19-nosdk as build
ENV MACOSX_DEPLOYMENT_TARGET 11.0
ENV MACOSX_DEPLOYMENT_TARGET 13.0
# -- DOWNLOADING STUFF
@@ -17,13 +17,13 @@ cp /tmp/arm-osx-mytriplet.cmake /vcpkg/triplets/community/arm-osx-mytriplet.cmak
EOF
## Install make
RUN --mount=type=cache,target=/var/lib/apt/lists/ apt update && apt install -y make cmake
RUN --mount=type=cache,target=/var/lib/apt/lists/ apt update && apt install -y make
## fix environment
### add install_name_tool for cmake command that won't have the right env set (see PostprocessBundle.cmake function postprocess_bundle())
RUN cp /osxcross/build/cctools-port/cctools/misc/install_name_tool /usr/bin/install_name_tool
### a cmake thing wants 'otool' and not '' apparently
RUN cp /osxcross/target/bin/aarch64-apple-darwin24-otool /usr/bin/otool
RUN cp /osxcross/target/bin/aarch64-apple-darwin23-otool /usr/bin/otool
## Clone glfw
RUN <<EOF
@@ -36,10 +36,10 @@ EOF
RUN --mount=type=cache,target=/cache <<EOF
## Download SDK is missing (it may have been removed from the image)
set -xe
if [ ! -d /osxcross/target/SDK/MacOSX15.0.sdk ]; then
wget https://github.com/joseluisq/macosx-sdks/releases/download/15.0/MacOSX15.0.sdk.tar.xz -O /cache/MacOSX15.0.sdk.tar.xz -nc || true
if [ ! -d /osxcross/target/SDK/MacOSX14.0.sdk ]; then
wget https://github.com/joseluisq/macosx-sdks/releases/download/14.0/MacOSX14.0.sdk.tar.xz -O /cache/MacOSX14.0.sdk.tar.xz -nc || true
mkdir -p /osxcross/target/SDK
tar -C /osxcross/target/SDK -xf /cache/MacOSX15.0.sdk.tar.xz
tar -C /osxcross/target/SDK -xf /cache/MacOSX14.0.sdk.tar.xz
fi
EOF
@@ -67,8 +67,6 @@ vcpkg install --triplet=arm-osx-mytriplet zlib
vcpkg install --triplet=arm-osx-mytriplet bzip2
vcpkg install --triplet=arm-osx-mytriplet liblzma
vcpkg install --triplet=arm-osx-mytriplet zstd
vcpkg install --triplet=arm-osx-mytriplet openssl
vcpkg install --triplet=arm-osx-mytriplet libssh2
EOF
## Install glfw3 dep
@@ -101,7 +99,7 @@ RUN --mount=type=cache,target=/cache <<EOF
make -j $JOBS install
# Now, we cross-compile it and install it in the libraries folder
CC=/osxcross/target/bin/aarch64-apple-darwin24-clang CXX=/osxcross/target/bin/aarch64-apple-darwin24-clang++ ./configure --prefix /vcpkg/installed/arm-osx-mytriplet --host $OSXCROSS_HOST
CC=/osxcross/target/bin/aarch64-apple-darwin23-clang CXX=/osxcross/target/bin/aarch64-apple-darwin23-clang++ ./configure --prefix /vcpkg/installed/arm-osx-mytriplet --host $OSXCROSS_HOST
make -j $JOBS
make install
@@ -132,7 +130,6 @@ if [ "$CUSTOM_GLFW" ]; then
mkdir build
cd build
CC=o64-clang CXX=o64-clang++ cmake -G "Ninja" \
-DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 \
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
@@ -140,7 +137,7 @@ if [ "$CUSTOM_GLFW" ]; then
-DCMAKE_OBJC_COMPILER_LAUNCHER=ccache \
-DCMAKE_OBJCXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_INSTALL_PREFIX=/vcpkg/installed/arm-osx-mytriplet \
-DVCPKG_TARGET_TRIPLET=arm-osx-mytriplet -DCMAKE_TOOLCHAIN_FILE=/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=/osxcross/target/toolchain.cmake -DCMAKE_OSX_SYSROOT=/osxcross/target/SDK/MacOSX14.0.sdk -DCMAKE_OSX_DEPLOYMENT_TARGET=13.3 \
-DVCPKG_TARGET_TRIPLET=arm-osx-mytriplet -DCMAKE_TOOLCHAIN_FILE=/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=/osxcross/target/toolchain.cmake -DCMAKE_OSX_SYSROOT=/osxcross/target/SDK/MacOSX14.0.sdk -DCMAKE_OSX_DEPLOYMENT_TARGET=13.0 \
..
ninja -j $JOBS install
@@ -151,25 +148,25 @@ EOF
# Build ImHex
## Copy ImHex
COPY --from=imhex / /mnt/ImHex
## Configure ImHex build
## Patch ImHex with hacks
# COPY toolchain.cmake.2 /osxcross/target/toolchain.cmake
# Configure ImHex build
RUN --mount=type=cache,target=/cache --mount=type=cache,target=/mnt/ImHex/build/_deps \
cd /mnt/ImHex && \
# compilers
CC=o64-clang CXX=o64-clang++ OBJC=/osxcross/target/bin/aarch64-apple-darwin24-clang OBJCXX=/osxcross/target/bin/aarch64-apple-darwin24-clang++ \
CC=o64-clang CXX=o64-clang++ OBJC=/osxcross/target/bin/aarch64-apple-darwin23-clang OBJCXX=/osxcross/target/bin/aarch64-apple-darwin23-clang++ \
cmake -G "Ninja" \
`# ccache flags` \
-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_OBJC_COMPILER_LAUNCHER=ccache -DCMAKE_OBJCXX_COMPILER_LAUNCHER=ccache \
`# MacOS cross-compiling flags` \
-DVCPKG_TARGET_TRIPLET=arm-osx-mytriplet -DCMAKE_TOOLCHAIN_FILE=/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=/osxcross/target/toolchain.cmake -DCMAKE_OSX_SYSROOT=/osxcross/target/SDK/MacOSX14.0.sdk -DCMAKE_OSX_DEPLOYMENT_TARGET=13.3 \
-DVCPKG_TARGET_TRIPLET=arm-osx-mytriplet -DCMAKE_TOOLCHAIN_FILE=/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=/osxcross/target/toolchain.cmake -DCMAKE_OSX_SYSROOT=/osxcross/target/SDK/MacOSX14.0.sdk -DCMAKE_OSX_DEPLOYMENT_TARGET=13.0 \
`# Override compilers for code generators` \
-DNATIVE_CMAKE_C_COMPILER=/usr/bin/clang -DNATIVE_CMAKE_CXX_COMPILER=/usr/bin/clang++ \
`# Normal ImHex flags` \
-DIMHEX_GENERATE_PACKAGE=ON -DCMAKE_BUILD_TYPE=$BUILD_TYPE \
`# other flags` \
-DIMHEX_STRICT_WARNINGS=OFF \
-DIMHEX_PATTERNS_PULL_MASTER=ON \
-DCMAKE_INSTALL_PREFIX=/mnt/ImHex/build/install \
-DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 \
-B build
## Build ImHex
RUN --mount=type=cache,target=/cache --mount=type=cache,target=/mnt/ImHex/build/_deps <<EOF
@@ -184,4 +181,4 @@ EOF
FROM scratch
COPY --from=build /mnt/ImHex/build/install/ImHex.app ImHex.app
COPY --from=build /mnt/ImHex/build/install/imhex.app imhex.app

View File

@@ -4,9 +4,9 @@ FROM ubuntu:22.04
ENV PATH $PATH:/osxcross/target/bin
ENV LD_LIBRARY_PATH /osxcross/target/lib
ENV OSXCROSS_SDK /osxcross/target/SDK/MacOSX14.0.sdk
ENV OSXCROSS_TARGET darwin24
ENV OSXCROSS_TARGET darwin23
ENV OSXCROSS_TARGET_DIR /osxcross/target
ENV OSXCROSS_HOST aarch64-apple-darwin24
ENV OSXCROSS_HOST aarch64-apple-darwin23
# -- DOWNLOADING STUFF

View File

@@ -1,11 +0,0 @@
set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_BUILD_TYPE release)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE static)
set(VCPKG_CMAKE_SYSTEM_NAME Darwin)
set(VCPKG_OSX_ARCHITECTURES x86_64)
set(VCPKG_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "" FORCE)
set(VCPKG_C_FLAGS "-mmacosx-version-min=10.15")
set(VCPKG_CXX_FLAGS "-mmacosx-version-min=10.15")
set(ENV{MACOSX_DEPLOYMENT_TARGET} "10.15")

4
dist/msys2/PKGBUILD vendored
View File

@@ -20,9 +20,7 @@ makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
"${MINGW_PACKAGE_PREFIX}-zlib"
"${MINGW_PACKAGE_PREFIX}-bzip2"
"${MINGW_PACKAGE_PREFIX}-xz"
"${MINGW_PACKAGE_PREFIX}-zstd"
"${MINGW_PACKAGE_PREFIX}-libssh2-wincng"
"${MINGW_PACKAGE_PREFIX}-md4c")
"${MINGW_PACKAGE_PREFIX}-zstd")
source=()
sha256sums=()

View File

@@ -1,71 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop">
<id>net.werwolv.ImHex</id>
<name>ImHex</name>
<summary>Modern REing Hex Editor</summary>
<description>
<p>
ImHex is a modern Hex Editor for Reverse Engineers, Developers, Malware Analysists and Hackers who value
their retinas when working at 3 AM once again.
</p>
<p>
Features:
</p>
<ul>
<li>Featureful hex view</li>
<li>Custom C++-like pattern language for parsing and highlighting a file's content</li>
<li>Data importing and exporting</li>
<li>Data inspector allowing interpretation of data as many different types</li>
<li>Huge file support with fast and efficient loading</li>
<li>Strings search</li>
<li>File hashing support</li>
<li>Disassembler supporting many different architectures: ARM, x86, PowerPC, MIPS, and more</li>
<li>Bookmarks</li>
<li>Data analyzer</li>
<li>
Helpful tools such as an Itanium and MSVC demangler, ASCII table, Regex
replacer, mathematical expression evaluator (calculator), hexadecimal
color picker and many more
</li>
<li>Doesn't burn out your retinas when used in late-night sessions</li>
</ul>
</description>
<metadata_license>CC0-1.0</metadata_license>
<project_license>GPL-2.0-only</project_license>
<developer id="net.werwolv">
<name>WerWolv</name>
</developer>
<url type="homepage">https://imhex.werwolv.net</url>
<url type="bugtracker">https://github.com/WerWolv/ImHex/issues</url>
<url type="help">https://docs.werwolv.net/imhex</url>
<url type="donation">https://github.com/sponsors/WerWolv</url>
<url type="contact">https://imhex.werwolv.net/discord</url>
<url type="vcs-browser">https://github.com/WerWolv/ImHex</url>
<url type="contribute">https://github.com/WerWolv/ImHex/blob/master/CONTRIBUTING.md</url>
<launchable type="desktop-id">imhex.desktop</launchable>
<screenshots>
<screenshot type="default" width="1920" height="1017">
<image type="source">https://raw.githubusercontent.com/flathub/net.werwolv.ImHex/master/screenshots/screenshot1.png</image>
<caption>Using a pattern to parse and highlight different sections of an ELF executable file</caption>
</screenshot>
<screenshot type="default" width="1920" height="1017">
<image type="source">https://raw.githubusercontent.com/flathub/net.werwolv.ImHex/master/screenshots/screenshot2.png</image>
<caption>Managing bookmarks, diffing two files and decrypting a region of data using the data preprocessor</caption>
</screenshot>
</screenshots>
<content_rating type="oars-1.1"/>
<branding>
<color type="primary" scheme_preference="light">#babec9</color>
<color type="primary" scheme_preference="dark">#0f0f0f</color>
</branding>
<releases>
<release version="1.0.0" date="2025-01-01">
<description></description>
</release>
</releases>
<update_contact>hey@werwolv.net</update_contact>
<recommends>
<control>keyboard</control>
<control>pointing</control>
</recommends>
</component>

22
dist/net.werwolv.ImHex.yaml vendored Normal file
View File

@@ -0,0 +1,22 @@
app-id: net.werwolv.ImHex
runtime: org.freedesktop.Platform
runtime-version: '20.08'
default-branch: stable
sdk: org.freedesktop.Sdk
command: imhex
finish-args:
- --share=ipc
- --socket=x11
- --filesystem=host
- --device=all
modules:
- name: imhex
buildsystem: cmake
config-opts:
- -DCMAKE_BUILD_TYPE=RelWithDebInfo
sources:
- type: git
url: https://github.com/WerWolv/ImHex.git

34
dist/net.werwolv.imhex.metainfo.xml vendored Normal file
View File

@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop-application">
<id>imhex</id>
<metadata_license>CC0-1.0</metadata_license>
<project_license>GPL-2.0</project_license>
<name>ImHex</name>
<developer_name>WerWolv</developer_name>
<update_contact>hey@werwolv.net</update_contact>
<summary>A Hex Editor for Reverse Engineers, Programmers and people who value their retinas when working at 3 AM</summary>
<description>
<p>ImHex is a feature-rich Hex Editor aimed towards Reverse Engineers working with foreign data formats, malware, executables and raw memory.
Besides all the features a common Hex Editor has, ImHex also features a custom scripting language used to declare and dissect data structures, support for running YARA rules, a node-based graphical data pre-processor and support for various data sources such as files, raw disks or GDB Servers.</p>
</description>
<launchable type="desktop-id">imhex.desktop</launchable>
<url type="homepage">https://imhex.werwolv.net</url>
<screenshots>
<screenshot type="default">
<image>https://user-images.githubusercontent.com/10835354/139717326-8044769d-527b-4d88-8adf-2d4ecafdca1f.png</image>
</screenshot>
<screenshot>
<image>https://user-images.githubusercontent.com/10835354/139717323-1f8c9d52-f7eb-4f43-9f11-097ac728ed6c.png</image>
</screenshot>
</screenshots>
<provides>
<id>imhex.desktop</id>
</provides>
<categories>
<category>Development</category>
</categories>
</component>

117
dist/rpm/imhex.spec vendored
View File

@@ -6,7 +6,7 @@ Release: 0%{?dist}
Summary: A hex editor for reverse engineers and programmers
License: GPL-2.0-only AND Zlib AND MIT AND Apache-2.0
# imhex is gplv2. capstone is custom.
# imhex is gplv2. capstone is custom. nativefiledialog is Zlib.
# see license dir for full breakdown
URL: https://imhex.werwolv.net/
# We need the archive with deps bundled
@@ -16,6 +16,7 @@ BuildRequires: cmake
BuildRequires: desktop-file-utils
BuildRequires: dbus-devel
BuildRequires: file-devel
BuildRequires: fontconfig-devel
BuildRequires: freetype-devel
BuildRequires: fmt-devel
BuildRequires: gcc-c++
@@ -24,41 +25,32 @@ BuildRequires: libglvnd-devel
BuildRequires: glfw-devel
BuildRequires: json-devel
BuildRequires: libcurl-devel
BuildRequires: libarchive-devel
BuildRequires: libzstd-devel
BuildRequires: zlib-devel
BuildRequires: bzip2-devel
BuildRequires: xz-devel
BuildRequires: llvm-devel
BuildRequires: mbedtls-devel
BuildRequires: yara-devel
BuildRequires: nativefiledialog-extended-devel
BuildRequires: lz4-devel
BuildRequires: libssh2-devel
%if 0%{?rhel} == 9
BuildRequires: dotnet-sdk-8.0
BuildRequires: libzstd-devel
BuildRequires: zlib-devel
BuildRequires: bzip2-devel
BuildRequires: xz-devel
%if 0%{?rhel}
BuildRequires: gcc-toolset-14
%endif
%if 0%{?fedora} || 0%{?rhel} > 9
BuildRequires: capstone-devel
%endif
BuildRequires: lunasvg-devel
Provides: bundled(gnulib)
%if 0%{?rhel} == 10
Provides: bundled(capstone) = 5.0.1
%endif
Provides: bundled(imgui) = 1.90.8
Provides: bundled(capstone) = 5.0-rc2
Provides: bundled(imgui)
Provides: bundled(libromfs)
Provides: bundled(microtar)
Provides: bundled(libpl) = %{version}
Provides: bundled(xdgpp)
# working on packaging this, bundling for now as to now delay updates
Provides: bundled(miniaudio) = 0.11.11
# ftbfs on these arches. armv7hl might compile when capstone 5.x
# is released upstream and we can build against it
# [7:02 PM] WerWolv: We're not supporting 32 bit anyways soooo
# [11:38 AM] WerWolv: Officially supported are x86_64 and aarch64
ExclusiveArch: x86_64 %{arm64}
ExclusiveArch: x86_64 %{arm64} ppc64le
%description
ImHex is a Hex Editor, a tool to display, decode and analyze binary data to
@@ -72,33 +64,16 @@ displayed, a disassembler, diffing support, bookmarks and much much more. At the
same time ImHex is completely free and open source under the GPLv2 language.
%package devel
Summary: Development files for %{name}
License: GPL-2.0-only
%description devel
%{summary}
%prep
%autosetup -n ImHex -p1
%autosetup -n ImHex
# remove bundled libs we aren't using
rm -rf lib/third_party/{curl,fmt,llvm,nlohmann_json,yara}
%if 0%{?fedora} || 0%{?rhel} > 9
rm -rf lib/third_party/capstone
%endif
# rhel 9 doesn't support all of the new appstream metainfo tags
%if 0%{?rhel} && 0%{?rhel} < 10
sed -i -e '/url type="vcs-browser"/d' \
-e '/url type="contribute"/d' \
dist/net.werwolv.ImHex.metainfo.xml
%endif
rm -rf lib/third_party/{fmt,nlohmann_json,yara}
%build
%if 0%{?rhel} == 9
%if 0%{?rhel}
. /opt/rh/gcc-toolset-14/enable
%set_build_flags
CXXFLAGS+=" -std=gnu++2b"
CXXFLAGS+=" -std=gnu++23"
%endif
%cmake \
-D CMAKE_BUILD_TYPE=Release \
@@ -106,31 +81,23 @@ CXXFLAGS+=" -std=gnu++2b"
-D IMHEX_OFFLINE_BUILD=ON \
-D USE_SYSTEM_NLOHMANN_JSON=ON \
-D USE_SYSTEM_FMT=ON \
-D USE_SYSTEM_CURL=ON \
-D USE_SYSTEM_LLVM=ON \
-D USE_SYSTEM_MD4C=OFF \
%if 0%{?fedora} || 0%{?rhel} > 9
-D USE_SYSTEM_CAPSTONE=ON \
%endif
-D USE_SYSTEM_LUNASVG=ON \
-D USE_SYSTEM_YARA=ON \
-D USE_SYSTEM_NFD=ON \
-D IMHEX_ENABLE_UNIT_TESTS=ON \
%if 0%{?rhel}
-D IMHEX_BUILD_HARDENING=OFF
%endif
# disable built-in build hardening because it is already
# done in rhel buildroots. adding the flags again from
# upstream generates build errors
-D IMHEX_USE_GTK_FILE_PICKER=ON \
-D IMHEX_BUNDLE_DOTNET=OFF \
# when capstone >= 5.x is released we should be able to build against \
# system libs of it \
# -D USE_SYSTEM_CAPSTONE=ON
%cmake_build
%check
# build binaries required for tests
%cmake_build --target unit_tests
%ctest --exclude-regex '(Helpers/StoreAPI|Helpers/TipsAPI|Helpers/ContentAPI)'
# Helpers/*API exclude tests that require network access
%if 0%{?rhel}
. /opt/rh/gcc-toolset-14/enable
%set_build_flags
CXXFLAGS+=" -std=gnu++23"
%endif
%install
@@ -138,15 +105,15 @@ CXXFLAGS+=" -std=gnu++2b"
desktop-file-validate %{buildroot}%{_datadir}/applications/%{name}.desktop
# this is a symlink for the old appdata name that we don't need
rm -f %{buildroot}%{_metainfodir}/net.werwolv.ImHex.appdata.xml
rm -f %{buildroot}%{_metainfodir}/net.werwolv.%{name}.appdata.xml
# AppData
appstream-util validate-relax --nonet %{buildroot}%{_metainfodir}/net.werwolv.ImHex.metainfo.xml
appstream-util validate-relax --nonet %{buildroot}%{_metainfodir}/net.werwolv.%{name}.metainfo.xml
# install licenses
%if 0%{?rhel} == 9
cp -a lib/third_party/capstone/LICENSES/LICENSE.TXT %{buildroot}%{_datadir}/licenses/%{name}/capstone-LICENSE
%endif
cp -a lib/third_party/nativefiledialog/LICENSE %{buildroot}%{_datadir}/licenses/%{name}/nativefiledialog-LICENSE
cp -a lib/third_party/capstone/LICENSE.TXT %{buildroot}%{_datadir}/licenses/%{name}/capstone-LICENSE
cp -a lib/third_party/capstone/suite/regress/LICENSE %{buildroot}%{_datadir}/licenses/%{name}/capstone-regress-LICENSE
cp -a lib/third_party/microtar/LICENSE %{buildroot}%{_datadir}/licenses/%{name}/microtar-LICENSE
cp -a lib/third_party/xdgpp/LICENSE %{buildroot}%{_datadir}/licenses/%{name}/xdgpp-LICENSE
@@ -155,16 +122,12 @@ cp -a lib/third_party/xdgpp/LICENSE %{buildroot
%license %{_datadir}/licenses/%{name}/
%doc README.md
%{_bindir}/imhex
%{_datadir}/imhex/imhex
%{_datadir}/pixmaps/%{name}.*
%{_bindir}/imhex-updater
%{_datadir}/pixmaps/%{name}.svg
%{_datadir}/applications/%{name}.desktop
%{_libdir}/libimhex.so.*
%{_libdir}/%{name}/
%{_metainfodir}/net.werwolv.ImHex.metainfo.xml
%exclude %{_bindir}/imhex-updater
%{_datadir}/mime/packages/%{name}.xml
%files devel
%{_libdir}/libimhex.so
%{_datadir}/%{name}/sdk/
%{_libdir}/libimhex.so*
%{_libdir}/%{name}/
%{_libdir}/*.hexpluglib
/usr/lib/debug/%{_libdir}/*.debug
%{_metainfodir}/net.werwolv.%{name}.metainfo.xml

View File

@@ -1,92 +0,0 @@
name: imhex
title: ImHex
base: core24
version: ${IMHEX_VERSION_STRING}
summary: Hex editor for reverse engineering
description: ImHex is a hex editor for reverse engineering, reverse engineering, and analyzing binary files. It provides a powerful and flexible interface for working with binary data, including features like pattern matching, scripting, and a customizable user interface.
grade: stable
confinement: classic
contact: https://github.com/WerWolv/ImHex/discussions
issues: https://github.com/WerWolv/ImHex/issues
source-code: https://github.com/WerWolv/ImHex
website: https://imhex.werwolv.net
donation: https://github.com/sponsors/WerWolv
license: GPL-2.0-only
icon: resources/icon.svg
adopt-info: imhex
platforms:
amd64:
arm64:
apps:
imhex:
command: usr/local/bin/imhex
desktop: usr/local/share/applications/imhex.desktop
environment:
LD_LIBRARY_PATH: '$SNAP/usr/local/lib:$SNAP/usr/local/lib/imhex:$SNAP/usr/lib/x86_64-linux-gnu:$SNAP/usr/lib/aarch64-linux-gnu:$LD_LIBRARY_PATH'
XDG_DATA_DIRS: '$XDG_DATA_DIRS:$SNAP/usr/local/share:$SNAP/usr/local/lib:$SNAP/usr/local/share'
XDG_CONFIG_DIRS: '$XDG_CONFIG_DIRS:$SNAP/usr/local/share'
XDG_DATA_HOME: '$XDG_DATA_HOME:$SNAP_DATA'
parts:
imhex:
plugin: cmake
source: .
build-environment:
- CC: /usr/bin/gcc-14
- CXX: /usr/bin/g++-14
cmake-parameters:
- -DCMAKE_BUILD_TYPE=Release
- -DCMAKE_C_COMPILER_LAUNCHER=${CCACHE}
- -DCMAKE_CXX_COMPILER_LAUNCHER=${CCACHE}
- -DIMHEX_PATTERNS_PULL_MASTER=ON
- -DIMHEX_BUNDLE_PLUGIN_SDK=OFF
cmake-generator: Ninja
build-packages:
- cmake
- ninja-build
- gcc-14
- g++-14
- git
- pkg-config
- libglfw3-dev
- libmagic-dev
- libmbedtls-dev
- libfontconfig-dev
- libfreetype-dev
- libdbus-1-dev
- libcurl4-gnutls-dev
- libgtk-3-dev
- zlib1g-dev
- libbz2-dev
- liblzma-dev
- libzstd-dev
- liblz4-dev
- libssh2-1-dev
- libmd4c-dev
- libmd4c-html0-dev
stage-packages:
- libglfw3
- libmagic1
- libmbedtls14
- libfontconfig1
- libfreetype6
- libdbus-1-3
- libcurl4-gnutls-dev
- libgtk-3-0
- zlib1g
- libbz2-1.0
- liblzma5
- libzstd1
- liblz4-1
- libssh2-1
prime:
- -usr/include/*
- -usr/local/include/*
- -usr/lib/**/*.a
- -usr/local/lib/**/*.a
- -usr/lib/**/*.la
- -usr/local/lib/**/*.la
- -usr/share/doc/*
- -usr/share/man/*

4
dist/vcpkg.json vendored
View File

@@ -11,8 +11,6 @@
"liblzma",
"zstd",
"glfw3",
"curl",
"libssh2",
"md4c"
"curl"
]
}

22
dist/web/Dockerfile vendored
View File

@@ -1,24 +1,24 @@
FROM emscripten/emsdk:4.0.21 AS build
FROM emscripten/emsdk:3.1.51 AS build
# Used to invalidate layer cache but not mount cache
# See https://github.com/moby/moby/issues/41715#issuecomment-733976493
ARG UNIQUEKEY=1
ARG UNIQUEKEY 1
RUN apt update
RUN apt install -y git ccache autoconf automake libtool pkg-config ninja-build
RUN apt install -y git ccache autoconf automake libtool cmake pkg-config ninja-build
RUN <<EOF
# Install vcpkg
# Note: we are a patch on the libmagic port
set -xe
git clone --depth 1 https://github.com/microsoft/vcpkg /vcpkg
git clone https://github.com/microsoft/vcpkg /vcpkg
git -C /vcpkg pull
/vcpkg/bootstrap-vcpkg.sh
sed -i 's/vcpkg_install_make(${EXTRA_ARGS})/vcpkg_install_make(${EXTRA_ARGS} SUBPATH src)/g' /vcpkg/ports/libmagic/portfile.cmake
EOF
# Patch vcpkg build instructions to add -pthread flag
# Even dependencies must be built with -pthread to be able to use USE_PTHREADS=1
# Patch vcpkg build instructions to add -pthread
RUN <<EOF
set -xe
@@ -50,18 +50,17 @@ ENV CCACHE_DIR=/cache/ccache
RUN mkdir /build
WORKDIR /build
ARG BUILD_TYPE=Release
RUN --mount=type=cache,target=/cache \
--mount=type=bind,source=.,target=/imhex <<EOF
set -xe
ccache -zs
/vcpkg/downloads/tools/cmake-*/cmake-*/bin/cmake /imhex \
cmake /imhex \
-G "Ninja" \
-DIMHEX_OFFLINE_BUILD=ON \
-DIMHEX_STATIC_LINK_PLUGINS=ON \
-DIMHEX_EXCLUDE_PLUGINS="script_loader;remote" \
-DIMHEX_EXCLUDE_PLUGINS="script_loader" \
-DIMHEX_COMPRESS_DEBUG_INFO=OFF \
-DNATIVE_CMAKE_C_COMPILER=gcc \
-DNATIVE_CMAKE_CXX_COMPILER=g++ \
@@ -70,8 +69,7 @@ ccache -zs
-DCMAKE_TOOLCHAIN_FILE=/vcpkg/scripts/buildsystems/vcpkg.cmake \
-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake \
-DLIBROMFS_COMPRESS_RESOURCES=OFF \
-DIMHEX_ENABLE_PLUGIN_TESTS=OFF \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE}
-DCMAKE_BUILD_TYPE=Release
ninja -j $JOBS
@@ -89,6 +87,7 @@ COPY --from=build [ \
"/build/imhex.wasm", \
"/build/imhex.wasm.size", \
"/build/imhex.js", \
"/build/imhex.worker.js", \
\
# Static files \
"/build/index.html", \
@@ -107,4 +106,3 @@ COPY --from=build [ \
FROM nginx
COPY --from=raw . /usr/share/nginx/html
RUN chmod -R 755 /usr/share/nginx/html

View File

@@ -1,9 +0,0 @@
FROM python:3.12-slim
WORKDIR /imhex
COPY ./out/ .
EXPOSE 9090
CMD [ "python", "/imhex/start_imhex_web.py" ]

View File

@@ -1,4 +1,5 @@
# docker compose -f dist/web/compose.yml up --build
version: '3'
services:
imhex_web:
image: imhex_web:latest

View File

@@ -15,17 +15,17 @@
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://web.imhex.werwolv.net/">
<meta property="og:url" content="https://imhex.werwolv.net/">
<meta property="og:title" content="ImHex Web - Online Hex Editor">
<meta property="og:image" content="splash_wasm.png">
<meta property="og:image" content="https://imhex.werwolv.net/assets/splash_wasm.png">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://web.imhex.werwolv.net/">
<meta property="twitter:url" content="https://imhex.werwolv.net/">
<meta property="twitter:title" content="ImHex Web - Online Hex Editor">
<meta property="twitter:description"
content="A Hex Editor for Reverse Engineers, Programmers and people who value their retinas when working at 3 AM.">
<meta property="twitter:image" content="splash_wasm.png">
<meta property="twitter:image" content="https://imhex.werwolv.net/assets/splash_wasm.png">
<link rel="stylesheet" type="text/css" href="style.css">
@@ -37,8 +37,8 @@
"email": "hey@werwolv.net",
"founder": "WerWolv",
"slogan": "A Hex Editor for Reverse Engineers, Programmers and people who value their retinas when working at 3 AM.",
"url": "https://web.imhex.werwolv.net",
"logo": "https://web.imhex.werwolv.net/icon.svg"
"url": "https://imhex.werwolv.net",
"logo": "https://imhex.werwolv.net/assets/logos/logo.svg"
}
</script>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 478 KiB

View File

@@ -9,9 +9,8 @@ fetch("imhex.wasm.size").then(async (resp) => {
// inspired from: https://github.com/WordPress/wordpress-playground/pull/46 (but had to be modified)
function monkeyPatch(progressFun) {
const _instantiateStreaming = WebAssembly.instantiateStreaming;
WebAssembly.instantiateStreaming = async (responsePromise, ...args) => {
WebAssembly.instantiateStreaming = (response, ...args) => {
// Do not collect wasm content length here see above
let response = await responsePromise
const file = response.url.substring(
new URL(response.url).origin.length + 1
);
@@ -59,14 +58,8 @@ monkeyPatch((file, done) => {
const mibTotal = (wasmSize / 1024**2).toFixed(1);
let root = document.querySelector(':root');
if (root != null) {
root.style.setProperty("--progress", `${percent}%`)
let progressBar = document.getElementById("progress-bar-content");
if (progressBar != null) {
progressBar.innerHTML = `${percent}% &nbsp;[${mibNow} MiB / ${mibTotal} MiB]`;
}
}
root.style.setProperty("--progress", `${percent}%`)
document.getElementById("progress-bar-content").innerHTML = `${percent}% &nbsp;[${mibNow} MiB / ${mibTotal} MiB]`;
});
function glfwSetCursorCustom(wnd, shape) {
@@ -106,9 +99,7 @@ var notWorkingTimer = setTimeout(() => {
}, 5000);
var Module = {
preRun: () => {
ENV.IMHEX_SKIP_SPLASH_SCREEN = "1";
},
preRun: [],
postRun: function() {
// Patch the emscripten GLFW module to send mouse and touch events in the right order
// For ImGui interactions to correctly work with touch input, MousePos events need
@@ -166,7 +157,7 @@ var Module = {
if (status == 1) {
GLFW.active.buttons |= (1 << eventButton);
try {
event.target.setPointerCapture(event.pointerId);
event.target.setCapture();
} catch (e) {}
} else {
GLFW.active.buttons &= ~(1 << eventButton);
@@ -182,9 +173,7 @@ var Module = {
},
onRuntimeInitialized: function() {
// Triggered when the wasm module is loaded and ready to use.
let loading = document.getElementById("loading");
if (loading != null)
document.getElementById("loading").style.display = "none"
document.getElementById("loading").style.display = "none"
document.getElementById("canvas").style.display = "initial"
clearTimeout(notWorkingTimer);
@@ -198,8 +187,6 @@ var Module = {
e.preventDefault();
}, false);
js_resizeCanvas()
// Turn long touches into right-clicks
let timer = null;
canvas.addEventListener('touchstart', event => {
@@ -248,11 +235,12 @@ var Module = {
totalDependencies: 0,
monitorRunDependencies: function(left) {
},
instantiateWasm: async function(imports, successCallback) {
instantiateWasm: function(imports, successCallback) {
imports.env.glfwSetCursor = glfwSetCursorCustom
imports.env.glfwCreateStandardCursor = glfwCreateStandardCursorCustom
let result = await instantiateAsync(null, findWasmBinary(), imports);
successCallback(result.instance, result.module)
instantiateAsync(wasmBinary, wasmBinaryFile, imports, (result) => {
successCallback(result.instance, result.module)
});
},
arguments: []
};
@@ -263,23 +251,17 @@ const urlParams = new URLSearchParams(queryString);
if (urlParams.has("lang")) {
Module["arguments"].push("--language");
Module["arguments"].push(urlParams.get("lang"));
} else if (urlParams.has("save-editor")) {
Module["arguments"].push("--save-editor");
Module["arguments"].push("gist");
Module["arguments"].push(urlParams.get("save-editor"));
}
window.addEventListener('resize', js_resizeCanvas, false);
function js_resizeCanvas() {
let canvas = document.getElementById('canvas');
canvas.top = canvas.parentElement.clientTop;
canvas.left = canvas.parentElement.clientLeft;
canvas.style.width = "100%";
canvas.style.height = "100%";
canvas.top = document.documentElement.clientTop;
canvas.left = document.documentElement.clientLeft;
canvas.width = Math.min(document.documentElement.clientWidth, window.innerWidth || 0);
canvas.height = Math.min(document.documentElement.clientHeight, window.innerHeight || 0);
}
let resizeObserver = new ResizeObserver(js_resizeCanvas);
resizeObserver.observe(document.getElementById("canvas"))
// Prevent some default browser shortcuts from preventing ImHex ones to work
document.addEventListener('keydown', e => {

View File

@@ -40,14 +40,10 @@ set(LIBIMHEX_SOURCES
source/helpers/imgui_hooks.cpp
source/helpers/semantic_version.cpp
source/helpers/keys.cpp
source/helpers/udp_server.cpp
source/helpers/scaling.cpp
source/helpers/binary_pattern.cpp
source/test/tests.cpp
source/providers/provider.cpp
source/providers/cached_provider.cpp
source/providers/memory_provider.cpp
source/providers/undo/stack.cpp
@@ -57,13 +53,19 @@ set(LIBIMHEX_SOURCES
source/ui/toast.cpp
source/ui/banner.cpp
source/mcp/client.cpp
source/mcp/server.cpp
source/subcommands/subcommands.cpp
)
if (APPLE)
set(OSX_11_0_SDK_PATH /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk)
if (NOT CMAKE_OSX_SYSROOT)
if (IS_DIRECTORY ${OSX_11_0_SDK_PATH})
set(CMAKE_OSX_SYSROOT ${OSX_11_0_SDK_PATH})
else ()
message(WARNING "CMAKE_OSX_SYSROOT not set and macOS 10.9 SDK not found! Using default one.")
endif ()
endif ()
set(LIBIMHEX_SOURCES ${LIBIMHEX_SOURCES}
source/helpers/utils_macos.m
source/helpers/macos_menu.m
@@ -80,21 +82,10 @@ else()
add_library(libimhex SHARED ${LIBIMHEX_SOURCES})
endif()
if (IMHEX_ENABLE_CXX_MODULES)
target_sources(libimhex
PUBLIC
FILE_SET cxx_modules TYPE CXX_MODULES
FILES
include/hex.cppm
)
endif()
set(LIBIMHEX_LIBRARY_TYPE PUBLIC)
target_compile_definitions(libimhex PRIVATE IMHEX_PROJECT_NAME="${PROJECT_NAME}")
endif()
addCppCheck(libimhex)
if (DEFINED IMHEX_COMMIT_HASH_LONG AND DEFINED IMHEX_COMMIT_BRANCH)
set(GIT_COMMIT_HASH_LONG "${IMHEX_COMMIT_HASH_LONG}")
@@ -129,9 +120,6 @@ endif ()
addDefineToSource(source/api/imhex_api.cpp "IMHEX_VERSION=\"${IMHEX_VERSION_STRING}\"")
string(TIMESTAMP IMHEX_BUILD_DATE UTC)
addDefineToSource(source/api/imhex_api.cpp "IMHEX_BUILD_DATE=\"${IMHEX_BUILD_DATE}\"")
enableUnityBuild(libimhex)
setupCompilerFlags(libimhex)
@@ -150,17 +138,12 @@ if (NOT IMHEX_EXTERNAL_PLUGIN_BUILD)
target_compile_definitions(libimhex PRIVATE EXPORT_SYMBOLS=1)
elseif (APPLE)
find_library(FOUNDATION NAMES Foundation)
find_library(USERNOTIFICATIONS NAMES UserNotifications)
target_link_libraries(libimhex PUBLIC ${FOUNDATION} ${USERNOTIFICATIONS})
target_link_libraries(libimhex PUBLIC ${FOUNDATION})
endif ()
target_link_libraries(libimhex PRIVATE libpl microtar ${NFD_LIBRARIES} magic)
target_link_libraries(libimhex PUBLIC libwolv libpl_includes libpl-gen ${IMGUI_LIBRARIES} ${JTHREAD_LIBRARIES})
if (IMHEX_ENABLE_IMGUI_TEST_ENGINE)
target_link_libraries(libimhex PUBLIC imgui_test_engine)
endif()
if (NOT WIN32)
target_link_libraries(libimhex PRIVATE dl)
endif()
@@ -177,7 +160,7 @@ if (NOT IMHEX_EXTERNAL_PLUGIN_BUILD)
precompileHeaders(libimhex "${CMAKE_CURRENT_SOURCE_DIR}/include")
endif()
target_link_libraries(libimhex ${LIBIMHEX_LIBRARY_TYPE} ${NLOHMANN_JSON_LIBRARIES} imgui_all_includes ${FMT_LIBRARIES} ${LUNASVG_LIBRARIES} ${BOOST_LIBRARIES} tracing)
target_link_libraries(libimhex ${LIBIMHEX_LIBRARY_TYPE} ${NLOHMANN_JSON_LIBRARIES} imgui_all_includes ${FMT_LIBRARIES} ${LUNASVG_LIBRARIES} ${BOOST_LIBRARIES})
set_property(TARGET libimhex PROPERTY INTERPROCEDURAL_OPTIMIZATION FALSE)

View File

@@ -1,58 +0,0 @@
module;
#include <cmath>
#include <map>
#include <string>
#include <string_view>
#include <vector>
#include <exception>
#include <algorithm>
#include <locale>
#include <array>
#include <filesystem>
#include <functional>
#include <memory>
#include <list>
#include <atomic>
#include <ranges>
#include <fstream>
#include <thread>
#include <future>
#include <fmt/format.h>
#include <nlohmann/json.hpp>
#include <wolv/io/file.hpp>
#include <imgui.h>
#include <imgui_internal.h>
#include <hex/ui/imgui_imhex_extensions.h>
#include <hex/helpers/auto_reset.hpp>
#include <hex/api/event_manager.hpp>
#include <hex/providers/provider.hpp>
#include <hex/providers/provider_data.hpp>
#include <hex/data_processor/node.hpp>
#include <hex/data_processor/link.hpp>
#include <hex/data_processor/attribute.hpp>
#include <pl/pattern_language.hpp>
export module hex;
#define HEX_MODULE_EXPORT
#include <hex/api/imhex_api/bookmarks.hpp>
#include <hex/api/imhex_api/hex_editor.hpp>
#include <hex/api/imhex_api/fonts.hpp>
#include <hex/api/imhex_api/messaging.hpp>
#include <hex/api/imhex_api/provider.hpp>
#include <hex/api/imhex_api/system.hpp>
#include <hex/api/task_manager.hpp>
#include <hex/api/achievement_manager.hpp>
#include <hex/api/layout_manager.hpp>
#include <hex/api/localization_manager.hpp>
#include <hex/api/plugin_manager.hpp>
#include <hex/api/shortcut_manager.hpp>
#include <hex/api/theme_manager.hpp>
#include <hex/api/tutorial_manager.hpp>
#include <hex/api/workspace_manager.hpp>

View File

@@ -1,9 +1,3 @@
#pragma once
#include <hex/helpers/types.hpp>
#if defined(HEX_MODULE_EXPORT)
#define EXPORT_MODULE export
#else
#define EXPORT_MODULE
#endif

View File

@@ -16,7 +16,7 @@
#include <hex/api/localization_manager.hpp>
#include <hex/helpers/auto_reset.hpp>
EXPORT_MODULE namespace hex {
namespace hex {
class AchievementManager;
@@ -145,17 +145,62 @@ EXPORT_MODULE namespace hex {
* @brief Returns the icon of the achievement
* @return Icon of the achievement
*/
[[nodiscard]] const char* getIcon() const {
return m_icon.c_str();
[[nodiscard]] const ImGuiExt::Texture &getIcon() const {
if (m_iconData.empty())
return m_icon;
if (m_icon.isValid())
return m_icon;
m_icon = ImGuiExt::Texture::fromImage(m_iconData.data(), m_iconData.size(), ImGuiExt::Texture::Filter::Linear);
return m_icon;
}
/**
* @brief Sets the icon of the achievement
* @param icon Icon glyph
* @param data Icon data
* @return Reference to the achievement
*/
Achievement& setIcon(std::string icon) {
m_icon = std::move(icon);
Achievement& setIcon(std::span<const std::byte> data) {
m_iconData.reserve(data.size());
for (auto &byte : data)
m_iconData.emplace_back(static_cast<u8>(byte));
return *this;
}
/**
* @brief Sets the icon of the achievement
* @param data Icon data
* @return Reference to the achievement
*/
Achievement& setIcon(std::span<const u8> data) {
m_iconData.assign(data.begin(), data.end());
return *this;
}
/**
* @brief Sets the icon of the achievement
* @param data Icon data
* @return Reference to the achievement
*/
Achievement& setIcon(std::vector<u8> data) {
m_iconData = std::move(data);
return *this;
}
/**
* @brief Sets the icon of the achievement
* @param data Icon data
* @return Reference to the achievement
*/
Achievement& setIcon(const std::vector<std::byte> &data) {
m_iconData.reserve(data.size());
for (auto &byte : data)
m_iconData.emplace_back(static_cast<u8>(byte));
return *this;
}
@@ -239,7 +284,8 @@ EXPORT_MODULE namespace hex {
std::function<void(Achievement &)> m_clickCallback;
std::string m_icon;
std::vector<u8> m_iconData;
mutable ImGuiExt::Texture m_icon;
u32 m_progress = 0;
u32 m_maxProgress = 1;
@@ -265,15 +311,11 @@ EXPORT_MODULE namespace hex {
}
[[nodiscard]] bool isUnlockable() const {
return std::ranges::all_of(this->parents, [](const auto &parent) {
return parent->achievement->isUnlocked();
});
return std::all_of(this->parents.begin(), this->parents.end(), [](auto &parent) { return parent->achievement->isUnlocked(); });
}
[[nodiscard]] bool isVisible() const {
return std::ranges::all_of(this->visibilityParents, [](const auto &parent) {
return parent->achievement->isUnlocked();
});
return std::all_of(this->visibilityParents.begin(), this->visibilityParents.end(), [](auto &parent) { return parent->achievement->isUnlocked(); });
}
[[nodiscard]] bool isUnlocked() const {

File diff suppressed because it is too large Load Diff

View File

@@ -1,22 +0,0 @@
#pragma once
#include <hex.hpp>
#include <functional>
#include <hex/api/localization_manager.hpp>
EXPORT_MODULE namespace hex {
/* Background Service Registry. Allows adding new background services */
namespace ContentRegistry::BackgroundServices {
namespace impl {
using Callback = std::function<void()>;
void stopServices();
}
void registerService(const UnlocalizedString &unlocalizedName, const impl::Callback &callback);
}
}

View File

@@ -1,104 +0,0 @@
#pragma once
#include <hex.hpp>
#include <hex/api/localization_manager.hpp>
#include <string>
#include <functional>
#include <optional>
#include <vector>
EXPORT_MODULE namespace hex {
/* Command Palette Command Registry. Allows adding of new commands to the command palette */
namespace ContentRegistry::CommandPalette {
enum class Type : u32 {
SymbolCommand,
KeywordCommand
};
namespace impl {
using QueryResultCallback = std::function<void(std::string)>;
struct QueryResult {
std::string name;
QueryResultCallback callback;
};
using ContentDisplayCallback = std::function<void()>;
using DisplayCallback = std::function<std::string(std::string)>;
using ExecuteCallback = std::function<std::optional<std::string>(std::string)>;
using QueryCallback = std::function<std::vector<QueryResult>(std::string)>;
struct Entry {
Type type;
std::string command;
UnlocalizedString unlocalizedDescription;
DisplayCallback displayCallback;
ExecuteCallback executeCallback;
};
struct Handler {
Type type;
std::string command;
QueryCallback queryCallback;
DisplayCallback displayCallback;
};
struct ContentDisplay {
bool showSearchBox;
ContentDisplayCallback callback;
};
const std::vector<Entry>& getEntries();
const std::vector<Handler>& getHandlers();
std::optional<ContentDisplay>& getDisplayedContent();
}
/**
* @brief Adds a new command to the command palette
* @param type The type of the command
* @param command The command to add
* @param unlocalizedDescription The description of the command
* @param displayCallback The callback that will be called when the command is displayed in the command palette
* @param executeCallback The callback that will be called when the command is executed
*/
void add(
Type type,
const std::string &command,
const UnlocalizedString &unlocalizedDescription,
const impl::DisplayCallback &displayCallback,
const impl::ExecuteCallback &executeCallback = [](auto) { return std::nullopt; });
/**
* @brief Adds a new command handler to the command palette
* @param type The type of the command
* @param command The command to add
* @param queryCallback The callback that will be called when the command palette wants to load the name and callback items
* @param displayCallback The callback that will be called when the command is displayed in the command palette
*/
void addHandler(
Type type,
const std::string &command,
const impl::QueryCallback &queryCallback,
const impl::DisplayCallback &displayCallback);
/**
* @brief Specify UI content that will be displayed inside the command palette
* @param displayCallback Display callback that will be called to display the content
*/
void setDisplayedContent(const impl::ContentDisplayCallback &displayCallback);
/**
* @brief Opens the command palette window, displaying a user defined interface
* @param displayCallback Display callback that will be called to display the content
*/
void openWithContent(const impl::ContentDisplayCallback &displayCallback);
}
}

View File

@@ -1,42 +0,0 @@
#pragma once
#include <hex.hpp>
#include <nlohmann/json_fwd.hpp>
#include <map>
#include <string>
#include <hex/mcp/server.hpp>
EXPORT_MODULE namespace hex {
/* Network Communication Interface Registry. Allows adding new communication interface endpoints */
namespace ContentRegistry::CommunicationInterface {
namespace impl {
using NetworkCallback = std::function<nlohmann::json(const nlohmann::json &)>;
const std::map<std::string, NetworkCallback>& getNetworkEndpoints();
}
void registerNetworkEndpoint(const std::string &endpoint, const impl::NetworkCallback &callback);
}
namespace ContentRegistry::MCP {
namespace impl {
std::unique_ptr<mcp::Server>& getMcpServerInstance();
void setEnabled(bool enabled);
}
bool isEnabled();
bool isConnected();
void registerTool(std::string_view capabilities, std::function<nlohmann::json(const nlohmann::json &params)> function);
}
}

View File

@@ -1,73 +0,0 @@
#pragma once
#include <hex.hpp>
#include <hex/api/localization_manager.hpp>
#include <string>
#include <functional>
#include <vector>
EXPORT_MODULE namespace hex {
#if !defined(HEX_MODULE_EXPORT)
namespace prv { class Provider; }
#endif
/* Data Formatter Registry. Allows adding formatters that are used in the Copy-As menu for example */
namespace ContentRegistry::DataFormatter {
namespace impl {
using Callback = std::function<std::string(prv::Provider *provider, u64 address, size_t size, bool preview)>;
struct ExportMenuEntry {
UnlocalizedString unlocalizedName;
Callback callback;
};
struct FindOccurrence {
Region region;
std::endian endian = std::endian::native;
enum class DecodeType : u8 { ASCII, UTF8, Binary, UTF16, Unsigned, Signed, Float, Double } decodeType;
bool selected;
std::string string;
};
using FindExporterCallback = std::function<std::vector<u8>(const std::vector<FindOccurrence>&, std::function<std::string(FindOccurrence)>)>;
struct FindExporterEntry {
UnlocalizedString unlocalizedName;
std::string fileExtension;
FindExporterCallback callback;
};
/**
* @brief Retrieves a list of all registered data formatters used by the 'File -> Export' menu
*/
const std::vector<ExportMenuEntry>& getExportMenuEntries();
/**
* @brief Retrieves a list of all registered data formatters used in the Results section of the 'Find' view
*/
const std::vector<FindExporterEntry>& getFindExporterEntries();
}
/**
* @brief Adds a new data formatter
* @param unlocalizedName The unlocalized name of the formatter
* @param callback The function to call to format the data
*/
void addExportMenuEntry(const UnlocalizedString &unlocalizedName, const impl::Callback &callback);
/**
* @brief Adds a new data exporter for Find results
* @param unlocalizedName The unlocalized name of the formatter
* @param fileExtension The file extension to use for the exported file
* @param callback The function to call to format the data
*/
void addFindExportFormatter(const UnlocalizedString &unlocalizedName, const std::string &fileExtension, const impl::FindExporterCallback &callback);
}
}

View File

@@ -1,81 +0,0 @@
#pragma once
#include <hex.hpp>
#include <hex/api/task_manager.hpp>
#include <hex/api/localization_manager.hpp>
#include <nlohmann/json_fwd.hpp>
#include <atomic>
#include <functional>
#include <memory>
#include <vector>
EXPORT_MODULE namespace hex {
#if !defined(HEX_MODULE_EXPORT)
namespace prv { class Provider; }
#endif
/* Data Information Registry. Allows adding new analyzers to the data information view */
namespace ContentRegistry::DataInformation {
class InformationSection {
public:
InformationSection(const UnlocalizedString &unlocalizedName, const UnlocalizedString &unlocalizedDescription = "", bool hasSettings = false)
: m_unlocalizedName(unlocalizedName), m_unlocalizedDescription(unlocalizedDescription),
m_hasSettings(hasSettings) { }
virtual ~InformationSection() = default;
[[nodiscard]] const UnlocalizedString& getUnlocalizedName() const { return m_unlocalizedName; }
[[nodiscard]] const UnlocalizedString& getUnlocalizedDescription() const { return m_unlocalizedDescription; }
virtual void process(Task &task, prv::Provider *provider, Region region) = 0;
virtual void reset() = 0;
virtual void drawSettings() { }
virtual void drawContent() = 0;
[[nodiscard]] bool isValid() const { return m_valid; }
void markValid(bool valid = true) { m_valid = valid; }
[[nodiscard]] bool isEnabled() const { return m_enabled; }
void setEnabled(bool enabled) { m_enabled = enabled; }
[[nodiscard]] bool isAnalyzing() const { return m_analyzing; }
void setAnalyzing(bool analyzing) { m_analyzing = analyzing; }
virtual void load(const nlohmann::json &data);
[[nodiscard]] virtual nlohmann::json store();
[[nodiscard]] bool hasSettings() const { return m_hasSettings; }
private:
UnlocalizedString m_unlocalizedName, m_unlocalizedDescription;
bool m_hasSettings;
std::atomic<bool> m_analyzing = false;
std::atomic<bool> m_valid = false;
std::atomic<bool> m_enabled = true;
};
namespace impl {
using CreateCallback = std::function<std::unique_ptr<InformationSection>()>;
const std::vector<CreateCallback>& getInformationSectionConstructors();
void addInformationSectionCreator(const CreateCallback &callback);
}
template<typename T>
void addInformationSection(auto && ...args) {
impl::addInformationSectionCreator([args...] {
return std::make_unique<T>(std::forward<decltype(args)>(args)...);
});
}
}
}

View File

@@ -1,112 +0,0 @@
#pragma once
#include <hex.hpp>
#include <hex/api/localization_manager.hpp>
#include <functional>
#include <optional>
#include <string>
#include <vector>
#include <bit>
EXPORT_MODULE namespace hex {
/* Data Inspector Registry. Allows adding of new types to the data inspector */
namespace ContentRegistry::DataInspector {
enum class NumberDisplayStyle : u8 {
Decimal,
Hexadecimal,
Octal
};
namespace impl {
struct DoNotUseThisByItselfTag {};
using DisplayFunction = std::function<std::string()>;
using EditingFunction = std::function<std::optional<std::vector<u8>>(std::string&, std::endian, DoNotUseThisByItselfTag)>;
using GeneratorFunction = std::function<DisplayFunction(const std::vector<u8> &, std::endian, NumberDisplayStyle)>;
struct Entry {
UnlocalizedString unlocalizedName;
size_t requiredSize;
size_t maxSize;
GeneratorFunction generatorFunction;
std::optional<EditingFunction> editingFunction;
};
const std::vector<Entry>& getEntries();
}
namespace EditWidget {
class Widget {
public:
using Function = std::function<std::vector<u8>(const std::string&, std::endian)>;
explicit Widget(const Function &function) : m_function(function) {}
virtual ~Widget() = default;
virtual std::optional<std::vector<u8>> draw(std::string &value, std::endian endian) = 0;
std::optional<std::vector<u8>> operator()(std::string &value, std::endian endian, impl::DoNotUseThisByItselfTag) {
return draw(value, endian);
}
std::vector<u8> getBytes(const std::string &value, std::endian endian) const {
return m_function(value, endian);
}
private:
Function m_function;
};
struct TextInput : Widget {
explicit TextInput(const Function &function) : Widget(function) {}
std::optional<std::vector<u8>> draw(std::string &value, std::endian endian) override;
};
}
/**
* @brief Adds a new entry to the data inspector
* @param unlocalizedName The unlocalized name of the entry
* @param requiredSize The minimum required number of bytes available for the entry to appear
* @param displayGeneratorFunction The function that will be called to generate the display function
* @param editingFunction The function that will be called to edit the data
*/
void add(
const UnlocalizedString &unlocalizedName,
size_t requiredSize,
impl::GeneratorFunction displayGeneratorFunction,
std::optional<impl::EditingFunction> editingFunction = std::nullopt
);
/**
* @brief Adds a new entry to the data inspector
* @param unlocalizedName The unlocalized name of the entry
* @param requiredSize The minimum required number of bytes available for the entry to appear
* @param maxSize The maximum number of bytes to read from the data
* @param displayGeneratorFunction The function that will be called to generate the display function
* @param editingFunction The function that will be called to edit the data
*/
void add(
const UnlocalizedString &unlocalizedName,
size_t requiredSize,
size_t maxSize,
impl::GeneratorFunction displayGeneratorFunction,
std::optional<impl::EditingFunction> editingFunction = std::nullopt
);
/**
* @brief Allows adding new menu items to data inspector row context menus. Call this function inside the
* draw function of the data inspector row definition.
* @param function Callback that will draw menu items
*/
void drawMenuItems(const std::function<void()> &function);
}
}

View File

@@ -1,64 +0,0 @@
#pragma once
#include <hex.hpp>
#include <hex/api/localization_manager.hpp>
#include <functional>
#include <memory>
#include <vector>
EXPORT_MODULE namespace hex {
#if !defined(HEX_MODULE_EXPORT)
namespace dp { class Node; }
#endif
/* Data Processor Node Registry. Allows adding new processor nodes to be used in the data processor */
namespace ContentRegistry::DataProcessor {
namespace impl {
using CreatorFunction = std::function<std::unique_ptr<dp::Node>()>;
struct Entry {
UnlocalizedString unlocalizedCategory;
UnlocalizedString unlocalizedName;
CreatorFunction creatorFunction;
};
void add(const Entry &entry);
const std::vector<Entry>& getEntries();
}
/**
* @brief Adds a new node to the data processor
* @tparam T The custom node class that extends dp::Node
* @tparam Args Arguments types
* @param unlocalizedCategory The unlocalized category name of the node
* @param unlocalizedName The unlocalized name of the node
* @param args Arguments passed to the constructor of the node
*/
template<std::derived_from<dp::Node> T, typename... Args>
void add(const UnlocalizedString &unlocalizedCategory, const UnlocalizedString &unlocalizedName, Args &&...args) {
add(impl::Entry {
unlocalizedCategory,
unlocalizedName,
[unlocalizedName, ...args = std::forward<Args>(args)]() mutable {
auto node = std::make_unique<T>(std::forward<Args>(args)...);
node->setUnlocalizedName(unlocalizedName);
return node;
}
});
}
/**
* @brief Adds a separator to the data processor right click menu
*/
void addSeparator();
}
}

View File

@@ -1,68 +0,0 @@
#pragma once
#include <hex.hpp>
#include <hex/api/localization_manager.hpp>
#include <wolv/container/interval_tree.hpp>
#include <vector>
#include <memory>
EXPORT_MODULE namespace hex {
#if !defined(HEX_MODULE_EXPORT)
namespace prv { class Provider; }
#endif
/* Diffing Registry. Allows adding new diffing algorithms */
namespace ContentRegistry::Diffing {
enum class DifferenceType : u8 {
Match = 0,
Insertion = 1,
Deletion = 2,
Mismatch = 3
};
using DiffTree = wolv::container::IntervalTree<DifferenceType>;
class Algorithm {
public:
explicit Algorithm(UnlocalizedString unlocalizedName, UnlocalizedString unlocalizedDescription)
: m_unlocalizedName(std::move(unlocalizedName)),
m_unlocalizedDescription(std::move(unlocalizedDescription)) { }
virtual ~Algorithm() = default;
virtual std::vector<DiffTree> analyze(prv::Provider *providerA, prv::Provider *providerB) const = 0;
virtual void drawSettings() { }
const UnlocalizedString& getUnlocalizedName() const { return m_unlocalizedName; }
const UnlocalizedString& getUnlocalizedDescription() const { return m_unlocalizedDescription; }
private:
UnlocalizedString m_unlocalizedName, m_unlocalizedDescription;
};
namespace impl {
const std::vector<std::unique_ptr<Algorithm>>& getAlgorithms();
void addAlgorithm(std::unique_ptr<Algorithm> &&hash);
}
/**
* @brief Adds a new hash
* @tparam T The hash type that extends hex::Hash
* @param args The arguments to pass to the constructor of the hash
*/
template<typename T, typename ... Args>
void addAlgorithm(Args && ... args) {
impl::addAlgorithm(std::make_unique<T>(std::forward<Args>(args)...));
}
}
}

View File

@@ -1,64 +0,0 @@
#pragma once
#include <hex.hpp>
#include <hex/api/localization_manager.hpp>
#include <string>
#include <map>
#include <memory>
#include <functional>
#include <optional>
#include <span>
EXPORT_MODULE namespace hex {
/* Disassembler Registry. Allows adding new disassembler architectures */
namespace ContentRegistry::Disassemblers {
struct Instruction {
u64 address;
u64 offset;
size_t size;
std::string bytes;
std::string mnemonic;
std::string operators;
};
class Architecture {
public:
explicit Architecture(std::string name) : m_name(std::move(name)) {}
virtual ~Architecture() = default;
virtual bool start() = 0;
virtual void end() = 0;
virtual std::optional<Instruction> disassemble(u64 imageBaseAddress, u64 instructionLoadAddress, u64 instructionDataAddress, std::span<const u8> code) = 0;
virtual void drawSettings() = 0;
[[nodiscard]] const std::string& getName() const { return m_name; }
private:
std::string m_name;
};
namespace impl {
using CreatorFunction = std::function<std::unique_ptr<Architecture>()>;
void addArchitectureCreator(CreatorFunction function);
const std::map<std::string, CreatorFunction>& getArchitectures();
}
template<std::derived_from<Architecture> T>
void add(auto && ...args) {
impl::addArchitectureCreator([...args = std::move(args)] {
return std::make_unique<T>(args...);
});
}
}
}

View File

@@ -1,36 +0,0 @@
#pragma once
#include <hex.hpp>
#include <hex/api/localization_manager.hpp>
#include <map>
#include <string>
EXPORT_MODULE namespace hex {
/* Experiments Registry. Allows adding new experiments */
namespace ContentRegistry::Experiments {
namespace impl {
struct Experiment {
UnlocalizedString unlocalizedName, unlocalizedDescription;
bool enabled;
};
const std::map<std::string, Experiment>& getExperiments();
}
void addExperiment(
const std::string &experimentName,
const UnlocalizedString &unlocalizedName,
const UnlocalizedString &unlocalizedDescription = ""
);
void enableExperiement(const std::string &experimentName, bool enabled);
[[nodiscard]] bool isExperimentEnabled(const std::string &experimentName);
}
}

View File

@@ -1,37 +0,0 @@
#pragma once
#include <hex.hpp>
#include <hex/helpers/fs.hpp>
#include <vector>
#include <string>
#include <functional>
EXPORT_MODULE namespace hex {
/* File Handler Registry. Allows adding handlers for opening files specific file types */
namespace ContentRegistry::FileTypeHandler {
namespace impl {
using Callback = std::function<bool(std::fs::path)>;
struct Entry {
std::vector<std::string> extensions;
Callback callback;
};
const std::vector<Entry>& getEntries();
}
/**
* @brief Adds a new file handler
* @param extensions The file extensions to handle
* @param callback The function to call to handle the file
*/
void add(const std::vector<std::string> &extensions, const impl::Callback &callback);
}
}

View File

@@ -1,91 +0,0 @@
#pragma once
#include <hex.hpp>
#include <hex/api/localization_manager.hpp>
#include <vector>
#include <string>
#include <memory>
#include <functional>
#include <nlohmann/json_fwd.hpp>
EXPORT_MODULE namespace hex {
#if !defined(HEX_MODULE_EXPORT)
namespace prv { class Provider; }
#endif
/* Hash Registry. Allows adding new hashes to the Hash view */
namespace ContentRegistry::Hashes {
class Hash {
public:
explicit Hash(UnlocalizedString unlocalizedName) : m_unlocalizedName(std::move(unlocalizedName)) {}
virtual ~Hash() = default;
class Function {
public:
using Callback = std::function<std::vector<u8>(const Region&, prv::Provider *)>;
Function(Hash *type, std::string name, Callback callback)
: m_type(type), m_name(std::move(name)), m_callback(std::move(callback)) {
}
[[nodiscard]] Hash *getType() { return m_type; }
[[nodiscard]] const Hash *getType() const { return m_type; }
[[nodiscard]] const std::string& getName() const { return m_name; }
std::vector<u8> get(const Region& region, prv::Provider *provider) const {
return m_callback(region, provider);
}
private:
Hash *m_type;
std::string m_name;
Callback m_callback;
};
virtual void draw() { }
[[nodiscard]] virtual Function create(std::string name) = 0;
[[nodiscard]] virtual nlohmann::json store() const = 0;
virtual void load(const nlohmann::json &json) = 0;
[[nodiscard]] const UnlocalizedString& getUnlocalizedName() const {
return m_unlocalizedName;
}
protected:
[[nodiscard]] Function create(const std::string &name, const Function::Callback &callback) {
return { this, name, callback };
}
private:
UnlocalizedString m_unlocalizedName;
};
namespace impl {
const std::vector<std::unique_ptr<Hash>>& getHashes();
void add(std::unique_ptr<Hash> &&hash);
}
/**
* @brief Adds a new hash
* @tparam T The hash type that extends hex::Hash
* @param args The arguments to pass to the constructor of the hash
*/
template<typename T, typename ... Args>
void add(Args && ... args) {
impl::add(std::make_unique<T>(std::forward<Args>(args)...));
}
}
}

View File

@@ -1,91 +0,0 @@
#pragma once
#include <hex.hpp>
#include <imgui.h>
#include <hex/api/localization_manager.hpp>
#include <functional>
#include <memory>
#include <string>
#include <vector>
#include <span>
EXPORT_MODULE namespace hex {
/* Hex Editor Registry. Allows adding new functionality to the hex editor */
namespace ContentRegistry::HexEditor {
class DataVisualizer {
public:
DataVisualizer(UnlocalizedString unlocalizedName, u16 bytesPerCell, u16 maxCharsPerCell)
: m_unlocalizedName(std::move(unlocalizedName)),
m_bytesPerCell(bytesPerCell),
m_maxCharsPerCell(maxCharsPerCell) { }
virtual ~DataVisualizer() = default;
virtual void draw(u64 address, const u8 *data, size_t size, bool upperCase) = 0;
virtual bool drawEditing(u64 address, u8 *data, size_t size, bool upperCase, bool startedEditing) = 0;
[[nodiscard]] u16 getBytesPerCell() const { return m_bytesPerCell; }
[[nodiscard]] u16 getMaxCharsPerCell() const { return m_maxCharsPerCell; }
[[nodiscard]] const UnlocalizedString& getUnlocalizedName() const { return m_unlocalizedName; }
[[nodiscard]] static int DefaultTextInputFlags();
protected:
bool drawDefaultScalarEditingTextBox(u64 address, const char *format, ImGuiDataType dataType, u8 *data, ImGuiInputTextFlags flags) const;
bool drawDefaultTextEditingTextBox(u64 address, std::string &data, ImGuiInputTextFlags flags) const;
private:
UnlocalizedString m_unlocalizedName;
u16 m_bytesPerCell;
u16 m_maxCharsPerCell;
};
struct MiniMapVisualizer {
using Callback = std::function<void(u64, std::span<const u8>, std::vector<ImColor>&)>;
UnlocalizedString unlocalizedName;
Callback callback;
};
namespace impl {
void addDataVisualizer(std::shared_ptr<DataVisualizer> &&visualizer);
const std::vector<std::shared_ptr<DataVisualizer>>& getVisualizers();
const std::vector<std::shared_ptr<MiniMapVisualizer>>& getMiniMapVisualizers();
}
/**
* @brief Adds a new cell data visualizer
* @tparam T The data visualizer type that extends hex::DataVisualizer
* @param args The arguments to pass to the constructor of the data visualizer
*/
template<std::derived_from<DataVisualizer> T, typename... Args>
void addDataVisualizer(Args &&...args) {
return impl::addDataVisualizer(std::make_shared<T>(std::forward<Args>(args)...));
}
/**
* @brief Gets a data visualizer by its unlocalized name
* @param unlocalizedName Unlocalized name of the data visualizer
* @return The data visualizer, or nullptr if it doesn't exist
*/
std::shared_ptr<DataVisualizer> getVisualizerByName(const UnlocalizedString &unlocalizedName);
/**
* @brief Adds a new minimap visualizer
* @param unlocalizedName Unlocalized name of the minimap visualizer
* @param callback The callback that will be called to get the color of a line
*/
void addMiniMapVisualizer(UnlocalizedString unlocalizedName, MiniMapVisualizer::Callback callback);
}
}

View File

@@ -1,155 +0,0 @@
#pragma once
#include <hex.hpp>
#include <pl/pattern_language.hpp>
#include <functional>
#include <span>
#include <string>
#include <map>
#include <vector>
#include <mutex>
EXPORT_MODULE namespace hex {
#if !defined(HEX_MODULE_EXPORT)
namespace prv { class Provider; }
#endif
/* Pattern Language Function Registry. Allows adding of new functions that may be used inside the pattern language */
namespace ContentRegistry::PatternLanguage {
namespace impl {
using VisualizerFunctionCallback = std::function<void(pl::ptrn::Pattern&, bool, std::span<const pl::core::Token::Literal>)>;
struct FunctionDefinition {
pl::api::Namespace ns;
std::string name;
pl::api::FunctionParameterCount parameterCount;
pl::api::FunctionCallback callback;
bool dangerous;
};
struct TypeDefinition {
pl::api::Namespace ns;
std::string name;
pl::api::FunctionParameterCount parameterCount;
pl::api::TypeCallback callback;
};
struct Visualizer {
pl::api::FunctionParameterCount parameterCount;
VisualizerFunctionCallback callback;
};
const std::map<std::string, Visualizer>& getVisualizers();
const std::map<std::string, Visualizer>& getInlineVisualizers();
const std::map<std::string, pl::api::PragmaHandler>& getPragmas();
const std::vector<FunctionDefinition>& getFunctions();
const std::vector<TypeDefinition>& getTypes();
}
/**
* @brief Provides access to the current provider's pattern language runtime
* @return Runtime
*/
pl::PatternLanguage& getRuntime();
/**
* @brief Provides access to the current provider's pattern language runtime's lock
* @return Lock
*/
std::mutex& getRuntimeLock();
/**
* @brief Configures the pattern language runtime using ImHex's default settings
* @param runtime The pattern language runtime to configure
* @param provider The provider to use for data access
*/
void configureRuntime(pl::PatternLanguage &runtime, prv::Provider *provider);
/**
* @brief Adds a new pragma to the pattern language
* @param name The name of the pragma
* @param handler The handler that will be called when the pragma is encountered
*/
void addPragma(const std::string &name, const pl::api::PragmaHandler &handler);
/**
* @brief Adds a new function to the pattern language
* @param ns The namespace of the function
* @param name The name of the function
* @param parameterCount The amount of parameters the function takes
* @param func The function callback
*/
void addFunction(
const pl::api::Namespace &ns,
const std::string &name,
pl::api::FunctionParameterCount parameterCount,
const pl::api::FunctionCallback &func
);
/**
* @brief Adds a new dangerous function to the pattern language
* @note Dangerous functions are functions that require the user to explicitly allow them to be used
* @param ns The namespace of the function
* @param name The name of the function
* @param parameterCount The amount of parameters the function takes
* @param func The function callback
*/
void addDangerousFunction(
const pl::api::Namespace &ns,
const std::string &name,
pl::api::FunctionParameterCount parameterCount,
const pl::api::FunctionCallback &func
);
/**
* @brief Adds a new type to the pattern language
* @param ns The namespace of the type
* @param name The name of the type
* @param parameterCount The amount of non-type template parameters the type takes
* @param func The type callback
*/
void addType(
const pl::api::Namespace &ns,
const std::string &name,
pl::api::FunctionParameterCount parameterCount,
const pl::api::TypeCallback &func
);
/**
* @brief Adds a new visualizer to the pattern language
* @note Visualizers are extensions to the [[hex::visualize]] attribute, used to visualize data
* @param name The name of the visualizer
* @param function The function callback
* @param parameterCount The amount of parameters the function takes
*/
void addVisualizer(
const std::string &name,
const impl::VisualizerFunctionCallback &function,
pl::api::FunctionParameterCount parameterCount
);
/**
* @brief Adds a new inline visualizer to the pattern language
* @note Inline visualizers are extensions to the [[hex::inline_visualize]] attribute, used to visualize data
* @param name The name of the visualizer
* @param function The function callback
* @param parameterCount The amount of parameters the function takes
*/
void addInlineVisualizer(
const std::string &name,
const impl::VisualizerFunctionCallback &function,
pl::api::FunctionParameterCount parameterCount
);
}
}

View File

@@ -1,54 +0,0 @@
#pragma once
#include <hex.hpp>
#include <hex/api/localization_manager.hpp>
#include <hex/providers/provider.hpp>
#include <functional>
#include <memory>
#include <string>
#include <vector>
EXPORT_MODULE namespace hex {
/* Provider Registry. Allows adding new data providers to be created from the UI */
namespace ContentRegistry::Provider {
namespace impl {
void addProviderName(const UnlocalizedString &unlocalizedName, const char *icon);
using ProviderCreationFunction = std::function<std::shared_ptr<prv::Provider>()>;
void add(const std::string &typeName, ProviderCreationFunction creationFunction);
struct Entry {
UnlocalizedString unlocalizedName;
const char *icon;
};
const std::vector<Entry>& getEntries();
}
/**
* @brief Adds a new provider to the list of providers
* @tparam T The provider type that extends hex::prv::Provider
* @param addToList Whether to display the provider in the Other Providers list in the welcome screen and File menu
*/
template<std::derived_from<prv::Provider> T>
void add(bool addToList = true) {
const T provider;
auto typeName = provider.getTypeName();
impl::add(typeName, []() -> std::unique_ptr<prv::Provider> {
return std::make_unique<T>();
});
if (addToList)
impl::addProviderName(typeName, provider.getIcon());
}
}
}

View File

@@ -1,34 +0,0 @@
#pragma once
#include <hex.hpp>
#include <functional>
#include <string>
#include <vector>
EXPORT_MODULE namespace hex {
#if !defined(HEX_MODULE_EXPORT)
namespace prv { class Provider; }
#endif
/* Reports Registry. Allows adding new sections to exported reports */
namespace ContentRegistry::Reports {
namespace impl {
using Callback = std::function<std::string(prv::Provider*)>;
struct ReportGenerator {
Callback callback;
};
const std::vector<ReportGenerator>& getGenerators();
}
void addReportProvider(impl::Callback callback);
}
}

View File

@@ -1,418 +0,0 @@
#pragma once
#include <hex.hpp>
#include <hex/api/localization_manager.hpp>
#include <hex/helpers/fs.hpp>
#include <string>
#include <vector>
#include <memory>
#include <functional>
#include <optional>
#include <nlohmann/json.hpp>
#include <imgui.h>
EXPORT_MODULE namespace hex {
/* Settings Registry. Allows adding of new entries into the ImHex preferences window. */
namespace ContentRegistry::Settings {
namespace Widgets {
class Widget {
public:
virtual ~Widget() = default;
virtual bool draw(const std::string &name) = 0;
virtual void load(const nlohmann::json &data) = 0;
virtual nlohmann::json store() = 0;
class Interface {
public:
friend class Widget;
Interface& requiresRestart() {
m_requiresRestart = true;
return *this;
}
Interface& setEnabledCallback(std::function<bool()> callback) {
m_enabledCallback = std::move(callback);
return *this;
}
Interface& setChangedCallback(std::function<void(Widget&)> callback) {
m_changedCallback = std::move(callback);
return *this;
}
Interface& setTooltip(const UnlocalizedString &tooltip) {
m_tooltip = tooltip;
return *this;
}
[[nodiscard]]
Widget& getWidget() const {
return *m_widget;
}
private:
explicit Interface(Widget *widget) : m_widget(widget) {}
Widget *m_widget;
bool m_requiresRestart = false;
std::function<bool()> m_enabledCallback;
std::function<void(Widget&)> m_changedCallback;
std::optional<UnlocalizedString> m_tooltip;
};
[[nodiscard]]
bool doesRequireRestart() const {
return m_interface.m_requiresRestart;
}
[[nodiscard]]
bool isEnabled() const {
return !m_interface.m_enabledCallback || m_interface.m_enabledCallback();
}
[[nodiscard]]
const std::optional<UnlocalizedString>& getTooltip() const {
return m_interface.m_tooltip;
}
void onChanged() {
if (m_interface.m_changedCallback)
m_interface.m_changedCallback(*this);
}
[[nodiscard]]
Interface& getInterface() {
return m_interface;
}
private:
Interface m_interface = Interface(this);
};
class Checkbox : public Widget {
public:
explicit Checkbox(bool defaultValue) : m_value(defaultValue) { }
bool draw(const std::string &name) override;
void load(const nlohmann::json &data) override;
nlohmann::json store() override;
[[nodiscard]] bool isChecked() const { return m_value; }
protected:
bool m_value;
};
class SliderInteger : public Widget {
public:
SliderInteger(i32 defaultValue, i32 min, i32 max) : m_value(defaultValue), m_min(min), m_max(max) { }
bool draw(const std::string &name) override;
void load(const nlohmann::json &data) override;
nlohmann::json store() override;
[[nodiscard]] i32 getValue() const { return m_value; }
protected:
int m_value;
i32 m_min, m_max;
};
class SliderFloat : public Widget {
public:
SliderFloat(float defaultValue, float min, float max) : m_value(defaultValue), m_min(min), m_max(max) { }
bool draw(const std::string &name) override;
void load(const nlohmann::json &data) override;
nlohmann::json store() override;
[[nodiscard]] float getValue() const { return m_value; }
protected:
float m_value;
float m_min, m_max;
};
class SliderDataSize : public Widget {
public:
SliderDataSize(u64 defaultValue, u64 min, u64 max, u64 stepSize) : m_value(defaultValue), m_min(min), m_max(max), m_stepSize(stepSize) { }
bool draw(const std::string &name) override;
void load(const nlohmann::json &data) override;
nlohmann::json store() override;
[[nodiscard]] i32 getValue() const { return m_value; }
protected:
u64 m_value;
u64 m_min, m_max;
u64 m_stepSize;
};
class ColorPicker : public Widget {
public:
explicit ColorPicker(ImColor defaultColor, ImGuiColorEditFlags flags = 0);
bool draw(const std::string &name) override;
void load(const nlohmann::json &data) override;
nlohmann::json store() override;
[[nodiscard]] ImColor getColor() const;
protected:
std::array<float, 4> m_value = {}, m_defaultValue = {};
ImGuiColorEditFlags m_flags;
};
class DropDown : public Widget {
public:
explicit DropDown(const std::vector<std::string> &items, const std::vector<nlohmann::json> &settingsValues, const nlohmann::json &defaultItem) : m_items(items.begin(), items.end()), m_settingsValues(settingsValues), m_defaultItem(defaultItem) { }
explicit DropDown(const std::vector<UnlocalizedString> &items, const std::vector<nlohmann::json> &settingsValues, const nlohmann::json &defaultItem) : m_items(items), m_settingsValues(settingsValues), m_defaultItem(defaultItem) { }
bool draw(const std::string &name) override;
void load(const nlohmann::json &data) override;
nlohmann::json store() override;
[[nodiscard]]
const nlohmann::json& getValue() const;
protected:
std::vector<UnlocalizedString> m_items;
std::vector<nlohmann::json> m_settingsValues;
nlohmann::json m_defaultItem;
int m_value = -1;
};
class TextBox : public Widget {
public:
explicit TextBox(std::string defaultValue) : m_value(std::move(defaultValue)) { }
bool draw(const std::string &name) override;
void load(const nlohmann::json &data) override;
nlohmann::json store() override;
[[nodiscard]]
const std::string& getValue() const { return m_value; }
protected:
std::string m_value;
};
class FilePicker : public Widget {
public:
bool draw(const std::string &name) override;
void load(const nlohmann::json &data) override;
nlohmann::json store() override;
[[nodiscard]] const std::fs::path& getPath() const {
return m_path;
}
protected:
std::fs::path m_path;
};
class Label : public Widget {
public:
bool draw(const std::string &name) override;
void load(const nlohmann::json &) override {}
nlohmann::json store() override { return {}; }
};
class Spacer : public Widget {
public:
bool draw(const std::string &name) override;
void load(const nlohmann::json &) override {}
nlohmann::json store() override { return {}; }
};
}
namespace impl {
struct Entry {
UnlocalizedString unlocalizedName;
std::unique_ptr<Widgets::Widget> widget;
};
struct SubCategory {
UnlocalizedString unlocalizedName;
std::vector<Entry> entries;
};
struct Category {
UnlocalizedString unlocalizedName;
UnlocalizedString unlocalizedDescription;
std::vector<SubCategory> subCategories;
};
void load();
void store();
void clear();
const std::vector<Category>& getSettings();
nlohmann::json& getSetting(const UnlocalizedString &unlocalizedCategory, const UnlocalizedString &unlocalizedName, const nlohmann::json &defaultValue);
const nlohmann::json& getSettingsData();
Widgets::Widget* add(const UnlocalizedString &unlocalizedCategory, const UnlocalizedString &unlocalizedSubCategory, const UnlocalizedString &unlocalizedName, std::unique_ptr<Widgets::Widget> &&widget);
void printSettingReadError(const UnlocalizedString &unlocalizedCategory, const UnlocalizedString &unlocalizedName, const nlohmann::json::exception &e);
void runOnChangeHandlers(const UnlocalizedString &unlocalizedCategory, const UnlocalizedString &unlocalizedName, const nlohmann::json &value);
}
template<std::derived_from<Widgets::Widget> T>
Widgets::Widget::Interface& add(const UnlocalizedString &unlocalizedCategory, const UnlocalizedString &unlocalizedSubCategory, const UnlocalizedString &unlocalizedName, auto && ... args) {
return impl::add(
unlocalizedCategory,
unlocalizedSubCategory,
unlocalizedName,
std::make_unique<T>(std::forward<decltype(args)>(args)...)
)->getInterface();
}
void setCategoryDescription(const UnlocalizedString &unlocalizedCategory, const UnlocalizedString &unlocalizedDescription);
class SettingsValue {
public:
SettingsValue(nlohmann::json value) : m_value(std::move(value)) {}
template<typename T> requires (!(std::is_reference_v<T> || std::is_const_v<T>))
[[nodiscard]] T get(T defaultValue) const {
try {
auto result = m_value;
if (result.is_number() && std::same_as<T, bool>)
result = m_value.get<int>() != 0;
if (m_value.is_null())
result = defaultValue;
return result.get<T>();
} catch (const nlohmann::json::exception &) {
return defaultValue;
}
}
private:
nlohmann::json m_value;
};
template<typename T> requires (!(std::is_reference_v<T> || std::is_const_v<T>))
[[nodiscard]] T read(const UnlocalizedString &unlocalizedCategory, const UnlocalizedString &unlocalizedName, T defaultValue) {
auto setting = impl::getSetting(unlocalizedCategory, unlocalizedName, defaultValue);
try {
if (setting.is_number() && std::same_as<T, bool>)
setting = setting.template get<int>() != 0;
if (setting.is_null())
setting = defaultValue;
return setting.template get<T>();
} catch (const nlohmann::json::exception &e) {
impl::printSettingReadError(unlocalizedCategory, unlocalizedName, e);
return defaultValue;
}
}
template<typename T> requires (!(std::is_reference_v<T> || std::is_const_v<T>))
void write(const UnlocalizedString &unlocalizedCategory, const UnlocalizedString &unlocalizedName, T value) {
impl::getSetting(unlocalizedCategory, unlocalizedName, value) = value;
impl::runOnChangeHandlers(unlocalizedCategory, unlocalizedName, value);
impl::store();
}
using OnChangeCallback = std::function<void(const SettingsValue &)>;
u64 onChange(const UnlocalizedString &unlocalizedCategory, const UnlocalizedString &unlocalizedName, const OnChangeCallback &callback);
void removeOnChangeHandler(u64 id);
using OnSaveCallback = std::function<void()>;
u64 onSave(const OnSaveCallback &callback);
template<typename T, wolv::type::StaticString UnlocalizedCategory, wolv::type::StaticString UnlocalizedName>
requires (!(std::is_reference_v<T> || std::is_const_v<T>))
class SettingsVariable {
public:
explicit(false) SettingsVariable(T defaultValue) : m_defaultValue(std::move(defaultValue)) { }
SettingsVariable(const SettingsVariable&) = delete;
SettingsVariable& operator=(const SettingsVariable&) = delete;
SettingsVariable(SettingsVariable&&) = delete;
SettingsVariable& operator=(SettingsVariable&&) = delete;
~SettingsVariable() {
if (m_onChangeId > 0)
removeOnChangeHandler(m_onChangeId);
}
[[nodiscard]] T get() const {
registerChangeHandler();
if (!m_value.has_value()) {
m_value = read<T>(
UnlocalizedCategory.value.data(),
UnlocalizedName.value.data(),
m_defaultValue
);
}
return m_value.value_or(m_defaultValue);
}
void set(T value) {
registerChangeHandler();
write<T>(
UnlocalizedCategory.value.data(),
UnlocalizedName.value.data(),
std::move(value)
);
}
explicit(false) operator T() const {
return get();
}
SettingsVariable& operator=(T value) {
set(std::move(value));
return *this;
}
private:
void registerChangeHandler() const {
if (m_onChangeId > 0)
return;
m_onChangeId = onChange(UnlocalizedCategory.value.data(), UnlocalizedName.value.data(), [this](const SettingsValue &value) {
m_value = value.get<T>(m_defaultValue);
});
}
private:
mutable std::optional<T> m_value;
T m_defaultValue;
mutable u64 m_onChangeId = 0;
};
}
}

View File

@@ -1,37 +0,0 @@
#pragma once
#include <hex.hpp>
#include <hex/api/localization_manager.hpp>
#include <functional>
#include <vector>
EXPORT_MODULE namespace hex {
/* Tools Registry. Allows adding new entries to the tools window */
namespace ContentRegistry::Tools {
namespace impl {
using Callback = std::function<void()>;
struct Entry {
UnlocalizedString unlocalizedName;
const char *icon;
Callback function;
};
const std::vector<Entry>& getEntries();
}
/**
* @brief Adds a new tool to the tools window
* @param unlocalizedName The unlocalized name of the tool
* @param function The function that will be called to draw the tool
*/
void add(const UnlocalizedString &unlocalizedName, const char *icon, const impl::Callback &function);
}
}

View File

@@ -1,305 +0,0 @@
#pragma once
#include <hex.hpp>
#include <hex/api/shortcut_manager.hpp>
#include <hex/ui/imgui_imhex_extensions.h>
#include <string>
#include <vector>
#include <map>
#include <functional>
EXPORT_MODULE namespace hex {
/* User Interface Registry. Allows adding new items to various interfaces */
namespace ContentRegistry::UserInterface {
struct Icon {
Icon(const char *glyph, ImGuiCustomCol color = ImGuiCustomCol(0x00)) : glyph(glyph), color(color) {}
std::string glyph;
ImGuiCustomCol color;
};
namespace impl {
using DrawCallback = std::function<void()>;
using MenuCallback = std::function<void()>;
using EnabledCallback = std::function<bool()>;
using SelectedCallback = std::function<bool()>;
using ClickCallback = std::function<void()>;
using ToggleCallback = std::function<void(bool)>;
struct MainMenuItem {
UnlocalizedString unlocalizedName;
};
struct MenuItem {
std::vector<UnlocalizedString> unlocalizedNames;
Icon icon;
Shortcut shortcut;
View *view;
MenuCallback callback;
EnabledCallback enabledCallback;
SelectedCallback selectedCallback;
i32 toolbarIndex;
};
struct SidebarItem {
std::string icon;
DrawCallback callback;
EnabledCallback enabledCallback;
};
struct TitleBarButton {
std::string icon;
ImGuiCustomCol color;
UnlocalizedString unlocalizedTooltip;
ClickCallback callback;
};
struct WelcomeScreenQuickSettingsToggle {
std::string onIcon, offIcon;
UnlocalizedString unlocalizedTooltip;
ToggleCallback callback;
mutable bool state;
};
constexpr static auto SeparatorValue = "$SEPARATOR$";
constexpr static auto SubMenuValue = "$SUBMENU$";
constexpr static auto TaskBarMenuValue = "$TASKBAR$";
const std::multimap<u32, MainMenuItem>& getMainMenuItems();
const std::multimap<u32, MenuItem>& getMenuItems();
const std::vector<MenuItem*>& getToolbarMenuItems();
std::multimap<u32, MenuItem>& getMenuItemsMutable();
const std::vector<DrawCallback>& getWelcomeScreenEntries();
const std::vector<DrawCallback>& getFooterItems();
const std::vector<DrawCallback>& getToolbarItems();
const std::vector<SidebarItem>& getSidebarItems();
const std::vector<TitleBarButton>& getTitlebarButtons();
const std::vector<WelcomeScreenQuickSettingsToggle>& getWelcomeScreenQuickSettingsToggles();
}
/**
* @brief Adds a new top-level main menu entry
* @param unlocalizedName The unlocalized name of the entry
* @param priority The priority of the entry. Lower values are displayed first
*/
void registerMainMenuItem(const UnlocalizedString &unlocalizedName, u32 priority);
/**
* @brief Adds a new main menu entry
* @param unlocalizedMainMenuNames The unlocalized names of the main menu entries
* @param icon The icon to use for the entry
* @param priority The priority of the entry. Lower values are displayed first
* @param shortcut The shortcut to use for the entry
* @param function The function to call when the entry is clicked
* @param enabledCallback The function to call to determine if the entry is enabled
* @param view The view to use for the entry. If nullptr, the shortcut will work globally
*/
void addMenuItem(
const std::vector<UnlocalizedString> &unlocalizedMainMenuNames,
const Icon &icon,
u32 priority,
const Shortcut &shortcut,
const impl::MenuCallback &function,
const impl::EnabledCallback& enabledCallback, View *view
);
/**
* @brief Adds a new main menu entry
* @param unlocalizedMainMenuNames The unlocalized names of the main menu entries
* @param icon The icon to use for the entry
* @param priority The priority of the entry. Lower values are displayed first
* @param shortcut The shortcut to use for the entry
* @param function The function to call when the entry is clicked
* @param enabledCallback The function to call to determine if the entry is enabled
* @param selectedCallback The function to call to determine if the entry is selected
* @param view The view to use for the entry. If nullptr, the shortcut will work globally
*/
void addMenuItem(
const std::vector<UnlocalizedString> &unlocalizedMainMenuNames,
const Icon &icon,
u32 priority,
Shortcut shortcut,
const impl::MenuCallback &function,
const impl::EnabledCallback& enabledCallback = []{ return true; },
const impl::SelectedCallback &selectedCallback = []{ return false; },
View *view = nullptr
);
/**
* @brief Adds a new main menu entry
* @param unlocalizedMainMenuNames The unlocalized names of the main menu entries
* @param priority The priority of the entry. Lower values are displayed first
* @param shortcut The shortcut to use for the entry
* @param function The function to call when the entry is clicked
* @param enabledCallback The function to call to determine if the entry is enabled
* @param selectedCallback The function to call to determine if the entry is selected
* @param view The view to use for the entry. If nullptr, the shortcut will work globally
*/
void addMenuItem(
const std::vector<UnlocalizedString> &unlocalizedMainMenuNames,
u32 priority,
const Shortcut &shortcut,
const impl::MenuCallback &function,
const impl::EnabledCallback& enabledCallback = []{ return true; },
const impl::SelectedCallback &selectedCallback = []{ return false; },
View *view = nullptr
);
/**
* @brief Adds a new main menu sub-menu entry
* @param unlocalizedMainMenuNames The unlocalized names of the main menu entries
* @param priority The priority of the entry. Lower values are displayed first
* @param function The function to call when the entry is clicked
* @param enabledCallback The function to call to determine if the entry is enabled
* @param view The view to use for the entry. If nullptr, the item will always be visible
* @param showOnWelcomeScreen If this entry should be shown on the welcome screen
*/
void addMenuItemSubMenu(
std::vector<UnlocalizedString> unlocalizedMainMenuNames,
u32 priority,
const impl::MenuCallback &function,
const impl::EnabledCallback& enabledCallback = []{ return true; },
View *view = nullptr,
bool showOnWelcomeScreen = false
);
/**
* @brief Adds a new main menu sub-menu entry
* @param unlocalizedMainMenuNames The unlocalized names of the main menu entries
* @param icon The icon to use for the entry
* @param priority The priority of the entry. Lower values are displayed first
* @param function The function to call when the entry is clicked
* @param enabledCallback The function to call to determine if the entry is enabled
* @param view The view to use for the entry. If nullptr, the item will always be visible
* @param showOnWelcomeScreen If this entry should be shown on the welcome screen
*/
void addMenuItemSubMenu(
std::vector<UnlocalizedString> unlocalizedMainMenuNames,
const char *icon,
u32 priority,
const impl::MenuCallback &function,
const impl::EnabledCallback& enabledCallback = []{ return true; },
View *view = nullptr,
bool showOnWelcomeScreen = false
);
/**
* @brief Adds a new main menu separator
* @param unlocalizedMainMenuNames The unlocalized names of the main menu entries
* @param priority The priority of the entry. Lower values are displayed first
* @param view The view to use for the entry. If nullptr, the item will always be visible
*/
void addMenuItemSeparator(std::vector<UnlocalizedString> unlocalizedMainMenuNames, u32 priority, View *view = nullptr);
/**
* @brief Adds a new main menu entry
* @param unlocalizedMainMenuNames The unlocalized names of the main menu entries
* @param priority The priority of the entry. Lower values are displayed first
* @param function The function to call when the entry is clicked
* @param enabledCallback The function to call to determine if the entry is enabled
*/
void addTaskBarMenuItem(
std::vector<UnlocalizedString> unlocalizedMainMenuNames,
u32 priority,
const impl::MenuCallback &function,
const impl::EnabledCallback& enabledCallback
);
/**
* @brief Adds a new welcome screen entry
* @param function The function to call to draw the entry
*/
void addWelcomeScreenEntry(const impl::DrawCallback &function);
/**
* @brief Adds a new footer item
* @param function The function to call to draw the item
*/
void addFooterItem(const impl::DrawCallback &function);
/**
* @brief Adds a new toolbar item
* @param function The function to call to draw the item
*/
void addToolbarItem(const impl::DrawCallback &function);
/**
* @brief Adds a menu item to the toolbar
* @param unlocalizedNames Unlocalized name of the menu item
* @param color Color of the toolbar icon
*/
void addMenuItemToToolbar(const std::vector<UnlocalizedString> &unlocalizedNames, ImGuiCustomCol color);
/**
* @brief Reconstructs the toolbar items list after they have been modified
*/
void updateToolbarItems();
/**
* @brief Adds a new sidebar item
* @param icon The icon to use for the item
* @param function The function to call to draw the item
* @param enabledCallback The function
*/
void addSidebarItem(
const std::string &icon,
const impl::DrawCallback &function,
const impl::EnabledCallback &enabledCallback = []{ return true; }
);
/**
* @brief Adds a new title bar button
* @param icon The icon to use for the button
* @param color The color of the icon
* @param unlocalizedTooltip The unlocalized tooltip to use for the button
* @param function The function to call when the button is clicked
*/
void addTitleBarButton(
const std::string &icon,
ImGuiCustomCol color,
const UnlocalizedString &unlocalizedTooltip,
const impl::ClickCallback &function
);
/**
* @brief Adds a new welcome screen quick settings toggle
* @param icon The icon to use for the button
* @param unlocalizedTooltip The unlocalized tooltip to use for the button
* @param defaultState The default state of the toggle
* @param function The function to call when the button is clicked
*/
void addWelcomeScreenQuickSettingsToggle(
const std::string &icon,
const UnlocalizedString &unlocalizedTooltip,
bool defaultState,
const impl::ToggleCallback &function
);
/**
* @brief Adds a new welcome screen quick settings toggle
* @param onIcon The icon to use for the button when it's on
* @param offIcon The icon to use for the button when it's off
* @param unlocalizedTooltip The unlocalized tooltip to use for the button
* @param defaultState The default state of the toggle
* @param function The function to call when the button is clicked
*/
void addWelcomeScreenQuickSettingsToggle(
const std::string &onIcon,
const std::string &offIcon,
const UnlocalizedString &unlocalizedTooltip,
bool defaultState,
const impl::ToggleCallback &function
);
}
}

View File

@@ -1,63 +0,0 @@
#pragma once
#include <hex.hpp>
#include <hex/api/localization_manager.hpp>
#include <hex/ui/view.hpp>
#include <map>
#include <memory>
#include <functional>
EXPORT_MODULE namespace hex {
/* View Registry. Allows adding of new windows */
namespace ContentRegistry::Views {
namespace impl {
void add(std::unique_ptr<View> &&view);
void setFullScreenView(std::unique_ptr<View> &&view);
const std::map<UnlocalizedString, std::unique_ptr<View>>& getEntries();
const std::unique_ptr<View>& getFullScreenView();
}
/**
* @brief Adds a new view to ImHex
* @tparam T The custom view class that extends View
* @tparam Args Arguments types
* @param args Arguments passed to the constructor of the view
*/
template<std::derived_from<View> T, typename... Args>
void add(Args &&...args) {
return impl::add(std::make_unique<T>(std::forward<Args>(args)...));
}
/**
* @brief Sets a view as a full-screen view. This will cause the view to take up the entire ImHex window
* @tparam T The custom view class that extends View
* @tparam Args Arguments types
* @param args Arguments passed to the constructor of the view
*/
template<std::derived_from<View> T, typename... Args>
void setFullScreenView(Args &&...args) {
return impl::setFullScreenView(std::make_unique<T>(std::forward<Args>(args)...));
}
/**
* @brief Gets a view by its unlocalized name
* @param unlocalizedName The unlocalized name of the view
* @return The view if it exists, nullptr otherwise
*/
View* getViewByName(const UnlocalizedString &unlocalizedName);
/**
* @brief Gets the currently focused view
* @return The view that is focused right now. nullptr if none is focused
*/
View* getFocusedView();
}
}

View File

@@ -9,48 +9,29 @@
#include <map>
#include <string_view>
#include <hex/api/imhex_api.hpp>
#include <hex/helpers/logger.hpp>
#include <wolv/types/type_name.hpp>
#define EVENT_DEF_IMPL(event_name, event_name_string, should_log, ...) \
struct event_name final : public hex::impl::Event<__VA_ARGS__> { \
constexpr static auto Id = [] { return hex::impl::EventId(event_name_string); }(); \
constexpr static auto ShouldLog = (should_log); \
explicit event_name(Callback func) noexcept : Event(std::move(func)) { } \
\
static EventManager::EventList::iterator subscribe(Event::Callback function) { \
return EventManager::subscribe<event_name>(std::move(function)); \
} \
template<typename = void> \
static EventManager::EventList::iterator subscribe(Event::BaseCallback function) \
requires (!std::same_as<Event::Callback, Event::BaseCallback>) { \
return EventManager::subscribe<event_name>([function = std::move(function)](auto && ...) { function(); }); \
} \
static void subscribe(void *token, Event::Callback function) { \
EventManager::subscribe<event_name>(token, std::move(function)); \
} \
template<typename = void> \
static void subscribe(void *token, Event::BaseCallback function) \
requires (!std::same_as<Event::Callback, Event::BaseCallback>) { \
return EventManager::subscribe<event_name>(token, [function = std::move(function)](auto && ...) { function(); }); \
} \
static void unsubscribe(const EventManager::EventList::iterator &token) noexcept { \
EventManager::unsubscribe(token); \
} \
static void unsubscribe(void *token) noexcept { \
EventManager::unsubscribe<event_name>(token); \
} \
static void post(auto &&...args) { \
EventManager::post<event_name>(std::forward<decltype(args)>(args)...); \
} \
#define EVENT_DEF_IMPL(event_name, event_name_string, should_log, ...) \
struct event_name final : public hex::impl::Event<__VA_ARGS__> { \
constexpr static auto Id = [] { return hex::impl::EventId(event_name_string); }(); \
constexpr static auto ShouldLog = (should_log); \
explicit event_name(Callback func) noexcept : Event(std::move(func)) { } \
\
static EventManager::EventList::iterator subscribe(Event::Callback function) { return EventManager::subscribe<event_name>(std::move(function)); } \
static void subscribe(void *token, Event::Callback function) { EventManager::subscribe<event_name>(token, std::move(function)); } \
static void unsubscribe(const EventManager::EventList::iterator &token) noexcept { EventManager::unsubscribe(token); } \
static void unsubscribe(void *token) noexcept { EventManager::unsubscribe<event_name>(token); } \
static void post(auto &&...args) { EventManager::post<event_name>(std::forward<decltype(args)>(args)...); } \
}
#define EVENT_DEF(event_name, ...) EVENT_DEF_IMPL(event_name, #event_name, true, __VA_ARGS__)
#define EVENT_DEF_NO_LOG(event_name, ...) EVENT_DEF_IMPL(event_name, #event_name, false, __VA_ARGS__)
EXPORT_MODULE namespace hex {
namespace hex {
namespace impl {
@@ -84,22 +65,17 @@ EXPORT_MODULE namespace hex {
template<typename... Params>
struct Event : EventBase {
using Callback = std::function<void(Params...)>;
using BaseCallback = std::function<void()>;
explicit Event(Callback func) noexcept : m_func(std::move(func)) { }
template<typename E>
void call(auto&& ... params) const {
#if defined(DEBUG)
m_func(std::forward<decltype(params)>(params)...);
#else
try {
m_func(std::forward<decltype(params)>(params)...);
} catch (const std::exception &e) {
log::error("An exception occurred while handling event {}: {}", wolv::type::getTypeName<E>(), e.what());
throw;
}
#endif
void call(Params... params) const {
try {
m_func(params...);
} catch (const std::exception &e) {
log::error("An exception occurred while handling event {}: {}", wolv::type::getTypeName<E>(), e.what());
throw;
}
}
private:
@@ -128,8 +104,8 @@ EXPORT_MODULE namespace hex {
* @return Token to unsubscribe from the event
*/
template<impl::EventType E>
static EventList::iterator subscribe(E::Callback function) {
std::lock_guard lock(getEventMutex());
static EventList::iterator subscribe(typename E::Callback function) {
std::scoped_lock lock(getEventMutex());
auto &events = getEvents();
return events.insert({ E::Id, std::make_unique<E>(function) });
@@ -142,15 +118,15 @@ EXPORT_MODULE namespace hex {
* @param function Function to call when the event is posted
*/
template<impl::EventType E>
static void subscribe(void *token, E::Callback function) {
std::lock_guard lock(getEventMutex());
static void subscribe(void *token, typename E::Callback function) {
std::scoped_lock lock(getEventMutex());
if (isAlreadyRegistered(token, E::Id)) {
log::fatal("The token '{}' has already registered the same event ('{}')", token, wolv::type::getTypeName<E>());
return;
}
getTokenStore().insert({ token, subscribe<E>(std::move(function)) });
getTokenStore().insert({ token, subscribe<E>(function) });
}
/**
@@ -158,7 +134,7 @@ EXPORT_MODULE namespace hex {
* @param token Token returned by subscribe
*/
static void unsubscribe(const EventList::iterator &token) noexcept {
std::lock_guard lock(getEventMutex());
std::scoped_lock lock(getEventMutex());
getEvents().erase(token);
}
@@ -170,7 +146,7 @@ EXPORT_MODULE namespace hex {
*/
template<impl::EventType E>
static void unsubscribe(void *token) noexcept {
std::lock_guard lock(getEventMutex());
std::scoped_lock lock(getEventMutex());
unsubscribe(token, E::Id);
}
@@ -182,9 +158,9 @@ EXPORT_MODULE namespace hex {
*/
template<impl::EventType E>
static void post(auto && ...args) {
std::lock_guard lock(getEventMutex());
std::scoped_lock lock(getEventMutex());
const auto &[begin, end] = getEvents().equal_range(E::Id);
auto [begin, end] = getEvents().equal_range(E::Id);
for (auto it = begin; it != end; ++it) {
const auto &[id, event] = *it;
(*static_cast<E *const>(event.get())).template call<E>(std::forward<decltype(args)>(args)...);
@@ -200,7 +176,7 @@ EXPORT_MODULE namespace hex {
* @brief Unsubscribe all subscribers from all events
*/
static void clear() noexcept {
std::lock_guard lock(getEventMutex());
std::scoped_lock lock(getEventMutex());
getEvents().clear();
getTokenStore().clear();

View File

@@ -4,15 +4,17 @@
/* Forward declarations */
struct GLFWwindow;
using ImGuiID = unsigned int;
namespace hex { class View; }
/* GUI events definitions */
namespace hex {
/**
* @brief Signals a newly opened view
* @brief Signals a newly opened window
*
* This event is sent when the view has just been opened by the Window manager.
* This event is sent when the window has just been opened and docked by the Window manager.
*
* FIXME: In the event that a newly created window is already docked, this will not be sent.
*
* FIXME: This is currently only used for the introduction tutorial.
* If the event's only purpose is this, maybe rename it?
@@ -21,15 +23,6 @@ namespace hex {
*/
EVENT_DEF(EventViewOpened, View*);
/**
* @brief Signals a newly closed view
*
* This event is sent when the view has just been closed.
*
* @param view the closed view reference
*/
EVENT_DEF(EventViewClosed, View*);
/**
* @brief Signals a change in the DPI scale.
*
@@ -61,6 +54,15 @@ namespace hex {
*/
EVENT_DEF(EventWindowClosing, GLFWwindow*);
/**
* @brief Informs that the main window is initialized
*
* On Windows OS, it is used to initialize system theme, if ImHex's theme is following it.
*
* FIXME: Change event name to reflect Theme detection, if it's only used for that purpose?
*/
EVENT_DEF(EventWindowInitialized);
/**
* @brief Informs that the main window is deinitializing
*

Some files were not shown because too many files have changed in this diff Show More