From 99fec63867c01cb2bd90e693b97cb8bbb0ee5e9c Mon Sep 17 00:00:00 2001 From: REL <25654009+34736384@users.noreply.github.com> Date: Wed, 9 Oct 2024 08:14:41 -0400 Subject: [PATCH] remove il2cpp bloat --- lib/YaeAchievementLib.vcxproj | 15 ++++----------- lib/src/HookManager.h | 3 ++- lib/src/dllmain.cpp | 19 ++++++++++++------- lib/src/il2cpp-appdata.h | 11 ----------- lib/src/il2cpp-functions.h | 9 --------- lib/src/il2cpp-init.cpp | 25 +++++-------------------- lib/src/pch.cpp | 1 - lib/src/pch.h | 23 ----------------------- lib/src/util.cpp | 4 +++- 9 files changed, 26 insertions(+), 84 deletions(-) delete mode 100644 lib/src/il2cpp-appdata.h delete mode 100644 lib/src/il2cpp-functions.h delete mode 100644 lib/src/pch.cpp delete mode 100644 lib/src/pch.h diff --git a/lib/YaeAchievementLib.vcxproj b/lib/YaeAchievementLib.vcxproj index e21d77a..5e11377 100644 --- a/lib/YaeAchievementLib.vcxproj +++ b/lib/YaeAchievementLib.vcxproj @@ -59,9 +59,9 @@ Level3 true - _DEBUG;YAEACHIEVEMENTLIB_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + _DEBUG;YAEACHIEVEMENTLIB_EXPORTS;_WINDOWS;_USRDLL;WIN32_LEAN_AND_MEAN;%(PreprocessorDefinitions) true - Use + NotUsing pch.h stdcpplatest stdc17 @@ -84,9 +84,9 @@ true true true - _AMD64_;NDEBUG;YAEACHIEVEMENTLIB_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + _AMD64_;NDEBUG;YAEACHIEVEMENTLIB_EXPORTS;_WINDOWS;_USRDLL;WIN32_LEAN_AND_MEAN;%(PreprocessorDefinitions) true - Use + NotUsing pch.h stdcpplatest stdc17 @@ -110,20 +110,13 @@ - - - - - Create - Create - diff --git a/lib/src/HookManager.h b/lib/src/HookManager.h index 7009c2a..6302ff6 100644 --- a/lib/src/HookManager.h +++ b/lib/src/HookManager.h @@ -1,6 +1,7 @@ #pragma once -#include "pch.h" +#include +#include #define CALL_ORIGIN(function, ...) \ HookManager::call(function, __func__, __VA_ARGS__) diff --git a/lib/src/dllmain.cpp b/lib/src/dllmain.cpp index 0bb8ba5..a23bc4a 100644 --- a/lib/src/dllmain.cpp +++ b/lib/src/dllmain.cpp @@ -6,9 +6,12 @@ // ReSharper disable CppDefaultCaseNotHandledInSwitchStatement // ReSharper disable CppClangTidyClangDiagnosticCastFunctionTypeStrict -#include "pch.h" +#include +#include + #include "util.h" #include "il2cpp-init.h" +#include "il2cpp-types.h" using Genshin::ByteArray; @@ -21,17 +24,18 @@ std::string checksum; namespace Hook { ByteArray* UnityEngine_RecordUserData(const INT type) { - if (type == 0) { + /*if (type == 0) { const auto len = checksum.length(); const auto arr = Genshin::il2cpp_array_new_specific(baClass, len); memcpy(&arr->vector[0], checksum.data(), len); return arr; } - return Genshin::il2cpp_array_new_specific(baClass, 0); + return Genshin::il2cpp_array_new_specific(baClass, 0);*/ + return {}; } uint16_t BitConverter_ToUInt16(ByteArray* val, const int startIndex) { - const auto ret = CALL_ORIGIN(BitConverter_ToUInt16, val, startIndex); + /*const auto ret = CALL_ORIGIN(BitConverter_ToUInt16, val, startIndex); if (ret == 0xAB89 && ReadMapped(val->vector, 2) == 24082) { const auto headLength = ReadMapped(val->vector, 4); const auto dataLength = ReadMapped(val->vector, 6); @@ -40,7 +44,8 @@ namespace Hook { CloseHandle(hPipe); ExitProcess(0); } - return ret; + return ret;*/ + return {}; } } @@ -53,13 +58,13 @@ void Run(HMODULE* phModule) { Sleep(5000); DisableVMProtect(); InitIL2CPP(); - for (int i = 0; i < 3; i++) { + /*for (int i = 0; i < 3; i++) { const auto result = Genshin::RecordUserData(i); checksum += string(reinterpret_cast(&result->vector[0]), result->max_length); baClass = result->klass; } HookManager::install(Genshin::RecordUserData, Hook::UnityEngine_RecordUserData); - HookManager::install(Genshin::BitConverter_ToUInt16, Hook::BitConverter_ToUInt16); + HookManager::install(Genshin::BitConverter_ToUInt16, Hook::BitConverter_ToUInt16);*/ hPipe = CreateFile(R"(\\.\pipe\YaeAchievementPipe)", GENERIC_WRITE, 0, nullptr, OPEN_EXISTING, 0, nullptr); if (hPipe == INVALID_HANDLE_VALUE) { Win32ErrorDialog(1001); diff --git a/lib/src/il2cpp-appdata.h b/lib/src/il2cpp-appdata.h deleted file mode 100644 index ac5ddc8..0000000 --- a/lib/src/il2cpp-appdata.h +++ /dev/null @@ -1,11 +0,0 @@ -// ReSharper disable CppClangTidyBugproneMacroParentheses - -#pragma once -#include "il2cpp-types.h" - -// Application-specific functions -#define DO_APP_FUNC(ca, oa, r, n, p) extern r (*n) p -namespace Genshin { -#include "il2cpp-functions.h" -} -#undef DO_APP_FUNC diff --git a/lib/src/il2cpp-functions.h b/lib/src/il2cpp-functions.h deleted file mode 100644 index 7a4310c..0000000 --- a/lib/src/il2cpp-functions.h +++ /dev/null @@ -1,9 +0,0 @@ -using namespace Genshin; - -// DO_APP_FUNC(CN_OFFSET, OS_OFFSET, RETURN, FUNC_NAME, (ARGS...)); - -DO_APP_FUNC(0x002ED400, 0x002ED390, ByteArray*, il2cpp_array_new_specific, (void* arrayTypeInfo, uint64_t length)); - -DO_APP_FUNC(0x0113ADC0, 0x0113AFC0, ByteArray*, RecordUserData, (int32_t nType)); - -DO_APP_FUNC(0x0F826CF0, 0x0F825F10, uint16_t, BitConverter_ToUInt16, (ByteArray* val, int startIndex)); diff --git a/lib/src/il2cpp-init.cpp b/lib/src/il2cpp-init.cpp index 637f2f6..f34e05c 100644 --- a/lib/src/il2cpp-init.cpp +++ b/lib/src/il2cpp-init.cpp @@ -3,25 +3,10 @@ // ReSharper disable CppClangTidyBugproneMacroParentheses // ReSharper disable CppClangTidyClangDiagnosticCastAlign -#include "pch.h" +#include +#include -#include "il2cpp-init.h" - -#define DO_APP_FUNC(ca, oa, r, n, p) r (*n) p -namespace Genshin { -#include "il2cpp-functions.h" -} -#undef DO_APP_FUNC - -using std::string; - -void InitIL2CPP() { - TCHAR szFileName[MAX_PATH]; - GetModuleFileName(nullptr, szFileName, MAX_PATH); - _strupr_s(szFileName); - const auto isCN = strstr(szFileName, "YUANSHEN.EXE"); - const auto uBase = reinterpret_cast(GetModuleHandle(isCN ? "YuanShen.exe" : "GenshinImpact.exe")); - #define DO_APP_FUNC(ca, oa, r, n, p) n = (r (*) p)(uBase + (isCN ? ca : oa)) - #include "il2cpp-functions.h" - #undef DO_APP_FUNC +void InitIL2CPP() +{ + } diff --git a/lib/src/pch.cpp b/lib/src/pch.cpp deleted file mode 100644 index bcb5590..0000000 --- a/lib/src/pch.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "pch.h" diff --git a/lib/src/pch.h b/lib/src/pch.h deleted file mode 100644 index f87cddb..0000000 --- a/lib/src/pch.h +++ /dev/null @@ -1,23 +0,0 @@ -// pch.h: 这是预编译标头文件。 -// 下方列出的文件仅编译一次,提高了将来生成的生成性能。 -// 这还将影响 IntelliSense 性能,包括代码完成和许多代码浏览功能。 -// 但是,如果此处列出的文件中的任何一个在生成之间有更新,它们全部都将被重新编译。 -// 请勿在此处添加要频繁更新的文件,这将使得性能优势无效。 - -#ifndef PCH_H -#define PCH_H - -#define WIN32_LEAN_AND_MEAN // 从 Windows 头文件中排除极少使用的内容 -// Windows 头文件 -#include - -// 添加要在此处预编译的标头 - -#include -#include -#include -#include -#include "HookManager.h" -#include "il2cpp-appdata.h" - -#endif //PCH_H diff --git a/lib/src/util.cpp b/lib/src/util.cpp index febc6b8..b82eb75 100644 --- a/lib/src/util.cpp +++ b/lib/src/util.cpp @@ -1,4 +1,6 @@ -#include "pch.h" +#include +#include + #include "util.h" VOID DisableVMProtect() {