mirror of
https://github.com/HolographicHat/Yae.git
synced 2025-12-06 14:42:52 +08:00
fix #49
This commit is contained in:
@@ -33,7 +33,7 @@ bool OnPacket(KcpPacket* pkt) {
|
||||
auto headLength = ReadMapped<UINT16>(data->vector, 4);
|
||||
auto dataLength = ReadMapped<UINT32>(data->vector, 6);
|
||||
auto iStr = Genshin::ToBase64String(data, 10 + headLength, dataLength, nullptr);
|
||||
auto cStr = IlStringToString(iStr) + "\n";
|
||||
auto cStr = ToString(iStr) + "\n";
|
||||
WriteFile(hPipe, cStr.c_str(), cStr.length(), nullptr, nullptr);
|
||||
CloseHandle(hPipe);
|
||||
ExitProcess(0);
|
||||
@@ -42,7 +42,7 @@ bool OnPacket(KcpPacket* pkt) {
|
||||
return true;
|
||||
}
|
||||
|
||||
std::map<INT, UINT> signatures;
|
||||
std::string checksum;
|
||||
|
||||
namespace Hook {
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace Hook {
|
||||
}
|
||||
|
||||
void SetVersion(void* obj, Il2CppString* value, void* method) {
|
||||
auto version = IlStringToString(value);
|
||||
auto version = ToString(value);
|
||||
value = string_new(version + " YaeAchievement");
|
||||
CALL_ORIGIN(SetVersion, obj, value, method);
|
||||
}
|
||||
@@ -65,7 +65,17 @@ namespace Hook {
|
||||
}
|
||||
|
||||
ByteArray* UnityEngine_RecordUserData(INT type) {
|
||||
return GCHandle_GetObject<ByteArray>(signatures[type]);
|
||||
return Genshin::GetBytes(Genshin::GetDefaultEncoding(), il2cpp_string_new(""));
|
||||
}
|
||||
|
||||
VOID SetChecksum(LPVOID obj, Il2CppString* value) {
|
||||
CALL_ORIGIN(SetChecksum, obj, il2cpp_string_new(checksum.c_str()));
|
||||
}
|
||||
|
||||
VOID RequestLogin(LPVOID obj, LPVOID token, UINT32 uid) {
|
||||
HookManager::install(Genshin::SetChecksum, SetChecksum);
|
||||
CALL_ORIGIN(RequestLogin, obj, token, uid);
|
||||
HookManager::detach(SetChecksum);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,14 +91,14 @@ void Run(HMODULE* phModule) {
|
||||
Sleep(5000);
|
||||
DisableVMProtect();
|
||||
InitIL2CPP();
|
||||
for (int i = 0; i < 4; i++) {
|
||||
auto result = Genshin::RecordUserData(i, nullptr);
|
||||
signatures[i] = GCHandle_New(result, true);
|
||||
auto enc = Genshin::GetDefaultEncoding();
|
||||
for (int i = 0; i < 3; i++) {
|
||||
checksum += ToString(Genshin::GetString(enc, Genshin::RecordUserData(i)));
|
||||
}
|
||||
signatures[3] = signatures[2];
|
||||
HookManager::install(Genshin::KcpSend, Hook::KcpSend);
|
||||
HookManager::install(Genshin::KcpRecv, Hook::KcpRecv);
|
||||
HookManager::install(Genshin::SetVersion, Hook::SetVersion);
|
||||
HookManager::install(Genshin::RequestLogin, Hook::RequestLogin);
|
||||
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) {
|
||||
|
||||
@@ -1,3 +1 @@
|
||||
DO_API(0x02D2B620, 0x02D290A0, uint32_t, il2cpp_gchandle_new, (Il2CppObject* obj, bool pinned)); // search GCHandle.cpp in strings 2974550
|
||||
DO_API(0x02D2B330, 0x02D28DB0, Il2CppObject*, il2cpp_gchandle_get_target, (uint32_t gchandle));
|
||||
DO_API(0x02D2E840, 0x02D2C0A0, Il2CppString*, il2cpp_string_new, (const char* str));
|
||||
|
||||
@@ -12,7 +12,7 @@ DO_APP_FUNC(0X05265A70, 0x052704C0, void, SetVersion, (void* obj, Il2CppString*
|
||||
|
||||
// N: UnityEngine.Application$RecordUserData
|
||||
// L: UnityEngine.CoreModule
|
||||
DO_APP_FUNC(0x09932F30, 0x09947590, ByteArray*, RecordUserData, (int32_t nType, void* method));
|
||||
DO_APP_FUNC(0x09932F30, 0x09947590, ByteArray*, RecordUserData, (int32_t nType));
|
||||
|
||||
// N: MoleMole.Packet$XorEncrypt [Obfuscated]
|
||||
// L: Assembly-CSharp
|
||||
@@ -26,6 +26,12 @@ DO_APP_FUNC(0x050BB390, 0x050C5AC0, int, KcpSend, (void* client, KcpPacket* pkt,
|
||||
// L: Assembly-CSharp
|
||||
DO_APP_FUNC(0x04496B50, 0x0449DBF0, bool, KcpRecv, (void* client, ClientKcpEvent* evt, void* method)); // GFFOOBHMCOJ
|
||||
|
||||
DO_APP_FUNC(0x09254010, 0x09269550, LPVOID, GetDefaultEncoding, (void* method));
|
||||
DO_APP_FUNC(0x09254010, 0x09269550, LPVOID, GetDefaultEncoding, ());
|
||||
|
||||
DO_APP_FUNC(0x092538C0, 0x09268DE0, Il2CppString*, GetString, (LPVOID encoding, LPVOID bytes, void* method));
|
||||
DO_APP_FUNC(0x092538C0, 0x09268DE0, Il2CppString*, GetString, (LPVOID encoding, LPVOID bytes));
|
||||
|
||||
DO_APP_FUNC(0x09252750, 0x09267C60, ByteArray*, GetBytes, (LPVOID encoding, LPVOID str));
|
||||
|
||||
DO_APP_FUNC(0X05069690, 0X05073B60, VOID, RequestLogin, (LPVOID obj, LPVOID token, UINT uid));
|
||||
|
||||
DO_APP_FUNC(0x03C751A0, 0x0500F3D0, VOID, SetChecksum, (LPVOID obj, Il2CppString* value));
|
||||
|
||||
@@ -14,7 +14,7 @@ VOID DisableVMProtect() {
|
||||
|
||||
#pragma region StringConvert
|
||||
|
||||
string IlStringToString(Il2CppString* str, UINT codePage) {
|
||||
string ToString(Il2CppString* str, UINT codePage) {
|
||||
auto chars = reinterpret_cast<const wchar_t*>(str->chars);
|
||||
auto len = WideCharToMultiByte(codePage, 0, chars, -1, nullptr, 0, nullptr, nullptr);
|
||||
auto buffer = new char[len];
|
||||
@@ -24,14 +24,6 @@ string IlStringToString(Il2CppString* str, UINT codePage) {
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region GC
|
||||
|
||||
UINT32 GCHandle_New(void* object, bool pinned) {
|
||||
return il2cpp_gchandle_new((Il2CppObject*)object, pinned);
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region ByteUtils
|
||||
|
||||
bool IsLittleEndian() {
|
||||
|
||||
@@ -5,8 +5,7 @@ using std::string;
|
||||
VOID DisableVMProtect();
|
||||
bool IsLittleEndian();
|
||||
HWND FindMainWindowByPID(DWORD pid);
|
||||
UINT32 GCHandle_New(LPVOID object, bool pinned);
|
||||
string IlStringToString(Il2CppString* str, UINT codePage = CP_ACP);
|
||||
string ToString(Il2CppString* str, UINT codePage = CP_ACP);
|
||||
|
||||
#define cstring_new(str) il2cpp_string_new(str)
|
||||
#define string_new(str) cstring_new((str).c_str())
|
||||
@@ -27,8 +26,3 @@ static T ReadMapped(void* data, int offset, bool littleEndian = false) {
|
||||
memcpy(&result, cData + offset, sizeof(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
static T* GCHandle_GetObject(UINT handle) {
|
||||
return (T*) il2cpp_gchandle_get_target(handle);
|
||||
}
|
||||
|
||||
@@ -4,12 +4,12 @@ using YaeAchievement.AppCenterSDK.Models;
|
||||
using YaeAchievement.res;
|
||||
using static YaeAchievement.Utils;
|
||||
|
||||
TryDisableQuickEdit();
|
||||
InstallExitHook();
|
||||
InstallExceptionHook();
|
||||
|
||||
await CheckVcRuntime();
|
||||
CheckSelfIsRunning();
|
||||
TryDisableQuickEdit();
|
||||
CheckGenshinIsRunning();
|
||||
|
||||
Console.WriteLine(@"----------------------------------------------------");
|
||||
|
||||
@@ -94,10 +94,7 @@ public static class Utils {
|
||||
File.WriteAllBytes(tmpPath, GetBucketFileAsByteArray(info.PackageLink));
|
||||
var updaterArgs = $"{Environment.ProcessId}|{Environment.ProcessPath}|{tmpPath}";
|
||||
var updaterPath = Path.Combine(GlobalVars.DataPath, "update.exe");
|
||||
var updaterHash = App.Updater.MD5Hash();
|
||||
if (!File.Exists(updaterPath) || File.ReadAllBytes(updaterPath).MD5Hash() != updaterHash) {
|
||||
File.WriteAllBytes(updaterPath, App.Updater);
|
||||
}
|
||||
File.WriteAllBytes(updaterPath, App.Updater);
|
||||
ShellOpen(updaterPath, updaterArgs.ToBytes().ToBase64());
|
||||
GlobalVars.PauseOnExit = false;
|
||||
Environment.Exit(0);
|
||||
|
||||
Reference in New Issue
Block a user