From 97bd3ce47305d433ce59e104f0b26ddf656b3e73 Mon Sep 17 00:00:00 2001 From: Herp Derpinstine Date: Thu, 26 Sep 2024 14:28:10 -0600 Subject: [PATCH] General Cleanup --- .../SupportModules/Il2Cpp/Il2Cpp.csproj | 5 ++++ Dependencies/SupportModules/Mono/Mono.csproj | 5 ++++ MelonLoader/Fixes/Il2CppICallInjector.cs | 26 ++++++++++++++++++- 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/Dependencies/SupportModules/Il2Cpp/Il2Cpp.csproj b/Dependencies/SupportModules/Il2Cpp/Il2Cpp.csproj index 8f8a89e8c..99045de06 100644 --- a/Dependencies/SupportModules/Il2Cpp/Il2Cpp.csproj +++ b/Dependencies/SupportModules/Il2Cpp/Il2Cpp.csproj @@ -16,6 +16,11 @@ https://nuget.bepinex.dev/v3/index.json + + + + + Libs\Il2Cppmscorlib.dll diff --git a/Dependencies/SupportModules/Mono/Mono.csproj b/Dependencies/SupportModules/Mono/Mono.csproj index 7c8204b89..99ac434c8 100644 --- a/Dependencies/SupportModules/Mono/Mono.csproj +++ b/Dependencies/SupportModules/Mono/Mono.csproj @@ -10,6 +10,11 @@ true embedded + + + + + Libs\UnityEngine.dll diff --git a/MelonLoader/Fixes/Il2CppICallInjector.cs b/MelonLoader/Fixes/Il2CppICallInjector.cs index 1d5a83e3c..bc2a8e7d7 100644 --- a/MelonLoader/Fixes/Il2CppICallInjector.cs +++ b/MelonLoader/Fixes/Il2CppICallInjector.cs @@ -161,6 +161,30 @@ private static IntPtr il2cpp_resolve_icall_Detour(IntPtr signature) return pair.Item3; } + private static Type FindType(string typeFullName) + { + if (string.IsNullOrEmpty(typeFullName)) + return null; + + Type result = null; + foreach (Assembly a in AppDomain.CurrentDomain.GetAssemblies()) + { + if (a == null) + continue; + + result = a.GetValidType($"Il2Cpp.{typeFullName}"); + if (result == null) + result = a.GetValidType($"Il2Cpp{typeFullName}"); + if (result == null) + result = a.GetValidType(typeFullName); + + if (result != null) + break; + } + + return result; + } + private static bool ShouldInject(string signature, out MethodInfo unityShimMethod) { unityShimMethod = null; @@ -170,7 +194,7 @@ private static bool ShouldInject(string signature, out MethodInfo unityShimMetho string typeName = split[0]; // Find Managed Type - Type newType = Il2CppInteropFixes.FixedFindType(typeName); + Type newType = FindType(typeName); if (newType == null) return false;