mirror of
https://github.com/HolographicHat/Yae.git
synced 2026-05-20 20:55:46 +08:00
simple test
This commit is contained in:
@@ -1,10 +1,31 @@
|
|||||||
#include "pch.h"
|
#include "pch.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "il2cpp-init.h"
|
||||||
|
#include "HookManager.h"
|
||||||
|
|
||||||
|
HWND unityWnd = 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
void Run(HMODULE* phModule) {
|
void Run(HMODULE* phModule) {
|
||||||
AllocConsole();
|
AllocConsole();
|
||||||
freopen_s((FILE**)stdout, "CONOUT$", "w", stdout);
|
freopen_s((FILE**)stdout, "CONOUT$", "w", stdout);
|
||||||
HWND unityWnd = 0;
|
|
||||||
while (
|
while (
|
||||||
GetModuleHandle("UserAssembly.dll") == nullptr ||
|
GetModuleHandle("UserAssembly.dll") == nullptr ||
|
||||||
(unityWnd = FindMainWindowByPID(GetCurrentProcessId())) == 0
|
(unityWnd = FindMainWindowByPID(GetCurrentProcessId())) == 0
|
||||||
@@ -12,24 +33,21 @@ void Run(HMODULE* phModule) {
|
|||||||
printf("Wait game initialize...\n");
|
printf("Wait game initialize...\n");
|
||||||
Sleep(1000);
|
Sleep(1000);
|
||||||
}
|
}
|
||||||
MessageBox(unityWnd, "YaeAchievementLib injection test on 原神 Beta (CNCBWIN2.7.53)", "", MB_OK | MB_ICONERROR | MB_SYSTEMMODAL);
|
InitIL2CPP();
|
||||||
//init_il2cpp();
|
HookManager::install(Genshin::Packet_SetDispstchData, SetDispstchData);
|
||||||
//HookManager::install(app::Unity_RecordUserData, OnRecordUserData);
|
/*HANDLE hPipe = CreateFile(R"(\\.\pipe\YaeAchievementPipe)", GENERIC_WRITE, 0, nullptr, OPEN_EXISTING, 0, nullptr);
|
||||||
for (int i = 0; i < 4; i++) {
|
|
||||||
//app::Application_RecordUserData(i, nullptr);
|
|
||||||
}
|
|
||||||
HANDLE hPipe = CreateFile(R"(\\.\pipe\genshin-checksum)", GENERIC_WRITE, 0, nullptr, OPEN_EXISTING, 0, nullptr);
|
|
||||||
if (hPipe == INVALID_HANDLE_VALUE) {
|
if (hPipe == INVALID_HANDLE_VALUE) {
|
||||||
printf("Failed to open pipe: %d\n", GetLastError());
|
printf("Failed to open pipe: %d\n", GetLastError());
|
||||||
ExitProcess(0);
|
ExitProcess(0);
|
||||||
return;
|
return;
|
||||||
}
|
}*/
|
||||||
ConnectNamedPipe(hPipe, nullptr);
|
//ErrorDialog("Press ok to continue.");
|
||||||
DWORD written;
|
//ConnectNamedPipe(hPipe, nullptr);
|
||||||
|
//DWORD written;
|
||||||
//WriteFile(hPipe, (checksum + "\n").c_str(), checksum.length() + 1, &written, nullptr);
|
//WriteFile(hPipe, (checksum + "\n").c_str(), checksum.length() + 1, &written, nullptr);
|
||||||
DisconnectNamedPipe(hPipe);
|
//DisconnectNamedPipe(hPipe);
|
||||||
CloseHandle(hPipe);
|
//CloseHandle(hPipe);
|
||||||
ExitProcess(0);
|
//ExitProcess(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// DLL entry point
|
// DLL entry point
|
||||||
|
|||||||
Reference in New Issue
Block a user