This commit is contained in:
HolographicHat
2022-07-14 16:47:05 +08:00
parent 31e23de4d6
commit d5a20b44d5
10 changed files with 62 additions and 56 deletions

View File

@@ -8,7 +8,7 @@ using std::to_string;
HWND unityWnd = 0;
HANDLE hPipe = 0;
std::set<UINT16> PacketWhitelist = { 109, 131, 141, 2668, 32, 17 };
std::set<UINT16> PacketWhitelist = { 172, 198, 112, 2676, 7, 21 }; // ping, token, loginreq
bool OnPacket(KcpPacket* pkt) {
if (pkt->data == nullptr) return true;
@@ -28,11 +28,11 @@ bool OnPacket(KcpPacket* pkt) {
delete[] data;
return false;
}
if (ReadMapped<UINT16>(data->vector, 2) == 2668) {
if (ReadMapped<UINT16>(data->vector, 2) == 2676) {
auto headLength = ReadMapped<UINT16>(data->vector, 4);
auto dataLength = ReadMapped<UINT32>(data->vector, 6);
auto iStr = Genshin::Convert_ToBase64String(data, 10 + headLength, dataLength, nullptr);
auto cStr = IlStringToString(reinterpret_cast<Il2CppString*>(iStr)) + "\n";
auto cStr = IlStringToString(iStr) + "\n";
WriteFile(hPipe, cStr.c_str(), cStr.length(), nullptr, nullptr);
CloseHandle(hPipe);
ExitProcess(0);
@@ -57,10 +57,8 @@ namespace Hook {
}
void Run(HMODULE* phModule) {
#ifdef _DEBUG
AllocConsole();
freopen_s((FILE**)stdout, "CONOUT$", "w", stdout);
#endif
//AllocConsole();
//freopen_s((FILE**)stdout, "CONOUT$", "w", stdout);
while (
GetModuleHandle("UserAssembly.dll") == nullptr ||
(unityWnd = FindMainWindowByPID(GetCurrentProcessId())) == 0

View File

@@ -7,7 +7,7 @@
#undef DO_API
// Application-specific functions
#define DO_APP_FUNC(a, r, n, p) extern r (*n) p
#define DO_APP_FUNC(ca, oa, r, n, p) extern r (*n) p
namespace Genshin {
#include "il2cpp-functions.h"
}

View File

@@ -1,7 +1,7 @@
using namespace Genshin;
DO_APP_FUNC(0x04E9B0A0, String*, Convert_ToBase64String, (ByteArray* value, int offset, int length, void* method));
DO_APP_FUNC(0x015913C0, void, Packet_Xor, (ByteArray** data, int length, void* method));
DO_APP_FUNC(0x05E24240, 0x04EA1150, Il2CppString*, Convert_ToBase64String, (ByteArray* value, int offset, int length, void* method));
DO_APP_FUNC(0x018280A0, 0x018293F0, void, Packet_Xor, (ByteArray** data, int length, void* method));
DO_APP_FUNC(0x016F70C0, int, Kcp_Send, (void* client, KcpPacket* pkt, void* method));
DO_APP_FUNC(0x02AB08D0, bool, Kcp_Recv, (void* client, ClientKcpEvent* evt, void* method));
DO_APP_FUNC(0x0193BA70, 0x0193C7D0, int, Kcp_Send, (void* client, KcpPacket* pkt, void* method));
DO_APP_FUNC(0x029EF820, 0x029F05C0, bool, Kcp_Recv, (void* client, ClientKcpEvent* evt, void* method));

View File

@@ -6,7 +6,7 @@
#include "il2cpp-api-functions.h"
#undef DO_API
#define DO_APP_FUNC(a, r, n, p) r (*n) p
#define DO_APP_FUNC(ca, oa, r, n, p) r (*n) p
namespace Genshin {
#include "il2cpp-functions.h"
}
@@ -20,12 +20,15 @@ UINT64 GetAddressByExports(HMODULE base, const char* name) {
}
void InitIL2CPP() {
TCHAR szFileName[MAX_PATH];
GetModuleFileName(NULL, szFileName, MAX_PATH);
auto isCN = string(szFileName).contains("YuanShen.exe");
auto hBase = GetModuleHandle("UserAssembly.dll");
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)
#define DO_APP_FUNC(ca, oa, r, n, p) n = (r (*) p)(bAddr + (isCN ? ca : oa))
#include "il2cpp-functions.h"
#undef DO_APP_FUNC
}