mirror of
https://github.com/HolographicHat/Yae.git
synced 2025-12-15 02:48:12 +08:00
update
This commit is contained in:
@@ -1,65 +1,67 @@
|
||||
#include "pch.h"
|
||||
#include "util.h"
|
||||
#include "il2cpp-init.h"
|
||||
#include "HookManager.h"
|
||||
|
||||
using Genshin::ByteArray, std::to_string;
|
||||
|
||||
HWND unityWnd = 0;
|
||||
HANDLE hPipe = 0;
|
||||
|
||||
std::string il2cppi_to_string(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];
|
||||
WideCharToMultiByte(codePage, 0, chars, -1, buffer, len, nullptr, nullptr);
|
||||
std::string strTemp(buffer);
|
||||
delete[] buffer;
|
||||
return strTemp;
|
||||
}
|
||||
namespace Hook {
|
||||
|
||||
void SetDispstchData(Genshin::ByteArray* data, MethodInfo* m) {
|
||||
CALL_ORIGIN(SetDispstchData, data, m);
|
||||
auto ilStr = Genshin::Convert_ToBase64String(data, nullptr);
|
||||
auto cStr = il2cppi_to_string(reinterpret_cast<Il2CppString*>(ilStr), CP_ACP);
|
||||
ErrorDialog(cStr.c_str());
|
||||
return;
|
||||
std::set<UINT16> PacketWhitelist = { 109, 131, 141, 2668 };
|
||||
|
||||
void Packet_Xor(ByteArray** src, int len, MethodInfo* m) {
|
||||
auto data = (ByteArray*)new BYTE[len + 32];
|
||||
data->max_length = len;
|
||||
memcpy(data->vector, (*src)->vector, len);
|
||||
if (ReadMapped<UINT16>(data->vector, 0) != 0x4567) {
|
||||
CALL_ORIGIN(Packet_Xor, &data, len, m);
|
||||
}
|
||||
if (ReadMapped<UINT16>(data->vector, 2) == 2668) {
|
||||
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";
|
||||
WriteFile(hPipe, cStr.c_str(), cStr.length(), nullptr, nullptr);
|
||||
CloseHandle(hPipe);
|
||||
ExitProcess(0);
|
||||
}
|
||||
delete[] data;
|
||||
CALL_ORIGIN(Packet_Xor, src, len, m);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void Run(HMODULE* phModule) {
|
||||
AllocConsole();
|
||||
freopen_s((FILE**)stdout, "CONOUT$", "w", stdout);
|
||||
while (
|
||||
GetModuleHandle("UserAssembly.dll") == nullptr ||
|
||||
GetModuleHandle("UserAssembly.dll") == nullptr ||
|
||||
(unityWnd = FindMainWindowByPID(GetCurrentProcessId())) == 0
|
||||
) {
|
||||
printf("Wait game initialize...\n");
|
||||
Sleep(1000);
|
||||
}
|
||||
InitIL2CPP();
|
||||
HookManager::install(Genshin::Packet_SetDispstchData, SetDispstchData);
|
||||
/*HANDLE hPipe = CreateFile(R"(\\.\pipe\YaeAchievementPipe)", GENERIC_WRITE, 0, nullptr, OPEN_EXISTING, 0, nullptr);
|
||||
HookManager::install(Genshin::Packet_Xor, Hook::Packet_Xor);
|
||||
hPipe = CreateFile(R"(\\.\pipe\YaeAchievementPipe)", GENERIC_WRITE, 0, nullptr, OPEN_EXISTING, 0, nullptr);
|
||||
if (hPipe == INVALID_HANDLE_VALUE) {
|
||||
printf("Failed to open pipe: %d\n", GetLastError());
|
||||
Win32ErrorDialog(1001);
|
||||
ExitProcess(0);
|
||||
return;
|
||||
}*/
|
||||
//ErrorDialog("Press ok to continue.");
|
||||
//ConnectNamedPipe(hPipe, nullptr);
|
||||
//DWORD written;
|
||||
//WriteFile(hPipe, (checksum + "\n").c_str(), checksum.length() + 1, &written, nullptr);
|
||||
//DisconnectNamedPipe(hPipe);
|
||||
//CloseHandle(hPipe);
|
||||
//ExitProcess(0);
|
||||
}
|
||||
}
|
||||
|
||||
// DLL entry point
|
||||
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ulReasonForCall, LPVOID lpReserved) {
|
||||
switch (ulReasonForCall) {
|
||||
case DLL_PROCESS_ATTACH:
|
||||
CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)Run, new HMODULE(hModule), 0, NULL);
|
||||
break;
|
||||
case DLL_THREAD_ATTACH:
|
||||
case DLL_THREAD_DETACH:
|
||||
case DLL_PROCESS_DETACH:
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
switch (ulReasonForCall) {
|
||||
case DLL_PROCESS_ATTACH:
|
||||
CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)Run, new HMODULE(hModule), 0, NULL);
|
||||
break;
|
||||
case DLL_THREAD_ATTACH:
|
||||
case DLL_THREAD_DETACH:
|
||||
case DLL_PROCESS_DETACH:
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using namespace Genshin;
|
||||
|
||||
DO_APP_FUNC(0x04E9B3F0, String*, Convert_ToBase64String, (ByteArray* value, MethodInfo* method));
|
||||
DO_APP_FUNC(0x0517DD30, String*, BitConverter_ToString, (ByteArray* value, INT32 start, INT32 length, MethodInfo* method));
|
||||
DO_APP_FUNC(0x04E9B0A0, String*, Convert_ToBase64String, (ByteArray* value, INT32 offset, INT32 length, MethodInfo* method));
|
||||
DO_APP_FUNC(0x015913C0, void, Packet_Xor, (ByteArray** data, INT32 length, MethodInfo* method));
|
||||
|
||||
@@ -2365,5 +2365,4 @@ namespace Genshin {
|
||||
void* monitor;
|
||||
struct IMessage_Fields fields;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -14,11 +14,14 @@
|
||||
// 添加要在此处预编译的标头
|
||||
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <codecvt>
|
||||
#include <cstdint>
|
||||
#include <iostream>
|
||||
#include <detours.h>
|
||||
#include "HookManager.h"
|
||||
#include "il2cpp-appdata.h"
|
||||
|
||||
#endif //PCH_H
|
||||
|
||||
@@ -8,6 +8,7 @@ string IlStringToString(Il2CppString* str, UINT codePage = CP_ACP);
|
||||
|
||||
#define ErrorDialogT(title, msg) MessageBox(unityWnd, msg, title, MB_OK | MB_ICONERROR | MB_SYSTEMMODAL);
|
||||
#define ErrorDialog(msg) ErrorDialogT("YaeAchievement", msg)
|
||||
#define Win32ErrorDialog(code) ErrorDialogT("YaeAchievement", ("CRITICAL ERROR!\nError code: " + std::to_string(GetLastError()) + "-"#code"\n\nPlease take the screenshot and contact developer by GitHub Issue to solve this problem\nNOT MIHOYO/COGNOSPHERE CUSTOMER SERVICE!").c_str())
|
||||
|
||||
template<class T>
|
||||
static T ReadMapped(void* data, int offset, bool littleEndian = false) {
|
||||
|
||||
@@ -58,7 +58,9 @@ StartAndWaitResult(@"D:\Genshin Impact Dev\2.8\YuanShen.exe", evt => {
|
||||
case PipeRecvEvent @event: {
|
||||
var bytes = @event.GetData();
|
||||
GlobalVars.UnexpectedExit = false;
|
||||
return BitConverter.ToUInt32(bytes, 2) == 123456;
|
||||
Console.WriteLine("On PRE");
|
||||
Console.WriteLine(Convert.ToBase64String(bytes));
|
||||
return false;
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user