From 1f311ed9876d375c7f822d55b0c30b7eb222d844 Mon Sep 17 00:00:00 2001 From: HolographicHat Date: Thu, 14 Mar 2024 23:55:36 +0800 Subject: [PATCH] 4.5 --- lib/src/dllmain.cpp | 24 ++++++++++++------------ lib/src/il2cpp-functions.h | 14 ++++---------- lib/src/il2cpp-types-ptr.h | 2 -- res/proto/AchievementAllDataNotify.proto | 12 ++++++------ src/GlobalVars.cs | 4 ++-- 5 files changed, 24 insertions(+), 32 deletions(-) diff --git a/lib/src/dllmain.cpp b/lib/src/dllmain.cpp index 495fc36..c607784 100644 --- a/lib/src/dllmain.cpp +++ b/lib/src/dllmain.cpp @@ -30,17 +30,17 @@ namespace Hook { return new ByteArray {}; } - void OnAchievementAllDataNotify(LPVOID obj, const LPVOID ntf) { - const auto cos = Genshin::il2cpp_object_new(*Genshin::CodedOutputStream__TypeInfo); - const auto len = Genshin::CalculateSize(ntf); - const auto buf = (ByteArray*) new uint8_t[0x20 + len] {}; - buf->max_length = len; - Genshin::CodedOutputStreamInit(cos, buf, 0, len); - Genshin::ProtoWriteTo(ntf, cos); - const auto str = base64_encode(buf->vector, len) + "\n"; - WriteFile(hPipe, str.c_str(), (DWORD) str.length(), nullptr, nullptr); - CloseHandle(hPipe); - ExitProcess(0); + uint16_t BitConverter_ToUInt16(ByteArray* val, const int startIndex) { + const auto ret = CALL_ORIGIN(BitConverter_ToUInt16, val, startIndex); + if (ret == 0xAB89 && ReadMapped(val->vector, 2) == 20248) { + const auto headLength = ReadMapped(val->vector, 4); + const auto dataLength = ReadMapped(val->vector, 6); + const auto cStr = base64_encode(val->vector + 10 + headLength, dataLength) + "\n"; + WriteFile(hPipe, cStr.c_str(), (DWORD) cStr.length(), nullptr, nullptr); + CloseHandle(hPipe); + ExitProcess(0); + } + return ret; } } @@ -57,7 +57,7 @@ void Run(HMODULE* phModule) { const auto result = Genshin::RecordUserData(i); checksum += string(reinterpret_cast(&result->vector[0]), result->max_length); } - HookManager::install(Genshin::OnAchievementAllDataNotify, Hook::OnAchievementAllDataNotify); + HookManager::install(Genshin::BitConverter_ToUInt16, Hook::BitConverter_ToUInt16); HookManager::install(Genshin::UnityEngine_RecordUserData, Hook::UnityEngine_RecordUserData); hPipe = CreateFile(R"(\\.\pipe\YaeAchievementPipe)", GENERIC_WRITE, 0, nullptr, OPEN_EXISTING, 0, nullptr); if (hPipe == INVALID_HANDLE_VALUE) { diff --git a/lib/src/il2cpp-functions.h b/lib/src/il2cpp-functions.h index 2b22277..1ddda5e 100644 --- a/lib/src/il2cpp-functions.h +++ b/lib/src/il2cpp-functions.h @@ -2,16 +2,10 @@ using namespace Genshin; // DO_APP_FUNC(CN_OFFSET, OS_OFFSET, RETURN, FUNC_NAME, (ARGS...)); -DO_APP_FUNC(0x504620, 0x5C3140, LPVOID, il2cpp_object_new, (LPVOID t)); +DO_APP_FUNC(0x569170, 0x568470, LPVOID, il2cpp_object_new, (LPVOID t)); -DO_APP_FUNC(0x05167E00, 0x05166410, ByteArray*, RecordUserData, (int32_t nType)); +DO_APP_FUNC(0x06C43A80, 0x06775280, ByteArray*, RecordUserData, (int32_t nType)); -DO_APP_FUNC(0x04450D40, 0x0444F3B0, void, OnAchievementAllDataNotify, (LPVOID obj, LPVOID ntf)); +DO_APP_FUNC(0x0C87B240, 0x0C89EFB0, uint16_t, BitConverter_ToUInt16, (ByteArray* val, int startIndex)); -DO_APP_FUNC(0x07A3EC40, 0x07A3DD10, int, CalculateSize, (LPVOID obj)); - -DO_APP_FUNC(0x07A3EB80, 0x07A3DC50, void, ProtoWriteTo, (LPVOID obj, LPVOID output)); - -DO_APP_FUNC(0x05BFDA50, 0x05BFCCD0, void, CodedOutputStreamInit, (LPVOID obj, LPVOID buffer, int offset, int length)); - -DO_UNI_FUNC(0x1051E0, 0x1051E0, ByteArray*, UnityEngine_RecordUserData, (int32_t nType)); +DO_UNI_FUNC(0x105560, 0x105560, ByteArray*, UnityEngine_RecordUserData, (int32_t nType)); diff --git a/lib/src/il2cpp-types-ptr.h b/lib/src/il2cpp-types-ptr.h index 74a8796..e69de29 100644 --- a/lib/src/il2cpp-types-ptr.h +++ b/lib/src/il2cpp-types-ptr.h @@ -1,2 +0,0 @@ -// NOLFKCJKECE -DO_TYPEDEF(0x2A35D58, 0x2A34D58, CodedOutputStream); diff --git a/res/proto/AchievementAllDataNotify.proto b/res/proto/AchievementAllDataNotify.proto index 38cfc32..6055ca1 100644 --- a/res/proto/AchievementAllDataNotify.proto +++ b/res/proto/AchievementAllDataNotify.proto @@ -9,13 +9,13 @@ message Achievement { FINISHED = 2; REWARD_TAKEN = 3; } - uint32 timestamp = 6; - uint32 current = 12; - uint32 total = 3; - uint32 id = 9; - Status status = 11; + uint32 timestamp = 14; + uint32 current = 13; + uint32 total = 9; + uint32 id = 7; + Status status = 10; } message AchievementAllDataNotify { - repeated Achievement list = 5; + repeated Achievement list = 15; } diff --git a/src/GlobalVars.cs b/src/GlobalVars.cs index 8c29658..ca9b380 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 = 44; - public const string AppVersionName = "3.4"; + public const uint AppVersionCode = 45; + public const string AppVersionName = "3.5"; public const string PipeName = "YaeAchievementPipe"; public const string BucketHost = "https://cn-cd-1259389942.file.myqcloud.com";