From c60d3a3b829ebdad69e73d1d28e3acbc9f47f54d Mon Sep 17 00:00:00 2001 From: HolographicHat Date: Wed, 12 Apr 2023 12:28:03 +0800 Subject: [PATCH] v2.7 --- lib/src/dllmain.cpp | 10 ++++----- lib/src/il2cpp-api-functions.h | 2 +- lib/src/il2cpp-functions.h | 28 ++++++++++++------------ lib/src/il2cpp-unity-functions.h | 2 +- lib/src/util.cpp | 12 +++++----- res/proto/AchievementAllDataNotify.proto | 12 +++++----- src/GlobalVars.cs | 4 ++-- 7 files changed, 35 insertions(+), 35 deletions(-) diff --git a/lib/src/dllmain.cpp b/lib/src/dllmain.cpp index 7afe083..a29de46 100644 --- a/lib/src/dllmain.cpp +++ b/lib/src/dllmain.cpp @@ -5,11 +5,11 @@ using Genshin::ByteArray, Genshin::ClientKcpEvent, Genshin::KcpPacket, Genshin::KcpEventType; using std::to_string; -HWND unityWnd = 0; -HANDLE hPipe = 0; +HWND unityWnd = nullptr; +HANDLE hPipe = nullptr; // Allow Protocol: GetPlayerToken, PlayerLogin, AchievementAllDataNotify, Ping -std::set PacketWhitelist = { 167, 175, 154, 164, 2698, 14, 34, 106 }; +std::set PacketWhitelist = { 190, 196, 189, 176, 2659, 16, 56, 152 }; bool OnPacket(KcpPacket* pkt) { if (pkt->data == nullptr) return true; @@ -30,7 +30,7 @@ bool OnPacket(KcpPacket* pkt) { return false; } printf("Passed cmdid: %d\n", ReadMapped(data->vector, 2)); - if (ReadMapped(data->vector, 2) == 2698) { + if (ReadMapped(data->vector, 2) == 2659) { auto headLength = ReadMapped(data->vector, 4); auto dataLength = ReadMapped(data->vector, 6); auto iStr = Genshin::ToBase64String(data, 10 + headLength, dataLength, nullptr); @@ -86,7 +86,7 @@ void Run(HMODULE* phModule) { //freopen_s((FILE**)stdout, "CONOUT$", "w", stdout); while ( GetModuleHandle("UserAssembly.dll") == nullptr || - (unityWnd = FindMainWindowByPID(GetCurrentProcessId())) == 0 + (unityWnd = FindMainWindowByPID(GetCurrentProcessId())) == nullptr ) { Sleep(1000); } diff --git a/lib/src/il2cpp-api-functions.h b/lib/src/il2cpp-api-functions.h index 9fab6a6..1003c54 100644 --- a/lib/src/il2cpp-api-functions.h +++ b/lib/src/il2cpp-api-functions.h @@ -1 +1 @@ -DO_API(0x991b10, 0x99ad10, Il2CppString*, il2cpp_string_new, (const char* str)); +DO_API(0x897c10, 0x8951f0, Il2CppString*, il2cpp_string_new, (const char* str)); diff --git a/lib/src/il2cpp-functions.h b/lib/src/il2cpp-functions.h index eaea7b7..8129446 100644 --- a/lib/src/il2cpp-functions.h +++ b/lib/src/il2cpp-functions.h @@ -2,30 +2,30 @@ using namespace Genshin; // DO_APP_FUNC(CN_OFFSET, OS_OFFSET, RETURN, FUNC_NAME, (ARGS...)); -DO_APP_FUNC(0x728c160, 0x71cc2e0, Il2CppString*, ToBase64String, (ByteArray* value, int offset, int length, void* method)); +DO_APP_FUNC(0x6790b00, 0x6839fa0, Il2CppString*, ToBase64String, (ByteArray* value, int offset, int length, void* method)); -DO_APP_FUNC(0x2e2c930, 0x2dc4b90, void, SetVersion, (void* obj, Il2CppString* value, void* method)); +DO_APP_FUNC(0x379bb90, 0x3821a40, void, SetVersion, (void* obj, Il2CppString* value, void* method)); -DO_APP_FUNC(0x7c318d0, 0x7b69060, ByteArray*, RecordUserData, (int32_t nType)); +DO_APP_FUNC(0x7040220, 0x70f3890, ByteArray*, RecordUserData, (int32_t nType)); -DO_APP_FUNC(0x1ba7d30, 0x1b7b9f0, void, XorEncrypt, (ByteArray** data, int length, void* method)); +DO_APP_FUNC(0xf85bf0, 0xf90450, void, XorEncrypt, (ByteArray** data, int length, void* method)); -DO_APP_FUNC(0xc3fe80, 0xc47280, int, KcpSend, (void* client, KcpPacket* pkt, void* method)); +DO_APP_FUNC(0x156e740, 0x158a1e0, int, KcpSend, (void* client, KcpPacket* pkt, void* method)); -DO_APP_FUNC(0xf1ec70, 0xf1bca0, bool, KcpRecv, (void* client, ClientKcpEvent* evt, void* method)); +DO_APP_FUNC(0x2ce2040, 0x2d44790, bool, KcpRecv, (void* client, ClientKcpEvent* evt, void* method)); -DO_APP_FUNC(0x75a6880, 0x74e4b80, LPVOID, GetDefaultEncoding, ()); +DO_APP_FUNC(0x6a4e700, 0x6afb5e0, LPVOID, GetDefaultEncoding, ()); -DO_APP_FUNC(0x75a6130, 0x74e4420, Il2CppString*, GetString, (LPVOID encoding, LPVOID bytes)); +DO_APP_FUNC(0x6a4dfb0, 0x6afae80, Il2CppString*, GetString, (LPVOID encoding, LPVOID bytes)); -DO_APP_FUNC(0x75a4fc0, 0x74e32b0, ByteArray*, GetBytes, (LPVOID encoding, LPVOID str)); +DO_APP_FUNC(0x6a4ce50, 0x6af9d50, ByteArray*, GetBytes, (LPVOID encoding, LPVOID str)); -DO_APP_FUNC(0x1bf31f0, 0x1bc5f60, VOID, RequestLogin, (LPVOID obj, LPVOID token, UINT uid)); +DO_APP_FUNC(0x36a1260, 0x3723bc0, VOID, RequestLogin, (LPVOID obj, LPVOID token, UINT uid)); -DO_APP_FUNC(0x4922d40, 0x4879590, VOID, SetChecksum, (LPVOID obj, Il2CppString* value)); +DO_APP_FUNC(0x26506b0, 0x1b0c690, VOID, SetChecksum, (LPVOID obj, Il2CppString* value)); -DO_APP_FUNC(0x34780d0, 0x3401460, VOID, ForceQuit, (LPVOID obj)); +DO_APP_FUNC(0xf25990, 0xf2f110, VOID, ForceQuit, (LPVOID obj)); -DO_APP_FUNC(0x57df820, 0x5727410, LPVOID, GetSingletonManager, ()); +DO_APP_FUNC(0x4aac4c0, 0x4b57410, LPVOID, GetSingletonManager, ()); -DO_APP_FUNC(0x57df550, 0x5727140, LPVOID, GetSingletonInstance, (LPVOID obj, Il2CppString* value)); +DO_APP_FUNC(0x4aac1f0, 0x4b57140, LPVOID, GetSingletonInstance, (LPVOID obj, Il2CppString* value)); diff --git a/lib/src/il2cpp-unity-functions.h b/lib/src/il2cpp-unity-functions.h index 00ad432..2fb7951 100644 --- a/lib/src/il2cpp-unity-functions.h +++ b/lib/src/il2cpp-unity-functions.h @@ -1,3 +1,3 @@ using namespace Genshin; -DO_UNI_FUNC(0x00100570, 0x00100570, ByteArray*, UnityEngine_RecordUserData, (int32_t nType)); +DO_UNI_FUNC(0x100640, 0x100640, ByteArray*, UnityEngine_RecordUserData, (int32_t nType)); diff --git a/lib/src/util.cpp b/lib/src/util.cpp index d6dc6d2..f1874c4 100644 --- a/lib/src/util.cpp +++ b/lib/src/util.cpp @@ -4,12 +4,12 @@ VOID DisableVMProtect() { DWORD oldProtect = 0; auto ntdll = GetModuleHandleA("ntdll.dll"); - BYTE callcode = ((BYTE*)GetProcAddress(ntdll, "NtQuerySection"))[4] - 1; - BYTE restore[] = { 0x4C, 0x8B, 0xD1, 0xB8, callcode }; - auto nt_vp = (BYTE*)GetProcAddress(ntdll, "NtProtectVirtualMemory"); - VirtualProtect(nt_vp, sizeof(restore), PAGE_EXECUTE_READWRITE, &oldProtect); - memcpy(nt_vp, restore, sizeof(restore)); - VirtualProtect(nt_vp, sizeof(restore), oldProtect, &oldProtect); + auto pNtProtectVirtualMemory = GetProcAddress(ntdll, "NtProtectVirtualMemory"); + auto pNtQuerySection = GetProcAddress(ntdll, "NtQuerySection"); + DWORD old; + VirtualProtect(pNtProtectVirtualMemory, 1, PAGE_EXECUTE_READWRITE, &old); + *(uintptr_t*)pNtProtectVirtualMemory = *(uintptr_t*)pNtQuerySection & ~(0xFFui64 << 32) | (uintptr_t)(*(uint32_t*)((uintptr_t)pNtQuerySection + 4) - 1) << 32; + VirtualProtect(pNtProtectVirtualMemory, 1, old, &old); } #pragma region StringConvert diff --git a/res/proto/AchievementAllDataNotify.proto b/res/proto/AchievementAllDataNotify.proto index 342f989..e8174d4 100644 --- a/res/proto/AchievementAllDataNotify.proto +++ b/res/proto/AchievementAllDataNotify.proto @@ -9,13 +9,13 @@ message Achievement { FINISHED = 2; REWARD_TAKEN = 3; } - uint32 timestamp = 13; - uint32 current = 2; - uint32 total = 5; - uint32 id = 9; - Status status = 6; + uint32 timestamp = 9; + uint32 current = 3; + uint32 total = 4; + uint32 id = 10; + Status status = 2; } message AchievementAllDataNotify { - repeated Achievement list = 15; + repeated Achievement list = 11; } diff --git a/src/GlobalVars.cs b/src/GlobalVars.cs index 27fb6c5..7e89e0a 100644 --- a/src/GlobalVars.cs +++ b/src/GlobalVars.cs @@ -20,8 +20,8 @@ public static class GlobalVars { public static readonly string CachePath = Path.Combine(DataPath, "cache"); public static readonly string LibFilePath = Path.Combine(DataPath, "YaeAchievement.dll"); - public const uint AppVersionCode = 36; - public const string AppVersionName = "2.6"; + public const uint AppVersionCode = 37; + public const string AppVersionName = "2.7"; public const string PipeName = "YaeAchievementPipe"; public const string BucketHost = "https://cn-cd-1259389942.file.myqcloud.com";