mirror of
https://github.com/Simplxss/SignerServer.git
synced 2024-11-21 00:37:53 +08:00
fix bug(fxxk microsoft)
This commit is contained in:
parent
d120834ac1
commit
52d2fa4851
60
src/main.cpp
60
src/main.cpp
@ -2,27 +2,28 @@
|
||||
|
||||
#include "../include/rapidjson/document.h"
|
||||
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
Server *server = nullptr;
|
||||
|
||||
void init()
|
||||
{
|
||||
try
|
||||
{
|
||||
#if defined(_WIN_PLATFORM_)
|
||||
std::string version = "9.9.12-25300";
|
||||
try
|
||||
{
|
||||
std::ifstream versionConfig("resources\\app\\versions\\config.json");
|
||||
TCHAR pathm[MAX_PATH];
|
||||
GetModuleFileName(NULL, pathm, MAX_PATH);
|
||||
std::filesystem::path path = pathm;
|
||||
path = path.parent_path().append("resources\\app\\versions\\config.json");
|
||||
std::ifstream versionConfig(path.wstring());
|
||||
if (versionConfig.is_open())
|
||||
{
|
||||
std::string versionConfigStr;
|
||||
versionConfig >> versionConfigStr;
|
||||
std::stringstream versionConfigStream;
|
||||
versionConfigStream << versionConfig.rdbuf();
|
||||
versionConfig.close();
|
||||
rapidjson::Document doc;
|
||||
doc.Parse(versionConfigStr.c_str(), versionConfigStr.size());
|
||||
doc.Parse(versionConfigStream.str().c_str(), versionConfigStream.str().size());
|
||||
if (doc.HasMember("curVersion") && doc["curVersion"].IsString())
|
||||
version = doc["curVersion"].GetString();
|
||||
}
|
||||
@ -40,11 +41,11 @@ void init()
|
||||
std::ifstream versionConfig("/opt/QQ/resources/app/package.json");
|
||||
if (versionConfig.is_open())
|
||||
{
|
||||
std::string versionConfigStr;
|
||||
versionConfig >> versionConfigStr;
|
||||
std::stringstream versionConfigStrBuf;
|
||||
versionConfigStrBuf << versionConfig.rdbuf();
|
||||
versionConfig.close();
|
||||
rapidjson::Document doc;
|
||||
doc.Parse(versionConfigStr.c_str(), versionConfigStr.size());
|
||||
doc.Parse(versionConfigStrBuf.str().c_str(), versionConfigStrBuf.str().c_str());
|
||||
if (doc.HasMember("version") && doc["version"].IsString())
|
||||
version = doc["version"].GetString();
|
||||
}
|
||||
@ -70,12 +71,12 @@ void init()
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string config;
|
||||
configFile >> config;
|
||||
std::stringstream configStream;
|
||||
configStream << configFile.rdbuf();
|
||||
configFile.close();
|
||||
try
|
||||
{
|
||||
doc.Parse(config.c_str(), config.size());
|
||||
doc.Parse(configStream.str().c_str(), configStream.str().size());
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
{
|
||||
@ -91,21 +92,21 @@ void init()
|
||||
if (doc.HasMember("version") && doc["version"].IsString())
|
||||
version = doc["version"].GetString();
|
||||
|
||||
printf("Start Init server\n");
|
||||
server = new Server();
|
||||
server->Init();
|
||||
|
||||
std::thread sign_init([version, ip, port]
|
||||
{
|
||||
printf("Start Init sign\n");
|
||||
std::thread([=] { // Cannot use '&' capture!!!!! will cause crash
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Sign::Init(version))
|
||||
{
|
||||
if (!server->Run(ip, port))
|
||||
printf("Start Init server\n");
|
||||
Server server;
|
||||
server.Init();
|
||||
if (!server.Run(ip, port))
|
||||
printf("Server run failed\n");
|
||||
break;
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
@ -113,23 +114,12 @@ void init()
|
||||
printf("Init failed: %s\n", e.what());
|
||||
}
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
}
|
||||
})
|
||||
.detach();
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
{
|
||||
printf("Init failed: %s\n", e.what());
|
||||
}
|
||||
} });
|
||||
sign_init.detach();
|
||||
}
|
||||
|
||||
void uninit()
|
||||
{
|
||||
if (server != nullptr)
|
||||
{
|
||||
delete server;
|
||||
server = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(_WIN_PLATFORM_)
|
||||
@ -156,7 +146,7 @@ void __attribute__((constructor)) my_init(void)
|
||||
init();
|
||||
}
|
||||
|
||||
void __attribute__ ((destructor)) my_fini(void)
|
||||
void __attribute__((destructor)) my_fini(void)
|
||||
{
|
||||
uninit();
|
||||
}
|
||||
|
@ -21,7 +21,6 @@ std::shared_ptr<void> (*nodeInitializeOncePerProcess)(
|
||||
|
||||
int __stdcall fakeWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
|
||||
{
|
||||
MessageBoxA(NULL, "Init", "fakeWinMain", MB_OK);
|
||||
checkRunAsNode(nullptr);
|
||||
return oriWinMain(hInstance, hPrevInstance, lpCmdLine, nShowCmd);
|
||||
}
|
||||
@ -43,11 +42,7 @@ bool RunAsNode::RunNode()
|
||||
[](auto &a)
|
||||
{ return std::wstring_convert<std::codecvt_utf8<wchar_t>>().to_bytes(a); });
|
||||
|
||||
MessageBoxA(NULL, "pre nodeInitializeOncePerProcess", "fakeWinMain", MB_OK);
|
||||
std::for_each(argv.begin(), argv.end(), [](const std::string &arg)
|
||||
{ MessageBoxA(NULL, arg.c_str(), "fakeWinMain", MB_OK); });
|
||||
nodeInitializeOncePerProcess(argv, (1 << 6) | (1 << 7));
|
||||
MessageBoxA(NULL, "post nodeInitializeOncePerProcess", "fakeWinMain", MB_OK);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2,8 +2,6 @@
|
||||
#include "../include/rapidjson/document.h"
|
||||
#include "../include/rapidjson/writer.h"
|
||||
|
||||
#include <thread>
|
||||
|
||||
std::string Server::GetSign(const std::string_view &cmd, const std::string_view &src, const int seq)
|
||||
{
|
||||
auto [signDataHex, extraDataHex, tokenDataHex] = Sign::Call(cmd, src, seq);
|
||||
|
@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#define _DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR
|
||||
|
||||
#include "sign.h"
|
||||
#include "../include/cpp-httplib/httplib.h"
|
||||
|
@ -5,6 +5,9 @@ for /f "tokens=2*" %%a in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\M
|
||||
set "RetString=%%b"
|
||||
goto :boot
|
||||
)
|
||||
echo QQ installation not found
|
||||
pause
|
||||
exit
|
||||
|
||||
:boot
|
||||
for %%a in ("!RetString!") do (
|
||||
@ -36,7 +39,8 @@ if errorlevel 1 (
|
||||
goto launch
|
||||
|
||||
:restart
|
||||
powershell Start-Process -FilePath cmd.exe -ArgumentList """/c pushd %~dp0 && %~s0 %*""" -Verb RunAs
|
||||
powershell Start-Process -FilePath cmd.exe -ArgumentList """/c pushd %~dp0 && %~s0 %*""" -Verb RunAs
|
||||
exit
|
||||
|
||||
:launch
|
||||
set "QQPath=!pathWithoutUninstall!QQ.exe"
|
||||
|
Loading…
x
Reference in New Issue
Block a user