fix windows

This commit is contained in:
Simplxs 2024-05-07 21:09:48 +08:00
parent 6336fec8ea
commit 82dc6e7585
No known key found for this signature in database
GPG Key ID: E23537FF14DD6507
5 changed files with 90 additions and 15 deletions

View File

@ -10,6 +10,47 @@
workflow_dispatch: workflow_dispatch:
jobs: 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: ubuntu:
name: run on ${{ matrix.os }}(${{ matrix.arch }}) name: run on ${{ matrix.os }}(${{ matrix.arch }})
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
@ -24,7 +65,7 @@
- name: Setup cmake - name: Setup cmake
uses: lukka/get-cmake@latest uses: lukka/get-cmake@latest
- name: Build And Test - name: Build project
uses: lukka/run-cmake@v10 uses: lukka/run-cmake@v10
with: with:
# This is the default path to the CMakeLists.txt along side the # This is the default path to the CMakeLists.txt along side the

View File

@ -1,4 +1,5 @@
cmake_minimum_required(VERSION 3.15) cmake_minimum_required(VERSION 3.15)
set(CMAKE_CXX_STANDARD 17)
project(SignerServer) project(SignerServer)
@ -6,18 +7,15 @@ project(SignerServer)
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows") if("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
add_definitions(-D _WIN_PLATFORM_) add_definitions(-D _WIN_PLATFORM_)
link_libraries(ws2_32) enable_language(ASM_MASM)
enable_language(ASM) link_libraries(ws2_32)
SET(CMAKE_ASM_FLAGS "${CFLAGS} -x assembler-with-cpp")
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin") elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
add_definitions(-D _MAC_PLATFORM_) add_definitions(-D _MAC_PLATFORM_)
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
add_definitions(-D _LINUX_PLATFORM_) add_definitions(-D _LINUX_PLATFORM_)
endif() endif()
# CPP
set(CMAKE_CXX_STANDARD 17)
file(GLOB SOURCE_FILES "./src/*.cpp" "./src/*.asm") file(GLOB SOURCE_FILES "./src/*.cpp" "./src/*.asm")

14
load.js
View File

@ -1 +1,13 @@
require("/opt/QQ/resources/app/wrapper.node"); 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"));
}

View File

@ -8,13 +8,11 @@
#include <thread> #include <thread>
#define _LINUX_PLATFORM_ // #define _LINUX_PLATFORM_
// #define _WIN_PLATFORM_ #define _WIN_PLATFORM_
#define _X64_ARCH_ #define _X64_ARCH_
#define CURRENT_ARCHITECTURE "x64"
#if defined(_WIN_PLATFORM_) #if defined(_WIN_PLATFORM_)
#include <Windows.h> #include <Windows.h>
#include <psapi.h> #include <psapi.h>
@ -54,7 +52,7 @@ std::map<std::string, uint64_t> addrMap = {
#endif #endif
#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 ExtraOffsets = 511;
int TokenOffsets = 255; int TokenOffsets = 255;
@ -97,10 +95,10 @@ void Sign::Init()
uint64_t HookAddress = 0; uint64_t HookAddress = 0;
#if defined(_WIN_PLATFORM_) #if defined(_WIN_PLATFORM_)
HMODULE wrapperModule = GetModuleHandleW(L"wrapper.node"); HMODULE wrapperModule = GetModuleHandleW(L"wrapper.node");
MODULEINFO modInfo; if (wrapperModule == NULL)
if (wrapperModule == NULL || !GetModuleInformation(GetCurrentProcess(), wrapperModule, &modInfo, sizeof(MODULEINFO))) throw std::runtime_error("Can't find wrapper.node module");
return;
HookAddress = reinterpret_cast<uint64_t>(wrapperModule) + addrMap[CURRENT_VERSION]; HookAddress = reinterpret_cast<uint64_t>(wrapperModule) + addrMap[CURRENT_VERSION];
printf("HookAddress: %llx\n", HookAddress);
#elif defined(_MAC_PLATFORM_) #elif defined(_MAC_PLATFORM_)
auto pmap = hak::get_maps(); auto pmap = hak::get_maps();
do do

26
start.bat Normal file
View File

@ -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 %*