diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5fa0436..be7ed31 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,12 +18,16 @@ jobs: - name: Installing dependencies run: | sudo apt-get update - sudo apt-get -y install cmake mingw-w64 mingw-w64-tools mingw-w64-i686-dev mingw-w64-x86-64-dev mingw-w64-common fakeroot build-essential debhelper + sudo apt-get -y install cmake fakeroot build-essential debhelper - name: Building ptr89 run: | - tools/build_deb.sh - tools/build_win.sh + fakeroot debian/rules binary + fakeroot debian/rules clean + cmake -B build -DBUILD_STATIC:BOOL=TRUE -DCMAKE_BUILD_TYPE=Release + cmake --build build -j$(nproc) + cd build + tar -cpvzf ptr89.tar.gz ./ptr89 - uses: softprops/action-gh-release@v1 with: @@ -31,4 +35,45 @@ jobs: prerelease: true files: | ../*.deb - build-win/ptr89.exe + build/ptr89.tar.gz + + - name: Check out homebrew tap + uses: actions/checkout@v3 + with: + repository: siemens-mobile-hacks/homebrew-tap + path: ./tap + token: ${{ secrets.TAP_GITHUB_TOKEN }} + + - name: Generate formula + run: | + sed -i "s/RELEASE_TAG_NAME/$GITHUB_REF_NAME/g" ptr89.rb + sed -i "s/RELEASE_TAG_HASH/$GITHUB_SHA/g" ptr89.rb + cat ptr89.rb + + cd tap + git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + git pull + cp ../ptr89.rb Formula/ptr89.rb + git add Formula/ptr89.rb + git commit -m "ptr89: $GITHUB_REF_NAME" + git push --set-upstream origin main + + build-windows: + runs-on: windows-2019 + steps: + - uses: actions/checkout@v3 + with: + submodules: true + + - name: Building ptr89 + run: | + cmake -B build + cmake --build build --config Release + + - uses: softprops/action-gh-release@v1 + with: + token: "${{ secrets.GITHUB_TOKEN }}" + prerelease: true + files: | + build/Release/ptr89.exe diff --git a/CMakeLists.txt b/CMakeLists.txt index 154e800..4297005 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,40 +1,33 @@ -cmake_minimum_required(VERSION 3.9) +cmake_minimum_required(VERSION 3.10) project(ptr89) set(CMAKE_CXX_STANDARD 20) set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE) -if (BUILD_WASM) - set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) -endif() - include_directories("./lib" "./third_party/argparse/include" "./third_party/json/include") set(LIB_SRC lib/src/Pattern.cpp lib/src/Tokenizer.cpp lib/src/Parser.cpp lib/src/utils.cpp) -if (BUILD_WASM) - # NodeJS - add_executable(ptr89-node src/main.cpp ${LIB_SRC}) - target_precompile_headers(ptr89-node PRIVATE ) - target_link_options(ptr89-node PUBLIC - -sMODULARIZE - -sINVOKE_RUN=0 - -sNODERAWFS - -sALLOW_MEMORY_GROWTH - -sEXPORTED_RUNTIME_METHODS=['ccall','callMain'] - -fwasm-exceptions - ) - target_compile_options(ptr89-node PUBLIC -O3 -fwasm-exceptions) -else() - add_executable(ptr89 src/main.cpp ${LIB_SRC}) - target_precompile_headers(ptr89 PRIVATE ) -# target_link_options(ptr89 PUBLIC -static) - target_compile_options(ptr89 PUBLIC -O3) - install(TARGETS ptr89 DESTINATION /usr/bin) +add_executable(ptr89 src/main.cpp ${LIB_SRC}) +target_precompile_headers(ptr89 PRIVATE ) +install(TARGETS ptr89) - if (BUILD_TESTS) - enable_testing() - add_executable(ptr89-tests src/tests.cpp ${LIB_SRC}) - add_test(NAME test COMMAND ptr89-tests) +if (MSVC) + add_definitions(-D_CRT_SECURE_NO_WARNINGS) +else() + if (BUILD_STATIC) + target_link_options(ptr89 PUBLIC -static -static-libgcc -static-libstdc++) endif() + + if (CMAKE_BUILD_TYPE MATCHES "Release") + target_link_options(ptr89 PUBLIC -s) + endif() + + target_compile_options(ptr89 PUBLIC -Wall -Wextra -Werror -O3) +endif() + +if (BUILD_TESTS) + enable_testing() + add_executable(ptr89-tests src/tests.cpp ${LIB_SRC}) + add_test(NAME test COMMAND ptr89-tests) endif() diff --git a/README.md b/README.md index 81dac99..501084b 100644 --- a/README.md +++ b/README.md @@ -18,18 +18,26 @@ The name was chosen in respect to [Viktor89](https://patches.kibab.com/user.php5 # DOWNLOAD - Windows: download .exe in [Releases](https://github.com/siemens-mobile-hacks/ptr89/releases). - ArchLinux: `yay -S ptr89-git` -- [Ubuntu/Debian/Fedora/OpenSUSE repository](https://software.opensuse.org//download.html?project=home%3AZhumarin&package=ptr89) -- Old Ubuntu/Debian: download .deb in [Releases](https://github.com/siemens-mobile-hacks/ptr89/releases). +- OSX: `brew install siemens-mobile-hacks/tap/ptr89` +- Ubuntu/Debian: download .deb in [Releases](https://github.com/siemens-mobile-hacks/ptr89/releases). - Build from sources: ```bash - # Ubuntu/Debian + git clone https://github.com/siemens-mobile-hacks/ptr89 + cd ptr89 + git submodule init + git submodule update + + # Ubuntu/Debian fakeroot debian/rules binary - - # OSX/Linux/Unix - mkdir build - cd build - cmake .. - make -j$(nproc) + + # OSX, Linux, Unix, MinGW, Windows MSVC + cmake -B build -DCMAKE_BUILD_TYPE=Release + cmake --build build + cmake --install build + + # Windows + cmake -B build + cmake --build build --config Release ``` # USAGE diff --git a/debian/changelog b/debian/changelog index 86fce84..f962f14 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -ptr89 (1.0.1) UNRELEASED; urgency=medium +ptr89 (1.0.2) UNRELEASED; urgency=medium * first release diff --git a/debian/rules b/debian/rules index acef0ef..12ddb20 100755 --- a/debian/rules +++ b/debian/rules @@ -16,5 +16,10 @@ ifneq (,$(findstring Ubuntu,$(OS))) endif endif +override_dh_auto_configure: + dh_auto_configure -- \ + -DCMAKE_BUILD_TYPE=Release \ + -DBUILD_STATIC:BOOL=ON + %: dh $@ --buildsystem=cmake diff --git a/lib/src/Parser.cpp b/lib/src/Parser.cpp index cc52900..aea2a23 100644 --- a/lib/src/Parser.cpp +++ b/lib/src/Parser.cpp @@ -130,7 +130,7 @@ void Parser::parseHexMask() { if (value.size() % 2 != 0) throw PatternError(this, "The hex number length must be even"); - for (int i = 0; i < value.size(); i += 2) { + for (size_t i = 0; i < value.size(); i += 2) { uint16_t mask = 0; uint16_t byte = 0; diff --git a/lib/src/Pattern.cpp b/lib/src/Pattern.cpp index 9b64e00..5393da6 100644 --- a/lib/src/Pattern.cpp +++ b/lib/src/Pattern.cpp @@ -3,10 +3,10 @@ #include #include #include -#include #include #include #include +#include #include "utils.h" @@ -60,9 +60,9 @@ bool Pattern::fuzzyMatch(const uint8_t *bytes, const uint8_t *masks, int pattern bool Pattern::checkPattern(const std::shared_ptr &pattern, size_t offset, const Memory &memory) { debugSectionBegin(); if (m_debugHandler) { - debug("Checking pattern: '%s' at %08lX\n", stringify(pattern).c_str(), memory.base + offset); + debug("Checking pattern: '%s' at %08" PRIu64 "X\n", stringify(pattern).c_str(), memory.base + offset); if (m_debugLevel == 0) - debug("Memory: %08X %08lX\n", memory.base, memory.size); + debug("Memory: %08X %08" PRIu64 "X\n", memory.base, memory.size); } if (pattern->type == PATTERN_TYPE_STATIC_VALUE) { @@ -78,7 +78,7 @@ bool Pattern::checkPattern(const std::shared_ptr &pattern, size_t offset if (offset + patternSize >= memory.size) { if (m_debugHandler) - debug("FAIL: Address %08lX is out of range.\n", memory.base + offset); + debug("FAIL: Address %08" PRIu64 "X is out of range.\n", memory.base + offset); debugSectionEnd(); return false; } @@ -116,7 +116,7 @@ bool Pattern::checkSubpatterns(const std::shared_ptr &pattern, size_t of case SUB_PATTERN_TYPE_BRANCH_2B: { if (m_debugHandler) - debug("Decoding THUMB B at %08lX\n", memory.base + offset + p.offset); + debug("Decoding THUMB B at %08" PRIu64 "X\n", memory.base + offset + p.offset); auto [isThumb, thumbAddr] = decodeThumbB(memory.base + offset + p.offset, memory.data + offset + p.offset); if (isThumb && inMemory(memory, thumbAddr, 4)) { @@ -135,7 +135,7 @@ bool Pattern::checkSubpatterns(const std::shared_ptr &pattern, size_t of case SUB_PATTERN_TYPE_BRANCH_4B: { if (m_debugHandler) - debug("Try decoding THUMB BL/BLX at %08lX\n", memory.base + offset + p.offset); + debug("Try decoding THUMB BL/BLX at %08" PRIu64 "X\n", memory.base + offset + p.offset); auto [isThumb, thumbAddr, isThumbBLX] = decodeThumbBL(memory.base + offset + p.offset, memory.data + offset + p.offset); if (isThumb && inMemory(memory, thumbAddr, 4)) { @@ -151,7 +151,7 @@ bool Pattern::checkSubpatterns(const std::shared_ptr &pattern, size_t of } if (m_debugHandler) - debug("Try decoding ARM B/BL/BLX at %08lX\n", memory.base + offset + p.offset); + debug("Try decoding ARM B/BL/BLX at %08" PRIu64 "X\n", memory.base + offset + p.offset); auto [isArm, armAddr, isArmBLX] = decodeArmBL(memory.base + offset + p.offset, memory.data + offset + p.offset); if (isArm && inMemory(memory, armAddr, 4)) { @@ -167,7 +167,7 @@ bool Pattern::checkSubpatterns(const std::shared_ptr &pattern, size_t of } if (m_debugHandler) - debug("Try decoding ARM THRUNK at %08lX\n", memory.base + offset + p.offset); + debug("Try decoding ARM THRUNK at %08" PRIu64 "X\n", memory.base + offset + p.offset); auto [isArmLdr, armLDR, isThunk] = decodeArmLDR(memory.base + offset + p.offset, memory.data + offset + p.offset); if (isArmLdr && isThunk) { @@ -193,7 +193,7 @@ bool Pattern::checkSubpatterns(const std::shared_ptr &pattern, size_t of case SUB_PATTERN_TYPE_LDR_2B: { if (m_debugHandler) - debug("Try decoding THUMB LDR at %08lX\n", memory.base + offset + p.offset); + debug("Try decoding THUMB LDR at %08" PRIu64 "X\n", memory.base + offset + p.offset); auto [isThumbLdr, thumbLdrAddr] = decodeThumbLDR(memory.base + offset + p.offset, memory.data + offset + p.offset); if (isThumbLdr) { @@ -218,7 +218,7 @@ bool Pattern::checkSubpatterns(const std::shared_ptr &pattern, size_t of case SUB_PATTERN_TYPE_LDR_4B: { if (m_debugHandler) - debug("Try decoding ARM LDR at %08lX\n", memory.base + offset + p.offset); + debug("Try decoding ARM LDR at %08" PRIu64 "X\n", memory.base + offset + p.offset); auto [isArmLdr, armLdrAddr, isArmThrunk] = decodeArmLDR(memory.base + offset + p.offset, memory.data + offset + p.offset); if (isArmLdr) { @@ -425,7 +425,7 @@ int Pattern::findAlignForPattern(const std::shared_ptr &pattern, int ali return align; } -std::vector Pattern::find(const std::shared_ptr &pattern, const Memory &memory, int maxResults) { +std::vector Pattern::find(const std::shared_ptr &pattern, const Memory &memory, size_t maxResults) { int firstNonWildcardByte = 0; bool isTrulyWildcard = true; int patternSize = pattern->bytes.size(); @@ -434,7 +434,7 @@ std::vector Pattern::find(const std::shared_ptr & if (m_debugHandler) { debug("Searching pattern: %s\n", stringify(pattern).c_str()); - debug("Memory: %08X %08lX\n", memory.base, memory.size); + debug("Memory: %08X %08" PRIu64 "X\n", memory.base, memory.size); debug("\n"); } @@ -489,7 +489,7 @@ std::vector Pattern::find(const std::shared_ptr & size_t foundOffset = i - firstNonWildcardByte; if (m_debugHandler) - debug("Possible result at %08lX\n", memory.base + foundOffset); + debug("Possible result at %08" PRIu64 "X\n", memory.base + foundOffset); if (checkSubpatterns(pattern, foundOffset, memory)) { auto [isDecoded, result] = decodeResult(pattern, foundOffset + pattern->inputOffset, memory); @@ -535,7 +535,7 @@ std::vector Pattern::find(const std::shared_ptr & if (fuzzyMatch(bytes, masks, size, memory.data + i)) { size_t foundOffset = i - firstNonWildcardByte; if (m_debugHandler) - debug("Possible result at %08lX\n", memory.base + foundOffset); + debug("Possible result at %08" PRIu64 "X\n", memory.base + foundOffset); if (checkSubpatterns(pattern, foundOffset, memory)) { auto [isDecoded, result] = decodeResult(pattern, foundOffset + pattern->inputOffset, memory); if (isDecoded) { @@ -576,7 +576,7 @@ std::vector Pattern::find(const std::shared_ptr & return searchResults; } -std::vector Pattern::finXRefs(uint32_t addr, const Memory &memory, int maxResults) { +std::vector Pattern::finXRefs(uint32_t addr, const Memory &memory, size_t maxResults) { debug("Searching XRef's for %08X\n", addr); std::vector searchResults; for (size_t i = 0; i < memory.size; i += 2) { @@ -584,15 +584,20 @@ std::vector Pattern::finXRefs(uint32_t addr, const Me auto [isBranchReference, branchAddr] = decodeBranchReference(i, memory); auto [isPointer, ptrAddr] = decodePointer(i + memory.base, memory); if (isBranchReference && (branchAddr & ~1) == (addr & ~1)) { - debug("FOUND: branch call at %08lX\n", i + memory.base); + debug("FOUND: branch call at %08" PRIu64 "X\n", i + memory.base); searchResults.push_back({ XREF_TYPE_BRANCH_CALL, static_cast(memory.base + i), static_cast(i) }); } else if (isReference && (refAddr & ~1) == (addr & ~1)) { - debug("FOUND: reference at %08lX\n", i + memory.base); + debug("FOUND: reference at %08" PRIu64 "X\n", i + memory.base); searchResults.push_back({ XREF_TYPE_REFERENCE, static_cast(memory.base + i), static_cast(i) }); } else if (isPointer && (ptrAddr & ~1) == (addr & ~1)) { - debug("FOUND: pointer at %08lX\n", i + memory.base); + debug("FOUND: pointer at %08" PRIu64 "X\n", i + memory.base); searchResults.push_back({ XREF_TYPE_POINTER, static_cast(memory.base + i), static_cast(i) }); } + + if (maxResults && searchResults.size() >= maxResults) { + debug("Maximum search results are reached.\n"); + break; + } } return searchResults; } @@ -742,7 +747,6 @@ std::pair Pattern::decodeThumbB(uint32_t offset, const uint8_t * std::pair Pattern::decodeThumbLDR(uint32_t offset, const uint8_t *bytes) { uint16_t instr1 = (bytes[1] << 8) | bytes[0]; - uint16_t instr2 = (bytes[3] << 8) | bytes[2]; if ((offset % 2) != 0) return { false, 0 }; diff --git a/lib/src/Pattern.h b/lib/src/Pattern.h index 5a78bb7..b94c2bb 100644 --- a/lib/src/Pattern.h +++ b/lib/src/Pattern.h @@ -93,8 +93,8 @@ class Pattern { static std::shared_ptr parse(const std::string &pattern); static std::string stringify(const std::shared_ptr &pattern); static int findAlignForPattern(const std::shared_ptr &pattern, int align); - static std::vector find(const std::shared_ptr &pattern, const Memory &memory, int maxResults = 0); - static std::vector finXRefs(uint32_t addr, const Memory &memory, int maxResults = 0); + static std::vector find(const std::shared_ptr &pattern, const Memory &memory, size_t maxResults = 0); + static std::vector finXRefs(uint32_t addr, const Memory &memory, size_t maxResults = 0); static bool checkPattern(const std::shared_ptr &pattern, size_t offset, const Memory &memory); static std::tuple decodeThumbBL(uint32_t offset, const uint8_t *bytes); static std::tuple decodeArmBL(uint32_t offset, const uint8_t *bytes); diff --git a/lib/src/Tokenizer.cpp b/lib/src/Tokenizer.cpp index f2153f8..de8042b 100644 --- a/lib/src/Tokenizer.cpp +++ b/lib/src/Tokenizer.cpp @@ -34,7 +34,7 @@ bool Tokenizer::isBinPattern(char c) { Tokenizer::Token Tokenizer::parseToken() { auto start = m_offset; - if (m_offset == m_input.size()) { + if (m_offset == (int) m_input.size()) { return { TOK_EOF, m_offset, m_offset }; } diff --git a/lib/src/Tokenizer.h b/lib/src/Tokenizer.h index 2c0ddcf..ab21129 100644 --- a/lib/src/Tokenizer.h +++ b/lib/src/Tokenizer.h @@ -34,9 +34,9 @@ class Tokenizer { }; struct Token { - TokenType type; - int start; - int end; + TokenType type = TOK_NULL; + int start = 0; + int end = 0; }; protected: diff --git a/lib/src/utils.cpp b/lib/src/utils.cpp index 9f7f908..812f2cc 100644 --- a/lib/src/utils.cpp +++ b/lib/src/utils.cpp @@ -1,5 +1,6 @@ #include "utils.h" +#include #include #include #include @@ -9,7 +10,7 @@ namespace Ptr89 { std::pair getLocByOffset(const std::string &text, int offset) { int line = 1; int col = 1; - for (int i = 0; i < text.size(); i++) { + for (int i = 0; i < std::ssize(text); i++) { if (text[i] == '\n') { line++; col = 1; @@ -46,14 +47,14 @@ std::string codeFrame(const std::string &text, int lineNum, int colNum) { std::string padStart(const std::string &line, int maxLength, char c) { std::string newStr = line; - while (newStr.size() < maxLength) + while (std::ssize(newStr) < maxLength) newStr = c + newStr; return newStr; } std::string str2spaces(const std::string &line) { std::string newStr = ""; - for (int i = 0; i < line.size(); i++) { + for (size_t i = 0; i < line.size(); i++) { newStr += ' '; } return newStr; @@ -62,7 +63,7 @@ std::string str2spaces(const std::string &line) { std::string tab2spaces(const std::string &line) { std::string newStr = ""; int virtualSymbols = 0; - for (int i = 0; i < line.size(); i++) { + for (size_t i = 0; i < line.size(); i++) { char c = line[i]; if (c == '\t') { int spacesCnt = 4 - virtualSymbols % 4; diff --git a/lib/src/utils.h b/lib/src/utils.h index f5acf73..326463c 100644 --- a/lib/src/utils.h +++ b/lib/src/utils.h @@ -3,6 +3,7 @@ #include #include #include +#include namespace Ptr89 { @@ -14,6 +15,21 @@ std::string tab2spaces(const std::string &line); std::string strJoin(const std::string &sep, const std::vector &lines); std::vector strSplit(const std::string &sep, const std::string &str); + +#if defined(_MSC_VER) +std::string strprintf(const char *format, ...); +#else std::string strprintf(const char *format, ...) __attribute__((format(printf, 1, 2))); +#endif + +template +constexpr auto toUnsigned(T const value) { + return static_cast>(value); +} + +template +constexpr auto toSigned(T const value) { + return static_cast>(value); +} }; // namespace Ptr89 diff --git a/obs/PKGBUILD b/obs/PKGBUILD deleted file mode 100644 index 3013596..0000000 --- a/obs/PKGBUILD +++ /dev/null @@ -1,21 +0,0 @@ -# Maintainer: Kirill Zhumarin -pkgname=ptr89 -pkgver=v1.0.2 -pkgrel=1 -pkgdesc='Yet another binary pattern finder.' -arch=(any) -url='https://github.com/siemens-mobile-hacks/ptr89' -license=(MIT) -depends=() -makedepends=(cmake) -source=($pkgname-$pkgver.tar.gz) -sha256sums=('SKIP') - -build() { - cmake -B build -S $pkgname-$pkgver - cmake --build build -} - -package() { - DESTDIR="$pkgdir" cmake --install build -} diff --git a/obs/debian.dsc b/obs/debian.dsc deleted file mode 100644 index cd946d7..0000000 --- a/obs/debian.dsc +++ /dev/null @@ -1,9 +0,0 @@ -Format: 3.0 (native) -Source: ptr89 -Version: 1.0.0 -Binary: ptr89 -Maintainer: Kirill Zhumarin -Homepage: https://github.com/siemens-mobile-hacks/ptr89 -Architecture: any -Standards-Version: 3.9.3 -Build-Depends: debhelper (>= 4.0.0), g++-12, gcc-12, cmake, quilt, lsb-release diff --git a/obs/ptr89.spec b/obs/ptr89.spec deleted file mode 100644 index d506b5c..0000000 --- a/obs/ptr89.spec +++ /dev/null @@ -1,37 +0,0 @@ -%global debug_package %{nil} -%define _unpackaged_files_terminate_build 0 - -Name: ptr89 -Version: 1.0 -Release: 0 -Summary: Yet another binary pattern finder -License: MIT -Source0: %{name}-%version.tar.gz -URL: https://github.com/siemens-mobile-hacks/ptr89 -BuildRequires: gcc -BuildRequires: gcc-c++ -BuildRequires: git -BuildRequires: cmake - -%description -Yet another binary pattern finder. - -%prep -%setup -q - -%build -%cmake -%cmake_build - -%install -%cmake_install - -%check -%ctest - -%files -/usr/bin/ptr89 -%license LICENSE -%doc README.md - -%changelog diff --git a/ptr89.rb b/ptr89.rb new file mode 100644 index 0000000..9a51846 --- /dev/null +++ b/ptr89.rb @@ -0,0 +1,26 @@ +class Elf2vkp < Formula + desc "Tool for converting .elf to .vkp patches" + homepage "https://github.com/siemens-mobile-hacks/ptr89" + url "https://github.com/siemens-mobile-hacks/ptr89.git", + tag: "RELEASE_TAG_NAME", + revision: "RELEASE_TAG_HASH" + license "MIT" + head "https://github.com/siemens-mobile-hacks/ptr89.git", branch: "main" + + livecheck do + url :stable + strategy :github_latest + end + + depends_on "cmake" => :build + + def install + system "cmake", "-S", ".", "-B", "build", *std_cmake_args + system "cmake", "--build", "build" + system "cmake", "--install", "build" + end + + test do + assert_match "Usage: ptr89", shell_output("#{bin}/ptr89 -h 2>&1", 1) + end +end diff --git a/src/main.cpp b/src/main.cpp index 6838d86..be41c6a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -8,7 +8,7 @@ using json = nlohmann::json; using namespace Ptr89; int main(int argc, char *argv[]) { - argparse::ArgumentParser program("ptr89", "1.0.1"); + argparse::ArgumentParser program("ptr89", "1.0.2"); program.add_argument("-f", "--file") .required() @@ -137,7 +137,7 @@ int main(int argc, char *argv[]) { j["patterns"].push_back(patternJson); } else { printf("Pattern: '%s'\n", patternStr.c_str()); - printf("Found %ld matches:\n", results.size()); + printf("Found %" PRIu64 "d matches:\n", results.size()); for (auto &result: results) { if (pattern->type == PATTERN_TYPE_OFFSET) { printf(" %08X: %08X (offset)\n", result.address, result.value); @@ -185,7 +185,7 @@ int main(int argc, char *argv[]) { } } else { printf("Searching x-refs for %08X\n", addr); - printf("Found %ld matches:\n", results.size()); + printf("Found %" PRIu64 "d matches:\n", results.size()); for (auto &result: results) { if (result.type == XREF_TYPE_REFERENCE) { printf(" %08X (reference)\n", result.address); @@ -325,7 +325,6 @@ std::pair readBinaryFile(const std::string &path) { size_t maxFileSize = std::filesystem::file_size(path); uint8_t *bytes = new uint8_t[maxFileSize]; - char buff[4096]; size_t readed = 0; while (!feof(fp) && readed < maxFileSize) { int ret = fread(bytes + readed, 1, std::min(static_cast(4096), maxFileSize - readed), fp); diff --git a/tools/build_wasm.sh b/tools/build_wasm.sh deleted file mode 100755 index cbb7007..0000000 --- a/tools/build_wasm.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -set -e -set -x -cd $(dirname $0)/../ - -[[ -d ./build-wasm ]] || mkdir build-wasm - -cd build-wasm -emcmake cmake .. -DBUILD_WASM=true -make -j$(nproc) diff --git a/tools/build_win.sh b/tools/build_win.sh index 550aa39..7dd117c 100755 --- a/tools/build_win.sh +++ b/tools/build_win.sh @@ -5,8 +5,7 @@ cd $(dirname $0)/../ [[ -d ./build-win ]] || mkdir build-win -cd build-win -cmake .. -DCMAKE_TOOLCHAIN_FILE=cmake/Toolchain-x86_64-w64-mingw32.cmake -make -j$(nproc) +cmake -B build-win -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=cmake/Toolchain-x86_64-w64-mingw32.cmake -DBUILD_STATIC:BOOL=TRUE +cmake --build build-win -- -j$(nproc) -ls -lah ptr89.exe +ls -lah build-win/ptr89.exe