diff --git a/Il2CppInterop.Runtime/Injection/Hooks/MetadataCache_GetTypeInfoFromTypeDefinitionIndex_Hook.cs b/Il2CppInterop.Runtime/Injection/Hooks/MetadataCache_GetTypeInfoFromTypeDefinitionIndex_Hook.cs index 943a9ad0c..5094446b1 100644 --- a/Il2CppInterop.Runtime/Injection/Hooks/MetadataCache_GetTypeInfoFromTypeDefinitionIndex_Hook.cs +++ b/Il2CppInterop.Runtime/Injection/Hooks/MetadataCache_GetTypeInfoFromTypeDefinitionIndex_Hook.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Linq; using System.Runtime.InteropServices; using Il2CppInterop.Common; @@ -75,8 +75,8 @@ private IntPtr FindGetTypeInfoFromTypeDefinitionIndex(bool forceICallMethod = fa else getTypeInfoFromTypeDefinitionIndex = imageGetTypeXrefs[0]; if ((getTypeInfoFromTypeDefinitionIndex.ToInt64() & 0xF) != 0) { - Logger.Instance.LogTrace("Image::GetType xref wasn't aligned, attempting to resolve from icall"); - return FindGetTypeInfoFromTypeDefinitionIndex(true); + Logger.Instance.LogTrace("Image::GetType xref wasn't aligned, GetTypeInfoFromTypeDefinitionIndex is likely inlined into Image::GetType"); + getTypeInfoFromTypeDefinitionIndex = imageGetType; } if (imageGetTypeXrefs.Count() > 1 && UnityVersionHandler.IsMetadataV29OrHigher) { diff --git a/Il2CppInterop.Runtime/Injection/InjectorHelpers.cs b/Il2CppInterop.Runtime/Injection/InjectorHelpers.cs index 9bd9b0de5..4662b236d 100644 --- a/Il2CppInterop.Runtime/Injection/InjectorHelpers.cs +++ b/Il2CppInterop.Runtime/Injection/InjectorHelpers.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; @@ -187,7 +187,7 @@ static nint GetClassInitSubstitute() } nint pClassInit = s_ClassInitSignatures .Select(s => MemoryUtils.FindSignatureInModule(Il2CppModule, s)) - .FirstOrDefault(p => p != 0); + .FirstOrDefault(p => p != 0 && (long)p >= (long)Il2CppModule.BaseAddress && (long)p < (long)Il2CppModule.BaseAddress + Il2CppModule.ModuleMemorySize); if (pClassInit == 0) {