From f004ee1f9109209b4d27ebc85f3732d90c400ec5 Mon Sep 17 00:00:00 2001 From: simplxs Date: Thu, 3 Oct 2024 20:47:36 +0800 Subject: [PATCH] macos (broken --- .github/workflows/build.yml | 46 +++++++++++++++++++++++++++++++++++++ .gitignore | 3 ++- CMakeLists.txt | 2 +- src/main.cpp | 22 ++++++++++++++++-- src/server.cpp | 4 ++-- start.command | 4 ++++ 6 files changed, 75 insertions(+), 6 deletions(-) create mode 100755 start.command diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 12657e8..2ac148f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -51,6 +51,7 @@ jobs: load.js start.sh start.bat + start.command ubuntu: name: run on ${{ matrix.os }}(${{ matrix.arch }}) @@ -93,3 +94,48 @@ jobs: load.js start.sh start.bat + start.command + + + macos: + name: run on ${{ matrix.os }}(${{ matrix.arch }}) + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [macos-latest] + arch: [x64, arm64] + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup cmake + uses: lukka/get-cmake@latest + + - name: Build project + uses: lukka/run-cmake@v10 + with: + # This is the default path to the CMakeLists.txt along side the + # CMakePresets.json. Change if you need have CMakeLists.txt and CMakePresets.json + # located elsewhere. + cmakeListsTxtPath: '${{ github.workspace }}/CMakeLists.txt' + + # 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' + + # This is the name of the CMakePresets.json's configuration to build the project. + buildPreset: 'ninja-release' + + - run: mv build/ninja/libSignerServer.dylib libSignerServer.dylib + + - name: Upload build + uses: actions/upload-artifact@v4 + with: + name: SignerServer-${{ matrix.os }}-${{ matrix.arch }} + path: | + libSignerServer.dylib + load.js + start.sh + start.bat + start.command diff --git a/.gitignore b/.gitignore index 91f3038..4a21cb4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .vscode build *.so -*.dll \ No newline at end of file +*.dll +*.dylib \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 098e8bd..e8c5cdd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,7 @@ if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL " add_definitions(-D _X64_ARCH_) elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86") add_definitions(-D _X86_ARCH_) -elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "ARM64") +elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64") add_definitions(-D _ARM64_ARCH_) endif() diff --git a/src/main.cpp b/src/main.cpp index b322415..2268f62 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -34,6 +34,24 @@ void init() } #elif defined(_MAC_PLATFORM_) std::string version = "6.9.19-16183"; + try + { + std::ifstream versionConfig("/Applications/QQ.app/Contents/resources/app/package.json"); + if (versionConfig.is_open()) + { + std::stringstream versionConfigStrBuf; + versionConfigStrBuf << versionConfig.rdbuf(); + versionConfig.close(); + rapidjson::Document doc; + doc.Parse(versionConfigStrBuf.str().c_str(), versionConfigStrBuf.str().size()); + if (doc.HasMember("version") && doc["version"].IsString()) + version = doc["version"].GetString(); + } + } + catch (const std::exception &e) + { + std::cerr << e.what() << '\n'; + } #elif defined(_LINUX_PLATFORM_) std::string version = "3.2.9-24815"; try @@ -141,12 +159,12 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) return TRUE; } #elif defined(_LINUX_PLATFORM_) || defined(_MAC_PLATFORM_) -void __attribute__((constructor)) my_init(void) +static void __attribute__((constructor)) my_init(void) { init(); } -void __attribute__((destructor)) my_fini(void) +static void __attribute__((destructor)) my_fini(void) { uninit(); } diff --git a/src/server.cpp b/src/server.cpp index 7baa119..726b424 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -48,8 +48,8 @@ void Server::Init() .Get("/sign", [this](const httplib::Request &req, httplib::Response &res) { try { - std::string_view cmd = req.get_param_value("cmd"); - std::string_view src = req.get_param_value("src"); + std::string cmd = req.get_param_value("cmd"); + std::string src = req.get_param_value("src"); int seq = std::stoi(req.get_param_value("seq")); std::string buffer = GetSign(cmd, src, seq); diff --git a/start.command b/start.command new file mode 100755 index 0000000..a0554bc --- /dev/null +++ b/start.command @@ -0,0 +1,4 @@ +#!/bin/bash +SCRIPT_DIR=$(realpath $(dirname "${BASH_SOURCE[0]}")) +export ELECTRON_RUN_AS_NODE=1 +DYLD_INSERT_LIBRARIES=./libSignerServer.dylib /Applications/QQ.app/Contents/MacOS/qq ${SCRIPT_DIR}/load.js $@