diff --git a/Il2CppInterop.Runtime/Injection/InjectorHelpers.cs b/Il2CppInterop.Runtime/Injection/InjectorHelpers.cs index 9bd9b0de..22e3d00a 100644 --- a/Il2CppInterop.Runtime/Injection/InjectorHelpers.cs +++ b/Il2CppInterop.Runtime/Injection/InjectorHelpers.cs @@ -75,13 +75,26 @@ internal static void Setup() GenericMethodGetMethodHook_Unity6.ApplyHook(); else GenericMethodGetMethodHook.ApplyHook(); - GetTypeInfoFromTypeDefinitionIndexHook.ApplyHook(); + if (IsHybridClrPresent()) + { + Logger.Instance.LogTrace("HybridCLR detected in game; MetadataCache::GetTypeInfoFromTypeDefinitionIndex will not be hooked."); + } + else + { + Logger.Instance.LogTrace("HybridCLR not detected; MetadataCache::GetTypeInfoFromTypeDefinitionIndex will be hooked."); + GetTypeInfoFromTypeDefinitionIndexHook.ApplyHook(); + } GetFieldDefaultValueHook.ApplyHook(); ClassInit ??= FindClassInit(); FromIl2CppTypeHook.ApplyHook(); FromNameHook.ApplyHook(); } + internal static bool IsHybridClrPresent() + { + return Il2CppSystem.Type.GetType("HybridCLR.RuntimeApi") != null; + } + internal static long CreateClassToken(IntPtr classPointer) { long newToken = Interlocked.Decrement(ref s_LastInjectedToken);