From 1a0d28b5143dd5e04f55ffa0744692deba4c1025 Mon Sep 17 00:00:00 2001 From: Simplxs Date: Fri, 10 May 2024 18:19:30 +0800 Subject: [PATCH] feat: arm64 --- .github/workflows/build.yml | 8 +++--- CMakePresets.json | 52 ++++++++----------------------------- src/sign.cpp | 25 +++++++----------- src/sign.h | 1 - 4 files changed, 25 insertions(+), 61 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cacb01c..e7c4559 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -57,7 +57,7 @@ strategy: matrix: os: [ubuntu-latest] - arch: [x64] + arch: [x64, arm64] steps: - name: Checkout repository uses: actions/checkout@v4 @@ -76,12 +76,12 @@ # This is the name of the CMakePresets.json's configuration to use to generate # the project files. This configuration leverages the vcpkg.cmake toolchain file to # run vcpkg and install all dependencies specified in vcpkg.json. - configurePreset: 'ninja-${{ matrix.arch }}' + configurePreset: 'ninja' # This is the name of the CMakePresets.json's configuration to build the project. - buildPreset: 'ninja-${{ matrix.arch }}-release' + buildPreset: 'ninja-release' - - run: mv build/ninja-${{ matrix.arch }}/libSignerServer.so libSignerServer.so + - run: mv build/ninja/libSignerServer.so libSignerServer.so - name: Upload build uses: actions/upload-artifact@v4 diff --git a/CMakePresets.json b/CMakePresets.json index e8d7329..ccb5326 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -2,29 +2,15 @@ "version": 2, "configurePresets": [ { - "name": "ninja-x64", - "displayName": "Configure ninja-x64", - "description": "Configure ninja-x64", + "name": "ninja", + "displayName": "Configure ninja", + "description": "Configure ninja", "generator": "Ninja", "binaryDir": "${sourceDir}/build/${presetName}", "cacheVariables": { "CMAKE_INSTALL_PREFIX": "${sourceDir}/install/${presetName}" } }, - { - "name": "ninja-arm64", - "displayName": "Configure ninja-arm64", - "description": "Configure ninja-arm64", - "generator": "Ninja", - "binaryDir": "${sourceDir}/build/${presetName}", - "cacheVariables": { - "CMAKE_INSTALL_PREFIX": "${sourceDir}/install/${presetName}" - }, - "architecture": { - "value": "arm64", - "strategy": "set" - } - }, { "name": "msvc-x64", "displayName": "Visual Studio Community 2022 Preview - amd64", @@ -42,34 +28,18 @@ ], "buildPresets": [ { - "name": "ninja-arm64-debug", - "description": "Build ninja-arm64 Debug", - "displayName": "Build ninja-arm64 Debug", - "configurePreset": "ninja-arm64", + "name": "ninja-debug", + "description": "Build ninja Debug", + "displayName": "Build ninja Debug", + "configurePreset": "ninja", "configuration": "Debug", "targets": "all" }, { - "name": "ninja-arm64-release", - "description": "Build ninja-arm64 Release", - "displayName": "Build ninja-arm64 Release", - "configurePreset": "ninja-arm64", - "configuration": "Release", - "targets": "all" - }, - { - "name": "ninja-x64-debug", - "description": "Build ninja-x64 Debug", - "displayName": "Build ninja-x64 Debug", - "configurePreset": "ninja-x64", - "configuration": "Debug", - "targets": "all" - }, - { - "name": "ninja-x64-release", - "description": "Build ninja-x64 Release", - "displayName": "Build ninja-x64 Release", - "configurePreset": "ninja-x64", + "name": "ninja-release", + "description": "Build ninja Release", + "displayName": "Build ninja Release", + "configurePreset": "ninja", "configuration": "Release", "targets": "all" }, diff --git a/src/sign.cpp b/src/sign.cpp index abd607d..3c5477d 100644 --- a/src/sign.cpp +++ b/src/sign.cpp @@ -83,8 +83,16 @@ std::string Bin2Hex(const uint8_t *ptr, size_t length) { } Sign::Sign() { - std::thread t(&Sign::InitEx, this); - t.detach(); + std::thread([this]{ while (false) { + try { + Init(); + } + catch (const std::exception &e) { + std::cerr << e.what() << '\n'; + std::this_thread::sleep_for(std::chrono::seconds(1)); + continue; + } + } }).detach(); } void Sign::Init() { @@ -121,19 +129,6 @@ void Sign::Init() { SignFunction = reinterpret_cast(HookAddress); } -void Sign::InitEx() { - while (true) { - try { - Init(); - break; - } - catch (const std::exception &e) { - std::cerr << e.what() << '\n'; - std::this_thread::sleep_for(std::chrono::seconds(1)); - } - } -} - std::tuple Sign::Call(const std::string_view cmd, const std::string_view src, int seq) { if (SignFunction == nullptr) { throw std::runtime_error("Sign function not initialized"); diff --git a/src/sign.h b/src/sign.h index c748c86..bcc32d0 100644 --- a/src/sign.h +++ b/src/sign.h @@ -10,7 +10,6 @@ private: typedef int (*SignFunctionType)(const char *cmd, const unsigned char *src, size_t src_len, int seq, unsigned char *result); SignFunctionType SignFunction = nullptr; void Init(); - void InitEx(); public: std::tuple Call(const std::string_view cmd, const std::string_view src, int seq);