mirror of
https://github.com/Simplxss/SignerServer.git
synced 2024-11-21 00:37:53 +08:00
update
This commit is contained in:
parent
c39acea3fb
commit
8b030c45c5
@ -1,13 +1,11 @@
|
|||||||
#ifndef _HOOK_H_
|
#ifndef _HOOK_H_
|
||||||
#define _HOOK_H_
|
#define _HOOK_H_
|
||||||
#include <string>
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#if defined(_WIN_PLATFORM_)
|
#if defined(_WIN_PLATFORM_)
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#elif defined(_LINUX_PLATFORM_) || defined(_MAC_PLATFORM_)
|
#elif defined(_LINUX_PLATFORM_) || defined(_MAC_PLATFORM_)
|
||||||
#include "proc_maps.h"
|
#include "proc_maps.h"
|
||||||
#include <cstring>
|
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -88,7 +86,7 @@ inline void *moehoo::search_and_fill_jump(uint64_t baseAddress, void *targetAddr
|
|||||||
}
|
}
|
||||||
searchStart += mbi.RegionSize;
|
searchStart += mbi.RegionSize;
|
||||||
}
|
}
|
||||||
#elif defined(_LINUX_PLATFORM_)
|
#elif defined(_LINUX_PLATFORM_) || defined(_MAC_PLATFORM_)
|
||||||
// 保证地址对齐
|
// 保证地址对齐
|
||||||
searchStart &= 0xfffffffffffff000;
|
searchStart &= 0xfffffffffffff000;
|
||||||
searchStart += 0x1000;
|
searchStart += 0x1000;
|
||||||
@ -163,7 +161,7 @@ inline bool moehoo::hook(uint8_t *callAddr, void *lpFunction)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
#elif defined(_LINUX_PLATFORM_)
|
#elif defined(_LINUX_PLATFORM_) || defined(_MAC_PLATFORM_)
|
||||||
// printf("Hooking %p to %p, distance: %ld\n", callAddr, lpFunction, distance);
|
// printf("Hooking %p to %p, distance: %ld\n", callAddr, lpFunction, distance);
|
||||||
|
|
||||||
auto get_page_addr = [](void *addr) -> void *
|
auto get_page_addr = [](void *addr) -> void *
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
#ifndef PROC_MAPS_H
|
#ifndef PROC_MAPS_H
|
||||||
#define PROC_MAPS_H
|
#define PROC_MAPS_H
|
||||||
#if defined(_MAC_PLATFORM_) || defined(_LINUX_PLATFORM_)
|
|
||||||
|
|
||||||
|
#if defined(_LINUX_PLATFORM_) || defined(_MAC_PLATFORM_)
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
namespace hak
|
namespace hak
|
||||||
{
|
{
|
||||||
@ -179,4 +178,5 @@ inline auto hak::get_maps(pid_t pid) -> std::shared_ptr<proc_maps>
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // PROC_MAPS_H
|
#endif // PROC_MAPS_H
|
@ -110,7 +110,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved)
|
|||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
#elif defined(_MAC_PLATFORM_) || defined(_LINUX_PLATFORM_)
|
#elif defined(_LINUX_PLATFORM_) || defined(_MAC_PLATFORM_)
|
||||||
void __attribute__((constructor)) my_init(void)
|
void __attribute__((constructor)) my_init(void)
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
#if defined(_WIN_PLATFORM_)
|
#if defined(_WIN_PLATFORM_)
|
||||||
#include "run_as_node.h"
|
#include "run_as_node.h"
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <codecvt>
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <vector>
|
||||||
|
#include <codecvt>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#if defined(_X64_ARCH_) // {call winmain, check run as node function}
|
#if defined(_X64_ARCH_) // {call winmain, check run as node function}
|
||||||
std::map<std::string, std::pair<uint64_t, uint64_t>> mainAddrMap = {
|
std::map<std::string, std::tuple<uint64_t, uint64_t, uint64_t>> mainAddrMap = {
|
||||||
{"9.9.12-25234", {0x457A76D, 0x3A5D70}}};
|
{"9.9.12-25234", {0x457A76D, 0x3A5D70, 0x1FFF710}}};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int(__stdcall *oriWinMain)(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd);
|
int(__stdcall *oriWinMain)(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd);
|
||||||
@ -86,12 +86,12 @@ bool RunAsNode::Init(const std::string &version)
|
|||||||
if (baseAddr == 0)
|
if (baseAddr == 0)
|
||||||
throw std::runtime_error("Can't find hook address");
|
throw std::runtime_error("Can't find hook address");
|
||||||
|
|
||||||
auto [callptr, funcptr] = mainAddrMap[version];
|
auto [callptr, func1ptr, func2ptr] = mainAddrMap[version];
|
||||||
|
|
||||||
uint8_t *abscallptr = reinterpret_cast<uint8_t *>(baseAddr + callptr);
|
uint8_t *abscallptr = reinterpret_cast<uint8_t *>(baseAddr + callptr);
|
||||||
oriWinMain = reinterpret_cast<int(__stdcall *)(HINSTANCE, HINSTANCE, LPSTR, int)>(moehoo::get_call_address(abscallptr));
|
oriWinMain = reinterpret_cast<int(__stdcall *)(HINSTANCE, HINSTANCE, LPSTR, int)>(moehoo::get_call_address(abscallptr));
|
||||||
checkRunAsNode = reinterpret_cast<void(__fastcall *)(void *)>(baseAddr + funcptr);
|
checkRunAsNode = reinterpret_cast<void(__fastcall *)(void *)>(baseAddr + func1ptr);
|
||||||
nodeInitializeOncePerProcess = reinterpret_cast<std::shared_ptr<void> (*)(const std::vector<std::string> &, uint32_t)>(baseAddr + 0x1FFF710);
|
nodeInitializeOncePerProcess = reinterpret_cast<std::shared_ptr<void> (*)(const std::vector<std::string> &, uint32_t)>(baseAddr + func2ptr);
|
||||||
return moehoo::hook(abscallptr, &fakeWinMain);
|
return moehoo::hook(abscallptr, &fakeWinMain);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
14
src/sign.cpp
14
src/sign.cpp
@ -1,22 +1,14 @@
|
|||||||
#include "sign.h"
|
#include "sign.h"
|
||||||
|
|
||||||
#include <sstream>
|
|
||||||
#include <vector>
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <vector>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
#include <stdexcept>
|
||||||
// #define _LINUX_PLATFORM_
|
|
||||||
// #define _WIN_PLATFORM_
|
|
||||||
|
|
||||||
// #define _X64_ARCH_
|
|
||||||
|
|
||||||
#if defined(_WIN_PLATFORM_)
|
#if defined(_WIN_PLATFORM_)
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#include <psapi.h>
|
#elif defined(_LINUX_PLATFORM_) || defined(_MAC_PLATFORM_)
|
||||||
#elif defined(_MAC_PLATFORM_) || defined(_LINUX_PLATFORM_)
|
|
||||||
#include "../include/moehoo/proc_maps.h"
|
#include "../include/moehoo/proc_maps.h"
|
||||||
#include <cstring>
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef int (*SignFunctionType)(const char *cmd, const unsigned char *src, size_t src_len, int seq, unsigned char *result);
|
typedef int (*SignFunctionType)(const char *cmd, const unsigned char *src, size_t src_len, int seq, unsigned char *result);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user