This commit is contained in:
HolographicHat
2022-06-12 15:59:43 +08:00
parent 1adc6c4c0f
commit 180ab8bab7
5 changed files with 43 additions and 22 deletions

View File

@@ -14,32 +14,18 @@ namespace Genshin {
using std::string;
ull GetAddressByExports(HMODULE base, const char* name) {
ull funcAddr = reinterpret_cast<ull>(GetProcAddress(base, name));
UINT64 GetAddressByExports(HMODULE base, const char* name) {
UINT64 funcAddr = reinterpret_cast<UINT64>(GetProcAddress(base, name));
return funcAddr == 0 ? 0 : funcAddr;
}
ull milliseconds_now() {
static LARGE_INTEGER s_frequency;
static BOOL s_use_qpc = QueryPerformanceFrequency(&s_frequency);
if (s_use_qpc) {
LARGE_INTEGER now;
QueryPerformanceCounter(&now);
return (1000LL * now.QuadPart) / s_frequency.QuadPart;
} else {
return GetTickCount64();
}
}
void InitIL2CPP() {
auto start = milliseconds_now();
auto hBase = GetModuleHandle("UserAssembly.dll");
auto bAddr = (ull)hBase;
auto bAddr = (UINT64)hBase;
#define DO_API(r, n, p) n = (r (*) p) GetAddressByExports(hBase, #n);
#include "il2cpp-api-functions.h"
#undef DO_API
#define DO_APP_FUNC(a, r, n, p) n = (r (*) p)(bAddr + a)
#include "il2cpp-functions.h"
#undef DO_APP_FUNC
printf("Initialized in %llu ms.\n", milliseconds_now() - start);
}