mirror of
https://github.com/Simplxss/SignerServer.git
synced 2024-11-21 00:37:53 +08:00
fix linux
This commit is contained in:
parent
5ba10cc6e1
commit
1a682ff12d
@ -1,6 +1,6 @@
|
||||
#if defined(_WIN_PLATFORM_)
|
||||
#include "run_as_node.h"
|
||||
|
||||
#if defined(_WIN_PLATFORM_)
|
||||
bool TlsOnce = false;
|
||||
// this runs way before dllmain
|
||||
void __stdcall TlsCallback(PVOID hModule, DWORD fdwReason, PVOID pContext)
|
||||
|
@ -1,5 +1,9 @@
|
||||
#if defined(_WIN_PLATFORM_)
|
||||
#include "run_as_node.h"
|
||||
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <codecvt>
|
||||
#include <map>
|
||||
|
||||
#if defined(_WIN_PLATFORM_)
|
||||
@ -14,12 +18,42 @@ int(__stdcall *oriWinMain)(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR l
|
||||
|
||||
void(__fastcall *checkRunAsNode)(void *a1);
|
||||
|
||||
std::shared_ptr<void> (*nodeInitializeOncePerProcess)(
|
||||
const std::vector<std::string> &args,
|
||||
uint32_t flags);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
bool RunAsNode::RunNode()
|
||||
{
|
||||
struct Arguments
|
||||
{
|
||||
int argc = 0;
|
||||
wchar_t **argv =
|
||||
::CommandLineToArgvW(::GetCommandLineW(), &argc);
|
||||
|
||||
~Arguments() { LocalFree(argv); }
|
||||
} arguments;
|
||||
|
||||
std::vector<std::string> argv(arguments.argc);
|
||||
|
||||
std::transform(arguments.argv, arguments.argv + arguments.argc, argv.begin(),
|
||||
[](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;
|
||||
}
|
||||
|
||||
bool RunAsNode::Init()
|
||||
{
|
||||
uint64_t baseAddr = 0;
|
||||
@ -60,5 +94,8 @@ bool RunAsNode::Init()
|
||||
uint8_t *abscallptr = reinterpret_cast<uint8_t *>(baseAddr + callptr);
|
||||
oriWinMain = reinterpret_cast<int(__stdcall *)(HINSTANCE, HINSTANCE, LPSTR, int)>(moehoo::get_call_address(abscallptr));
|
||||
checkRunAsNode = reinterpret_cast<void(__fastcall *)(void *)>(baseAddr + funcptr);
|
||||
nodeInitializeOncePerProcess = reinterpret_cast<std::shared_ptr<void> (*)(const std::vector<std::string> &, uint32_t)>(baseAddr + 0x1FFF710);
|
||||
return moehoo::hook(abscallptr, &fakeWinMain);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -4,5 +4,6 @@
|
||||
|
||||
namespace RunAsNode
|
||||
{
|
||||
bool RunNode();
|
||||
bool Init();
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user