diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 764f4b3..cacb01c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,6 +10,47 @@ workflow_dispatch: jobs: + windows: + name: run on ${{ matrix.os }}(${{ matrix.arch }}) + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [windows-latest] + arch: [x64] + 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: 'msvc-${{ matrix.arch }}' + + # This is the name of the CMakePresets.json's configuration to build the project. + buildPreset: 'msvc-${{ matrix.arch }}-release' + + - run: mv build/msvc-${{ matrix.arch }}/Release/SignerServer.dll SignerServer.dll + + - name: Upload build + uses: actions/upload-artifact@v4 + with: + name: SignerServer-${{ matrix.os }}-${{ matrix.arch }} + path: | + SignerServer.dll + load.js + start.sh + ubuntu: name: run on ${{ matrix.os }}(${{ matrix.arch }}) runs-on: ${{ matrix.os }} @@ -24,7 +65,7 @@ - name: Setup cmake uses: lukka/get-cmake@latest - - name: Build And Test + - name: Build project uses: lukka/run-cmake@v10 with: # This is the default path to the CMakeLists.txt along side the diff --git a/CMakeLists.txt b/CMakeLists.txt index 42b1657..828df88 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,5 @@ cmake_minimum_required(VERSION 3.15) +set(CMAKE_CXX_STANDARD 17) project(SignerServer) @@ -6,18 +7,15 @@ project(SignerServer) if("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows") add_definitions(-D _WIN_PLATFORM_) - link_libraries(ws2_32) + enable_language(ASM_MASM) - enable_language(ASM) - SET(CMAKE_ASM_FLAGS "${CFLAGS} -x assembler-with-cpp") + link_libraries(ws2_32) elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin") add_definitions(-D _MAC_PLATFORM_) elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") add_definitions(-D _LINUX_PLATFORM_) endif() -# 设置CPP标准 -set(CMAKE_CXX_STANDARD 17) file(GLOB SOURCE_FILES "./src/*.cpp" "./src/*.asm") diff --git a/load.js b/load.js index b8ec99e..60a4d66 100644 --- a/load.js +++ b/load.js @@ -1 +1,13 @@ -require("/opt/QQ/resources/app/wrapper.node"); \ No newline at end of file +const path = require('node:path'); +const fs = require('node:fs'); +const os = require('node:os'); + +const exePath = path.dirname(process.execPath); + +if (os.platform() === "win32") { + let configVersionInfoPath = path.join(exePath, "resources/app/versions/config.json"); + const qqVersionConfigInfo = JSON.parse(fs.readFileSync(configVersionInfoPath).toString()); + require(path.join(exePath, "resources/app/versions", qqVersionConfigInfo.curVersion, "wrapper.node")); +} else { + require(path.join(exePath, "resources/app/wrapper.node")); +} \ No newline at end of file diff --git a/src/sign.cpp b/src/sign.cpp index 1909981..a39b18a 100644 --- a/src/sign.cpp +++ b/src/sign.cpp @@ -8,13 +8,11 @@ #include -#define _LINUX_PLATFORM_ -// #define _WIN_PLATFORM_ +// #define _LINUX_PLATFORM_ +#define _WIN_PLATFORM_ #define _X64_ARCH_ -#define CURRENT_ARCHITECTURE "x64" - #if defined(_WIN_PLATFORM_) #include #include @@ -54,7 +52,7 @@ std::map addrMap = { #endif #endif -int SignOffsets = 562; // 562 before 3.1.2-13107, 767 in others +int SignOffsets = 767; // 562 before 3.1.2-13107, 767 in others int ExtraOffsets = 511; int TokenOffsets = 255; @@ -97,10 +95,10 @@ void Sign::Init() uint64_t HookAddress = 0; #if defined(_WIN_PLATFORM_) HMODULE wrapperModule = GetModuleHandleW(L"wrapper.node"); - MODULEINFO modInfo; - if (wrapperModule == NULL || !GetModuleInformation(GetCurrentProcess(), wrapperModule, &modInfo, sizeof(MODULEINFO))) - return; + if (wrapperModule == NULL) + throw std::runtime_error("Can't find wrapper.node module"); HookAddress = reinterpret_cast(wrapperModule) + addrMap[CURRENT_VERSION]; + printf("HookAddress: %llx\n", HookAddress); #elif defined(_MAC_PLATFORM_) auto pmap = hak::get_maps(); do diff --git a/start.bat b/start.bat new file mode 100644 index 0000000..3a7a303 --- /dev/null +++ b/start.bat @@ -0,0 +1,26 @@ +@echo off +setlocal enabledelayedexpansion + +for /f "tokens=2*" %%a in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\QQ" /v "UninstallString"') do ( + set "RetString=%%b" + goto :boot +) + +:boot +for %%a in ("!RetString!") do ( + set "pathWithoutUninstall=%%~dpa" +) + +if not exist %pathWithoutUninstall%version.dll ( + if not exist %~dp0SignerServer.dll ( + echo SignerServer.dll not found + exit + ) + copy /y "%~dp0SignerServer.dll" "%pathWithoutUninstall%version.dll" 1>NUL 2>NUL || powershell Start-Process -FilePath cmd.exe -ArgumentList """/c pushd %~dp0 && %~s0 %*""" -Verb RunAs && exit +) + +set "QQPath=!pathWithoutUninstall!QQ.exe" +set ELECTRON_RUN_AS_NODE=1 +echo !QQPath! + +"!QQPath!" %~dp0load.js %*