using System; using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using System.Threading; using Il2CppInterop.Common; using Il2CppInterop.Common.Attributes; using Il2CppInterop.Common.Extensions; using Il2CppInterop.Common.Host; using Il2CppInterop.Common.XrefScans; using Il2CppInterop.Runtime.Attributes; using Il2CppInterop.Runtime.Injection; using Il2CppInterop.Runtime.Injection.Hooks; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppInterop.Runtime.InteropTypes.Fields; using Il2CppInterop.Runtime.Runtime; using Il2CppInterop.Runtime.Runtime.VersionSpecific.Assembly; using Il2CppInterop.Runtime.Runtime.VersionSpecific.AssemblyName; using Il2CppInterop.Runtime.Runtime.VersionSpecific.Class; using Il2CppInterop.Runtime.Runtime.VersionSpecific.EventInfo; using Il2CppInterop.Runtime.Runtime.VersionSpecific.Exception; using Il2CppInterop.Runtime.Runtime.VersionSpecific.FieldInfo; using Il2CppInterop.Runtime.Runtime.VersionSpecific.Image; using Il2CppInterop.Runtime.Runtime.VersionSpecific.MethodInfo; using Il2CppInterop.Runtime.Runtime.VersionSpecific.ParameterInfo; using Il2CppInterop.Runtime.Runtime.VersionSpecific.PropertyInfo; using Il2CppInterop.Runtime.Runtime.VersionSpecific.Type; using Il2CppInterop.Runtime.Startup; using Il2CppInterop.Runtime.XrefScans; using Il2CppSystem; using Il2CppSystem.Reflection; using Il2CppSystem.Runtime.CompilerServices; using Microsoft.CodeAnalysis; using Microsoft.Extensions.Logging; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = "")] [assembly: InternalsVisibleTo("Il2CppInterop.HarmonySupport")] [assembly: AssemblyCompany("knah, BepInEx et al.")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Runtime tools for bridging .NET and Il2Cpp together")] [assembly: AssemblyFileVersion("1.4.6.0")] [assembly: AssemblyInformationalVersion("1.4.6-ci.389")] [assembly: AssemblyProduct("Il2CppInterop.Runtime")] [assembly: AssemblyTitle("Il2CppInterop.Runtime")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.4.6.0")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class IsUnmanagedAttribute : Attribute { } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NativeIntegerAttribute : Attribute { public readonly bool[] TransformFlags; public NativeIntegerAttribute() { TransformFlags = new bool[1] { true }; } public NativeIntegerAttribute(bool[] P_0) { TransformFlags = P_0; } } } namespace Il2CppInterop.Runtime { public static class DelegateSupport { internal class MethodSignature : IEquatable { public readonly bool ConstructedFromNative; public readonly bool HasThis; private readonly int _hashCode; public MethodSignature(MethodInfo methodInfo, bool hasThis) { HasThis = hasThis; ConstructedFromNative = true; HashCode hashCode = default(HashCode); hashCode.Add(((Object)methodInfo.ReturnType).GetHashCode()); if (hasThis) { hashCode.Add(((Object)((MemberInfo)methodInfo).DeclaringType).GetHashCode()); } foreach (ParameterInfo parameter in ((MethodBase)methodInfo).GetParameters()) { hashCode.Add(((Object)parameter.ParameterType).GetHashCode()); } _hashCode = hashCode.ToHashCode(); } public MethodSignature(MethodInfo methodInfo, bool hasThis) { HasThis = hasThis; ConstructedFromNative = false; HashCode hashCode = default(HashCode); hashCode.Add(methodInfo.ReturnType.NativeType()); if (hasThis) { hashCode.Add(methodInfo.DeclaringType.NativeType()); } ParameterInfo[] parameters = methodInfo.GetParameters(); foreach (ParameterInfo parameterInfo in parameters) { hashCode.Add(parameterInfo.ParameterType.NativeType()); } _hashCode = hashCode.ToHashCode(); } public override int GetHashCode() { return _hashCode; } public bool Equals(MethodSignature other) { if ((object)other == null) { return false; } if ((object)this == other) { return true; } return _hashCode.GetHashCode() == other.GetHashCode(); } public override bool Equals(object obj) { if (obj == null) { return false; } if (this == obj) { return true; } if (obj.GetType() != GetType()) { return false; } return Equals((MethodSignature)obj); } public static bool operator ==(MethodSignature left, MethodSignature right) { return object.Equals(left, right); } public static bool operator !=(MethodSignature left, MethodSignature right) { return !object.Equals(left, right); } } private class Il2CppToMonoDelegateReference : Object { public IntPtr MethodInfo; public Delegate ReferencedDelegate; public Il2CppToMonoDelegateReference(IntPtr obj0) : base(obj0) { } public Il2CppToMonoDelegateReference(Delegate referencedDelegate, IntPtr methodInfo) : base(ClassInjector.DerivedConstructorPointer()) { ClassInjector.DerivedConstructorBody((Il2CppObjectBase)(object)this); ReferencedDelegate = referencedDelegate; MethodInfo = methodInfo; } ~Il2CppToMonoDelegateReference() { try { Marshal.FreeHGlobal(MethodInfo); MethodInfo = IntPtr.Zero; ReferencedDelegate = null; } finally { ((Il2CppObjectBase)this).Finalize(); } } } private static readonly ConcurrentDictionary ourDelegateTypes = new ConcurrentDictionary(); private static readonly AssemblyBuilder AssemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("Il2CppTrampolineDelegates"), AssemblyBuilderAccess.Run); private static readonly ModuleBuilder ModuleBuilder = AssemblyBuilder.DefineDynamicModule("Il2CppTrampolineDelegates"); private static readonly ConcurrentDictionary NativeToManagedTrampolines = new ConcurrentDictionary(); internal static Type GetOrCreateDelegateType(MethodSignature signature, MethodInfo managedMethod) { return ourDelegateTypes.GetOrAdd(signature, (MethodSignature signature, MethodInfo managedMethodInner) => CreateDelegateType(managedMethodInner, signature), managedMethod); } private unsafe static Type CreateDelegateType(MethodInfo managedMethodInner, MethodSignature signature) { string name = "Il2CppToManagedDelegate_" + managedMethodInner.DeclaringType?.ToString() + "_" + signature.GetHashCode() + (signature.HasThis ? "HasThis" : "") + (signature.ConstructedFromNative ? "FromNative" : ""); TypeBuilder typeBuilder = ModuleBuilder.DefineType(name, TypeAttributes.Public | TypeAttributes.Sealed, typeof(MulticastDelegate)); typeBuilder.SetCustomAttribute(new CustomAttributeBuilder(typeof(UnmanagedFunctionPointerAttribute).GetConstructor(new Type[1] { typeof(CallingConvention) }), new object[1] { CallingConvention.Cdecl })); typeBuilder.DefineConstructor(MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.SpecialName | MethodAttributes.RTSpecialName, CallingConventions.HasThis, new Type[2] { typeof(object), typeof(IntPtr) }).SetImplementationFlags(MethodImplAttributes.CodeTypeMask); int num = (signature.HasThis ? 1 : 0); ParameterInfo[] parameters = managedMethodInner.GetParameters(); Type[] array = new Type[parameters.Length + 1 + num]; if (signature.HasThis) { array[0] = typeof(IntPtr); } array[^1] = typeof(Il2CppMethodInfo*); for (int i = 0; i < parameters.Length; i++) { array[i + num] = parameters[i].ParameterType.NativeType(); } typeBuilder.DefineMethod("Invoke", MethodAttributes.Public | MethodAttributes.Virtual | MethodAttributes.HideBySig | MethodAttributes.VtableLayoutMask, CallingConventions.HasThis, managedMethodInner.ReturnType.NativeType(), array).SetImplementationFlags(MethodImplAttributes.CodeTypeMask); typeBuilder.DefineMethod("BeginInvoke", MethodAttributes.Public | MethodAttributes.Virtual | MethodAttributes.HideBySig | MethodAttributes.VtableLayoutMask, CallingConventions.HasThis, typeof(IAsyncResult), array.Concat(new Type[2] { typeof(AsyncCallback), typeof(object) }).ToArray()).SetImplementationFlags(MethodImplAttributes.CodeTypeMask); typeBuilder.DefineMethod("EndInvoke", MethodAttributes.Public | MethodAttributes.Virtual | MethodAttributes.HideBySig | MethodAttributes.VtableLayoutMask, CallingConventions.HasThis, managedMethodInner.ReturnType.NativeType(), new Type[1] { typeof(IAsyncResult) }).SetImplementationFlags(MethodImplAttributes.CodeTypeMask); return typeBuilder.CreateType(); } private static string ExtractSignature(MethodInfo methodInfo) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(methodInfo.ReturnType.FullName); if (!methodInfo.IsStatic) { stringBuilder.Append('_'); stringBuilder.Append(methodInfo.DeclaringType.FullName); } ParameterInfo[] parameters = methodInfo.GetParameters(); foreach (ParameterInfo parameterInfo in parameters) { stringBuilder.Append('_'); stringBuilder.Append(parameterInfo.ParameterType.FullName); } return stringBuilder.ToString(); } private static Delegate GetOrCreateNativeToManagedTrampoline(MethodSignature signature, MethodInfo nativeMethod, MethodInfo managedMethod) { return NativeToManagedTrampolines.GetOrAdd(managedMethod, (MethodInfo _, (MethodInfo nativeMethod, MethodInfo managedMethod, MethodSignature signature) tuple) => GenerateNativeToManagedTrampoline(tuple.nativeMethod, tuple.managedMethod, tuple.signature), (nativeMethod, managedMethod, signature)); } private unsafe static Delegate GenerateNativeToManagedTrampoline(MethodInfo nativeMethod, MethodInfo managedMethod, MethodSignature signature) { Type type = managedMethod.ReturnType.NativeType(); ParameterInfo[] parameters = managedMethod.GetParameters(); ((MethodBase)nativeMethod).GetParameters(); Type[] array = new Type[parameters.Length + 1 + 1]; array[0] = typeof(IntPtr); array[parameters.Length + 1] = typeof(Il2CppMethodInfo*); for (int i = 0; i < parameters.Length; i++) { array[i + 1] = parameters[i].ParameterType.NativeType(); } DynamicMethod dynamicMethod = new DynamicMethod("(il2cpp delegate trampoline) " + ExtractSignature(managedMethod), MethodAttributes.Public | MethodAttributes.Static, CallingConventions.Standard, type, array, typeof(DelegateSupport), skipVisibility: true); ILGenerator iLGenerator = dynamicMethod.GetILGenerator(); iLGenerator.BeginExceptionBlock(); iLGenerator.Emit(OpCodes.Ldarg_0); iLGenerator.Emit(OpCodes.Call, typeof(ClassInjectorBase).GetMethod("GetMonoObjectFromIl2CppPointer")); iLGenerator.Emit(OpCodes.Castclass, typeof(Il2CppToMonoDelegateReference)); iLGenerator.Emit(OpCodes.Ldfld, typeof(Il2CppToMonoDelegateReference).GetField("ReferencedDelegate")); for (int j = 0; j < parameters.Length; j++) { Type parameterType = parameters[j].ParameterType; iLGenerator.Emit(OpCodes.Ldarg, j + 1); if (parameterType == typeof(string)) { iLGenerator.Emit(OpCodes.Call, typeof(IL2CPP).GetMethod("Il2CppStringToManaged")); } else if (!parameterType.IsValueType) { Label label = iLGenerator.DefineLabel(); Label label2 = iLGenerator.DefineLabel(); iLGenerator.Emit(OpCodes.Brfalse, label); iLGenerator.Emit(OpCodes.Ldarg, j + 1); iLGenerator.Emit(OpCodes.Newobj, parameterType.GetConstructor(new Type[1] { typeof(IntPtr) })); iLGenerator.Emit(OpCodes.Br, label2); iLGenerator.MarkLabel(label); iLGenerator.Emit(OpCodes.Ldnull); iLGenerator.MarkLabel(label2); } } iLGenerator.Emit(OpCodes.Call, managedMethod); if (type == typeof(string)) { iLGenerator.Emit(OpCodes.Call, typeof(IL2CPP).GetMethod("ManagedStringToIl2Cpp")); } else if (!type.IsValueType) { Label label3 = iLGenerator.DefineLabel(); Label label4 = iLGenerator.DefineLabel(); iLGenerator.Emit(OpCodes.Dup); iLGenerator.Emit(OpCodes.Brfalse, label3); iLGenerator.Emit(OpCodes.Call, typeof(Il2CppObjectBase).GetProperty("Pointer").GetMethod); iLGenerator.Emit(OpCodes.Br, label4); iLGenerator.MarkLabel(label3); iLGenerator.Emit(OpCodes.Pop); iLGenerator.Emit(OpCodes.Ldc_I4_0); iLGenerator.Emit(OpCodes.Conv_I); iLGenerator.MarkLabel(label4); } LocalBuilder localBuilder = null; if (type != typeof(void)) { localBuilder = iLGenerator.DeclareLocal(type); iLGenerator.Emit(OpCodes.Stloc, localBuilder); } LocalBuilder local = iLGenerator.DeclareLocal(typeof(Exception)); iLGenerator.BeginCatchBlock(typeof(Exception)); iLGenerator.Emit(OpCodes.Stloc, local); iLGenerator.Emit(OpCodes.Ldstr, "Exception in IL2CPP-to-Managed trampoline, not passing it to il2cpp: "); iLGenerator.Emit(OpCodes.Ldloc, local); iLGenerator.Emit(OpCodes.Callvirt, typeof(object).GetMethod("ToString")); iLGenerator.Emit(OpCodes.Call, typeof(string).GetMethod("Concat", new Type[2] { typeof(string), typeof(string) })); iLGenerator.Emit(OpCodes.Call, typeof(DelegateSupport).GetMethod("LogError", BindingFlags.Static | BindingFlags.NonPublic)); iLGenerator.EndExceptionBlock(); if (localBuilder != null) { iLGenerator.Emit(OpCodes.Ldloc, localBuilder); } iLGenerator.Emit(OpCodes.Ret); return dynamicMethod.CreateDelegate(GetOrCreateDelegateType(signature, managedMethod)); } private static void LogError(string message) { Logger.Instance.LogError("{Message}", message); } public static TIl2Cpp? ConvertDelegate(Delegate @delegate) where TIl2Cpp : Il2CppObjectBase { //IL_0478: Unknown result type (might be due to invalid IL or missing references) //IL_047f: Expected O, but got Unknown //IL_02fc: Unknown result type (might be due to invalid IL or missing references) if ((object)@delegate == null) { return null; } if (!typeof(Delegate).IsAssignableFrom(typeof(TIl2Cpp))) { throw new ArgumentException($"{typeof(TIl2Cpp)} is not a delegate"); } MethodInfo method = @delegate.GetType().GetMethod("Invoke"); ParameterInfo[] parameters = method.GetParameters(); ParameterInfo[] array = parameters; for (int i = 0; i < array.Length; i++) { Type parameterType = array[i].ParameterType; if (parameterType.IsGenericParameter) { throw new ArgumentException($"Delegate has unsubstituted generic parameter ({parameterType}) which is not supported"); } if (parameterType.BaseType == typeof(ValueType)) { throw new ArgumentException($"Delegate has parameter of type {parameterType} (non-blittable struct) which is not supported"); } } IntPtr nativeClassPointer = Il2CppClassPointerStore.GetNativeClassPointer(typeof(TIl2Cpp)); if (nativeClassPointer == IntPtr.Zero) { throw new ArgumentException($"Type {typeof(TIl2Cpp)} has uninitialized class pointer"); } if (Il2CppClassPointerStore.NativeClassPtr == IntPtr.Zero) { ClassInjector.RegisterTypeInIl2Cpp(); } MethodInfo method2 = Type.internal_from_handle(IL2CPP.il2cpp_class_get_type(nativeClassPointer)).GetMethod("Invoke"); Il2CppReferenceArray parameters2 = ((MethodBase)method2).GetParameters(); if (parameters2.Count != parameters.Length) { throw new ArgumentException($"Managed delegate has {parameters.Length} parameters, native has {parameters2.Count}, these should match"); } for (int j = 0; j < parameters2.Count; j++) { Type parameterType2 = parameters2[j].ParameterType; Type parameterType3 = parameters[j].ParameterType; if (parameterType2.IsPrimitive || parameterType3.IsPrimitive) { if (parameterType2.FullName != parameterType3.FullName) { throw new ArgumentException($"Parameter type mismatch at parameter {j}: {parameterType2.FullName} != {parameterType3.FullName}"); } continue; } IntPtr intPtr = (IntPtr)typeof(Il2CppClassPointerStore<>).MakeGenericType(parameterType3).GetField("NativeClassPtr").GetValue(null); IntPtr intPtr2 = IL2CPP.il2cpp_class_from_type(parameterType2._impl.value); if (intPtr != intPtr2) { throw new ArgumentException($"Parameter type at {j} has mismatched native type pointers; types: {parameterType2.FullName} != {parameterType3.FullName}"); } if (parameterType2.IsByRef || parameterType3.IsByRef) { throw new ArgumentException($"Parameter at {j} is passed by reference, this is not supported"); } } Delegate orCreateNativeToManagedTrampoline = GetOrCreateNativeToManagedTrampoline(new MethodSignature(method2, hasThis: true), method2, method); INativeMethodInfoStruct nativeMethodInfoStruct = UnityVersionHandler.NewMethod(); nativeMethodInfoStruct.MethodPointer = Marshal.GetFunctionPointerForDelegate(orCreateNativeToManagedTrampoline); nativeMethodInfoStruct.ParametersCount = (byte)parameters.Length; nativeMethodInfoStruct.Slot = ushort.MaxValue; nativeMethodInfoStruct.IsMarshalledFromNative = true; Il2CppToMonoDelegateReference il2CppToMonoDelegateReference = new Il2CppToMonoDelegateReference(@delegate, nativeMethodInfoStruct.Pointer); Delegate val = (Delegate)((!UnityVersionHandler.MustUseDelegateConstructor) ? ((object)new Delegate(IL2CPP.il2cpp_object_new(nativeClassPointer))) : ((object)((Il2CppObjectBase)(TIl2Cpp)Activator.CreateInstance(typeof(TIl2Cpp), ((Il2CppObjectBase)(object)il2CppToMonoDelegateReference).Cast(), nativeMethodInfoStruct.Pointer)).Cast())); val.method_ptr = nativeMethodInfoStruct.MethodPointer; val.method_info = method2; val.method = nativeMethodInfoStruct.Pointer; val.m_target = (Object)(object)il2CppToMonoDelegateReference; if (UnityVersionHandler.MustUseDelegateConstructor) { val.invoke_impl = val.method_ptr; val.method_code = ((Il2CppObjectBase)(object)val.m_target).Pointer; } return ((Il2CppObjectBase)(object)val).Cast(); } } public static class IL2CPP { private static readonly Dictionary ourImagesMap; unsafe static IL2CPP() { ourImagesMap = new Dictionary(); IntPtr intPtr = il2cpp_domain_get(); if (intPtr == IntPtr.Zero) { Logger.Instance.LogError("No il2cpp domain found; sad!"); return; } uint size = 0u; IntPtr* ptr = il2cpp_domain_get_assemblies(intPtr, ref size); for (int i = 0; i < size; i++) { IntPtr intPtr2 = il2cpp_assembly_get_image(ptr[i]); string key = Marshal.PtrToStringAnsi(il2cpp_image_get_name(intPtr2)); ourImagesMap[key] = intPtr2; } } internal static IntPtr GetIl2CppImage(string name) { if (ourImagesMap.ContainsKey(name)) { return ourImagesMap[name]; } return IntPtr.Zero; } internal static IntPtr[] GetIl2CppImages() { return ourImagesMap.Values.ToArray(); } public static IntPtr GetIl2CppClass(string assemblyName, string namespaze, string className) { if (!ourImagesMap.TryGetValue(assemblyName, out var value)) { Logger.Instance.LogError("Assembly {AssemblyName} is not registered in il2cpp", assemblyName); return IntPtr.Zero; } return il2cpp_class_from_name(value, namespaze, className); } public static IntPtr GetIl2CppField(IntPtr clazz, string fieldName) { if (clazz == IntPtr.Zero) { return IntPtr.Zero; } IntPtr intPtr = il2cpp_class_get_field_from_name(clazz, fieldName); if (intPtr == IntPtr.Zero) { Logger.Instance.LogError("Field {FieldName} was not found on class {ClassName}", fieldName, Marshal.PtrToStringUTF8(il2cpp_class_get_name(clazz))); } return intPtr; } public static IntPtr GetIl2CppMethodByToken(IntPtr clazz, int token) { if (clazz == IntPtr.Zero) { return NativeStructUtils.GetMethodInfoForMissingMethod(token.ToString()); } IntPtr iter = IntPtr.Zero; IntPtr intPtr; while ((intPtr = il2cpp_class_get_methods(clazz, ref iter)) != IntPtr.Zero) { if (il2cpp_method_get_token(intPtr) == token) { return intPtr; } } string text = Marshal.PtrToStringAnsi(il2cpp_class_get_name(clazz)); Logger.Instance.LogTrace("Unable to find method {ClassName}::{Token}", text, token); return NativeStructUtils.GetMethodInfoForMissingMethod(text + "::" + token); } public static IntPtr GetIl2CppMethod(IntPtr clazz, bool isGeneric, string methodName, string returnTypeName, params string[] argTypes) { if (clazz == IntPtr.Zero) { return NativeStructUtils.GetMethodInfoForMissingMethod(methodName + "(" + string.Join(", ", argTypes) + ")"); } returnTypeName = Regex.Replace(returnTypeName, "\\`\\d+", "").Replace('/', '.').Replace('+', '.'); for (int i = 0; i < argTypes.Length; i++) { string input = argTypes[i]; argTypes[i] = Regex.Replace(input, "\\`\\d+", "").Replace('/', '.').Replace('+', '.'); } int num = 0; IntPtr intPtr = IntPtr.Zero; IntPtr iter = IntPtr.Zero; IntPtr intPtr2; while ((intPtr2 = il2cpp_class_get_methods(clazz, ref iter)) != IntPtr.Zero) { if (Marshal.PtrToStringAnsi(il2cpp_method_get_name(intPtr2)) != methodName || il2cpp_method_get_param_count(intPtr2) != argTypes.Length || il2cpp_method_is_generic(intPtr2) != isGeneric || Marshal.PtrToStringAnsi(il2cpp_type_get_name(il2cpp_method_get_return_type(intPtr2))) != returnTypeName) { continue; } num++; intPtr = intPtr2; bool flag = false; for (int j = 0; j < argTypes.Length; j++) { if (Marshal.PtrToStringAnsi(il2cpp_type_get_name(il2cpp_method_get_param(intPtr2, (uint)j))) != argTypes[j]) { flag = true; break; } } if (!flag) { return intPtr2; } } string text = Marshal.PtrToStringAnsi(il2cpp_class_get_name(clazz)); if (num == 1) { Logger.Instance.LogTrace("Method {ClassName}::{MethodName} was stubbed with a random matching method of the same name", text, methodName); Logger.Instance.LogTrace("Stubby return type/target: {LastMethod} / {ReturnTypeName}", Marshal.PtrToStringUTF8(il2cpp_type_get_name(il2cpp_method_get_return_type(intPtr))), returnTypeName); Logger.Instance.LogTrace("Stubby parameter types/targets follow:"); for (int k = 0; k < argTypes.Length; k++) { string text2 = Marshal.PtrToStringAnsi(il2cpp_type_get_name(il2cpp_method_get_param(intPtr, (uint)k))); Logger.Instance.LogTrace(" {TypeName} / {ArgType}", text2, argTypes[k]); } return intPtr; } Logger.Instance.LogTrace("Unable to find method {ClassName}::{MethodName}; signature follows", text, methodName); Logger.Instance.LogTrace(" return {ReturnTypeName}", returnTypeName); foreach (string text3 in argTypes) { Logger.Instance.LogTrace(" {ArgType}", text3); } Logger.Instance.LogTrace("Available methods of this name follow:"); iter = IntPtr.Zero; while ((intPtr2 = il2cpp_class_get_methods(clazz, ref iter)) != IntPtr.Zero) { if (!(Marshal.PtrToStringAnsi(il2cpp_method_get_name(intPtr2)) != methodName)) { uint num2 = il2cpp_method_get_param_count(intPtr2); Logger.Instance.LogTrace("Method starts"); Logger.Instance.LogTrace(" return {MethodTypeName}", Marshal.PtrToStringUTF8(il2cpp_type_get_name(il2cpp_method_get_return_type(intPtr2)))); for (int m = 0; m < num2; m++) { string text4 = Marshal.PtrToStringAnsi(il2cpp_type_get_name(il2cpp_method_get_param(intPtr2, (uint)m))); Logger.Instance.LogTrace(" {TypeName}", text4); } return intPtr2; } } return NativeStructUtils.GetMethodInfoForMissingMethod(text + "::" + methodName + "(" + string.Join(", ", argTypes) + ")"); } public unsafe static string? Il2CppStringToManaged(IntPtr il2CppString) { if (il2CppString == IntPtr.Zero) { return null; } int length = il2cpp_string_length(il2CppString); return new string(il2cpp_string_chars(il2CppString), 0, length); } public unsafe static IntPtr ManagedStringToIl2Cpp(string str) { if (str == null) { return IntPtr.Zero; } fixed (char* text = str) { return il2cpp_string_new_utf16(text, str.Length); } } public static IntPtr Il2CppObjectBaseToPtr(Il2CppObjectBase obj) { return obj?.Pointer ?? IntPtr.Zero; } public static IntPtr Il2CppObjectBaseToPtrNotNull(Il2CppObjectBase obj) { if (obj == null) { throw new NullReferenceException(); } return obj.Pointer; } public static IntPtr GetIl2CppNestedType(IntPtr enclosingType, string nestedTypeName) { if (enclosingType == IntPtr.Zero) { return IntPtr.Zero; } IntPtr iter = IntPtr.Zero; if (il2cpp_class_is_inflated(enclosingType)) { Logger.Instance.LogTrace("Original class was inflated, falling back to reflection"); return RuntimeReflectionHelper.GetNestedTypeViaReflection(enclosingType, nestedTypeName); } IntPtr intPtr; while ((intPtr = il2cpp_class_get_nested_types(enclosingType, ref iter)) != IntPtr.Zero) { if (Marshal.PtrToStringAnsi(il2cpp_class_get_name(intPtr)) == nestedTypeName) { return intPtr; } } Logger.Instance.LogError("Nested type {NestedTypeName} on {EnclosingTypeName} not found!", nestedTypeName, Marshal.PtrToStringUTF8(il2cpp_class_get_name(enclosingType))); return IntPtr.Zero; } public static void ThrowIfNull(object arg) { if (arg == null) { throw new NullReferenceException(); } } public static T ResolveICall(string signature) where T : Delegate { IntPtr intPtr = il2cpp_resolve_icall(signature); if (intPtr == IntPtr.Zero) { Logger.Instance.LogTrace("ICall {Signature} not resolved", signature); return GenerateDelegateForMissingICall(signature); } return Marshal.GetDelegateForFunctionPointer(intPtr); } private static T GenerateDelegateForMissingICall(string signature) where T : Delegate { MethodInfo method = typeof(T).GetMethod("Invoke"); DynamicMethod dynamicMethod = new DynamicMethod("(missing icall delegate) " + typeof(T).FullName, method.ReturnType, (from it in method.GetParameters() select it.ParameterType).ToArray(), typeof(IL2CPP), skipVisibility: true); ILGenerator iLGenerator = dynamicMethod.GetILGenerator(); iLGenerator.Emit(OpCodes.Ldstr, "ICall with signature " + signature + " was not resolved"); iLGenerator.Emit(OpCodes.Newobj, typeof(Exception).GetConstructor(new Type[1] { typeof(string) })); iLGenerator.Emit(OpCodes.Throw); return (T)dynamicMethod.CreateDelegate(typeof(T)); } public unsafe static T? PointerToValueGeneric(IntPtr objectPointer, bool isFieldPointer, bool valueTypeWouldBeBoxed) { if (isFieldPointer) { objectPointer = ((!il2cpp_class_is_valuetype(Il2CppClassPointerStore.NativeClassPtr)) ? (*(IntPtr*)(void*)objectPointer) : il2cpp_value_box(Il2CppClassPointerStore.NativeClassPtr, objectPointer)); } if (!valueTypeWouldBeBoxed && il2cpp_class_is_valuetype(Il2CppClassPointerStore.NativeClassPtr)) { objectPointer = il2cpp_value_box(Il2CppClassPointerStore.NativeClassPtr, objectPointer); } if (typeof(T) == typeof(string)) { return (T)(object)Il2CppStringToManaged(objectPointer); } if (objectPointer == IntPtr.Zero) { return default(T); } if (typeof(T).IsValueType) { return Il2CppObjectBase.UnboxUnsafe(objectPointer); } return Il2CppObjectPool.Get(objectPointer); } public static string RenderTypeName(bool addRefMarker = false) { return RenderTypeName(typeof(T), addRefMarker); } public static string RenderTypeName(Type t, bool addRefMarker = false) { if (addRefMarker) { return RenderTypeName(t) + "&"; } if (t.IsArray) { return RenderTypeName(t.GetElementType()) + "[]"; } if (t.IsByRef) { return RenderTypeName(t.GetElementType()) + "&"; } if (t.IsPointer) { return RenderTypeName(t.GetElementType()) + "*"; } if (t.IsGenericParameter) { return t.Name; } if (t.IsGenericType) { if (t.TypeHasIl2CppArrayBase()) { return RenderTypeName(t.GetGenericArguments()[0]) + "[]"; } StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(t.GetGenericTypeDefinition().FullNameObfuscated().TrimIl2CppPrefix()); stringBuilder.Append('<'); Type[] genericArguments = t.GetGenericArguments(); for (int i = 0; i < genericArguments.Length; i++) { if (i != 0) { stringBuilder.Append(','); } stringBuilder.Append(RenderTypeName(genericArguments[i])); } stringBuilder.Append('>'); return stringBuilder.ToString(); } if (t == typeof(Il2CppStringArray)) { return "System.String[]"; } return t.FullNameObfuscated().TrimIl2CppPrefix(); } private static string FullNameObfuscated(this Type t) { ObfuscatedNameAttribute customAttribute = ((MemberInfo)t).GetCustomAttribute(); if (customAttribute == null) { return t.FullName; } return customAttribute.ObfuscatedName; } private static string TrimIl2CppPrefix(this string s) { if (!s.StartsWith("Il2Cpp")) { return s; } return s.Substring("Il2Cpp".Length); } private static bool TypeHasIl2CppArrayBase(this Type type) { if (type == null) { return false; } if (type.IsConstructedGenericType) { type = type.GetGenericTypeDefinition(); } if (type == typeof(Il2CppArrayBase<>)) { return true; } return type.BaseType.TypeHasIl2CppArrayBase(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe static void FieldWriteWbarrierStub(IntPtr obj, IntPtr targetAddress, IntPtr value) { *(IntPtr*)(void*)targetAddress = value; } [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern void il2cpp_init(IntPtr domain_name); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern void il2cpp_init_utf16(IntPtr domain_name); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern void il2cpp_shutdown(); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern void il2cpp_set_config_dir(IntPtr config_path); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern void il2cpp_set_data_dir(IntPtr data_path); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern void il2cpp_set_temp_dir(IntPtr temp_path); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern void il2cpp_set_commandline_arguments(int argc, IntPtr argv, IntPtr basedir); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern void il2cpp_set_commandline_arguments_utf16(int argc, IntPtr argv, IntPtr basedir); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern void il2cpp_set_config_utf16(IntPtr executablePath); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern void il2cpp_set_config(IntPtr executablePath); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern void il2cpp_set_memory_callbacks(IntPtr callbacks); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_get_corlib(); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern void il2cpp_add_internal_call(IntPtr name, IntPtr method); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_resolve_icall([MarshalAs(UnmanagedType.LPStr)] string name); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_alloc(uint size); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern void il2cpp_free(IntPtr ptr); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_array_class_get(IntPtr element_class, uint rank); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern uint il2cpp_array_length(IntPtr array); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern uint il2cpp_array_get_byte_length(IntPtr array); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_array_new(IntPtr elementTypeInfo, ulong length); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_array_new_specific(IntPtr arrayTypeInfo, ulong length); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_array_new_full(IntPtr array_class, ref ulong lengths, ref ulong lower_bounds); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_bounded_array_class_get(IntPtr element_class, uint rank, [MarshalAs(UnmanagedType.I1)] bool bounded); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern int il2cpp_array_element_size(IntPtr array_class); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_assembly_get_image(IntPtr assembly); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_class_enum_basetype(IntPtr klass); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool il2cpp_class_is_generic(IntPtr klass); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool il2cpp_class_is_inflated(IntPtr klass); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool il2cpp_class_is_assignable_from(IntPtr klass, IntPtr oklass); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool il2cpp_class_is_subclass_of(IntPtr klass, IntPtr klassc, [MarshalAs(UnmanagedType.I1)] bool check_interfaces); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool il2cpp_class_has_parent(IntPtr klass, IntPtr klassc); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_class_from_il2cpp_type(IntPtr type); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_class_from_name(IntPtr image, [MarshalAs(UnmanagedType.LPUTF8Str)] string namespaze, [MarshalAs(UnmanagedType.LPUTF8Str)] string name); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_class_from_system_type(IntPtr type); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_class_get_element_class(IntPtr klass); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_class_get_events(IntPtr klass, ref IntPtr iter); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_class_get_fields(IntPtr klass, ref IntPtr iter); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_class_get_nested_types(IntPtr klass, ref IntPtr iter); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_class_get_interfaces(IntPtr klass, ref IntPtr iter); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_class_get_properties(IntPtr klass, ref IntPtr iter); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_class_get_property_from_name(IntPtr klass, IntPtr name); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_class_get_field_from_name(IntPtr klass, [MarshalAs(UnmanagedType.LPUTF8Str)] string name); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_class_get_methods(IntPtr klass, ref IntPtr iter); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_class_get_method_from_name(IntPtr klass, [MarshalAs(UnmanagedType.LPStr)] string name, int argsCount); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_class_get_name(IntPtr klass); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_class_get_namespace(IntPtr klass); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_class_get_parent(IntPtr klass); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_class_get_declaring_type(IntPtr klass); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern int il2cpp_class_instance_size(IntPtr klass); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern uint il2cpp_class_num_fields(IntPtr enumKlass); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool il2cpp_class_is_valuetype(IntPtr klass); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern int il2cpp_class_value_size(IntPtr klass, ref uint align); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool il2cpp_class_is_blittable(IntPtr klass); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern int il2cpp_class_get_flags(IntPtr klass); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool il2cpp_class_is_abstract(IntPtr klass); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool il2cpp_class_is_interface(IntPtr klass); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern int il2cpp_class_array_element_size(IntPtr klass); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_class_from_type(IntPtr type); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_class_get_type(IntPtr klass); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern uint il2cpp_class_get_type_token(IntPtr klass); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool il2cpp_class_has_attribute(IntPtr klass, IntPtr attr_class); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool il2cpp_class_has_references(IntPtr klass); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool il2cpp_class_is_enum(IntPtr klass); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_class_get_image(IntPtr klass); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_class_get_assemblyname(IntPtr klass); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern int il2cpp_class_get_rank(IntPtr klass); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern uint il2cpp_class_get_bitmap_size(IntPtr klass); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern void il2cpp_class_get_bitmap(IntPtr klass, ref uint bitmap); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool il2cpp_stats_dump_to_file(IntPtr path); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_domain_get(); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_domain_assembly_open(IntPtr domain, IntPtr name); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public unsafe static extern IntPtr* il2cpp_domain_get_assemblies(IntPtr domain, ref uint size); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_exception_from_name_msg(IntPtr image, IntPtr name_space, IntPtr name, IntPtr msg); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_get_exception_argument_null(IntPtr arg); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public unsafe static extern void il2cpp_format_exception(IntPtr ex, void* message, int message_size); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public unsafe static extern void il2cpp_format_stack_trace(IntPtr ex, void* output, int output_size); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern void il2cpp_unhandled_exception(IntPtr ex); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern int il2cpp_field_get_flags(IntPtr field); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_field_get_name(IntPtr field); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_field_get_parent(IntPtr field); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern uint il2cpp_field_get_offset(IntPtr field); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_field_get_type(IntPtr field); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public unsafe static extern void il2cpp_field_get_value(IntPtr obj, IntPtr field, void* value); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_field_get_value_object(IntPtr field, IntPtr obj); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool il2cpp_field_has_attribute(IntPtr field, IntPtr attr_class); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public unsafe static extern void il2cpp_field_set_value(IntPtr obj, IntPtr field, void* value); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public unsafe static extern void il2cpp_field_static_get_value(IntPtr field, void* value); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public unsafe static extern void il2cpp_field_static_set_value(IntPtr field, void* value); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern void il2cpp_field_set_value_object(IntPtr instance, IntPtr field, IntPtr value); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern void il2cpp_gc_collect(int maxGenerations); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern int il2cpp_gc_collect_a_little(); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern void il2cpp_gc_disable(); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern void il2cpp_gc_enable(); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool il2cpp_gc_is_disabled(); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern long il2cpp_gc_get_used_size(); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern long il2cpp_gc_get_heap_size(); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern void il2cpp_gc_wbarrier_set_field(IntPtr obj, IntPtr targetAddress, IntPtr gcObj); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern nint il2cpp_gchandle_new(IntPtr obj, [MarshalAs(UnmanagedType.I1)] bool pinned); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern nint il2cpp_gchandle_new_weakref(IntPtr obj, [MarshalAs(UnmanagedType.I1)] bool track_resurrection); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_gchandle_get_target(nint gchandle); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern void il2cpp_gchandle_free(nint gchandle); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_unity_liveness_calculation_begin(IntPtr filter, int max_object_count, IntPtr callback, IntPtr userdata, IntPtr onWorldStarted, IntPtr onWorldStopped); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern void il2cpp_unity_liveness_calculation_end(IntPtr state); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern void il2cpp_unity_liveness_calculation_from_root(IntPtr root, IntPtr state); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern void il2cpp_unity_liveness_calculation_from_statics(IntPtr state); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_method_get_return_type(IntPtr method); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_method_get_declaring_type(IntPtr method); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_method_get_name(IntPtr method); [MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe static IntPtr il2cpp_method_get_from_reflection(IntPtr method) { if (UnityVersionHandler.HasGetMethodFromReflection) { return _il2cpp_method_get_from_reflection(method); } Il2CppReflectionMethod* ptr = (Il2CppReflectionMethod*)(void*)method; return (IntPtr)ptr->method; } [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, EntryPoint = "il2cpp_method_get_from_reflection")] private static extern IntPtr _il2cpp_method_get_from_reflection(IntPtr method); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_method_get_object(IntPtr method, IntPtr refclass); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool il2cpp_method_is_generic(IntPtr method); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool il2cpp_method_is_inflated(IntPtr method); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool il2cpp_method_is_instance(IntPtr method); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern uint il2cpp_method_get_param_count(IntPtr method); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_method_get_param(IntPtr method, uint index); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_method_get_class(IntPtr method); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool il2cpp_method_has_attribute(IntPtr method, IntPtr attr_class); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern uint il2cpp_method_get_flags(IntPtr method, ref uint iflags); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern uint il2cpp_method_get_token(IntPtr method); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_method_get_param_name(IntPtr method, uint index); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern void il2cpp_profiler_install(IntPtr prof, IntPtr shutdown_callback); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern void il2cpp_profiler_install_enter_leave(IntPtr enter, IntPtr fleave); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern void il2cpp_profiler_install_allocation(IntPtr callback); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern void il2cpp_profiler_install_gc(IntPtr callback, IntPtr heap_resize_callback); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern void il2cpp_profiler_install_fileio(IntPtr callback); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern void il2cpp_profiler_install_thread(IntPtr start, IntPtr end); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern uint il2cpp_property_get_flags(IntPtr prop); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_property_get_get_method(IntPtr prop); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_property_get_set_method(IntPtr prop); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_property_get_name(IntPtr prop); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_property_get_parent(IntPtr prop); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_object_get_class(IntPtr obj); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern uint il2cpp_object_get_size(IntPtr obj); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_object_get_virtual_method(IntPtr obj, IntPtr method); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_object_new(IntPtr klass); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_object_unbox(IntPtr obj); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_value_box(IntPtr klass, IntPtr data); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern void il2cpp_monitor_enter(IntPtr obj); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool il2cpp_monitor_try_enter(IntPtr obj, uint timeout); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern void il2cpp_monitor_exit(IntPtr obj); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern void il2cpp_monitor_pulse(IntPtr obj); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern void il2cpp_monitor_pulse_all(IntPtr obj); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern void il2cpp_monitor_wait(IntPtr obj); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool il2cpp_monitor_try_wait(IntPtr obj, uint timeout); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public unsafe static extern IntPtr il2cpp_runtime_invoke(IntPtr method, IntPtr obj, void** param, ref IntPtr exc); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public unsafe static extern IntPtr il2cpp_runtime_invoke_convert_args(IntPtr method, IntPtr obj, void** param, int paramCount, ref IntPtr exc); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern void il2cpp_runtime_class_init(IntPtr klass); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern void il2cpp_runtime_object_init(IntPtr obj); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern void il2cpp_runtime_object_init_exception(IntPtr obj, ref IntPtr exc); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern int il2cpp_string_length(IntPtr str); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public unsafe static extern char* il2cpp_string_chars(IntPtr str); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_string_new(string str); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_string_new_len(string str, uint length); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public unsafe static extern IntPtr il2cpp_string_new_utf16(char* text, int len); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_string_new_wrapper(string str); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_string_intern(string str); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_string_is_interned(string str); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_thread_current(); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_thread_attach(IntPtr domain); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern void il2cpp_thread_detach(IntPtr thread); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public unsafe static extern void** il2cpp_thread_get_all_attached_threads(ref uint size); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool il2cpp_is_vm_thread(IntPtr thread); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern void il2cpp_current_thread_walk_frame_stack(IntPtr func, IntPtr user_data); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern void il2cpp_thread_walk_frame_stack(IntPtr thread, IntPtr func, IntPtr user_data); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool il2cpp_current_thread_get_top_frame(IntPtr frame); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool il2cpp_thread_get_top_frame(IntPtr thread, IntPtr frame); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool il2cpp_current_thread_get_frame_at(int offset, IntPtr frame); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool il2cpp_thread_get_frame_at(IntPtr thread, int offset, IntPtr frame); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern int il2cpp_current_thread_get_stack_depth(); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern int il2cpp_thread_get_stack_depth(IntPtr thread); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_type_get_object(IntPtr type); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern int il2cpp_type_get_type(IntPtr type); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_type_get_class_or_element_class(IntPtr type); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_type_get_name(IntPtr type); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool il2cpp_type_is_byref(IntPtr type); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern uint il2cpp_type_get_attrs(IntPtr type); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool il2cpp_type_equals(IntPtr type, IntPtr otherType); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_type_get_assembly_qualified_name(IntPtr type); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_image_get_assembly(IntPtr image); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_image_get_name(IntPtr image); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_image_get_filename(IntPtr image); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_image_get_entry_point(IntPtr image); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern uint il2cpp_image_get_class_count(IntPtr image); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_image_get_class(IntPtr image, uint index); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_capture_memory_snapshot(); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern void il2cpp_free_captured_memory_snapshot(IntPtr snapshot); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern void il2cpp_set_find_plugin_callback(IntPtr method); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern void il2cpp_register_log_callback(IntPtr method); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern void il2cpp_debugger_set_agent_options(IntPtr options); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool il2cpp_is_debugger_attached(); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public unsafe static extern void il2cpp_unity_install_unitytls_interface(void* unitytlsInterfaceStruct); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_custom_attrs_from_class(IntPtr klass); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_custom_attrs_from_method(IntPtr method); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_custom_attrs_get_attr(IntPtr ainfo, IntPtr attr_klass); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool il2cpp_custom_attrs_has_attr(IntPtr ainfo, IntPtr attr_klass); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr il2cpp_custom_attrs_construct(IntPtr cinfo); [DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern void il2cpp_custom_attrs_free(IntPtr ainfo); } public static class Il2CppClassPointerStore { public static IntPtr GetNativeClassPointer(Type type) { if (type == typeof(void)) { return Il2CppClassPointerStore.NativeClassPtr; } if (type == typeof(String)) { return Il2CppClassPointerStore.NativeClassPtr; } return (IntPtr)typeof(Il2CppClassPointerStore<>).MakeGenericType(type).GetField("NativeClassPtr").GetValue(null); } internal static void SetNativeClassPointer(Type type, IntPtr value) { typeof(Il2CppClassPointerStore<>).MakeGenericType(type).GetField("NativeClassPtr").SetValue(null, value); } } public static class Il2CppClassPointerStore { public static IntPtr NativeClassPtr; public static Type CreatedTypeRedirect; static Il2CppClassPointerStore() { Type typeFromHandle = typeof(T); if (!typeFromHandle.IsEnum) { RuntimeHelpers.RunClassConstructor(typeFromHandle.TypeHandle); } else { string assemblyName = typeFromHandle.Module.Name; string namespaze = typeFromHandle.Namespace ?? ""; string text = typeFromHandle.Name; foreach (CustomAttributeData customAttribute in typeFromHandle.CustomAttributes) { if (!(customAttribute.AttributeType != typeof(OriginalNameAttribute))) { assemblyName = (string)customAttribute.ConstructorArguments[0].Value; namespaze = (string)customAttribute.ConstructorArguments[1].Value; text = (string)customAttribute.ConstructorArguments[2].Value; } } if (typeFromHandle.IsNested) { NativeClassPtr = IL2CPP.GetIl2CppNestedType(Il2CppClassPointerStore.GetNativeClassPointer(typeFromHandle.DeclaringType), text); } else { NativeClassPtr = IL2CPP.GetIl2CppClass(assemblyName, namespaze, text); } } if (typeFromHandle.IsPrimitive || typeFromHandle == typeof(string)) { RuntimeHelpers.RunClassConstructor(AppDomain.CurrentDomain.GetAssemblies().Single((Assembly it) => it.GetName().Name == "Il2Cppmscorlib").GetType("Il2Cpp" + typeFromHandle.FullName) .TypeHandle); } foreach (CustomAttributeData customAttribute2 in typeFromHandle.CustomAttributes) { if (!(customAttribute2.AttributeType != typeof(AlsoInitializeAttribute))) { RuntimeHelpers.RunClassConstructor(((Type)customAttribute2.ConstructorArguments[0].Value).TypeHandle); } } } } public class Il2CppException : Exception { [ThreadStatic] private static byte[] ourMessageBytes; public static Func ParseMessageHook; public Il2CppException(IntPtr exception) : base(BuildMessage(exception)) { } private unsafe static string BuildMessage(IntPtr exception) { //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown if (ParseMessageHook != null) { return ParseMessageHook(exception); } if (ourMessageBytes == null) { ourMessageBytes = new byte[65536]; } fixed (byte* message = ourMessageBytes) { IL2CPP.il2cpp_format_exception(exception, message, ourMessageBytes.Length); } string @string = Encoding.UTF8.GetString(ourMessageBytes, 0, Array.IndexOf(ourMessageBytes, (byte)0)); Exception val = new Exception(exception); return @string + "\n--- BEGIN IL2CPP STACK TRACE ---\n" + val.ToString(false, true) + "\n--- END IL2CPP STACK TRACE ---\n"; } public static void RaiseExceptionIfNecessary(IntPtr returnedException) { if (returnedException == IntPtr.Zero) { return; } throw new Il2CppException(returnedException); } } public static class Il2CppType { public static Type TypeFromPointer(IntPtr classPointer, string typeName = "") { return TypeFromPointerInternal(classPointer, typeName, throwOnFailure: true); } private static Type? TypeFromPointerInternal(IntPtr classPointer, string typeName, bool throwOnFailure) { if (classPointer == IntPtr.Zero) { if (throwOnFailure) { throw new ArgumentException(typeName + " does not have a corresponding IL2CPP class pointer"); } return null; } IntPtr intPtr = IL2CPP.il2cpp_class_get_type(classPointer); if (intPtr == IntPtr.Zero) { if (throwOnFailure) { throw new ArgumentException(typeName + " does not have a corresponding IL2CPP type pointer"); } return null; } return Type.internal_from_handle(intPtr); } public static Type From(Type type) { return From(type, throwOnFailure: true); } public static Type From(Type type, bool throwOnFailure) { return TypeFromPointerInternal(Il2CppClassPointerStore.GetNativeClassPointer(type), type.Name, throwOnFailure); } public static Type Of() { return Of(throwOnFailure: true); } public static Type Of(bool throwOnFailure) { return TypeFromPointerInternal(Il2CppClassPointerStore.NativeClassPtr, typeof(T).Name, throwOnFailure); } } internal class MemoryUtils { public struct SignatureDefinition { public string pattern; public string mask; public int offset; public bool xref; } public static nint FindSignatureInModule(ProcessModule module, SignatureDefinition sigDef) { nint num = FindSignatureInBlock(module.BaseAddress, module.ModuleMemorySize, sigDef.pattern, sigDef.mask, sigDef.offset); if (num != 0 && sigDef.xref) { num = XrefScannerLowLevel.JumpTargets((IntPtr)num, false).FirstOrDefault(); } return num; } public static nint FindSignatureInBlock(nint block, long blockSize, string pattern, string mask, long sigOffset = 0L) { return FindSignatureInBlock(block, blockSize, pattern.ToCharArray(), mask.ToCharArray(), sigOffset); } public unsafe static nint FindSignatureInBlock(nint block, long blockSize, char[] pattern, char[] mask, long sigOffset = 0L) { for (long num = 0L; num < blockSize; num++) { bool flag = true; for (uint num2 = 0u; num2 < mask.Length; num2++) { if (*(byte*)(num + block + num2) != (byte)pattern[num2] && mask[num2] != '?') { flag = false; break; } } if (flag) { return (nint)(num + block + sigOffset); } } return 0; } } public class ObjectCollectedException : Exception { public ObjectCollectedException(string message) : base(message) { } } public static class RuntimeReflectionHelper { public static IntPtr GetNestedTypeViaReflection(IntPtr enclosingClass, string nestedTypeName) { Type nestedType = Type.internal_from_handle(IL2CPP.il2cpp_class_get_type(enclosingClass)).GetNestedType(nestedTypeName, (BindingFlags)48); if (!(nestedType != (Type)null)) { return IntPtr.Zero; } return IL2CPP.il2cpp_class_from_system_type(((Il2CppObjectBase)(object)nestedType).Pointer); } public static RuntimeTypeHandle GetRuntimeTypeHandle() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return Il2CppType.Of().TypeHandle; } } public static class RuntimeSpecificsStore { private static readonly ReaderWriterLockSlim Lock = new ReaderWriterLockSlim(); private static readonly Dictionary WasInjectedStore = new Dictionary(); public static bool IsInjected(IntPtr nativeClass) { Lock.EnterReadLock(); try { bool value; return WasInjectedStore.TryGetValue(nativeClass, out value) && value; } finally { Lock.ExitReadLock(); } } public static void SetClassInfo(IntPtr nativeClass, bool wasInjected) { Lock.EnterWriteLock(); try { WasInjectedStore[nativeClass] = wasInjected; } finally { Lock.ExitWriteLock(); } } } } namespace Il2CppInterop.Runtime.XrefScans { public static class XrefInstanceExtensions { public static Object? ReadAsObject(this XrefInstance self) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown if ((int)self.Type != 0) { throw new InvalidOperationException("Can't read non-global xref as object"); } IntPtr intPtr = Marshal.ReadIntPtr(self.Pointer); if (intPtr == IntPtr.Zero) { return null; } return new Object(intPtr); } public static MethodBase TryResolve(this XrefInstance self) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_0014: Unknown result type (might be due to invalid IL or missing references) if ((int)self.Type != 1) { throw new InvalidOperationException("Can't resolve non-method xrefs"); } return XrefScanMethodDb.TryResolvePointer(self.Pointer); } } internal class XrefScanImpl : IXrefScannerImpl { private static Func>? getAssemblies; public unsafe (InitMetadataForMethod, IntPtr)? GetMetadataResolver() { if (getAssemblies == null) { getAssemblies = typeof(AppDomain).GetMethod("GetAssemblies", BindingFlags.Static | BindingFlags.Public)?.CreateDelegate(typeof(Func>)) as Func>; } IntPtr intPtr = XrefScannerLowLevel.JumpTargets(*(IntPtr*)(void*)IL2CPP.il2cpp_method_get_from_reflection(((Il2CppObjectBase)(object)getAssemblies(AppDomain.CurrentDomain).Single((Assembly it) => it.GetName().Name == "UnityEngine.CoreModule").GetType("UnityEngine.Object").GetConstructors((BindingFlags)40) .Single()).Pointer), false).First(); return (Marshal.GetDelegateForFunctionPointer(intPtr), intPtr); } public bool XrefGlobalClassFilter(IntPtr movTarget) { IntPtr intPtr = (IntPtr)Marshal.ReadInt64(movTarget); if (intPtr != IntPtr.Zero) { IntPtr intPtr2 = (IntPtr)Marshal.ReadInt64(intPtr); if (!(intPtr2 == Il2CppClassPointerStore.NativeClassPtr)) { return intPtr2 == Il2CppClassPointerStore.NativeClassPtr; } return true; } return false; } } } namespace Il2CppInterop.Runtime.Startup { public record RuntimeConfiguration { public Version UnityVersion { get; init; } public IDetourProvider DetourProvider { get; init; } } public sealed class Il2CppInteropRuntime : BaseHost { public static Il2CppInteropRuntime Instance => BaseHost.GetInstance(); public Version UnityVersion { get; private init; } public IDetourProvider DetourProvider { get; private init; } private Il2CppInteropRuntime() { } public static Il2CppInteropRuntime Create(RuntimeConfiguration configuration) { Il2CppInteropRuntime obj = new Il2CppInteropRuntime { UnityVersion = configuration.UnityVersion, DetourProvider = configuration.DetourProvider }; BaseHost.SetInstance(obj); XrefScannerManagerExtensions.AddXrefScanner(obj); return obj; } public override void Start() { UnityVersionHandler.RecalculateHandlers(); ((BaseHost)this).Start(); } } } namespace Il2CppInterop.Runtime.Runtime { internal struct InjectedClassData { public IntPtr managedGcHandle; } public static class ClassInjectorBase { public static object GetMonoObjectFromIl2CppPointer(IntPtr pointer) { return GCHandle.FromIntPtr(GetGcHandlePtrFromIl2CppObject(pointer)).Target; } public unsafe static IntPtr GetGcHandlePtrFromIl2CppObject(IntPtr pointer) { return GetInjectedData(pointer)->managedGcHandle; } internal unsafe static InjectedClassData* GetInjectedData(IntPtr objectPointer) { Il2CppClass* classPointer = (Il2CppClass*)(void*)IL2CPP.il2cpp_object_get_class(objectPointer); return (InjectedClassData*)(objectPointer + (int)UnityVersionHandler.Wrap(classPointer).InstanceSize - sizeof(InjectedClassData)).ToPointer(); } } internal static class Il2CppApi { public static bool il2cpp_stats_dump_to_file(IntPtr path) { return IL2CPP.il2cpp_stats_dump_to_file(path); } public static void il2cpp_init(IntPtr domain_name) { IL2CPP.il2cpp_init(domain_name); } public static void il2cpp_init_utf16(IntPtr domain_name) { IL2CPP.il2cpp_init_utf16(domain_name); } public static void il2cpp_shutdown() { IL2CPP.il2cpp_shutdown(); } public static void il2cpp_set_config_dir(IntPtr config_path) { IL2CPP.il2cpp_set_config_dir(config_path); } public static void il2cpp_set_data_dir(IntPtr data_path) { IL2CPP.il2cpp_set_data_dir(data_path); } public static void il2cpp_set_temp_dir(IntPtr temp_path) { IL2CPP.il2cpp_set_temp_dir(temp_path); } public static void il2cpp_set_commandline_arguments(int argc, IntPtr argv, IntPtr basedir) { IL2CPP.il2cpp_set_commandline_arguments(argc, argv, basedir); } public static void il2cpp_set_commandline_arguments_utf16(int argc, IntPtr argv, IntPtr basedir) { IL2CPP.il2cpp_set_commandline_arguments_utf16(argc, argv, basedir); } public static void il2cpp_set_config_utf16(IntPtr executablePath) { IL2CPP.il2cpp_set_config_utf16(executablePath); } public static void il2cpp_set_config(IntPtr executablePath) { IL2CPP.il2cpp_set_config(executablePath); } public static void il2cpp_set_memory_callbacks(IntPtr callbacks) { IL2CPP.il2cpp_set_memory_callbacks(callbacks); } public static IntPtr il2cpp_get_corlib() { return IL2CPP.il2cpp_get_corlib(); } public static void il2cpp_add_internal_call(IntPtr name, IntPtr method) { IL2CPP.il2cpp_add_internal_call(name, method); } public static IntPtr il2cpp_resolve_icall([MarshalAs(UnmanagedType.LPStr)] string name) { return IL2CPP.il2cpp_resolve_icall(name); } public static IntPtr il2cpp_alloc(uint size) { return IL2CPP.il2cpp_alloc(size); } public static void il2cpp_free(IntPtr ptr) { IL2CPP.il2cpp_free(ptr); } public static IntPtr il2cpp_array_class_get(IntPtr element_class, uint rank) { return IL2CPP.il2cpp_array_class_get(element_class, rank); } public static uint il2cpp_array_length(IntPtr array) { return IL2CPP.il2cpp_array_length(array); } public static uint il2cpp_array_get_byte_length(IntPtr array) { return IL2CPP.il2cpp_array_get_byte_length(array); } public static IntPtr il2cpp_array_new(IntPtr elementTypeInfo, ulong length) { return IL2CPP.il2cpp_array_new(elementTypeInfo, length); } public static IntPtr il2cpp_array_new_specific(IntPtr arrayTypeInfo, ulong length) { return IL2CPP.il2cpp_array_new_specific(arrayTypeInfo, length); } public static IntPtr il2cpp_array_new_full(IntPtr array_class, ref ulong lengths, ref ulong lower_bounds) { return IL2CPP.il2cpp_array_new_full(array_class, ref lengths, ref lower_bounds); } public static IntPtr il2cpp_bounded_array_class_get(IntPtr element_class, uint rank, bool bounded) { return IL2CPP.il2cpp_bounded_array_class_get(element_class, rank, bounded); } public static int il2cpp_array_element_size(IntPtr array_class) { return IL2CPP.il2cpp_array_element_size(array_class); } public static IntPtr il2cpp_assembly_get_image(IntPtr assembly) { return IL2CPP.il2cpp_assembly_get_image(assembly); } public unsafe static IntPtr il2cpp_assembly_get_name(IntPtr assembly) { return UnityVersionHandler.Wrap((Il2CppAssembly*)(void*)assembly).Name.Name; } public static IntPtr il2cpp_class_enum_basetype(IntPtr klass) { return IL2CPP.il2cpp_class_enum_basetype(klass); } public static bool il2cpp_class_is_generic(IntPtr klass) { return IL2CPP.il2cpp_class_is_generic(klass); } public static bool il2cpp_class_is_inflated(IntPtr klass) { return IL2CPP.il2cpp_class_is_inflated(klass); } public static bool il2cpp_class_is_assignable_from(IntPtr klass, IntPtr oklass) { return IL2CPP.il2cpp_class_is_assignable_from(klass, oklass); } public static bool il2cpp_class_is_subclass_of(IntPtr klass, IntPtr klassc, bool check_interfaces) { return IL2CPP.il2cpp_class_is_subclass_of(klass, klassc, check_interfaces); } public static bool il2cpp_class_has_parent(IntPtr klass, IntPtr klassc) { return IL2CPP.il2cpp_class_has_parent(klass, klassc); } public static IntPtr il2cpp_class_from_il2cpp_type(IntPtr type) { return IL2CPP.il2cpp_class_from_il2cpp_type(type); } public static IntPtr il2cpp_class_from_name(IntPtr image, [MarshalAs(UnmanagedType.LPStr)] string namespaze, [MarshalAs(UnmanagedType.LPStr)] string name) { return IL2CPP.il2cpp_class_from_name(image, namespaze, name); } public static IntPtr il2cpp_class_from_system_type(IntPtr type) { return IL2CPP.il2cpp_class_from_system_type(type); } public static IntPtr il2cpp_class_get_element_class(IntPtr klass) { return IL2CPP.il2cpp_class_get_element_class(klass); } public static IntPtr il2cpp_class_get_events(IntPtr klass, ref IntPtr iter) { return IL2CPP.il2cpp_class_get_events(klass, ref iter); } public static IntPtr il2cpp_class_get_fields(IntPtr klass, ref IntPtr iter) { return IL2CPP.il2cpp_class_get_fields(klass, ref iter); } public static IntPtr il2cpp_class_get_nested_types(IntPtr klass, ref IntPtr iter) { return IL2CPP.il2cpp_class_get_nested_types(klass, ref iter); } public static IntPtr il2cpp_class_get_interfaces(IntPtr klass, ref IntPtr iter) { return IL2CPP.il2cpp_class_get_interfaces(klass, ref iter); } public static IntPtr il2cpp_class_get_properties(IntPtr klass, ref IntPtr iter) { return IL2CPP.il2cpp_class_get_properties(klass, ref iter); } public static IntPtr il2cpp_class_get_property_from_name(IntPtr klass, IntPtr name) { return IL2CPP.il2cpp_class_get_property_from_name(klass, name); } public static IntPtr il2cpp_class_get_field_from_name(IntPtr klass, [MarshalAs(UnmanagedType.LPStr)] string name) { return IL2CPP.il2cpp_class_get_field_from_name(klass, name); } public static IntPtr il2cpp_class_get_methods(IntPtr klass, ref IntPtr iter) { return IL2CPP.il2cpp_class_get_methods(klass, ref iter); } public static IntPtr il2cpp_class_get_method_from_name(IntPtr klass, [MarshalAs(UnmanagedType.LPStr)] string name, int argsCount) { return IL2CPP.il2cpp_class_get_method_from_name(klass, name, argsCount); } public static IntPtr il2cpp_class_get_name(IntPtr klass) { return IL2CPP.il2cpp_class_get_name(klass); } public static IntPtr il2cpp_class_get_namespace(IntPtr klass) { return IL2CPP.il2cpp_class_get_namespace(klass); } public static IntPtr il2cpp_class_get_parent(IntPtr klass) { return IL2CPP.il2cpp_class_get_parent(klass); } public static IntPtr il2cpp_class_get_declaring_type(IntPtr klass) { return IL2CPP.il2cpp_class_get_declaring_type(klass); } public static int il2cpp_class_instance_size(IntPtr klass) { return IL2CPP.il2cpp_class_instance_size(klass); } public static uint il2cpp_class_num_fields(IntPtr enumKlass) { return IL2CPP.il2cpp_class_num_fields(enumKlass); } public static bool il2cpp_class_is_valuetype(IntPtr klass) { return IL2CPP.il2cpp_class_is_valuetype(klass); } public static int il2cpp_class_value_size(IntPtr klass, ref uint align) { return IL2CPP.il2cpp_class_value_size(klass, ref align); } public static bool il2cpp_class_is_blittable(IntPtr klass) { return IL2CPP.il2cpp_class_is_blittable(klass); } public static int il2cpp_class_get_flags(IntPtr klass) { return IL2CPP.il2cpp_class_get_flags(klass); } public static bool il2cpp_class_is_abstract(IntPtr klass) { return IL2CPP.il2cpp_class_is_abstract(klass); } public static bool il2cpp_class_is_interface(IntPtr klass) { return IL2CPP.il2cpp_class_is_interface(klass); } public static int il2cpp_class_array_element_size(IntPtr klass) { return IL2CPP.il2cpp_class_array_element_size(klass); } public static IntPtr il2cpp_class_from_type(IntPtr type) { return IL2CPP.il2cpp_class_from_type(type); } public static IntPtr il2cpp_class_get_type(IntPtr klass) { return IL2CPP.il2cpp_class_get_type(klass); } public static uint il2cpp_class_get_type_token(IntPtr klass) { return IL2CPP.il2cpp_class_get_type_token(klass); } public static bool il2cpp_class_has_attribute(IntPtr klass, IntPtr attr_class) { return IL2CPP.il2cpp_class_has_attribute(klass, attr_class); } public static bool il2cpp_class_has_references(IntPtr klass) { return IL2CPP.il2cpp_class_has_references(klass); } public static bool il2cpp_class_is_enum(IntPtr klass) { return IL2CPP.il2cpp_class_is_enum(klass); } public static IntPtr il2cpp_class_get_image(IntPtr klass) { return IL2CPP.il2cpp_class_get_image(klass); } public static IntPtr il2cpp_class_get_assemblyname(IntPtr klass) { return IL2CPP.il2cpp_class_get_assemblyname(klass); } public static int il2cpp_class_get_rank(IntPtr klass) { return IL2CPP.il2cpp_class_get_rank(klass); } public static uint il2cpp_class_get_bitmap_size(IntPtr klass) { return IL2CPP.il2cpp_class_get_bitmap_size(klass); } public static void il2cpp_class_get_bitmap(IntPtr klass, ref uint bitmap) { IL2CPP.il2cpp_class_get_bitmap(klass, ref bitmap); } public static IntPtr il2cpp_custom_attrs_from_class(IntPtr klass) { return IL2CPP.il2cpp_custom_attrs_from_class(klass); } public static IntPtr il2cpp_custom_attrs_from_method(IntPtr method) { return IL2CPP.il2cpp_custom_attrs_from_method(method); } public static IntPtr il2cpp_custom_attrs_get_attr(IntPtr ainfo, IntPtr attr_klass) { return IL2CPP.il2cpp_custom_attrs_get_attr(ainfo, attr_klass); } public static bool il2cpp_custom_attrs_has_attr(IntPtr ainfo, IntPtr attr_klass) { return IL2CPP.il2cpp_custom_attrs_has_attr(ainfo, attr_klass); } public static IntPtr il2cpp_custom_attrs_construct(IntPtr cinfo) { return IL2CPP.il2cpp_custom_attrs_construct(cinfo); } public static void il2cpp_custom_attrs_free(IntPtr ainfo) { IL2CPP.il2cpp_custom_attrs_free(ainfo); } public static void il2cpp_set_find_plugin_callback(IntPtr method) { IL2CPP.il2cpp_set_find_plugin_callback(method); } public static void il2cpp_register_log_callback(IntPtr method) { IL2CPP.il2cpp_register_log_callback(method); } public static void il2cpp_debugger_set_agent_options(IntPtr options) { IL2CPP.il2cpp_debugger_set_agent_options(options); } public static bool il2cpp_is_debugger_attached() { return IL2CPP.il2cpp_is_debugger_attached(); } public unsafe static void il2cpp_unity_install_unitytls_interface(void* unitytlsInterfaceStruct) { IL2CPP.il2cpp_unity_install_unitytls_interface(unitytlsInterfaceStruct); } public static IntPtr il2cpp_domain_get() { return IL2CPP.il2cpp_domain_get(); } public static IntPtr il2cpp_domain_assembly_open(IntPtr domain, IntPtr name) { return IL2CPP.il2cpp_domain_assembly_open(domain, name); } public unsafe static IntPtr* il2cpp_domain_get_assemblies(IntPtr domain, ref uint size) { return IL2CPP.il2cpp_domain_get_assemblies(domain, ref size); } public static IntPtr il2cpp_exception_from_name_msg(IntPtr image, IntPtr name_space, IntPtr name, IntPtr msg) { return IL2CPP.il2cpp_exception_from_name_msg(image, name_space, name, msg); } public static IntPtr il2cpp_get_exception_argument_null(IntPtr arg) { return IL2CPP.il2cpp_get_exception_argument_null(arg); } public unsafe static void il2cpp_format_exception(IntPtr ex, void* message, int message_size) { IL2CPP.il2cpp_format_exception(ex, message, message_size); } public unsafe static void il2cpp_format_stack_trace(IntPtr ex, void* output, int output_size) { IL2CPP.il2cpp_format_stack_trace(ex, output, output_size); } public static void il2cpp_unhandled_exception(IntPtr ex) { IL2CPP.il2cpp_unhandled_exception(ex); } public static int il2cpp_field_get_flags(IntPtr field) { return IL2CPP.il2cpp_field_get_flags(field); } public unsafe static IntPtr il2cpp_field_get_name(IntPtr field) { return UnityVersionHandler.Wrap((Il2CppFieldInfo*)(void*)field).Name; } public unsafe static IntPtr il2cpp_field_get_parent(IntPtr field) { return (IntPtr)UnityVersionHandler.Wrap((Il2CppFieldInfo*)(void*)field).Parent; } public unsafe static uint il2cpp_field_get_offset(IntPtr field) { return (uint)UnityVersionHandler.Wrap((Il2CppFieldInfo*)(void*)field).Offset; } public unsafe static IntPtr il2cpp_field_get_type(IntPtr field) { return (IntPtr)UnityVersionHandler.Wrap((Il2CppFieldInfo*)(void*)field).Type; } public unsafe static void il2cpp_field_get_value(IntPtr obj, IntPtr field, void* value) { IL2CPP.il2cpp_field_get_value(obj, field, value); } public static IntPtr il2cpp_field_get_value_object(IntPtr field, IntPtr obj) { return IL2CPP.il2cpp_field_get_value_object(field, obj); } public static bool il2cpp_field_has_attribute(IntPtr field, IntPtr attr_class) { return IL2CPP.il2cpp_field_has_attribute(field, attr_class); } public unsafe static void il2cpp_field_set_value(IntPtr obj, IntPtr field, void* value) { IL2CPP.il2cpp_field_set_value(obj, field, value); } public unsafe static void il2cpp_field_static_get_value(IntPtr field, void* value) { IL2CPP.il2cpp_field_static_get_value(field, value); } public unsafe static void il2cpp_field_static_set_value(IntPtr field, void* value) { IL2CPP.il2cpp_field_static_set_value(field, value); } public static void il2cpp_field_set_value_object(IntPtr instance, IntPtr field, IntPtr value) { IL2CPP.il2cpp_field_set_value_object(instance, field, value); } public static void il2cpp_gc_collect(int maxGenerations) { IL2CPP.il2cpp_gc_collect(maxGenerations); } public static int il2cpp_gc_collect_a_little() { return IL2CPP.il2cpp_gc_collect_a_little(); } public static void il2cpp_gc_disable() { IL2CPP.il2cpp_gc_disable(); } public static void il2cpp_gc_enable() { IL2CPP.il2cpp_gc_enable(); } public static bool il2cpp_gc_is_disabled() { return IL2CPP.il2cpp_gc_is_disabled(); } public static long il2cpp_gc_get_used_size() { return IL2CPP.il2cpp_gc_get_used_size(); } public static long il2cpp_gc_get_heap_size() { return IL2CPP.il2cpp_gc_get_heap_size(); } public static void il2cpp_gc_wbarrier_set_field(IntPtr obj, IntPtr targetAddress, IntPtr gcObj) { IL2CPP.il2cpp_gc_wbarrier_set_field(obj, targetAddress, gcObj); } public static nint il2cpp_gchandle_new(IntPtr obj, bool pinned) { return IL2CPP.il2cpp_gchandle_new(obj, pinned); } public static nint il2cpp_gchandle_new_weakref(IntPtr obj, bool track_resurrection) { return IL2CPP.il2cpp_gchandle_new_weakref(obj, track_resurrection); } public static IntPtr il2cpp_gchandle_get_target(nint gchandle) { return IL2CPP.il2cpp_gchandle_get_target(gchandle); } public static void il2cpp_gchandle_free(nint gchandle) { IL2CPP.il2cpp_gchandle_free(gchandle); } public static IntPtr il2cpp_image_get_assembly(IntPtr image) { return IL2CPP.il2cpp_image_get_assembly(image); } public static IntPtr il2cpp_image_get_name(IntPtr image) { return IL2CPP.il2cpp_image_get_name(image); } public static IntPtr il2cpp_image_get_filename(IntPtr image) { return IL2CPP.il2cpp_image_get_filename(image); } public static IntPtr il2cpp_image_get_entry_point(IntPtr image) { return IL2CPP.il2cpp_image_get_entry_point(image); } public static uint il2cpp_image_get_class_count(IntPtr image) { return IL2CPP.il2cpp_image_get_class_count(image); } public static IntPtr il2cpp_image_get_class(IntPtr image, uint index) { return IL2CPP.il2cpp_image_get_class(image, index); } public static IntPtr il2cpp_capture_memory_snapshot() { return IL2CPP.il2cpp_capture_memory_snapshot(); } public static void il2cpp_free_captured_memory_snapshot(IntPtr snapshot) { IL2CPP.il2cpp_free_captured_memory_snapshot(snapshot); } public unsafe static IntPtr il2cpp_method_get_return_type(IntPtr method) { return (IntPtr)UnityVersionHandler.Wrap((Il2CppMethodInfo*)(void*)method).ReturnType; } public static IntPtr il2cpp_method_get_declaring_type(IntPtr method) { return IL2CPP.il2cpp_method_get_declaring_type(method); } public unsafe static IntPtr il2cpp_method_get_name(IntPtr method) { return UnityVersionHandler.Wrap((Il2CppMethodInfo*)(void*)method).Name; } public static IntPtr il2cpp_method_get_from_reflection(IntPtr method) { return IL2CPP.il2cpp_method_get_from_reflection(method); } public static IntPtr il2cpp_method_get_object(IntPtr method, IntPtr refclass) { return IL2CPP.il2cpp_method_get_object(method, refclass); } public static bool il2cpp_method_is_generic(IntPtr method) { return IL2CPP.il2cpp_method_is_generic(method); } public static bool il2cpp_method_is_inflated(IntPtr method) { return IL2CPP.il2cpp_method_is_inflated(method); } public static bool il2cpp_method_is_instance(IntPtr method) { return IL2CPP.il2cpp_method_is_instance(method); } public unsafe static uint il2cpp_method_get_param_count(IntPtr method) { return UnityVersionHandler.Wrap((Il2CppMethodInfo*)(void*)method).ParametersCount; } public static IntPtr il2cpp_method_get_param(IntPtr method, uint index) { return IL2CPP.il2cpp_method_get_param(method, index); } public unsafe static IntPtr il2cpp_method_get_class(IntPtr method) { return (IntPtr)UnityVersionHandler.Wrap((Il2CppMethodInfo*)(void*)method).Class; } public static bool il2cpp_method_has_attribute(IntPtr method, IntPtr attr_class) { return IL2CPP.il2cpp_method_has_attribute(method, attr_class); } public static uint il2cpp_method_get_flags(IntPtr method, ref uint iflags) { return IL2CPP.il2cpp_method_get_flags(method, ref iflags); } public unsafe static uint il2cpp_method_get_token(IntPtr method) { return UnityVersionHandler.Wrap((Il2CppMethodInfo*)(void*)method).Token; } public static IntPtr il2cpp_method_get_param_name(IntPtr method, uint index) { return IL2CPP.il2cpp_method_get_param_name(method, index); } public static void il2cpp_monitor_enter(IntPtr obj) { IL2CPP.il2cpp_monitor_enter(obj); } public static bool il2cpp_monitor_try_enter(IntPtr obj, uint timeout) { return IL2CPP.il2cpp_monitor_try_enter(obj, timeout); } public static void il2cpp_monitor_exit(IntPtr obj) { IL2CPP.il2cpp_monitor_exit(obj); } public static void il2cpp_monitor_pulse(IntPtr obj) { IL2CPP.il2cpp_monitor_pulse(obj); } public static void il2cpp_monitor_pulse_all(IntPtr obj) { IL2CPP.il2cpp_monitor_pulse_all(obj); } public static void il2cpp_monitor_wait(IntPtr obj) { IL2CPP.il2cpp_monitor_wait(obj); } public static bool il2cpp_monitor_try_wait(IntPtr obj, uint timeout) { return IL2CPP.il2cpp_monitor_try_wait(obj, timeout); } public static IntPtr il2cpp_object_get_class(IntPtr obj) { return IL2CPP.il2cpp_object_get_class(obj); } public static uint il2cpp_object_get_size(IntPtr obj) { return IL2CPP.il2cpp_object_get_size(obj); } public static IntPtr il2cpp_object_get_virtual_method(IntPtr obj, IntPtr method) { return IL2CPP.il2cpp_object_get_virtual_method(obj, method); } public static IntPtr il2cpp_object_new(IntPtr klass) { return IL2CPP.il2cpp_object_new(klass); } public static IntPtr il2cpp_object_unbox(IntPtr obj) { return IL2CPP.il2cpp_object_unbox(obj); } public static IntPtr il2cpp_value_box(IntPtr klass, IntPtr data) { return IL2CPP.il2cpp_value_box(klass, data); } public static void il2cpp_profiler_install(IntPtr prof, IntPtr shutdown_callback) { IL2CPP.il2cpp_profiler_install(prof, shutdown_callback); } public static void il2cpp_profiler_install_enter_leave(IntPtr enter, IntPtr leave) { IL2CPP.il2cpp_profiler_install_enter_leave(enter, leave); } public static void il2cpp_profiler_install_allocation(IntPtr callback) { IL2CPP.il2cpp_profiler_install_allocation(callback); } public static void il2cpp_profiler_install_gc(IntPtr callback, IntPtr heap_resize_callback) { IL2CPP.il2cpp_profiler_install_gc(callback, heap_resize_callback); } public static void il2cpp_profiler_install_fileio(IntPtr callback) { IL2CPP.il2cpp_profiler_install_fileio(callback); } public static void il2cpp_profiler_install_thread(IntPtr start, IntPtr end) { IL2CPP.il2cpp_profiler_install_thread(start, end); } public static uint il2cpp_property_get_flags(IntPtr prop) { return IL2CPP.il2cpp_property_get_flags(prop); } public unsafe static IntPtr il2cpp_property_get_get_method(IntPtr prop) { return (IntPtr)UnityVersionHandler.Wrap((Il2CppPropertyInfo*)(void*)prop).Get; } public unsafe static IntPtr il2cpp_property_get_set_method(IntPtr prop) { return (IntPtr)UnityVersionHandler.Wrap((Il2CppPropertyInfo*)(void*)prop).Set; } public unsafe static IntPtr il2cpp_property_get_name(IntPtr prop) { return UnityVersionHandler.Wrap((Il2CppPropertyInfo*)(void*)prop).Name; } public unsafe static IntPtr il2cpp_property_get_parent(IntPtr prop) { return (IntPtr)UnityVersionHandler.Wrap((Il2CppPropertyInfo*)(void*)prop).Parent; } public unsafe static IntPtr il2cpp_runtime_invoke(IntPtr method, IntPtr obj, void** param, ref IntPtr exc) { return IL2CPP.il2cpp_runtime_invoke(method, obj, param, ref exc); } public unsafe static IntPtr il2cpp_runtime_invoke_convert_args(IntPtr method, IntPtr obj, void** param, int paramCount, ref IntPtr exc) { return IL2CPP.il2cpp_runtime_invoke_convert_args(method, obj, param, paramCount, ref exc); } public static void il2cpp_runtime_class_init(IntPtr klass) { IL2CPP.il2cpp_runtime_class_init(klass); } public static void il2cpp_runtime_object_init(IntPtr obj) { IL2CPP.il2cpp_runtime_object_init(obj); } public static void il2cpp_runtime_object_init_exception(IntPtr obj, ref IntPtr exc) { IL2CPP.il2cpp_runtime_object_init_exception(obj, ref exc); } public static int il2cpp_string_length(IntPtr str) { return IL2CPP.il2cpp_string_length(str); } public unsafe static char* il2cpp_string_chars(IntPtr str) { return IL2CPP.il2cpp_string_chars(str); } public static IntPtr il2cpp_string_new(string str) { return IL2CPP.il2cpp_string_new(str); } public static IntPtr il2cpp_string_new_len(string str, uint length) { return IL2CPP.il2cpp_string_new_len(str, length); } public unsafe static IntPtr il2cpp_string_new_utf16(char* text, int len) { return IL2CPP.il2cpp_string_new_utf16(text, len); } public static IntPtr il2cpp_string_new_wrapper(string str) { return IL2CPP.il2cpp_string_new_wrapper(str); } public static IntPtr il2cpp_string_intern(string str) { return IL2CPP.il2cpp_string_intern(str); } public static IntPtr il2cpp_string_is_interned(string str) { return IL2CPP.il2cpp_string_is_interned(str); } public static IntPtr il2cpp_thread_current() { return IL2CPP.il2cpp_thread_current(); } public static IntPtr il2cpp_thread_attach(IntPtr domain) { return IL2CPP.il2cpp_thread_attach(domain); } public static void il2cpp_thread_detach(IntPtr thread) { IL2CPP.il2cpp_thread_detach(thread); } public unsafe static void** il2cpp_thread_get_all_attached_threads(ref uint size) { return IL2CPP.il2cpp_thread_get_all_attached_threads(ref size); } public static bool il2cpp_is_vm_thread(IntPtr thread) { return IL2CPP.il2cpp_is_vm_thread(thread); } public static void il2cpp_current_thread_walk_frame_stack(IntPtr func, IntPtr user_data) { IL2CPP.il2cpp_current_thread_walk_frame_stack(func, user_data); } public static void il2cpp_thread_walk_frame_stack(IntPtr thread, IntPtr func, IntPtr user_data) { IL2CPP.il2cpp_thread_walk_frame_stack(thread, func, user_data); } public static bool il2cpp_current_thread_get_top_frame(IntPtr frame) { return IL2CPP.il2cpp_current_thread_get_top_frame(frame); } public static bool il2cpp_thread_get_top_frame(IntPtr thread, IntPtr frame) { return IL2CPP.il2cpp_thread_get_top_frame(thread, frame); } public static bool il2cpp_current_thread_get_frame_at(int offset, IntPtr frame) { return IL2CPP.il2cpp_current_thread_get_frame_at(offset, frame); } public static bool il2cpp_thread_get_frame_at(IntPtr thread, int offset, IntPtr frame) { return IL2CPP.il2cpp_thread_get_frame_at(thread, offset, frame); } public static int il2cpp_current_thread_get_stack_depth() { return IL2CPP.il2cpp_current_thread_get_stack_depth(); } public static int il2cpp_thread_get_stack_depth(IntPtr thread) { return IL2CPP.il2cpp_thread_get_stack_depth(thread); } public static IntPtr il2cpp_type_get_object(IntPtr type) { return IL2CPP.il2cpp_type_get_object(type); } public static int il2cpp_type_get_type(IntPtr type) { return IL2CPP.il2cpp_type_get_type(type); } public static IntPtr il2cpp_type_get_class_or_element_class(IntPtr type) { return IL2CPP.il2cpp_type_get_class_or_element_class(type); } public static IntPtr il2cpp_type_get_name(IntPtr type) { return IL2CPP.il2cpp_type_get_name(type); } public static bool il2cpp_type_is_byref(IntPtr type) { return IL2CPP.il2cpp_type_is_byref(type); } public static uint il2cpp_type_get_attrs(IntPtr type) { return IL2CPP.il2cpp_type_get_attrs(type); } public static bool il2cpp_type_equals(IntPtr type, IntPtr otherType) { return IL2CPP.il2cpp_type_equals(type, otherType); } public static IntPtr il2cpp_type_get_assembly_qualified_name(IntPtr type) { return IL2CPP.il2cpp_type_get_assembly_qualified_name(type); } public static IntPtr il2cpp_unity_liveness_calculation_begin(IntPtr filter, int max_object_count, IntPtr callback, IntPtr userdata, IntPtr onWorldStarted, IntPtr onWorldStopped) { return IL2CPP.il2cpp_unity_liveness_calculation_begin(filter, max_object_count, callback, userdata, onWorldStarted, onWorldStopped); } public static void il2cpp_unity_liveness_calculation_end(IntPtr state) { IL2CPP.il2cpp_unity_liveness_calculation_end(state); } public static void il2cpp_unity_liveness_calculation_from_root(IntPtr root, IntPtr state) { IL2CPP.il2cpp_unity_liveness_calculation_from_root(root, state); } public static void il2cpp_unity_liveness_calculation_from_statics(IntPtr state) { IL2CPP.il2cpp_unity_liveness_calculation_from_statics(state); } } public static class Il2CppObjectPool { private static readonly ConcurrentDictionary> s_cache = new ConcurrentDictionary>(); internal static bool DisableCaching { get; set; } internal static void Remove(IntPtr ptr) { s_cache.TryRemove(ptr, out var _); } public unsafe static T Get(IntPtr ptr) { //IL_00c3: Unknown result type (might be due to invalid IL or missing references) if (ptr == IntPtr.Zero) { return default(T); } if (RuntimeSpecificsStore.IsInjected(IL2CPP.il2cpp_object_get_class(ptr))) { object monoObjectFromIl2CppPointer = ClassInjectorBase.GetMonoObjectFromIl2CppPointer(ptr); if (monoObjectFromIl2CppPointer is T) { return (T)monoObjectFromIl2CppPointer; } } if (DisableCaching) { return Il2CppObjectBase.InitializerStore.Initializer(ptr); } if (s_cache.TryGetValue(ptr, out var value) && value.TryGetTarget(out var target)) { if (target is T) { return (T)(object)((target is T) ? target : null); } target.pooledPtr = IntPtr.Zero; } T source = Il2CppObjectBase.InitializerStore.Initializer(ptr); if (!UnityVersionHandler.Wrap((Il2CppClass*)(void*)Il2CppClassPointerStore.NativeClassPtr).HasFinalize) { object obj = source; GC.ReRegisterForFinalize((Object)(((obj is Object) ? obj : null) ?? ((object)new Object(ptr)))); } Il2CppObjectBase il2CppObjectBase = Unsafe.As(ref source); s_cache[ptr] = new WeakReference(il2CppObjectBase); il2CppObjectBase.pooledPtr = ptr; return source; } } [StructLayout(LayoutKind.Sequential, Size = 1)] public struct Il2CppAssembly { } [StructLayout(LayoutKind.Sequential, Size = 1)] public struct Il2CppClass { } [StructLayout(LayoutKind.Sequential, Size = 1)] public struct Il2CppEventInfo { } [StructLayout(LayoutKind.Sequential, Size = 1)] public struct Il2CppException { } [StructLayout(LayoutKind.Sequential, Size = 1)] public struct Il2CppFieldInfo { } [StructLayout(LayoutKind.Sequential, Size = 1)] public struct Il2CppImage { } [StructLayout(LayoutKind.Sequential, Size = 1)] public struct Il2CppMethodInfo { } [StructLayout(LayoutKind.Sequential, Size = 1)] public struct Il2CppParameterInfo { } [StructLayout(LayoutKind.Sequential, Size = 1)] public struct Il2CppPropertyInfo { } [StructLayout(LayoutKind.Sequential, Size = 1)] public struct Il2CppTypeStruct { } [StructLayout(LayoutKind.Sequential, Size = 1)] public struct Il2CppAssemblyName { } [StructLayout(LayoutKind.Sequential, Size = 1)] public struct Il2CppString { } public struct Il2CppMetadataTypeHandle { private unsafe readonly void* dummy; } public struct Il2CppMetadataGenericContainerHandle { private unsafe readonly void* dummy; } public struct Il2CppMetadataImageHandle { private unsafe readonly void* dummy; } public struct il2cpp_hresult_t { private readonly int dummy; } public struct Il2CppGCHandle { private unsafe readonly void* dummy; } [Flags] public enum Il2CppMethodImplFlags : ushort { METHOD_IMPL_ATTRIBUTE_CODE_TYPE_MASK = 3, METHOD_IMPL_ATTRIBUTE_IL = 0, METHOD_IMPL_ATTRIBUTE_NATIVE = 1, METHOD_IMPL_ATTRIBUTE_OPTIL = 2, METHOD_IMPL_ATTRIBUTE_RUNTIME = 3, METHOD_IMPL_ATTRIBUTE_MANAGED_MASK = 4, METHOD_IMPL_ATTRIBUTE_UNMANAGED = 4, METHOD_IMPL_ATTRIBUTE_MANAGED = 0, METHOD_IMPL_ATTRIBUTE_FORWARD_REF = 0x10, METHOD_IMPL_ATTRIBUTE_PRESERVE_SIG = 0x80, METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL = 0x1000, METHOD_IMPL_ATTRIBUTE_SYNCHRONIZED = 0x20, METHOD_IMPL_ATTRIBUTE_NOINLINING = 8, METHOD_IMPL_ATTRIBUTE_MAX_METHOD_IMPL_VAL = ushort.MaxValue } [Flags] public enum Il2CppMethodFlags : ushort { METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK = 7, METHOD_ATTRIBUTE_COMPILER_CONTROLLED = 0, METHOD_ATTRIBUTE_PRIVATE = 1, METHOD_ATTRIBUTE_FAM_AND_ASSEM = 2, METHOD_ATTRIBUTE_ASSEM = 3, METHOD_ATTRIBUTE_FAMILY = 4, METHOD_ATTRIBUTE_FAM_OR_ASSEM = 5, METHOD_ATTRIBUTE_PUBLIC = 6, METHOD_ATTRIBUTE_STATIC = 0x10, METHOD_ATTRIBUTE_FINAL = 0x20, METHOD_ATTRIBUTE_VIRTUAL = 0x40, METHOD_ATTRIBUTE_HIDE_BY_SIG = 0x80, METHOD_ATTRIBUTE_VTABLE_LAYOUT_MASK = 0x100, METHOD_ATTRIBUTE_REUSE_SLOT = 0, METHOD_ATTRIBUTE_NEW_SLOT = 0x100, METHOD_ATTRIBUTE_STRICT = 0x200, METHOD_ATTRIBUTE_ABSTRACT = 0x400, METHOD_ATTRIBUTE_SPECIAL_NAME = 0x800, METHOD_ATTRIBUTE_PINVOKE_IMPL = 0x2000, METHOD_ATTRIBUTE_UNMANAGED_EXPORT = 8, METHOD_ATTRIBUTE_RESERVED_MASK = 0xD000, METHOD_ATTRIBUTE_RT_SPECIAL_NAME = 0x1000, METHOD_ATTRIBUTE_HAS_SECURITY = 0x4000, METHOD_ATTRIBUTE_REQUIRE_SEC_OBJECT = 0x8000 } [Flags] public enum Il2CppClassAttributes : uint { TYPE_ATTRIBUTE_VISIBILITY_MASK = 7u, TYPE_ATTRIBUTE_NOT_PUBLIC = 0u, TYPE_ATTRIBUTE_PUBLIC = 1u, TYPE_ATTRIBUTE_NESTED_PUBLIC = 2u, TYPE_ATTRIBUTE_NESTED_PRIVATE = 3u, TYPE_ATTRIBUTE_NESTED_FAMILY = 4u, TYPE_ATTRIBUTE_NESTED_ASSEMBLY = 5u, TYPE_ATTRIBUTE_NESTED_FAM_AND_ASSEM = 6u, TYPE_ATTRIBUTE_NESTED_FAM_OR_ASSEM = 7u, TYPE_ATTRIBUTE_LAYOUT_MASK = 0x18u, TYPE_ATTRIBUTE_AUTO_LAYOUT = 0u, TYPE_ATTRIBUTE_SEQUENTIAL_LAYOUT = 8u, TYPE_ATTRIBUTE_EXPLICIT_LAYOUT = 0x10u, TYPE_ATTRIBUTE_CLASS_SEMANTIC_MASK = 0x20u, TYPE_ATTRIBUTE_CLASS = 0u, TYPE_ATTRIBUTE_INTERFACE = 0x20u, TYPE_ATTRIBUTE_ABSTRACT = 0x80u, TYPE_ATTRIBUTE_SEALED = 0x100u, TYPE_ATTRIBUTE_SPECIAL_NAME = 0x400u, TYPE_ATTRIBUTE_IMPORT = 0x1000u, TYPE_ATTRIBUTE_SERIALIZABLE = 0x2000u, TYPE_ATTRIBUTE_STRING_FORMAT_MASK = 0x30000u, TYPE_ATTRIBUTE_ANSI_CLASS = 0u, TYPE_ATTRIBUTE_UNICODE_CLASS = 0x10000u, TYPE_ATTRIBUTE_AUTO_CLASS = 0x20000u, TYPE_ATTRIBUTE_BEFORE_FIELD_INIT = 0x100000u, TYPE_ATTRIBUTE_FORWARDER = 0x200000u, TYPE_ATTRIBUTE_RESERVED_MASK = 0x40800u, TYPE_ATTRIBUTE_RT_SPECIAL_NAME = 0x800u, TYPE_ATTRIBUTE_HAS_SECURITY = 0x40000u } public enum Il2CppTypeEnum : byte { IL2CPP_TYPE_END = 0, IL2CPP_TYPE_VOID = 1, IL2CPP_TYPE_BOOLEAN = 2, IL2CPP_TYPE_CHAR = 3, IL2CPP_TYPE_I1 = 4, IL2CPP_TYPE_U1 = 5, IL2CPP_TYPE_I2 = 6, IL2CPP_TYPE_U2 = 7, IL2CPP_TYPE_I4 = 8, IL2CPP_TYPE_U4 = 9, IL2CPP_TYPE_I8 = 10, IL2CPP_TYPE_U8 = 11, IL2CPP_TYPE_R4 = 12, IL2CPP_TYPE_R8 = 13, IL2CPP_TYPE_STRING = 14, IL2CPP_TYPE_PTR = 15, IL2CPP_TYPE_BYREF = 16, IL2CPP_TYPE_VALUETYPE = 17, IL2CPP_TYPE_CLASS = 18, IL2CPP_TYPE_VAR = 19, IL2CPP_TYPE_ARRAY = 20, IL2CPP_TYPE_GENERICINST = 21, IL2CPP_TYPE_TYPEDBYREF = 22, IL2CPP_TYPE_I = 24, IL2CPP_TYPE_U = 25, IL2CPP_TYPE_FNPTR = 27, IL2CPP_TYPE_OBJECT = 28, IL2CPP_TYPE_SZARRAY = 29, IL2CPP_TYPE_MVAR = 30, IL2CPP_TYPE_CMOD_REQD = 31, IL2CPP_TYPE_CMOD_OPT = 32, IL2CPP_TYPE_INTERNAL = 33, IL2CPP_TYPE_MODIFIER = 64, IL2CPP_TYPE_SENTINEL = 65, IL2CPP_TYPE_PINNED = 69, IL2CPP_TYPE_ENUM = 85 } public struct VirtualInvokeData { public IntPtr methodPtr; public unsafe Il2CppMethodInfo* method; } public struct Il2CppRuntimeInterfaceOffsetPair { public unsafe Il2CppClass* interfaceType; public int offset; } public struct Il2CppObject { private readonly IntPtr data; private readonly IntPtr monitor; } public struct Il2CppImageGlobalMetadata { public int typeStart; public int exportedTypeStart; public int customAttributeStart; public int entryPointIndex; public unsafe Il2CppImage* image; } public struct Il2CppGenericInst { public uint type_argc; public unsafe Il2CppTypeStruct** type_argv; } public struct Il2CppGenericContext { public unsafe Il2CppGenericInst* class_inst; public unsafe Il2CppGenericInst* method_inst; } public struct Il2CppGenericMethod { public unsafe Il2CppMethodInfo* methodDefinition; public Il2CppGenericContext context; } public struct Il2CppReflectionMethod { public Il2CppObject _object; public unsafe Il2CppMethodInfo* method; public unsafe Il2CppString* name; public IntPtr reftype; } public static class NativeStructUtils { public static IntPtr GetMethodInfoForMissingMethod(string methodName) { INativeMethodInfoStruct nativeMethodInfoStruct = UnityVersionHandler.NewMethod(); nativeMethodInfoStruct.Name = Marshal.StringToHGlobalAnsi(methodName); nativeMethodInfoStruct.Slot = ushort.MaxValue; return nativeMethodInfoStruct.Pointer; } public unsafe static bool CheckBit(this INativeStruct self, int startOffset, int bit) { int num = bit / 8; int num2 = bit % 8; IntPtr intPtr = self.Pointer + startOffset + num; int num3 = 1 << num2; return (*(byte*)intPtr.ToPointer() & num3) == num3; } public unsafe static void SetBit(this INativeStruct self, int startOffset, int bit, bool value) { int num = bit / 8; int num2 = bit % 8; IntPtr intPtr = self.Pointer + startOffset + num; int num3 = ~(1 << num2); byte* ptr = (byte*)intPtr.ToPointer(); byte b = (byte)((*ptr & num3) | ((value ? 1 : 0) << num2)); *ptr = b; } } public interface INativeStructHandler { int Size(); } public interface INativeStruct { IntPtr Pointer { get; } } [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)] internal class ApplicableToUnityVersionsSinceAttribute : Attribute { public string StartVersion { get; } public ApplicableToUnityVersionsSinceAttribute(string startVersion) { StartVersion = startVersion; } } public static class UnityVersionHandler { private static readonly Type[] InterfacesOfInterest; private static readonly Dictionary> VersionedHandlers; private static readonly Dictionary Handlers; internal static INativeAssemblyStructHandler assemblyStructHandler; internal static INativeAssemblyNameStructHandler assemblyNameStructHandler; internal static INativeClassStructHandler classStructHandler; internal static INativeEventInfoStructHandler eventInfoStructHandler; internal static INativeExceptionStructHandler exceptionStructHandler; internal static INativeFieldInfoStructHandler fieldInfoStructHandler; internal static INativeImageStructHandler imageStructHandler; internal static INativeMethodInfoStructHandler methodInfoStructHandler; internal static INativeParameterInfoStructHandler parameterInfoStructHandler; internal static INativePropertyInfoStructHandler propertyInfoStructHandler; internal static INativeTypeStructHandler typeStructHandler; public static bool HasGetMethodFromReflection { get; private set; } public static bool HasShimForGetMethod { get; private set; } public static bool IsMetadataV29OrHigher { get; private set; } public static bool MustUseDelegateConstructor => IsMetadataV29OrHigher; static UnityVersionHandler() { VersionedHandlers = new Dictionary>(); Handlers = new Dictionary(); Type[] allTypesSafe = GetAllTypesSafe(); Type[] interfacesOfInterest = allTypesSafe.Where((Type t) => t.IsInterface && typeof(INativeStructHandler).IsAssignableFrom(t) && t != typeof(INativeStructHandler)).ToArray(); InterfacesOfInterest = interfacesOfInterest; Type[] array = interfacesOfInterest; foreach (Type key in array) { VersionedHandlers[key] = new List<(Version, object)>(); } foreach (Type item2 in allTypesSafe.Where((Type t) => !t.IsAbstract && interfacesOfInterest.Any((Type i) => i.IsAssignableFrom(t)))) { foreach (ApplicableToUnityVersionsSinceAttribute customAttribute in item2.GetCustomAttributes()) { object item = Activator.CreateInstance(item2); array = item2.GetInterfaces(); foreach (Type type in array) { if (interfacesOfInterest.Contains(type)) { VersionedHandlers[type].Add((Version.Parse(customAttribute.StartVersion), item)); } } } } foreach (List<(Version, object)> value in VersionedHandlers.Values) { value.Sort(((Version Version, object Handler) a, (Version Version, object Handler) b) => -a.Version.CompareTo(b.Version)); } RecalculateHandlers(); } internal static void RecalculateHandlers() { Handlers.Clear(); Version unityVersion = Il2CppInteropRuntime.Instance.UnityVersion; Type[] interfacesOfInterest = InterfacesOfInterest; foreach (Type key in interfacesOfInterest) { foreach (var item in VersionedHandlers[key]) { if (!(item.Version > unityVersion)) { Handlers[key] = item.Handler; break; } } } HasGetMethodFromReflection = unityVersion > new Version(2018, 1, 0); IsMetadataV29OrHigher = unityVersion >= new Version(2021, 2, 0); HasShimForGetMethod = unityVersion >= new Version(2020, 3, 41) || IsMetadataV29OrHigher; assemblyStructHandler = GetHandler(); assemblyNameStructHandler = GetHandler(); classStructHandler = GetHandler(); eventInfoStructHandler = GetHandler(); exceptionStructHandler = GetHandler(); fieldInfoStructHandler = GetHandler(); imageStructHandler = GetHandler(); methodInfoStructHandler = GetHandler(); parameterInfoStructHandler = GetHandler(); propertyInfoStructHandler = GetHandler(); typeStructHandler = GetHandler(); } private static T GetHandler() { if (Handlers.TryGetValue(typeof(T), out var value)) { return (T)value; } Logger.Instance.LogError("No direct for {TypeFullName} found for Unity {UnityVersion}; this likely indicates a severe error somewhere", typeof(T).FullName, Il2CppInteropRuntime.Instance.UnityVersion); throw new ApplicationException("No handler"); } private static Type[] GetAllTypesSafe() { return AssemblyExtensions.GetTypesSafe(typeof(UnityVersionHandler).Assembly); } public static INativeAssemblyStruct NewAssembly() { return assemblyStructHandler.CreateNewStruct(); } public unsafe static INativeAssemblyStruct Wrap(Il2CppAssembly* assemblyPointer) { return assemblyStructHandler.Wrap(assemblyPointer); } public static int AssemblySize() { return assemblyStructHandler.Size(); } public static INativeAssemblyNameStruct NewAssemblyName() { return assemblyNameStructHandler.CreateNewStruct(); } public unsafe static INativeAssemblyNameStruct Wrap(Il2CppAssemblyName* assemblyNamePointer) { return assemblyNameStructHandler.Wrap(assemblyNamePointer); } public static int AssemblyNameSize() { return assemblyNameStructHandler.Size(); } public static INativeClassStruct NewClass(int vTableSlots) { return classStructHandler.CreateNewStruct(vTableSlots); } public unsafe static INativeClassStruct Wrap(Il2CppClass* classPointer) { return classStructHandler.Wrap(classPointer); } public static int ClassSize() { return classStructHandler.Size(); } public static INativeEventInfoStruct NewEvent() { return eventInfoStructHandler.CreateNewStruct(); } public unsafe static INativeEventInfoStruct Wrap(Il2CppEventInfo* eventInfoPointer) { return eventInfoStructHandler.Wrap(eventInfoPointer); } public static int EventSize() { return eventInfoStructHandler.Size(); } public static INativeExceptionStruct NewException() { return exceptionStructHandler.CreateNewStruct(); } public unsafe static INativeExceptionStruct Wrap(Il2CppException* exceptionPointer) { return exceptionStructHandler.Wrap(exceptionPointer); } public static int ExceptionSize() { return exceptionStructHandler.Size(); } public static INativeFieldInfoStruct NewField() { return fieldInfoStructHandler.CreateNewStruct(); } public unsafe static INativeFieldInfoStruct Wrap(Il2CppFieldInfo* fieldInfoPointer) { return fieldInfoStructHandler.Wrap(fieldInfoPointer); } public static int FieldInfoSize() { return fieldInfoStructHandler.Size(); } public static INativeImageStruct NewImage() { return imageStructHandler.CreateNewStruct(); } public unsafe static INativeImageStruct Wrap(Il2CppImage* imagePointer) { return imageStructHandler.Wrap(imagePointer); } public static int ImageSize() { return imageStructHandler.Size(); } public static INativeMethodInfoStruct NewMethod() { return methodInfoStructHandler.CreateNewStruct(); } public unsafe static INativeMethodInfoStruct Wrap(Il2CppMethodInfo* methodPointer) { return methodInfoStructHandler.Wrap(methodPointer); } public static int MethodSize() { return methodInfoStructHandler.Size(); } public unsafe static Il2CppParameterInfo*[] NewMethodParameterArray(int count) { return parameterInfoStructHandler.CreateNewParameterInfoArray(count); } public unsafe static INativeParameterInfoStruct Wrap(Il2CppParameterInfo* parameterInfo) { return parameterInfoStructHandler.Wrap(parameterInfo); } public unsafe static INativeParameterInfoStruct Wrap(Il2CppParameterInfo* parameterInfo, int index) { return parameterInfoStructHandler.Wrap(parameterInfo, index); } public static bool ParameterInfoHasNamePosToken() { return parameterInfoStructHandler.HasNamePosToken; } public static INativePropertyInfoStruct NewProperty() { return propertyInfoStructHandler.CreateNewStruct(); } public unsafe static INativePropertyInfoStruct Wrap(Il2CppPropertyInfo* propertyInfoPointer) { return propertyInfoStructHandler.Wrap(propertyInfoPointer); } public static int ParameterInfoSize() { return parameterInfoStructHandler.Size(); } public static INativeTypeStruct NewType() { return typeStructHandler.CreateNewStruct(); } public unsafe static INativeTypeStruct Wrap(Il2CppTypeStruct* typePointer) { return typeStructHandler.Wrap(typePointer); } public static int TypeSize() { return typeStructHandler.Size(); } } } namespace Il2CppInterop.Runtime.Runtime.VersionSpecific.Type { public interface INativeTypeStructHandler : INativeStructHandler { INativeTypeStruct CreateNewStruct(); unsafe INativeTypeStruct Wrap(Il2CppTypeStruct* typePointer); } public interface INativeTypeStruct : INativeStruct { unsafe Il2CppTypeStruct* TypePointer { get; } ref IntPtr Data { get; } ref ushort Attrs { get; } ref Il2CppTypeEnum Type { get; } bool ByRef { get; set; } bool Pinned { get; set; } bool ValueType { get; set; } } [ApplicableToUnityVersionsSince("5.2.2")] public class NativeTypeStructHandler_16_0 : INativeTypeStructHandler, INativeStructHandler { internal struct Il2CppType_16_0 { internal enum Bitfield0 : byte { BIT_byref = 6, byref = 64, BIT_pinned = 7, pinned = 128 } public unsafe void* data; public ushort attrs; public byte type; public Bitfield0 _bitfield0; } internal class NativeStructWrapper : INativeTypeStruct, INativeStruct { private static int _bitfield0offset = Marshal.OffsetOf("_bitfield0").ToInt32(); public IntPtr Pointer { get; } private unsafe Il2CppType_16_0* _ => (Il2CppType_16_0*)(void*)Pointer; public unsafe Il2CppTypeStruct* TypePointer => (Il2CppTypeStruct*)(void*)Pointer; public unsafe ref IntPtr Data => ref *(IntPtr*)(&_->data); public unsafe ref ushort Attrs => ref _->attrs; public unsafe ref Il2CppTypeEnum Type => ref *(Il2CppTypeEnum*)(&_->type); public bool ByRef { get { return this.CheckBit(_bitfield0offset, 6); } set { this.SetBit(_bitfield0offset, 6, value); } } public bool Pinned { get { return this.CheckBit(_bitfield0offset, 7); } set { this.SetBit(_bitfield0offset, 7, value); } } public bool ValueType { get { return false; } set { } } public NativeStructWrapper(IntPtr ptr) { Pointer = ptr; } } public unsafe int Size() { return sizeof(Il2CppType_16_0); } public unsafe INativeTypeStruct CreateNewStruct() { IntPtr intPtr = Marshal.AllocHGlobal(Size()); Il2CppType_16_0* ptr = (Il2CppType_16_0*)(void*)intPtr; *ptr = default(Il2CppType_16_0); return new NativeStructWrapper(intPtr); } public unsafe INativeTypeStruct Wrap(Il2CppTypeStruct* ptr) { if (ptr == null) { return null; } return new NativeStructWrapper((IntPtr)ptr); } } [ApplicableToUnityVersionsSince("2021.1.0")] public class NativeTypeStructHandler_27_0 : INativeTypeStructHandler, INativeStructHandler { internal struct Il2CppType_27_0 { internal enum Bitfield0 : byte { BIT_byref = 5, byref = 32, BIT_pinned = 6, pinned = 64, BIT_valuetype = 7, valuetype = 128 } public unsafe void* data; public ushort attrs; public byte type; public Bitfield0 _bitfield0; } internal class NativeStructWrapper : INativeTypeStruct, INativeStruct { private static int _bitfield0offset = Marshal.OffsetOf("_bitfield0").ToInt32(); public IntPtr Pointer { get; } private unsafe Il2CppType_27_0* _ => (Il2CppType_27_0*)(void*)Pointer; public unsafe Il2CppTypeStruct* TypePointer => (Il2CppTypeStruct*)(void*)Pointer; public unsafe ref IntPtr Data => ref *(IntPtr*)(&_->data); public unsafe ref ushort Attrs => ref _->attrs; public unsafe ref Il2CppTypeEnum Type => ref *(Il2CppTypeEnum*)(&_->type); public bool ByRef { get { return this.CheckBit(_bitfield0offset, 5); } set { this.SetBit(_bitfield0offset, 5, value); } } public bool Pinned { get { return this.CheckBit(_bitfield0offset, 6); } set { this.SetBit(_bitfield0offset, 6, value); } } public bool ValueType { get { return this.CheckBit(_bitfield0offset, 7); } set { this.SetBit(_bitfield0offset, 7, value); } } public NativeStructWrapper(IntPtr ptr) { Pointer = ptr; } } public unsafe int Size() { return sizeof(Il2CppType_27_0); } public unsafe INativeTypeStruct CreateNewStruct() { IntPtr intPtr = Marshal.AllocHGlobal(Size()); Il2CppType_27_0* ptr = (Il2CppType_27_0*)(void*)intPtr; *ptr = default(Il2CppType_27_0); return new NativeStructWrapper(intPtr); } public unsafe INativeTypeStruct Wrap(Il2CppTypeStruct* ptr) { if (ptr == null) { return null; } return new NativeStructWrapper((IntPtr)ptr); } } } namespace Il2CppInterop.Runtime.Runtime.VersionSpecific.PropertyInfo { public interface INativePropertyInfoStructHandler : INativeStructHandler { INativePropertyInfoStruct CreateNewStruct(); unsafe INativePropertyInfoStruct Wrap(Il2CppPropertyInfo* propertyInfoPointer); } public interface INativePropertyInfoStruct : INativeStruct { unsafe Il2CppPropertyInfo* PropertyInfoPointer { get; } ref IntPtr Name { get; } unsafe ref Il2CppClass* Parent { get; } unsafe ref Il2CppMethodInfo* Get { get; } unsafe ref Il2CppMethodInfo* Set { get; } ref uint Attrs { get; } } [ApplicableToUnityVersionsSince("5.2.2")] public class NativePropertyInfoStructHandler_16_0 : INativePropertyInfoStructHandler, INativeStructHandler { internal struct Il2CppPropertyInfo_16_0 { public unsafe Il2CppClass* parent; public unsafe byte* name; public unsafe Il2CppMethodInfo* get; public unsafe Il2CppMethodInfo* set; public uint attrs; public int customAttributeIndex; } internal class NativeStructWrapper : INativePropertyInfoStruct, INativeStruct { public IntPtr Pointer { get; } private unsafe Il2CppPropertyInfo_16_0* _ => (Il2CppPropertyInfo_16_0*)(void*)Pointer; public unsafe Il2CppPropertyInfo* PropertyInfoPointer => (Il2CppPropertyInfo*)(void*)Pointer; public unsafe ref IntPtr Name => ref *(IntPtr*)(&_->name); public unsafe ref Il2CppClass* Parent => ref _->parent; public unsafe ref Il2CppMethodInfo* Get => ref _->get; public unsafe ref Il2CppMethodInfo* Set => ref _->set; public unsafe ref uint Attrs => ref _->attrs; public NativeStructWrapper(IntPtr ptr) { Pointer = ptr; } } public unsafe int Size() { return sizeof(Il2CppPropertyInfo_16_0); } public unsafe INativePropertyInfoStruct CreateNewStruct() { IntPtr intPtr = Marshal.AllocHGlobal(Size()); Il2CppPropertyInfo_16_0* ptr = (Il2CppPropertyInfo_16_0*)(void*)intPtr; *ptr = default(Il2CppPropertyInfo_16_0); return new NativeStructWrapper(intPtr); } public unsafe INativePropertyInfoStruct Wrap(Il2CppPropertyInfo* ptr) { if (ptr == null) { return null; } return new NativeStructWrapper((IntPtr)ptr); } } [ApplicableToUnityVersionsSince("5.3.2")] public class NativePropertyInfoStructHandler_19_0 : INativePropertyInfoStructHandler, INativeStructHandler { internal struct Il2CppPropertyInfo_19_0 { public unsafe Il2CppClass* parent; public unsafe byte* name; public unsafe Il2CppMethodInfo* get; public unsafe Il2CppMethodInfo* set; public uint attrs; public int customAttributeIndex; public uint token; } internal class NativeStructWrapper : INativePropertyInfoStruct, INativeStruct { public IntPtr Pointer { get; } private unsafe Il2CppPropertyInfo_19_0* _ => (Il2CppPropertyInfo_19_0*)(void*)Pointer; public unsafe Il2CppPropertyInfo* PropertyInfoPointer => (Il2CppPropertyInfo*)(void*)Pointer; public unsafe ref IntPtr Name => ref *(IntPtr*)(&_->name); public unsafe ref Il2CppClass* Parent => ref _->parent; public unsafe ref Il2CppMethodInfo* Get => ref _->get; public unsafe ref Il2CppMethodInfo* Set => ref _->set; public unsafe ref uint Attrs => ref _->attrs; public NativeStructWrapper(IntPtr ptr) { Pointer = ptr; } } public unsafe int Size() { return sizeof(Il2CppPropertyInfo_19_0); } public unsafe INativePropertyInfoStruct CreateNewStruct() { IntPtr intPtr = Marshal.AllocHGlobal(Size()); Il2CppPropertyInfo_19_0* ptr = (Il2CppPropertyInfo_19_0*)(void*)intPtr; *ptr = default(Il2CppPropertyInfo_19_0); return new NativeStructWrapper(intPtr); } public unsafe INativePropertyInfoStruct Wrap(Il2CppPropertyInfo* ptr) { if (ptr == null) { return null; } return new NativeStructWrapper((IntPtr)ptr); } } [ApplicableToUnityVersionsSince("2018.3.0")] public class NativePropertyInfoStructHandler_24_0 : INativePropertyInfoStructHandler, INativeStructHandler { internal struct Il2CppPropertyInfo_24_0 { public unsafe Il2CppClass* parent; public unsafe byte* name; public unsafe Il2CppMethodInfo* get; public unsafe Il2CppMethodInfo* set; public uint attrs; public uint token; } internal class NativeStructWrapper : INativePropertyInfoStruct, INativeStruct { public IntPtr Pointer { get; } private unsafe Il2CppPropertyInfo_24_0* _ => (Il2CppPropertyInfo_24_0*)(void*)Pointer; public unsafe Il2CppPropertyInfo* PropertyInfoPointer => (Il2CppPropertyInfo*)(void*)Pointer; public unsafe ref IntPtr Name => ref *(IntPtr*)(&_->name); public unsafe ref Il2CppClass* Parent => ref _->parent; public unsafe ref Il2CppMethodInfo* Get => ref _->get; public unsafe ref Il2CppMethodInfo* Set => ref _->set; public unsafe ref uint Attrs => ref _->attrs; public NativeStructWrapper(IntPtr ptr) { Pointer = ptr; } } public unsafe int Size() { return sizeof(Il2CppPropertyInfo_24_0); } public unsafe INativePropertyInfoStruct CreateNewStruct() { IntPtr intPtr = Marshal.AllocHGlobal(Size()); Il2CppPropertyInfo_24_0* ptr = (Il2CppPropertyInfo_24_0*)(void*)intPtr; *ptr = default(Il2CppPropertyInfo_24_0); return new NativeStructWrapper(intPtr); } public unsafe INativePropertyInfoStruct Wrap(Il2CppPropertyInfo* ptr) { if (ptr == null) { return null; } return new NativeStructWrapper((IntPtr)ptr); } } } namespace Il2CppInterop.Runtime.Runtime.VersionSpecific.ParameterInfo { public interface INativeParameterInfoStructHandler : INativeStructHandler { bool HasNamePosToken { get; } unsafe Il2CppParameterInfo*[] CreateNewParameterInfoArray(int paramCount); unsafe INativeParameterInfoStruct Wrap(Il2CppParameterInfo* paramInfoPointer); unsafe INativeParameterInfoStruct Wrap(Il2CppParameterInfo* paramInfoListBegin, int index); } public interface INativeParameterInfoStruct : INativeStruct { unsafe Il2CppParameterInfo* ParameterInfoPointer { get; } bool HasNamePosToken { get; } ref IntPtr Name { get; } ref int Position { get; } ref uint Token { get; } unsafe ref Il2CppTypeStruct* ParameterType { get; } } [ApplicableToUnityVersionsSince("5.3.0")] internal class NativeParameterInfoStructHandler_16_0 : INativeParameterInfoStructHandler, INativeStructHandler { internal struct Il2CppParameterInfo_16_0 { public IntPtr name; public int position; public uint token; public int customAttributeIndex; public unsafe Il2CppTypeStruct* parameter_type; } internal class NativeParameterInfoStructWrapper : INativeParameterInfoStruct, INativeStruct { private unsafe Il2CppParameterInfo_16_0* NativeParameter => (Il2CppParameterInfo_16_0*)(void*)Pointer; public IntPtr Pointer { get; } public unsafe Il2CppParameterInfo* ParameterInfoPointer => (Il2CppParameterInfo*)(void*)Pointer; public bool HasNamePosToken => true; public unsafe ref IntPtr Name => ref NativeParameter->name; public unsafe ref int Position => ref NativeParameter->position; public unsafe ref uint Token => ref NativeParameter->token; public unsafe ref Il2CppTypeStruct* ParameterType => ref NativeParameter->parameter_type; public NativeParameterInfoStructWrapper(IntPtr pointer) { Pointer = pointer; } } public bool HasNamePosToken => true; public unsafe int Size() { return sizeof(Il2CppParameterInfo_16_0); } public unsafe Il2CppParameterInfo*[] CreateNewParameterInfoArray(int paramCount) { Il2CppParameterInfo_16_0* ptr = (Il2CppParameterInfo_16_0*)(void*)Marshal.AllocHGlobal(Marshal.SizeOf() * paramCount); Il2CppParameterInfo*[] array = new Il2CppParameterInfo*[paramCount]; for (int i = 0; i < paramCount; i++) { ptr[i] = default(Il2CppParameterInfo_16_0); array[i] = (Il2CppParameterInfo*)(ptr + i); } return array; } public unsafe INativeParameterInfoStruct? Wrap(Il2CppParameterInfo* paramInfoPointer) { if ((IntPtr)paramInfoPointer == IntPtr.Zero) { return null; } return new NativeParameterInfoStructWrapper((IntPtr)paramInfoPointer); } public unsafe INativeParameterInfoStruct? Wrap(Il2CppParameterInfo* paramInfoListBegin, int index) { if ((IntPtr)paramInfoListBegin == IntPtr.Zero) { return null; } return new NativeParameterInfoStructWrapper((IntPtr)paramInfoListBegin + Marshal.SizeOf() * index); } } [ApplicableToUnityVersionsSince("2018.3.0")] internal class NativeParameterInfoStructHandler_24_1 : INativeParameterInfoStructHandler, INativeStructHandler { internal struct Il2CppParameterInfo_24_1 { public IntPtr name; public int position; public uint token; public unsafe Il2CppTypeStruct* parameter_type; } internal class NativeParameterInfoStructWrapper : INativeParameterInfoStruct, INativeStruct { private unsafe Il2CppParameterInfo_24_1* NativeParameter => (Il2CppParameterInfo_24_1*)(void*)Pointer; public IntPtr Pointer { get; } public unsafe Il2CppParameterInfo* ParameterInfoPointer => (Il2CppParameterInfo*)(void*)Pointer; public bool HasNamePosToken => true; public unsafe ref IntPtr Name => ref NativeParameter->name; public unsafe ref int Position => ref NativeParameter->position; public unsafe ref uint Token => ref NativeParameter->token; public unsafe ref Il2CppTypeStruct* ParameterType => ref NativeParameter->parameter_type; public NativeParameterInfoStructWrapper(IntPtr pointer) { Pointer = pointer; } } public bool HasNamePosToken => true; public unsafe int Size() { return sizeof(Il2CppParameterInfo_24_1); } public unsafe Il2CppParameterInfo*[] CreateNewParameterInfoArray(int paramCount) { Il2CppParameterInfo_24_1* ptr = (Il2CppParameterInfo_24_1*)(void*)Marshal.AllocHGlobal(Marshal.SizeOf() * paramCount); Il2CppParameterInfo*[] array = new Il2CppParameterInfo*[paramCount]; for (int i = 0; i < paramCount; i++) { ptr[i] = default(Il2CppParameterInfo_24_1); array[i] = (Il2CppParameterInfo*)(ptr + i); } return array; } public unsafe INativeParameterInfoStruct? Wrap(Il2CppParameterInfo* paramInfoPointer) { if ((IntPtr)paramInfoPointer == IntPtr.Zero) { return null; } return new NativeParameterInfoStructWrapper((IntPtr)paramInfoPointer); } public unsafe INativeParameterInfoStruct? Wrap(Il2CppParameterInfo* paramInfoListBegin, int index) { if ((IntPtr)paramInfoListBegin == IntPtr.Zero) { return null; } return new NativeParameterInfoStructWrapper((IntPtr)paramInfoListBegin + Marshal.SizeOf() * index); } } [ApplicableToUnityVersionsSince("2021.2.0")] internal class NativeParameterInfoStructHandler_27_3 : INativeParameterInfoStructHandler, INativeStructHandler { internal struct Il2CppParameterInfo_27_3 { public unsafe Il2CppTypeStruct* parameter_type; } internal class NativeParameterInfoStructWrapper : INativeParameterInfoStruct, INativeStruct { private unsafe Il2CppParameterInfo_27_3* NativeParameter => (Il2CppParameterInfo_27_3*)(void*)Pointer; public IntPtr Pointer { get; } public unsafe Il2CppParameterInfo* ParameterInfoPointer => (Il2CppParameterInfo*)(void*)Pointer; public bool HasNamePosToken => false; public ref IntPtr Name { get { throw new NotSupportedException("ParameterInfo does not exist in Unity 2021.2.0+"); } } public ref int Position { get { throw new NotSupportedException("ParameterInfo does not exist in Unity 2021.2.0+"); } } public ref uint Token { get { throw new NotSupportedException("ParameterInfo does not exist in Unity 2021.2.0+"); } } public unsafe ref Il2CppTypeStruct* ParameterType => ref NativeParameter->parameter_type; public NativeParameterInfoStructWrapper(IntPtr pointer) { Pointer = pointer; } } public bool HasNamePosToken => false; public unsafe int Size() { return sizeof(Il2CppParameterInfo_27_3); } public unsafe Il2CppParameterInfo*[] CreateNewParameterInfoArray(int paramCount) { Il2CppParameterInfo_27_3* ptr = (Il2CppParameterInfo_27_3*)(void*)Marshal.AllocHGlobal(Marshal.SizeOf() * paramCount); Il2CppParameterInfo*[] array = new Il2CppParameterInfo*[paramCount]; for (int i = 0; i < paramCount; i++) { ptr[i] = default(Il2CppParameterInfo_27_3); array[i] = (Il2CppParameterInfo*)(ptr + i); } return array; } public unsafe INativeParameterInfoStruct? Wrap(Il2CppParameterInfo* paramInfoPointer) { if ((IntPtr)paramInfoPointer == IntPtr.Zero) { return null; } return new NativeParameterInfoStructWrapper((IntPtr)paramInfoPointer); } public unsafe INativeParameterInfoStruct? Wrap(Il2CppParameterInfo* paramInfoListBegin, int index) { if ((IntPtr)paramInfoListBegin == IntPtr.Zero) { return null; } return new NativeParameterInfoStructWrapper((IntPtr)paramInfoListBegin + Marshal.SizeOf() * index); } } } namespace Il2CppInterop.Runtime.Runtime.VersionSpecific.MethodInfo { public interface INativeMethodInfoStructHandler : INativeStructHandler { INativeMethodInfoStruct CreateNewStruct(); unsafe INativeMethodInfoStruct Wrap(Il2CppMethodInfo* methodPointer); } public interface INativeMethodInfoStruct : INativeStruct { unsafe Il2CppMethodInfo* MethodInfoPointer { get; } ref IntPtr Name { get; } ref ushort Slot { get; } ref IntPtr MethodPointer { get; } ref IntPtr VirtualMethodPointer { get; } unsafe ref Il2CppClass* Class { get; } ref IntPtr InvokerMethod { get; } unsafe ref Il2CppTypeStruct* ReturnType { get; } ref Il2CppMethodFlags Flags { get; } ref byte ParametersCount { get; } unsafe ref Il2CppParameterInfo* Parameters { get; } ref uint Token { get; } bool IsGeneric { get; set; } bool IsInflated { get; set; } bool IsMarshalledFromNative { get; set; } } [ApplicableToUnityVersionsSince("5.2.2")] public class NativeMethodInfoStructHandler_16_0 : INativeMethodInfoStructHandler, INativeStructHandler { internal struct Il2CppMethodInfo_16_0 { internal enum Bitfield0 : byte { BIT_is_generic = 0, is_generic = 1, BIT_is_inflated = 1, is_inflated = 2 } public unsafe void* method; public unsafe void* invoker_method; public unsafe byte* name; public unsafe Il2CppClass* declaring_type; public unsafe Il2CppTypeStruct* return_type; public unsafe Il2CppParameterInfo* parameters; public unsafe void* runtime_data; public unsafe void* generic_data; public int customAttributeIndex; public uint token; public ushort flags; public ushort iflags; public ushort slot; public byte parameters_count; public Bitfield0 _bitfield0; } internal class NativeStructWrapper : INativeMethodInfoStruct, INativeStruct { private static int _bitfield0offset = Marshal.OffsetOf("_bitfield0").ToInt32(); public IntPtr Pointer { get; } private unsafe Il2CppMethodInfo_16_0* _ => (Il2CppMethodInfo_16_0*)(void*)Pointer; public unsafe Il2CppMethodInfo* MethodInfoPointer => (Il2CppMethodInfo*)(void*)Pointer; public unsafe ref IntPtr Name => ref *(IntPtr*)(&_->name); public unsafe ref ushort Slot => ref _->slot; public unsafe ref IntPtr MethodPointer => ref *(IntPtr*)(&_->method); public unsafe ref IntPtr VirtualMethodPointer => ref *(IntPtr*)(&_->method); public unsafe ref Il2CppClass* Class => ref _->declaring_type; public unsafe ref IntPtr InvokerMethod => ref *(IntPtr*)(&_->invoker_method); public unsafe ref Il2CppTypeStruct* ReturnType => ref _->return_type; public unsafe ref Il2CppMethodFlags Flags => ref *(Il2CppMethodFlags*)(&_->flags); public unsafe ref byte ParametersCount => ref _->parameters_count; public unsafe ref Il2CppParameterInfo* Parameters => ref _->parameters; public unsafe ref uint Token => ref _->token; public bool IsGeneric { get { return this.CheckBit(_bitfield0offset, 0); } set { this.SetBit(_bitfield0offset, 0, value); } } public bool IsInflated { get { return this.CheckBit(_bitfield0offset, 1); } set { this.SetBit(_bitfield0offset, 1, value); } } public bool IsMarshalledFromNative { get { return false; } set { } } public NativeStructWrapper(IntPtr ptr) { Pointer = ptr; } } public unsafe int Size() { return sizeof(Il2CppMethodInfo_16_0); } public unsafe INativeMethodInfoStruct CreateNewStruct() { IntPtr intPtr = Marshal.AllocHGlobal(Size()); Il2CppMethodInfo_16_0* ptr = (Il2CppMethodInfo_16_0*)(void*)intPtr; *ptr = default(Il2CppMethodInfo_16_0); return new NativeStructWrapper(intPtr); } public unsafe INativeMethodInfoStruct Wrap(Il2CppMethodInfo* ptr) { if (ptr == null) { return null; } return new NativeStructWrapper((IntPtr)ptr); } } [ApplicableToUnityVersionsSince("5.3.6")] public class NativeMethodInfoStructHandler_21_0 : INativeMethodInfoStructHandler, INativeStructHandler { internal struct Il2CppMethodInfo_21_0 { internal enum Bitfield0 : byte { BIT_is_generic = 0, is_generic = 1, BIT_is_inflated = 1, is_inflated = 2 } public unsafe void* methodPointer; public unsafe void* invoker_method; public unsafe byte* name; public unsafe Il2CppClass* declaring_type; public unsafe Il2CppTypeStruct* return_type; public unsafe Il2CppParameterInfo* parameters; public unsafe void* runtime_data; public unsafe void* generic_data; public int customAttributeIndex; public uint token; public ushort flags; public ushort iflags; public ushort slot; public byte parameters_count; public Bitfield0 _bitfield0; } internal class NativeStructWrapper : INativeMethodInfoStruct, INativeStruct { private static int _bitfield0offset = Marshal.OffsetOf("_bitfield0").ToInt32(); public IntPtr Pointer { get; } private unsafe Il2CppMethodInfo_21_0* _ => (Il2CppMethodInfo_21_0*)(void*)Pointer; public unsafe Il2CppMethodInfo* MethodInfoPointer => (Il2CppMethodInfo*)(void*)Pointer; public unsafe ref IntPtr Name => ref *(IntPtr*)(&_->name); public unsafe ref ushort Slot => ref _->slot; public unsafe ref IntPtr MethodPointer => ref *(IntPtr*)(&_->methodPointer); public unsafe ref IntPtr VirtualMethodPointer => ref *(IntPtr*)(&_->methodPointer); public unsafe ref Il2CppClass* Class => ref _->declaring_type; public unsafe ref IntPtr InvokerMethod => ref *(IntPtr*)(&_->invoker_method); public unsafe ref Il2CppTypeStruct* ReturnType => ref _->return_type; public unsafe ref Il2CppMethodFlags Flags => ref *(Il2CppMethodFlags*)(&_->flags); public unsafe ref byte ParametersCount => ref _->parameters_count; public unsafe ref Il2CppParameterInfo* Parameters => ref _->parameters; public unsafe ref uint Token => ref _->token; public bool IsGeneric { get { return this.CheckBit(_bitfield0offset, 0); } set { this.SetBit(_bitfield0offset, 0, value); } } public bool IsInflated { get { return this.CheckBit(_bitfield0offset, 1); } set { this.SetBit(_bitfield0offset, 1, value); } } public bool IsMarshalledFromNative { get { return false; } set { } } public NativeStructWrapper(IntPtr ptr) { Pointer = ptr; } } public unsafe int Size() { return sizeof(Il2CppMethodInfo_21_0); } public unsafe INativeMethodInfoStruct CreateNewStruct() { IntPtr intPtr = Marshal.AllocHGlobal(Size()); Il2CppMethodInfo_21_0* ptr = (Il2CppMethodInfo_21_0*)(void*)intPtr; *ptr = default(Il2CppMethodInfo_21_0); return new NativeStructWrapper(intPtr); } public unsafe INativeMethodInfoStruct Wrap(Il2CppMethodInfo* ptr) { if (ptr == null) { return null; } return new NativeStructWrapper((IntPtr)ptr); } } [ApplicableToUnityVersionsSince("2018.1.0")] public class NativeMethodInfoStructHandler_24_0 : INativeMethodInfoStructHandler, INativeStructHandler { internal struct Il2CppMethodInfo_24_0 { internal enum Bitfield0 : byte { BIT_is_generic = 0, is_generic = 1, BIT_is_inflated = 1, is_inflated = 2, BIT_wrapper_type = 2, wrapper_type = 4, BIT_is_marshaled_from_native = 3, is_marshaled_from_native = 8 } public unsafe void* methodPointer; public unsafe void* invoker_method; public unsafe byte* name; public unsafe Il2CppClass* klass; public unsafe Il2CppTypeStruct* return_type; public unsafe Il2CppParameterInfo* parameters; public unsafe void* runtime_data; public unsafe void* generic_data; public int customAttributeIndex; public uint token; public ushort flags; public ushort iflags; public ushort slot; public byte parameters_count; public Bitfield0 _bitfield0; } internal class NativeStructWrapper : INativeMethodInfoStruct, INativeStruct { private static int _bitfield0offset = Marshal.OffsetOf("_bitfield0").ToInt32(); public IntPtr Pointer { get; } private unsafe Il2CppMethodInfo_24_0* _ => (Il2CppMethodInfo_24_0*)(void*)Pointer; public unsafe Il2CppMethodInfo* MethodInfoPointer => (Il2CppMethodInfo*)(void*)Pointer; public unsafe ref IntPtr Name => ref *(IntPtr*)(&_->name); public unsafe ref ushort Slot => ref _->slot; public unsafe ref IntPtr MethodPointer => ref *(IntPtr*)(&_->methodPointer); public unsafe ref IntPtr VirtualMethodPointer => ref *(IntPtr*)(&_->methodPointer); public unsafe ref Il2CppClass* Class => ref _->klass; public unsafe ref IntPtr InvokerMethod => ref *(IntPtr*)(&_->invoker_method); public unsafe ref Il2CppTypeStruct* ReturnType => ref _->return_type; public unsafe ref Il2CppMethodFlags Flags => ref *(Il2CppMethodFlags*)(&_->flags); public unsafe ref byte ParametersCount => ref _->parameters_count; public unsafe ref Il2CppParameterInfo* Parameters => ref _->parameters; public unsafe ref uint Token => ref _->token; public bool IsGeneric { get { return this.CheckBit(_bitfield0offset, 0); } set { this.SetBit(_bitfield0offset, 0, value); } } public bool IsInflated { get { return this.CheckBit(_bitfield0offset, 1); } set { this.SetBit(_bitfield0offset, 1, value); } } public bool IsMarshalledFromNative { get { return this.CheckBit(_bitfield0offset, 3); } set { this.SetBit(_bitfield0offset, 3, value); } } public NativeStructWrapper(IntPtr ptr) { Pointer = ptr; } } public unsafe int Size() { return sizeof(Il2CppMethodInfo_24_0); } public unsafe INativeMethodInfoStruct CreateNewStruct() { IntPtr intPtr = Marshal.AllocHGlobal(Size()); Il2CppMethodInfo_24_0* ptr = (Il2CppMethodInfo_24_0*)(void*)intPtr; *ptr = default(Il2CppMethodInfo_24_0); return new NativeStructWrapper(intPtr); } public unsafe INativeMethodInfoStruct Wrap(Il2CppMethodInfo* ptr) { if (ptr == null) { return null; } return new NativeStructWrapper((IntPtr)ptr); } } [ApplicableToUnityVersionsSince("2018.3.0")] public class NativeMethodInfoStructHandler_24_1 : INativeMethodInfoStructHandler, INativeStructHandler { internal struct Il2CppMethodInfo_24_1 { internal enum Bitfield0 : byte { BIT_is_generic = 0, is_generic = 1, BIT_is_inflated = 1, is_inflated = 2, BIT_wrapper_type = 2, wrapper_type = 4, BIT_is_marshaled_from_native = 3, is_marshaled_from_native = 8 } public unsafe void* methodPointer; public unsafe void* invoker_method; public unsafe byte* name; public unsafe Il2CppClass* klass; public unsafe Il2CppTypeStruct* return_type; public unsafe Il2CppParameterInfo* parameters; public unsafe void* runtime_data; public unsafe void* generic_data; public uint token; public ushort flags; public ushort iflags; public ushort slot; public byte parameters_count; public Bitfield0 _bitfield0; } internal class NativeStructWrapper : INativeMethodInfoStruct, INativeStruct { private static int _bitfield0offset = Marshal.OffsetOf("_bitfield0").ToInt32(); public IntPtr Pointer { get; } private unsafe Il2CppMethodInfo_24_1* _ => (Il2CppMethodInfo_24_1*)(void*)Pointer; public unsafe Il2CppMethodInfo* MethodInfoPointer => (Il2CppMethodInfo*)(void*)Pointer; public unsafe ref IntPtr Name => ref *(IntPtr*)(&_->name); public unsafe ref ushort Slot => ref _->slot; public unsafe ref IntPtr MethodPointer => ref *(IntPtr*)(&_->methodPointer); public unsafe ref IntPtr VirtualMethodPointer => ref *(IntPtr*)(&_->methodPointer); public unsafe ref Il2CppClass* Class => ref _->klass; public unsafe ref IntPtr InvokerMethod => ref *(IntPtr*)(&_->invoker_method); public unsafe ref Il2CppTypeStruct* ReturnType => ref _->return_type; public unsafe ref Il2CppMethodFlags Flags => ref *(Il2CppMethodFlags*)(&_->flags); public unsafe ref byte ParametersCount => ref _->parameters_count; public unsafe ref Il2CppParameterInfo* Parameters => ref _->parameters; public unsafe ref uint Token => ref _->token; public bool IsGeneric { get { return this.CheckBit(_bitfield0offset, 0); } set { this.SetBit(_bitfield0offset, 0, value); } } public bool IsInflated { get { return this.CheckBit(_bitfield0offset, 1); } set { this.SetBit(_bitfield0offset, 1, value); } } public bool IsMarshalledFromNative { get { return this.CheckBit(_bitfield0offset, 3); } set { this.SetBit(_bitfield0offset, 3, value); } } public NativeStructWrapper(IntPtr ptr) { Pointer = ptr; } } public unsafe int Size() { return sizeof(Il2CppMethodInfo_24_1); } public unsafe INativeMethodInfoStruct CreateNewStruct() { IntPtr intPtr = Marshal.AllocHGlobal(Size()); Il2CppMethodInfo_24_1* ptr = (Il2CppMethodInfo_24_1*)(void*)intPtr; *ptr = default(Il2CppMethodInfo_24_1); return new NativeStructWrapper(intPtr); } public unsafe INativeMethodInfoStruct Wrap(Il2CppMethodInfo* ptr) { if (ptr == null) { return null; } return new NativeStructWrapper((IntPtr)ptr); } } [ApplicableToUnityVersionsSince("2021.2.0")] public class NativeMethodInfoStructHandler_29_0 : INativeMethodInfoStructHandler, INativeStructHandler { internal struct Il2CppMethodInfo_29_0 { internal enum Bitfield0 : byte { BIT_is_generic = 0, is_generic = 1, BIT_is_inflated = 1, is_inflated = 2, BIT_wrapper_type = 2, wrapper_type = 4, BIT_has_full_generic_sharing_signature = 3, has_full_generic_sharing_signature = 8, BIT_indirect_call_via_invokers = 4, indirect_call_via_invokers = 16 } public unsafe void* methodPointer; public unsafe void* virtualMethodPointer; public unsafe void* invoker_method; public unsafe byte* name; public unsafe Il2CppClass* klass; public unsafe Il2CppTypeStruct* return_type; public unsafe Il2CppTypeStruct** parameters; public unsafe void* runtime_data; public unsafe void* generic_data; public uint token; public ushort flags; public ushort iflags; public ushort slot; public byte parameters_count; public Bitfield0 _bitfield0; } internal class NativeStructWrapper : INativeMethodInfoStruct, INativeStruct { private static int _bitfield0offset = Marshal.OffsetOf("_bitfield0").ToInt32(); public IntPtr Pointer { get; } private unsafe Il2CppMethodInfo_29_0* _ => (Il2CppMethodInfo_29_0*)(void*)Pointer; public unsafe Il2CppMethodInfo* MethodInfoPointer => (Il2CppMethodInfo*)(void*)Pointer; public unsafe ref IntPtr Name => ref *(IntPtr*)(&_->name); public unsafe ref ushort Slot => ref _->slot; public unsafe ref IntPtr MethodPointer => ref *(IntPtr*)(&_->methodPointer); public unsafe ref IntPtr VirtualMethodPointer => ref *(IntPtr*)(&_->virtualMethodPointer); public unsafe ref Il2CppClass* Class => ref _->klass; public unsafe ref IntPtr InvokerMethod => ref *(IntPtr*)(&_->invoker_method); public unsafe ref Il2CppTypeStruct* ReturnType => ref _->return_type; public unsafe ref Il2CppMethodFlags Flags => ref *(Il2CppMethodFlags*)(&_->flags); public unsafe ref byte ParametersCount => ref _->parameters_count; public unsafe ref Il2CppParameterInfo* Parameters => ref *(Il2CppParameterInfo**)(&_->parameters); public unsafe ref uint Token => ref _->token; public bool IsGeneric { get { return this.CheckBit(_bitfield0offset, 0); } set { this.SetBit(_bitfield0offset, 0, value); } } public bool IsInflated { get { return this.CheckBit(_bitfield0offset, 1); } set { this.SetBit(_bitfield0offset, 1, value); } } public bool IsMarshalledFromNative { get { return false; } set { } } public NativeStructWrapper(IntPtr ptr) { Pointer = ptr; } } public unsafe int Size() { return sizeof(Il2CppMethodInfo_29_0); } public unsafe INativeMethodInfoStruct CreateNewStruct() { IntPtr intPtr = Marshal.AllocHGlobal(Size()); Il2CppMethodInfo_29_0* ptr = (Il2CppMethodInfo_29_0*)(void*)intPtr; *ptr = default(Il2CppMethodInfo_29_0); return new NativeStructWrapper(intPtr); } public unsafe INativeMethodInfoStruct Wrap(Il2CppMethodInfo* ptr) { if (ptr == null) { return null; } return new NativeStructWrapper((IntPtr)ptr); } } [ApplicableToUnityVersionsSince("2022.1.0")] public class NativeMethodInfoStructHandler_29_1 : INativeMethodInfoStructHandler, INativeStructHandler { internal struct Il2CppMethodInfo_29_1 { internal enum Bitfield0 : byte { BIT_is_generic = 0, is_generic = 1, BIT_is_inflated = 1, is_inflated = 2, BIT_wrapper_type = 2, wrapper_type = 4, BIT_has_full_generic_sharing_signature = 3, has_full_generic_sharing_signature = 8 } public unsafe void* methodPointer; public unsafe void* virtualMethodPointer; public unsafe void* invoker_method; public unsafe byte* name; public unsafe Il2CppClass* klass; public unsafe Il2CppTypeStruct* return_type; public unsafe Il2CppTypeStruct** parameters; public unsafe void* runtime_data; public unsafe void* generic_data; public uint token; public ushort flags; public ushort iflags; public ushort slot; public byte parameters_count; public Bitfield0 _bitfield0; } internal class NativeStructWrapper : INativeMethodInfoStruct, INativeStruct { private static int _bitfield0offset = Marshal.OffsetOf("_bitfield0").ToInt32(); public IntPtr Pointer { get; } private unsafe Il2CppMethodInfo_29_1* _ => (Il2CppMethodInfo_29_1*)(void*)Pointer; public unsafe Il2CppMethodInfo* MethodInfoPointer => (Il2CppMethodInfo*)(void*)Pointer; public unsafe ref IntPtr Name => ref *(IntPtr*)(&_->name); public unsafe ref ushort Slot => ref _->slot; public unsafe ref IntPtr MethodPointer => ref *(IntPtr*)(&_->methodPointer); public unsafe ref IntPtr VirtualMethodPointer => ref *(IntPtr*)(&_->virtualMethodPointer); public unsafe ref Il2CppClass* Class => ref _->klass; public unsafe ref IntPtr InvokerMethod => ref *(IntPtr*)(&_->invoker_method); public unsafe ref Il2CppTypeStruct* ReturnType => ref _->return_type; public unsafe ref Il2CppMethodFlags Flags => ref *(Il2CppMethodFlags*)(&_->flags); public unsafe ref byte ParametersCount => ref _->parameters_count; public unsafe ref Il2CppParameterInfo* Parameters => ref *(Il2CppParameterInfo**)(&_->parameters); public unsafe ref uint Token => ref _->token; public bool IsGeneric { get { return this.CheckBit(_bitfield0offset, 0); } set { this.SetBit(_bitfield0offset, 0, value); } } public bool IsInflated { get { return this.CheckBit(_bitfield0offset, 1); } set { this.SetBit(_bitfield0offset, 1, value); } } public bool IsMarshalledFromNative { get { return false; } set { } } public NativeStructWrapper(IntPtr ptr) { Pointer = ptr; } } public unsafe int Size() { return sizeof(Il2CppMethodInfo_29_1); } public unsafe INativeMethodInfoStruct CreateNewStruct() { IntPtr intPtr = Marshal.AllocHGlobal(Size()); Il2CppMethodInfo_29_1* ptr = (Il2CppMethodInfo_29_1*)(void*)intPtr; *ptr = default(Il2CppMethodInfo_29_1); return new NativeStructWrapper(intPtr); } public unsafe INativeMethodInfoStruct Wrap(Il2CppMethodInfo* ptr) { if (ptr == null) { return null; } return new NativeStructWrapper((IntPtr)ptr); } } [ApplicableToUnityVersionsSince("2023.2.0")] public class NativeMethodInfoStructHandler_29_2 : INativeMethodInfoStructHandler, INativeStructHandler { internal struct Il2CppMethodInfo_29_2 { internal enum Bitfield0 : byte { BIT_is_generic = 0, is_generic = 1, BIT_is_inflated = 1, is_inflated = 2, BIT_wrapper_type = 2, wrapper_type = 4, BIT_has_full_generic_sharing_signature = 3, has_full_generic_sharing_signature = 8, BIT_is_unmanaged_callers_only = 4, is_unmanaged_callers_only = 16 } public unsafe void* methodPointer; public unsafe void* virtualMethodPointer; public unsafe void* invoker_method; public unsafe byte* name; public unsafe Il2CppClass* klass; public unsafe Il2CppTypeStruct* return_type; public unsafe Il2CppTypeStruct** parameters; public unsafe void* runtime_data; public unsafe void* generic_data; public uint token; public ushort flags; public ushort iflags; public ushort slot; public byte parameters_count; public Bitfield0 _bitfield0; } internal class NativeStructWrapper : INativeMethodInfoStruct, INativeStruct { private static int _bitfield0offset = Marshal.OffsetOf("_bitfield0").ToInt32(); public IntPtr Pointer { get; } private unsafe Il2CppMethodInfo_29_2* _ => (Il2CppMethodInfo_29_2*)(void*)Pointer; public unsafe Il2CppMethodInfo* MethodInfoPointer => (Il2CppMethodInfo*)(void*)Pointer; public unsafe ref IntPtr Name => ref *(IntPtr*)(&_->name); public unsafe ref ushort Slot => ref _->slot; public unsafe ref IntPtr MethodPointer => ref *(IntPtr*)(&_->methodPointer); public unsafe ref IntPtr VirtualMethodPointer => ref *(IntPtr*)(&_->virtualMethodPointer); public unsafe ref Il2CppClass* Class => ref _->klass; public unsafe ref IntPtr InvokerMethod => ref *(IntPtr*)(&_->invoker_method); public unsafe ref Il2CppTypeStruct* ReturnType => ref _->return_type; public unsafe ref Il2CppMethodFlags Flags => ref *(Il2CppMethodFlags*)(&_->flags); public unsafe ref byte ParametersCount => ref _->parameters_count; public unsafe ref Il2CppParameterInfo* Parameters => ref *(Il2CppParameterInfo**)(&_->parameters); public unsafe ref uint Token => ref _->token; public bool IsGeneric { get { return this.CheckBit(_bitfield0offset, 0); } set { this.SetBit(_bitfield0offset, 0, value); } } public bool IsInflated { get { return this.CheckBit(_bitfield0offset, 1); } set { this.SetBit(_bitfield0offset, 1, value); } } public bool IsMarshalledFromNative { get { return false; } set { } } public NativeStructWrapper(IntPtr ptr) { Pointer = ptr; } } public unsafe int Size() { return sizeof(Il2CppMethodInfo_29_2); } public unsafe INativeMethodInfoStruct CreateNewStruct() { IntPtr intPtr = Marshal.AllocHGlobal(Size()); Il2CppMethodInfo_29_2* ptr = (Il2CppMethodInfo_29_2*)(void*)intPtr; *ptr = default(Il2CppMethodInfo_29_2); return new NativeStructWrapper(intPtr); } public unsafe INativeMethodInfoStruct Wrap(Il2CppMethodInfo* ptr) { if (ptr == null) { return null; } return new NativeStructWrapper((IntPtr)ptr); } } } namespace Il2CppInterop.Runtime.Runtime.VersionSpecific.Image { [ApplicableToUnityVersionsSince("5.2.2")] public class NativeImageStructHandler_16_0 : INativeImageStructHandler, INativeStructHandler { internal struct Il2CppImage_16_0 { public unsafe byte* name; public int assemblyIndex; public int typeStart; public uint typeCount; public int entryPointIndex; public unsafe void* nameToClassHashTable; } internal class NativeStructWrapper : INativeImageStruct, INativeStruct { private byte _dynamicDummy; public IntPtr Pointer { get; } private unsafe Il2CppImage_16_0* _ => (Il2CppImage_16_0*)(void*)Pointer; public unsafe Il2CppImage* ImagePointer => (Il2CppImage*)(void*)Pointer; public bool HasNameNoExt => false; public unsafe ref Il2CppAssembly* Assembly { get { throw new NotSupportedException(); } } public ref byte Dynamic => ref _dynamicDummy; public unsafe ref IntPtr Name => ref *(IntPtr*)(&_->name); public ref IntPtr NameNoExt { get { throw new NotSupportedException(); } } public NativeStructWrapper(IntPtr ptr) { Pointer = ptr; } } public unsafe int Size() { return sizeof(Il2CppImage_16_0); } public unsafe INativeImageStruct CreateNewStruct() { IntPtr intPtr = Marshal.AllocHGlobal(Size()); Il2CppImage_16_0* ptr = (Il2CppImage_16_0*)(void*)intPtr; *ptr = default(Il2CppImage_16_0); return new NativeStructWrapper(intPtr); } public unsafe INativeImageStruct Wrap(Il2CppImage* ptr) { if (ptr == null) { return null; } return new NativeStructWrapper((IntPtr)ptr); } } [ApplicableToUnityVersionsSince("5.3.2")] public class NativeImageStructHandler_19_0 : INativeImageStructHandler, INativeStructHandler { internal struct Il2CppImage_19_0 { public unsafe byte* name; public int assemblyIndex; public int typeStart; public uint typeCount; public int entryPointIndex; public unsafe void* nameToClassHashTable; public uint token; } internal class NativeStructWrapper : INativeImageStruct, INativeStruct { private byte _dynamicDummy; public IntPtr Pointer { get; } private unsafe Il2CppImage_19_0* _ => (Il2CppImage_19_0*)(void*)Pointer; public unsafe Il2CppImage* ImagePointer => (Il2CppImage*)(void*)Pointer; public bool HasNameNoExt => false; public unsafe ref Il2CppAssembly* Assembly { get { throw new NotSupportedException(); } } public ref byte Dynamic => ref _dynamicDummy; public unsafe ref IntPtr Name => ref *(IntPtr*)(&_->name); public ref IntPtr NameNoExt { get { throw new NotSupportedException(); } } public NativeStructWrapper(IntPtr ptr) { Pointer = ptr; } } public unsafe int Size() { return sizeof(Il2CppImage_19_0); } public unsafe INativeImageStruct CreateNewStruct() { IntPtr intPtr = Marshal.AllocHGlobal(Size()); Il2CppImage_19_0* ptr = (Il2CppImage_19_0*)(void*)intPtr; *ptr = default(Il2CppImage_19_0); return new NativeStructWrapper(intPtr); } public unsafe INativeImageStruct Wrap(Il2CppImage* ptr) { if (ptr == null) { return null; } return new NativeStructWrapper((IntPtr)ptr); } } [ApplicableToUnityVersionsSince("2017.1.0")] public class NativeImageStructHandler_24_0 : INativeImageStructHandler, INativeStructHandler { internal struct Il2CppImage_24_0 { public unsafe byte* name; public int assemblyIndex; public int typeStart; public uint typeCount; public int exportedTypeStart; public uint exportedTypeCount; public int entryPointIndex; public unsafe void* nameToClassHashTable; public uint token; } internal class NativeStructWrapper : INativeImageStruct, INativeStruct { private byte _dynamicDummy; public IntPtr Pointer { get; } private unsafe Il2CppImage_24_0* _ => (Il2CppImage_24_0*)(void*)Pointer; public unsafe Il2CppImage* ImagePointer => (Il2CppImage*)(void*)Pointer; public bool HasNameNoExt => false; public unsafe ref Il2CppAssembly* Assembly { get { throw new NotSupportedException(); } } public ref byte Dynamic => ref _dynamicDummy; public unsafe ref IntPtr Name => ref *(IntPtr*)(&_->name); public ref IntPtr NameNoExt { get { throw new NotSupportedException(); } } public NativeStructWrapper(IntPtr ptr) { Pointer = ptr; } } public unsafe int Size() { return sizeof(Il2CppImage_24_0); } public unsafe INativeImageStruct CreateNewStruct() { IntPtr intPtr = Marshal.AllocHGlobal(Size()); Il2CppImage_24_0* ptr = (Il2CppImage_24_0*)(void*)intPtr; *ptr = default(Il2CppImage_24_0); return new NativeStructWrapper(intPtr); } public unsafe INativeImageStruct Wrap(Il2CppImage* ptr) { if (ptr == null) { return null; } return new NativeStructWrapper((IntPtr)ptr); } } [ApplicableToUnityVersionsSince("2017.1.3")] public class NativeImageStructHandler_24_1 : INativeImageStructHandler, INativeStructHandler { internal struct Il2CppImage_24_1 { public unsafe byte* name; public unsafe byte* nameNoExt; public int assemblyIndex; public int typeStart; public uint typeCount; public int exportedTypeStart; public uint exportedTypeCount; public int entryPointIndex; public unsafe void* nameToClassHashTable; public uint token; } internal class NativeStructWrapper : INativeImageStruct, INativeStruct { private byte _dynamicDummy; public IntPtr Pointer { get; } private unsafe Il2CppImage_24_1* _ => (Il2CppImage_24_1*)(void*)Pointer; public unsafe Il2CppImage* ImagePointer => (Il2CppImage*)(void*)Pointer; public bool HasNameNoExt => true; public unsafe ref Il2CppAssembly* Assembly { get { throw new NotSupportedException(); } } public ref byte Dynamic => ref _dynamicDummy; public unsafe ref IntPtr Name => ref *(IntPtr*)(&_->name); public unsafe ref IntPtr NameNoExt => ref *(IntPtr*)(&_->nameNoExt); public NativeStructWrapper(IntPtr ptr) { Pointer = ptr; } } public unsafe int Size() { return sizeof(Il2CppImage_24_1); } public unsafe INativeImageStruct CreateNewStruct() { IntPtr intPtr = Marshal.AllocHGlobal(Size()); Il2CppImage_24_1* ptr = (Il2CppImage_24_1*)(void*)intPtr; *ptr = default(Il2CppImage_24_1); return new NativeStructWrapper(intPtr); } public unsafe INativeImageStruct Wrap(Il2CppImage* ptr) { if (ptr == null) { return null; } return new NativeStructWrapper((IntPtr)ptr); } } [ApplicableToUnityVersionsSince("2018.1.0")] public class NativeImageStructHandler_24_2 : INativeImageStructHandler, INativeStructHandler { internal struct Il2CppImage_24_2 { public unsafe byte* name; public unsafe byte* nameNoExt; public unsafe Il2CppAssembly* assembly; public int typeStart; public uint typeCount; public int exportedTypeStart; public uint exportedTypeCount; public int entryPointIndex; public unsafe void* nameToClassHashTable; public uint token; public byte dynamic; } internal class NativeStructWrapper : INativeImageStruct, INativeStruct { public IntPtr Pointer { get; } private unsafe Il2CppImage_24_2* _ => (Il2CppImage_24_2*)(void*)Pointer; public unsafe Il2CppImage* ImagePointer => (Il2CppImage*)(void*)Pointer; public bool HasNameNoExt => true; public unsafe ref Il2CppAssembly* Assembly => ref _->assembly; public unsafe ref byte Dynamic => ref _->dynamic; public unsafe ref IntPtr Name => ref *(IntPtr*)(&_->name); public unsafe ref IntPtr NameNoExt => ref *(IntPtr*)(&_->nameNoExt); public NativeStructWrapper(IntPtr ptr) { Pointer = ptr; } } public unsafe int Size() { return sizeof(Il2CppImage_24_2); } public unsafe INativeImageStruct CreateNewStruct() { IntPtr intPtr = Marshal.AllocHGlobal(Size()); Il2CppImage_24_2* ptr = (Il2CppImage_24_2*)(void*)intPtr; *ptr = default(Il2CppImage_24_2); return new NativeStructWrapper(intPtr); } public unsafe INativeImageStruct Wrap(Il2CppImage* ptr) { if (ptr == null) { return null; } return new NativeStructWrapper((IntPtr)ptr); } } [ApplicableToUnityVersionsSince("2018.3.0")] public class NativeImageStructHandler_24_3 : INativeImageStructHandler, INativeStructHandler { internal struct Il2CppImage_24_3 { public unsafe byte* name; public unsafe byte* nameNoExt; public unsafe Il2CppAssembly* assembly; public int typeStart; public uint typeCount; public int exportedTypeStart; public uint exportedTypeCount; public int customAttributeStart; public uint customAttributeCount; public int entryPointIndex; public unsafe void* nameToClassHashTable; public uint token; public byte dynamic; } internal class NativeStructWrapper : INativeImageStruct, INativeStruct { public IntPtr Pointer { get; } private unsafe Il2CppImage_24_3* _ => (Il2CppImage_24_3*)(void*)Pointer; public unsafe Il2CppImage* ImagePointer => (Il2CppImage*)(void*)Pointer; public bool HasNameNoExt => true; public unsafe ref Il2CppAssembly* Assembly => ref _->assembly; public unsafe ref byte Dynamic => ref _->dynamic; public unsafe ref IntPtr Name => ref *(IntPtr*)(&_->name); public unsafe ref IntPtr NameNoExt => ref *(IntPtr*)(&_->nameNoExt); public NativeStructWrapper(IntPtr ptr) { Pointer = ptr; } } public unsafe int Size() { return sizeof(Il2CppImage_24_3); } public unsafe INativeImageStruct CreateNewStruct() { IntPtr intPtr = Marshal.AllocHGlobal(Size()); Il2CppImage_24_3* ptr = (Il2CppImage_24_3*)(void*)intPtr; *ptr = default(Il2CppImage_24_3); return new NativeStructWrapper(intPtr); } public unsafe INativeImageStruct Wrap(Il2CppImage* ptr) { if (ptr == null) { return null; } return new NativeStructWrapper((IntPtr)ptr); } } [ApplicableToUnityVersionsSince("2019.1.0")] public class NativeImageStructHandler_24_4 : INativeImageStructHandler, INativeStructHandler { internal struct Il2CppImage_24_4 { public unsafe byte* name; public unsafe byte* nameNoExt; public unsafe Il2CppAssembly* assembly; public int typeStart; public uint typeCount; public int exportedTypeStart; public uint exportedTypeCount; public int customAttributeStart; public uint customAttributeCount; public int entryPointIndex; public unsafe void* nameToClassHashTable; public unsafe void* codeGenModule; public uint token; public byte dynamic; } internal class NativeStructWrapper : INativeImageStruct, INativeStruct { public IntPtr Pointer { get; } private unsafe Il2CppImage_24_4* _ => (Il2CppImage_24_4*)(void*)Pointer; public unsafe Il2CppImage* ImagePointer => (Il2CppImage*)(void*)Pointer; public bool HasNameNoExt => true; public unsafe ref Il2CppAssembly* Assembly => ref _->assembly; public unsafe ref byte Dynamic => ref _->dynamic; public unsafe ref IntPtr Name => ref *(IntPtr*)(&_->name); public unsafe ref IntPtr NameNoExt => ref *(IntPtr*)(&_->nameNoExt); public NativeStructWrapper(IntPtr ptr) { Pointer = ptr; } } public unsafe int Size() { return sizeof(Il2CppImage_24_4); } public unsafe INativeImageStruct CreateNewStruct() { IntPtr intPtr = Marshal.AllocHGlobal(Size()); Il2CppImage_24_4* ptr = (Il2CppImage_24_4*)(void*)intPtr; *ptr = default(Il2CppImage_24_4); return new NativeStructWrapper(intPtr); } public unsafe INativeImageStruct Wrap(Il2CppImage* ptr) { if (ptr == null) { return null; } return new NativeStructWrapper((IntPtr)ptr); } } [ApplicableToUnityVersionsSince("2020.2.0")] public class NativeImageStructHandler_27_0 : INativeImageStructHandler, INativeStructHandler { internal struct Il2CppImage_27_0 { public unsafe byte* name; public unsafe byte* nameNoExt; public unsafe Il2CppAssembly* assembly; public uint typeCount; public uint exportedTypeCount; public uint customAttributeCount; public Il2CppMetadataImageHandle metadataHandle; public unsafe void* nameToClassHashTable; public unsafe void* codeGenModule; public uint token; public byte dynamic; } internal class NativeStructWrapper : INativeImageStruct, INativeStruct { public IntPtr Pointer { get; } private unsafe Il2CppImage_27_0* _ => (Il2CppImage_27_0*)(void*)Pointer; public unsafe Il2CppImage* ImagePointer => (Il2CppImage*)(void*)Pointer; public bool HasNameNoExt => true; public unsafe ref Il2CppAssembly* Assembly => ref _->assembly; public unsafe ref byte Dynamic => ref _->dynamic; public unsafe ref IntPtr Name => ref *(IntPtr*)(&_->name); public unsafe ref IntPtr NameNoExt => ref *(IntPtr*)(&_->nameNoExt); public NativeStructWrapper(IntPtr ptr) { Pointer = ptr; } } public unsafe int Size() { return sizeof(Il2CppImage_27_0); } public unsafe INativeImageStruct CreateNewStruct() { IntPtr intPtr = Marshal.AllocHGlobal(Size()); Il2CppImage_27_0* ptr = (Il2CppImage_27_0*)(void*)intPtr; *ptr = default(Il2CppImage_27_0); Il2CppImageGlobalMetadata* ptr2 = (Il2CppImageGlobalMetadata*)(void*)Marshal.AllocHGlobal(sizeof(Il2CppImageGlobalMetadata)); ptr2->image = (Il2CppImage*)ptr; *(Il2CppImageGlobalMetadata**)(&ptr->metadataHandle) = ptr2; return new NativeStructWrapper(intPtr); } public unsafe INativeImageStruct Wrap(Il2CppImage* ptr) { if (ptr == null) { return null; } return new NativeStructWrapper((IntPtr)ptr); } } public interface INativeImageStructHandler : INativeStructHandler { INativeImageStruct CreateNewStruct(); unsafe INativeImageStruct Wrap(Il2CppImage* imagePointer); } public interface INativeImageStruct : INativeStruct { unsafe Il2CppImage* ImagePointer { get; } unsafe ref Il2CppAssembly* Assembly { get; } ref byte Dynamic { get; } ref IntPtr Name { get; } bool HasNameNoExt { get; } ref IntPtr NameNoExt { get; } } } namespace Il2CppInterop.Runtime.Runtime.VersionSpecific.FieldInfo { [ApplicableToUnityVersionsSince("5.2.2")] public class NativeFieldInfoStructHandler_16_0 : INativeFieldInfoStructHandler, INativeStructHandler { internal struct Il2CppFieldInfo_16_0 { public unsafe byte* name; public unsafe Il2CppTypeStruct* type; public unsafe Il2CppClass* parent; public int offset; public int customAttributeIndex; } internal class NativeStructWrapper : INativeFieldInfoStruct, INativeStruct { public IntPtr Pointer { get; } private unsafe Il2CppFieldInfo_16_0* _ => (Il2CppFieldInfo_16_0*)(void*)Pointer; public unsafe Il2CppFieldInfo* FieldInfoPointer => (Il2CppFieldInfo*)(void*)Pointer; public unsafe ref IntPtr Name => ref *(IntPtr*)(&_->name); public unsafe ref Il2CppTypeStruct* Type => ref _->type; public unsafe ref Il2CppClass* Parent => ref _->parent; public unsafe ref int Offset => ref _->offset; public NativeStructWrapper(IntPtr ptr) { Pointer = ptr; } } public unsafe int Size() { return sizeof(Il2CppFieldInfo_16_0); } public unsafe INativeFieldInfoStruct CreateNewStruct() { IntPtr intPtr = Marshal.AllocHGlobal(Size()); Il2CppFieldInfo_16_0* ptr = (Il2CppFieldInfo_16_0*)(void*)intPtr; *ptr = default(Il2CppFieldInfo_16_0); return new NativeStructWrapper(intPtr); } public unsafe INativeFieldInfoStruct Wrap(Il2CppFieldInfo* ptr) { if (ptr == null) { return null; } return new NativeStructWrapper((IntPtr)ptr); } } [ApplicableToUnityVersionsSince("5.3.2")] public class NativeFieldInfoStructHandler_19_0 : INativeFieldInfoStructHandler, INativeStructHandler { internal struct Il2CppFieldInfo_19_0 { public unsafe byte* name; public unsafe Il2CppTypeStruct* type; public unsafe Il2CppClass* parent; public int offset; public int customAttributeIndex; public uint token; } internal class NativeStructWrapper : INativeFieldInfoStruct, INativeStruct { public IntPtr Pointer { get; } private unsafe Il2CppFieldInfo_19_0* _ => (Il2CppFieldInfo_19_0*)(void*)Pointer; public unsafe Il2CppFieldInfo* FieldInfoPointer => (Il2CppFieldInfo*)(void*)Pointer; public unsafe ref IntPtr Name => ref *(IntPtr*)(&_->name); public unsafe ref Il2CppTypeStruct* Type => ref _->type; public unsafe ref Il2CppClass* Parent => ref _->parent; public unsafe ref int Offset => ref _->offset; public NativeStructWrapper(IntPtr ptr) { Pointer = ptr; } } public unsafe int Size() { return sizeof(Il2CppFieldInfo_19_0); } public unsafe INativeFieldInfoStruct CreateNewStruct() { IntPtr intPtr = Marshal.AllocHGlobal(Size()); Il2CppFieldInfo_19_0* ptr = (Il2CppFieldInfo_19_0*)(void*)intPtr; *ptr = default(Il2CppFieldInfo_19_0); return new NativeStructWrapper(intPtr); } public unsafe INativeFieldInfoStruct Wrap(Il2CppFieldInfo* ptr) { if (ptr == null) { return null; } return new NativeStructWrapper((IntPtr)ptr); } } [ApplicableToUnityVersionsSince("2018.3.0")] public class NativeFieldInfoStructHandler_24_0 : INativeFieldInfoStructHandler, INativeStructHandler { internal struct Il2CppFieldInfo_24_0 { public unsafe byte* name; public unsafe Il2CppTypeStruct* type; public unsafe Il2CppClass* parent; public int offset; public uint token; } internal class NativeStructWrapper : INativeFieldInfoStruct, INativeStruct { public IntPtr Pointer { get; } private unsafe Il2CppFieldInfo_24_0* _ => (Il2CppFieldInfo_24_0*)(void*)Pointer; public unsafe Il2CppFieldInfo* FieldInfoPointer => (Il2CppFieldInfo*)(void*)Pointer; public unsafe ref IntPtr Name => ref *(IntPtr*)(&_->name); public unsafe ref Il2CppTypeStruct* Type => ref _->type; public unsafe ref Il2CppClass* Parent => ref _->parent; public unsafe ref int Offset => ref _->offset; public NativeStructWrapper(IntPtr ptr) { Pointer = ptr; } } public unsafe int Size() { return sizeof(Il2CppFieldInfo_24_0); } public unsafe INativeFieldInfoStruct CreateNewStruct() { IntPtr intPtr = Marshal.AllocHGlobal(Size()); Il2CppFieldInfo_24_0* ptr = (Il2CppFieldInfo_24_0*)(void*)intPtr; *ptr = default(Il2CppFieldInfo_24_0); return new NativeStructWrapper(intPtr); } public unsafe INativeFieldInfoStruct Wrap(Il2CppFieldInfo* ptr) { if (ptr == null) { return null; } return new NativeStructWrapper((IntPtr)ptr); } } public interface INativeFieldInfoStructHandler : INativeStructHandler { INativeFieldInfoStruct CreateNewStruct(); unsafe INativeFieldInfoStruct Wrap(Il2CppFieldInfo* fieldInfoPointer); } public interface INativeFieldInfoStruct : INativeStruct { unsafe Il2CppFieldInfo* FieldInfoPointer { get; } ref IntPtr Name { get; } unsafe ref Il2CppTypeStruct* Type { get; } unsafe ref Il2CppClass* Parent { get; } ref int Offset { get; } } } namespace Il2CppInterop.Runtime.Runtime.VersionSpecific.Exception { [ApplicableToUnityVersionsSince("5.2.2")] public class NativeExceptionStructHandler_16_0 : INativeExceptionStructHandler, INativeStructHandler { internal struct Il2CppException_16_0 { public Il2CppObject _object; public unsafe void* trace_ips; public unsafe Il2CppObject* inner_ex; public unsafe Il2CppString* message; public unsafe Il2CppString* help_link; public unsafe Il2CppString* class_name; public unsafe Il2CppString* stack_trace; public unsafe Il2CppString* remote_stack_trace; public int remote_stack_index; public int hresult; public unsafe Il2CppString* source; public unsafe Il2CppObject* _data; } internal class NativeStructWrapper : INativeExceptionStruct, INativeStruct { public IntPtr Pointer { get; } private unsafe Il2CppException_16_0* _ => (Il2CppException_16_0*)(void*)Pointer; public unsafe Il2CppException* ExceptionPointer => (Il2CppException*)(void*)Pointer; public unsafe ref Il2CppException* InnerException => ref *(Il2CppException**)(&_->inner_ex); public unsafe ref Il2CppString* Message => ref _->message; public unsafe ref Il2CppString* HelpLink => ref _->help_link; public unsafe ref Il2CppString* ClassName => ref _->class_name; public unsafe ref Il2CppString* StackTrace => ref _->stack_trace; public unsafe ref Il2CppString* RemoteStackTrace => ref _->remote_stack_trace; public NativeStructWrapper(IntPtr ptr) { Pointer = ptr; } } public unsafe int Size() { return sizeof(Il2CppException_16_0); } public unsafe INativeExceptionStruct CreateNewStruct() { IntPtr intPtr = Marshal.AllocHGlobal(Size()); Il2CppException_16_0* ptr = (Il2CppException_16_0*)(void*)intPtr; *ptr = default(Il2CppException_16_0); return new NativeStructWrapper(intPtr); } public unsafe INativeExceptionStruct Wrap(Il2CppException* ptr) { if (ptr == null) { return null; } return new NativeStructWrapper((IntPtr)ptr); } } [ApplicableToUnityVersionsSince("5.3.3")] public class NativeExceptionStructHandler_20_0 : INativeExceptionStructHandler, INativeStructHandler { internal struct Il2CppException_20_0 { public Il2CppObject _object; public unsafe void* trace_ips; public unsafe Il2CppObject* inner_ex; public unsafe Il2CppString* message; public unsafe Il2CppString* help_link; public unsafe Il2CppString* class_name; public unsafe Il2CppString* stack_trace; public unsafe Il2CppString* remote_stack_trace; public int remote_stack_index; public il2cpp_hresult_t hresult; public unsafe Il2CppString* source; public unsafe Il2CppObject* _data; } internal class NativeStructWrapper : INativeExceptionStruct, INativeStruct { public IntPtr Pointer { get; } private unsafe Il2CppException_20_0* _ => (Il2CppException_20_0*)(void*)Pointer; public unsafe Il2CppException* ExceptionPointer => (Il2CppException*)(void*)Pointer; public unsafe ref Il2CppException* InnerException => ref *(Il2CppException**)(&_->inner_ex); public unsafe ref Il2CppString* Message => ref _->message; public unsafe ref Il2CppString* HelpLink => ref _->help_link; public unsafe ref Il2CppString* ClassName => ref _->class_name; public unsafe ref Il2CppString* StackTrace => ref _->stack_trace; public unsafe ref Il2CppString* RemoteStackTrace => ref _->remote_stack_trace; public NativeStructWrapper(IntPtr ptr) { Pointer = ptr; } } public unsafe int Size() { return sizeof(Il2CppException_20_0); } public unsafe INativeExceptionStruct CreateNewStruct() { IntPtr intPtr = Marshal.AllocHGlobal(Size()); Il2CppException_20_0* ptr = (Il2CppException_20_0*)(void*)intPtr; *ptr = default(Il2CppException_20_0); return new NativeStructWrapper(intPtr); } public unsafe INativeExceptionStruct Wrap(Il2CppException* ptr) { if (ptr == null) { return null; } return new NativeStructWrapper((IntPtr)ptr); } } [ApplicableToUnityVersionsSince("5.3.5")] public class NativeExceptionStructHandler_21_0 : INativeExceptionStructHandler, INativeStructHandler { internal struct Il2CppException_21_0 { public Il2CppObject _object; public unsafe void* trace_ips; public unsafe Il2CppException* inner_ex; public unsafe Il2CppString* message; public unsafe Il2CppString* help_link; public unsafe Il2CppString* class_name; public unsafe Il2CppString* stack_trace; public unsafe Il2CppString* remote_stack_trace; public int remote_stack_index; public il2cpp_hresult_t hresult; public unsafe Il2CppString* source; public unsafe Il2CppObject* _data; } internal class NativeStructWrapper : INativeExceptionStruct, INativeStruct { public IntPtr Pointer { get; } private unsafe Il2CppException_21_0* _ => (Il2CppException_21_0*)(void*)Pointer; public unsafe Il2CppException* ExceptionPointer => (Il2CppException*)(void*)Pointer; public unsafe ref Il2CppException* InnerException => ref _->inner_ex; public unsafe ref Il2CppString* Message => ref _->message; public unsafe ref Il2CppString* HelpLink => ref _->help_link; public unsafe ref Il2CppString* ClassName => ref _->class_name; public unsafe ref Il2CppString* StackTrace => ref _->stack_trace; public unsafe ref Il2CppString* RemoteStackTrace => ref _->remote_stack_trace; public NativeStructWrapper(IntPtr ptr) { Pointer = ptr; } } public unsafe int Size() { return sizeof(Il2CppException_21_0); } public unsafe INativeExceptionStruct CreateNewStruct() { IntPtr intPtr = Marshal.AllocHGlobal(Size()); Il2CppException_21_0* ptr = (Il2CppException_21_0*)(void*)intPtr; *ptr = default(Il2CppException_21_0); return new NativeStructWrapper(intPtr); } public unsafe INativeExceptionStruct Wrap(Il2CppException* ptr) { if (ptr == null) { return null; } return new NativeStructWrapper((IntPtr)ptr); } } [ApplicableToUnityVersionsSince("2019.3.0")] public class NativeExceptionStructHandler_24_0 : INativeExceptionStructHandler, INativeStructHandler { internal struct Il2CppException_24_0 { public Il2CppObject _object; public unsafe Il2CppString* className; public unsafe Il2CppString* message; public unsafe Il2CppObject* _data; public unsafe Il2CppException* inner_ex; public unsafe Il2CppString* _helpURL; public unsafe void* trace_ips; public unsafe Il2CppString* stack_trace; public unsafe Il2CppString* remote_stack_trace; public int remote_stack_index; public unsafe Il2CppObject* _dynamicMethods; public il2cpp_hresult_t hresult; public unsafe Il2CppString* source; public unsafe Il2CppObject* safeSerializationManager; public unsafe void* captured_traces; public unsafe void* native_trace_ips; } internal class NativeStructWrapper : INativeExceptionStruct, INativeStruct { public IntPtr Pointer { get; } private unsafe Il2CppException_24_0* _ => (Il2CppException_24_0*)(void*)Pointer; public unsafe Il2CppException* ExceptionPointer => (Il2CppException*)(void*)Pointer; public unsafe ref Il2CppException* InnerException => ref _->inner_ex; public unsafe ref Il2CppString* Message => ref _->message; public unsafe ref Il2CppString* HelpLink => ref _->_helpURL; public unsafe ref Il2CppString* ClassName => ref _->className; public unsafe ref Il2CppString* StackTrace => ref _->stack_trace; public unsafe ref Il2CppString* RemoteStackTrace => ref _->remote_stack_trace; public NativeStructWrapper(IntPtr ptr) { Pointer = ptr; } } public unsafe int Size() { return sizeof(Il2CppException_24_0); } public unsafe INativeExceptionStruct CreateNewStruct() { IntPtr intPtr = Marshal.AllocHGlobal(Size()); Il2CppException_24_0* ptr = (Il2CppException_24_0*)(void*)intPtr; *ptr = default(Il2CppException_24_0); return new NativeStructWrapper(intPtr); } public unsafe INativeExceptionStruct Wrap(Il2CppException* ptr) { if (ptr == null) { return null; } return new NativeStructWrapper((IntPtr)ptr); } } [ApplicableToUnityVersionsSince("2021.2.0")] public class NativeExceptionStructHandler_29_0 : INativeExceptionStructHandler, INativeStructHandler { internal struct Il2CppException_29_0 { public Il2CppObject _object; public unsafe Il2CppString* className; public unsafe Il2CppString* message; public unsafe Il2CppObject* _data; public unsafe Il2CppException* inner_ex; public unsafe Il2CppString* _helpURL; public unsafe void* trace_ips; public unsafe Il2CppString* stack_trace; public unsafe Il2CppString* remote_stack_trace; public int remote_stack_index; public unsafe Il2CppObject* _dynamicMethods; public il2cpp_hresult_t hresult; public unsafe Il2CppString* source; public unsafe Il2CppObject* safeSerializationManager; public unsafe void* captured_traces; public unsafe void* native_trace_ips; public int caught_in_unmanaged; } internal class NativeStructWrapper : INativeExceptionStruct, INativeStruct { public IntPtr Pointer { get; } private unsafe Il2CppException_29_0* _ => (Il2CppException_29_0*)(void*)Pointer; public unsafe Il2CppException* ExceptionPointer => (Il2CppException*)(void*)Pointer; public unsafe ref Il2CppException* InnerException => ref _->inner_ex; public unsafe ref Il2CppString* Message => ref _->message; public unsafe ref Il2CppString* HelpLink => ref _->_helpURL; public unsafe ref Il2CppString* ClassName => ref _->className; public unsafe ref Il2CppString* StackTrace => ref _->stack_trace; public unsafe ref Il2CppString* RemoteStackTrace => ref _->remote_stack_trace; public NativeStructWrapper(IntPtr ptr) { Pointer = ptr; } } public unsafe int Size() { return sizeof(Il2CppException_29_0); } public unsafe INativeExceptionStruct CreateNewStruct() { IntPtr intPtr = Marshal.AllocHGlobal(Size()); Il2CppException_29_0* ptr = (Il2CppException_29_0*)(void*)intPtr; *ptr = default(Il2CppException_29_0); return new NativeStructWrapper(intPtr); } public unsafe INativeExceptionStruct Wrap(Il2CppException* ptr) { if (ptr == null) { return null; } return new NativeStructWrapper((IntPtr)ptr); } } public interface INativeExceptionStructHandler : INativeStructHandler { INativeExceptionStruct CreateNewStruct(); unsafe INativeExceptionStruct Wrap(Il2CppException* exceptionPointer); } public interface INativeExceptionStruct : INativeStruct { unsafe Il2CppException* ExceptionPointer { get; } unsafe ref Il2CppException* InnerException { get; } unsafe ref Il2CppString* Message { get; } unsafe ref Il2CppString* HelpLink { get; } unsafe ref Il2CppString* ClassName { get; } unsafe ref Il2CppString* StackTrace { get; } unsafe ref Il2CppString* RemoteStackTrace { get; } } } namespace Il2CppInterop.Runtime.Runtime.VersionSpecific.EventInfo { [ApplicableToUnityVersionsSince("5.2.2")] public class NativeEventInfoStructHandler_16_0 : INativeEventInfoStructHandler, INativeStructHandler { internal struct Il2CppEventInfo_16_0 { public unsafe byte* name; public unsafe Il2CppTypeStruct* eventType; public unsafe Il2CppClass* parent; public unsafe Il2CppMethodInfo* add; public unsafe Il2CppMethodInfo* remove; public unsafe Il2CppMethodInfo* raise; public int customAttributeIndex; } internal class NativeStructWrapper : INativeEventInfoStruct, INativeStruct { public IntPtr Pointer { get; } private unsafe Il2CppEventInfo_16_0* _ => (Il2CppEventInfo_16_0*)(void*)Pointer; public unsafe Il2CppEventInfo* EventInfoPointer => (Il2CppEventInfo*)(void*)Pointer; public unsafe ref IntPtr Name => ref *(IntPtr*)(&_->name); public unsafe ref Il2CppTypeStruct* EventType => ref _->eventType; public unsafe ref Il2CppClass* Parent => ref _->parent; public unsafe ref Il2CppMethodInfo* Add => ref _->add; public unsafe ref Il2CppMethodInfo* Remove => ref _->remove; public unsafe ref Il2CppMethodInfo* Raise => ref _->raise; public NativeStructWrapper(IntPtr ptr) { Pointer = ptr; } } public unsafe int Size() { return sizeof(Il2CppEventInfo_16_0); } public unsafe INativeEventInfoStruct CreateNewStruct() { IntPtr intPtr = Marshal.AllocHGlobal(Size()); Il2CppEventInfo_16_0* ptr = (Il2CppEventInfo_16_0*)(void*)intPtr; *ptr = default(Il2CppEventInfo_16_0); return new NativeStructWrapper(intPtr); } public unsafe INativeEventInfoStruct Wrap(Il2CppEventInfo* ptr) { if (ptr == null) { return null; } return new NativeStructWrapper((IntPtr)ptr); } } [ApplicableToUnityVersionsSince("5.3.2")] public class NativeEventInfoStructHandler_19_0 : INativeEventInfoStructHandler, INativeStructHandler { internal struct Il2CppEventInfo_19_0 { public unsafe byte* name; public unsafe Il2CppTypeStruct* eventType; public unsafe Il2CppClass* parent; public unsafe Il2CppMethodInfo* add; public unsafe Il2CppMethodInfo* remove; public unsafe Il2CppMethodInfo* raise; public int customAttributeIndex; public uint token; } internal class NativeStructWrapper : INativeEventInfoStruct, INativeStruct { public IntPtr Pointer { get; } private unsafe Il2CppEventInfo_19_0* _ => (Il2CppEventInfo_19_0*)(void*)Pointer; public unsafe Il2CppEventInfo* EventInfoPointer => (Il2CppEventInfo*)(void*)Pointer; public unsafe ref IntPtr Name => ref *(IntPtr*)(&_->name); public unsafe ref Il2CppTypeStruct* EventType => ref _->eventType; public unsafe ref Il2CppClass* Parent => ref _->parent; public unsafe ref Il2CppMethodInfo* Add => ref _->add; public unsafe ref Il2CppMethodInfo* Remove => ref _->remove; public unsafe ref Il2CppMethodInfo* Raise => ref _->raise; public NativeStructWrapper(IntPtr ptr) { Pointer = ptr; } } public unsafe int Size() { return sizeof(Il2CppEventInfo_19_0); } public unsafe INativeEventInfoStruct CreateNewStruct() { IntPtr intPtr = Marshal.AllocHGlobal(Size()); Il2CppEventInfo_19_0* ptr = (Il2CppEventInfo_19_0*)(void*)intPtr; *ptr = default(Il2CppEventInfo_19_0); return new NativeStructWrapper(intPtr); } public unsafe INativeEventInfoStruct Wrap(Il2CppEventInfo* ptr) { if (ptr == null) { return null; } return new NativeStructWrapper((IntPtr)ptr); } } [ApplicableToUnityVersionsSince("2018.3.0")] public class NativeEventInfoStructHandler_24_0 : INativeEventInfoStructHandler, INativeStructHandler { internal struct Il2CppEventInfo_24_0 { public unsafe byte* name; public unsafe Il2CppTypeStruct* eventType; public unsafe Il2CppClass* parent; public unsafe Il2CppMethodInfo* add; public unsafe Il2CppMethodInfo* remove; public unsafe Il2CppMethodInfo* raise; public uint token; } internal class NativeStructWrapper : INativeEventInfoStruct, INativeStruct { public IntPtr Pointer { get; } private unsafe Il2CppEventInfo_24_0* _ => (Il2CppEventInfo_24_0*)(void*)Pointer; public unsafe Il2CppEventInfo* EventInfoPointer => (Il2CppEventInfo*)(void*)Pointer; public unsafe ref IntPtr Name => ref *(IntPtr*)(&_->name); public unsafe ref Il2CppTypeStruct* EventType => ref _->eventType; public unsafe ref Il2CppClass* Parent => ref _->parent; public unsafe ref Il2CppMethodInfo* Add => ref _->add; public unsafe ref Il2CppMethodInfo* Remove => ref _->remove; public unsafe ref Il2CppMethodInfo* Raise => ref _->raise; public NativeStructWrapper(IntPtr ptr) { Pointer = ptr; } } public unsafe int Size() { return sizeof(Il2CppEventInfo_24_0); } public unsafe INativeEventInfoStruct CreateNewStruct() { IntPtr intPtr = Marshal.AllocHGlobal(Size()); Il2CppEventInfo_24_0* ptr = (Il2CppEventInfo_24_0*)(void*)intPtr; *ptr = default(Il2CppEventInfo_24_0); return new NativeStructWrapper(intPtr); } public unsafe INativeEventInfoStruct Wrap(Il2CppEventInfo* ptr) { if (ptr == null) { return null; } return new NativeStructWrapper((IntPtr)ptr); } } public interface INativeEventInfoStructHandler : INativeStructHandler { INativeEventInfoStruct CreateNewStruct(); unsafe INativeEventInfoStruct Wrap(Il2CppEventInfo* eventInfoPointer); } public interface INativeEventInfoStruct : INativeStruct { unsafe Il2CppEventInfo* EventInfoPointer { get; } ref IntPtr Name { get; } unsafe ref Il2CppTypeStruct* EventType { get; } unsafe ref Il2CppClass* Parent { get; } unsafe ref Il2CppMethodInfo* Add { get; } unsafe ref Il2CppMethodInfo* Remove { get; } unsafe ref Il2CppMethodInfo* Raise { get; } } } namespace Il2CppInterop.Runtime.Runtime.VersionSpecific.Class { [ApplicableToUnityVersionsSince("5.2.2")] public class NativeClassStructHandler_16_0 : INativeClassStructHandler, INativeStructHandler { internal struct Il2CppClass_16_0 { internal enum Bitfield0 : byte { BIT_valuetype = 0, valuetype = 1, BIT_initialized = 1, initialized = 2, BIT_enumtype = 2, enumtype = 4, BIT_is_generic = 3, is_generic = 8, BIT_has_references = 4, has_references = 16, BIT_init_pending = 5, init_pending = 32, BIT_size_inited = 6, size_inited = 64, BIT_has_finalize = 7, has_finalize = 128 } internal enum Bitfield1 : byte { BIT_has_cctor = 0, has_cctor = 1, BIT_is_blittable = 1, is_blittable = 2 } public unsafe Il2CppImage* image; public unsafe void* gc_desc; public unsafe byte* name; public unsafe byte* namespaze; public unsafe Il2CppTypeStruct* byval_arg; public unsafe Il2CppTypeStruct* this_arg; public unsafe Il2CppClass* element_class; public unsafe Il2CppClass* castClass; public unsafe Il2CppClass* declaringType; public unsafe Il2CppClass* parent; public unsafe void* generic_class; public unsafe void* typeDefinition; public unsafe Il2CppFieldInfo* fields; public unsafe Il2CppEventInfo* events; public unsafe Il2CppPropertyInfo* properties; public unsafe Il2CppMethodInfo** methods; public unsafe Il2CppClass** nestedTypes; public unsafe Il2CppClass** implementedInterfaces; public unsafe Il2CppMethodInfo** vtable; public unsafe Il2CppRuntimeInterfaceOffsetPair* interfaceOffsets; public unsafe void* static_fields; public unsafe void* rgctx_data; public unsafe Il2CppClass** typeHierarchy; public uint cctor_started; public uint cctor_finished; public ulong cctor_thread; public int genericContainerIndex; public int customAttributeIndex; public uint instance_size; public uint actualSize; public uint element_size; public int native_size; public uint static_fields_size; public uint thread_static_fields_size; public int thread_static_fields_offset; public uint flags; public ushort method_count; public ushort property_count; public ushort field_count; public ushort event_count; public ushort nested_type_count; public ushort vtable_count; public ushort interfaces_count; public ushort interface_offsets_count; public byte typeHierarchyDepth; public byte rank; public byte minimumAlignment; public byte packingSize; public Bitfield0 _bitfield0; public Bitfield1 _bitfield1; } internal class NativeStructWrapper : INativeClassStruct, INativeStruct { private static int _bitfield0offset = Marshal.OffsetOf("_bitfield0").ToInt32(); private static int _bitfield1offset = Marshal.OffsetOf("_bitfield1").ToInt32(); private unsafe Il2CppClass* _klassDummy; public IntPtr Pointer { get; } private unsafe Il2CppClass_16_0* _ => (Il2CppClass_16_0*)(void*)Pointer; public unsafe IntPtr VTable => IntPtr.Add(Pointer, sizeof(Il2CppClass_16_0)); public unsafe Il2CppClass* ClassPointer => (Il2CppClass*)(void*)Pointer; public unsafe INativeTypeStruct ByValArg => UnityVersionHandler.Wrap(_->byval_arg); public unsafe INativeTypeStruct ThisArg => UnityVersionHandler.Wrap(_->this_arg); public unsafe ref uint InstanceSize => ref _->instance_size; public unsafe ref ushort VtableCount => ref _->vtable_count; public unsafe ref ushort InterfaceCount => ref _->interfaces_count; public unsafe ref ushort InterfaceOffsetsCount => ref _->interface_offsets_count; public unsafe ref byte TypeHierarchyDepth => ref _->typeHierarchyDepth; public unsafe ref int NativeSize => ref _->native_size; public unsafe ref uint ActualSize => ref _->actualSize; public unsafe ref ushort MethodCount => ref _->method_count; public unsafe ref ushort FieldCount => ref _->field_count; public unsafe ref Il2CppClassAttributes Flags => ref *(Il2CppClassAttributes*)(&_->flags); public unsafe ref IntPtr Name => ref *(IntPtr*)(&_->name); public unsafe ref IntPtr Namespace => ref *(IntPtr*)(&_->namespaze); public unsafe ref Il2CppImage* Image => ref _->image; public unsafe ref Il2CppClass* Parent => ref _->parent; public unsafe ref Il2CppClass* ElementClass => ref _->element_class; public unsafe ref Il2CppClass* CastClass => ref _->castClass; public unsafe ref Il2CppClass* DeclaringType => ref _->declaringType; public unsafe ref Il2CppClass* Class => ref _klassDummy; public unsafe ref Il2CppFieldInfo* Fields => ref _->fields; public unsafe ref Il2CppMethodInfo** Methods => ref _->methods; public unsafe ref Il2CppClass** ImplementedInterfaces => ref _->implementedInterfaces; public unsafe ref Il2CppRuntimeInterfaceOffsetPair* InterfaceOffsets => ref _->interfaceOffsets; public unsafe ref Il2CppClass** TypeHierarchy => ref _->typeHierarchy; public bool ValueType { get { return this.CheckBit(_bitfield0offset, 0); } set { this.SetBit(_bitfield0offset, 0, value); } } public bool Initialized { get { return this.CheckBit(_bitfield0offset, 1); } set { this.SetBit(_bitfield0offset, 1, value); } } public bool EnumType { get { return this.CheckBit(_bitfield0offset, 2); } set { this.SetBit(_bitfield0offset, 2, value); } } public bool IsGeneric { get { return this.CheckBit(_bitfield0offset, 3); } set { this.SetBit(_bitfield0offset, 3, value); } } public bool HasReferences { get { return this.CheckBit(_bitfield0offset, 4); } set { this.SetBit(_bitfield0offset, 4, value); } } public bool SizeInited { get { return this.CheckBit(_bitfield0offset, 6); } set { this.SetBit(_bitfield0offset, 6, value); } } public bool HasFinalize { get { return this.CheckBit(_bitfield0offset, 7); } set { this.SetBit(_bitfield0offset, 7, value); } } public bool IsVtableInitialized { get { return false; } set { } } public bool InitializedAndNoError { get { return true; } set { } } public NativeStructWrapper(IntPtr ptr) { Pointer = ptr; } } public unsafe int Size() { return sizeof(Il2CppClass_16_0); } public unsafe INativeClassStruct CreateNewStruct(int vTableSlots) { IntPtr intPtr = Marshal.AllocHGlobal(Size() + sizeof(VirtualInvokeData) * vTableSlots); Il2CppClass_16_0* ptr = (Il2CppClass_16_0*)(void*)intPtr; *ptr = default(Il2CppClass_16_0); Marshal.FreeHGlobal(intPtr); throw new NotSupportedException("The native struct 'Il2CppClass_16_0' has a vtable field which is not currently supported!"); } public unsafe INativeClassStruct Wrap(Il2CppClass* ptr) { if (ptr == null) { return null; } return new NativeStructWrapper((IntPtr)ptr); } } [ApplicableToUnityVersionsSince("5.3.2")] public class NativeClassStructHandler_19_0 : INativeClassStructHandler, INativeStructHandler { internal struct Il2CppClass_19_0 { internal enum Bitfield0 : byte { BIT_valuetype = 0, valuetype = 1, BIT_initialized = 1, initialized = 2, BIT_enumtype = 2, enumtype = 4, BIT_is_generic = 3, is_generic = 8, BIT_has_references = 4, has_references = 16, BIT_init_pending = 5, init_pending = 32, BIT_size_inited = 6, size_inited = 64, BIT_has_finalize = 7, has_finalize = 128 } internal enum Bitfield1 : byte { BIT_has_cctor = 0, has_cctor = 1, BIT_is_blittable = 1, is_blittable = 2 } public unsafe Il2CppImage* image; public unsafe void* gc_desc; public unsafe byte* name; public unsafe byte* namespaze; public unsafe Il2CppTypeStruct* byval_arg; public unsafe Il2CppTypeStruct* this_arg; public unsafe Il2CppClass* element_class; public unsafe Il2CppClass* castClass; public unsafe Il2CppClass* declaringType; public unsafe Il2CppClass* parent; public unsafe void* generic_class; public unsafe void* typeDefinition; public unsafe Il2CppFieldInfo* fields; public unsafe Il2CppEventInfo* events; public unsafe Il2CppPropertyInfo* properties; public unsafe Il2CppMethodInfo** methods; public unsafe Il2CppClass** nestedTypes; public unsafe Il2CppClass** implementedInterfaces; public unsafe Il2CppMethodInfo** vtable; public unsafe Il2CppRuntimeInterfaceOffsetPair* interfaceOffsets; public unsafe void* static_fields; public unsafe void* rgctx_data; public unsafe Il2CppClass** typeHierarchy; public uint cctor_started; public uint cctor_finished; public ulong cctor_thread; public int genericContainerIndex; public int customAttributeIndex; public uint instance_size; public uint actualSize; public uint element_size; public int native_size; public uint static_fields_size; public uint thread_static_fields_size; public int thread_static_fields_offset; public uint flags; public uint token; public ushort method_count; public ushort property_count; public ushort field_count; public ushort event_count; public ushort nested_type_count; public ushort vtable_count; public ushort interfaces_count; public ushort interface_offsets_count; public byte typeHierarchyDepth; public byte rank; public byte minimumAlignment; public byte packingSize; public Bitfield0 _bitfield0; public Bitfield1 _bitfield1; } internal class NativeStructWrapper : INativeClassStruct, INativeStruct { private static int _bitfield0offset = Marshal.OffsetOf("_bitfield0").ToInt32(); private static int _bitfield1offset = Marshal.OffsetOf("_bitfield1").ToInt32(); private unsafe Il2CppClass* _klassDummy; public IntPtr Pointer { get; } private unsafe Il2CppClass_19_0* _ => (Il2CppClass_19_0*)(void*)Pointer; public unsafe IntPtr VTable => IntPtr.Add(Pointer, sizeof(Il2CppClass_19_0)); public unsafe Il2CppClass* ClassPointer => (Il2CppClass*)(void*)Pointer; public unsafe INativeTypeStruct ByValArg => UnityVersionHandler.Wrap(_->byval_arg); public unsafe INativeTypeStruct ThisArg => UnityVersionHandler.Wrap(_->this_arg); public unsafe ref uint InstanceSize => ref _->instance_size; public unsafe ref ushort VtableCount => ref _->vtable_count; public unsafe ref ushort InterfaceCount => ref _->interfaces_count; public unsafe ref ushort InterfaceOffsetsCount => ref _->interface_offsets_count; public unsafe ref byte TypeHierarchyDepth => ref _->typeHierarchyDepth; public unsafe ref int NativeSize => ref _->native_size; public unsafe ref uint ActualSize => ref _->actualSize; public unsafe ref ushort MethodCount => ref _->method_count; public unsafe ref ushort FieldCount => ref _->field_count; public unsafe ref Il2CppClassAttributes Flags => ref *(Il2CppClassAttributes*)(&_->flags); public unsafe ref IntPtr Name => ref *(IntPtr*)(&_->name); public unsafe ref IntPtr Namespace => ref *(IntPtr*)(&_->namespaze); public unsafe ref Il2CppImage* Image => ref _->image; public unsafe ref Il2CppClass* Parent => ref _->parent; public unsafe ref Il2CppClass* ElementClass => ref _->element_class; public unsafe ref Il2CppClass* CastClass => ref _->castClass; public unsafe ref Il2CppClass* DeclaringType => ref _->declaringType; public unsafe ref Il2CppClass* Class => ref _klassDummy; public unsafe ref Il2CppFieldInfo* Fields => ref _->fields; public unsafe ref Il2CppMethodInfo** Methods => ref _->methods; public unsafe ref Il2CppClass** ImplementedInterfaces => ref _->implementedInterfaces; public unsafe ref Il2CppRuntimeInterfaceOffsetPair* InterfaceOffsets => ref _->interfaceOffsets; public unsafe ref Il2CppClass** TypeHierarchy => ref _->typeHierarchy; public bool ValueType { get { return this.CheckBit(_bitfield0offset, 0); } set { this.SetBit(_bitfield0offset, 0, value); } } public bool Initialized { get { return this.CheckBit(_bitfield0offset, 1); } set { this.SetBit(_bitfield0offset, 1, value); } } public bool EnumType { get { return this.CheckBit(_bitfield0offset, 2); } set { this.SetBit(_bitfield0offset, 2, value); } } public bool IsGeneric { get { return this.CheckBit(_bitfield0offset, 3); } set { this.SetBit(_bitfield0offset, 3, value); } } public bool HasReferences { get { return this.CheckBit(_bitfield0offset, 4); } set { this.SetBit(_bitfield0offset, 4, value); } } public bool SizeInited { get { return this.CheckBit(_bitfield0offset, 6); } set { this.SetBit(_bitfield0offset, 6, value); } } public bool HasFinalize { get { return this.CheckBit(_bitfield0offset, 7); } set { this.SetBit(_bitfield0offset, 7, value); } } public bool IsVtableInitialized { get { return false; } set { } } public bool InitializedAndNoError { get { return true; } set { } } public NativeStructWrapper(IntPtr ptr) { Pointer = ptr; } } public unsafe int Size() { return sizeof(Il2CppClass_19_0); } public unsafe INativeClassStruct CreateNewStruct(int vTableSlots) { IntPtr intPtr = Marshal.AllocHGlobal(Size() + sizeof(VirtualInvokeData) * vTableSlots); Il2CppClass_19_0* ptr = (Il2CppClass_19_0*)(void*)intPtr; *ptr = default(Il2CppClass_19_0); Marshal.FreeHGlobal(intPtr); throw new NotSupportedException("The native struct 'Il2CppClass_19_0' has a vtable field which is not currently supported!"); } public unsafe INativeClassStruct Wrap(Il2CppClass* ptr) { if (ptr == null) { return null; } return new NativeStructWrapper((IntPtr)ptr); } } [ApplicableToUnityVersionsSince("5.3.3")] public class NativeClassStructHandler_20_0 : INativeClassStructHandler, INativeStructHandler { internal struct Il2CppClass_20_0 { internal enum Bitfield0 : byte { BIT_valuetype = 0, valuetype = 1, BIT_initialized = 1, initialized = 2, BIT_enumtype = 2, enumtype = 4, BIT_is_generic = 3, is_generic = 8, BIT_has_references = 4, has_references = 16, BIT_init_pending = 5, init_pending = 32, BIT_size_inited = 6, size_inited = 64, BIT_has_finalize = 7, has_finalize = 128 } internal enum Bitfield1 : byte { BIT_has_cctor = 0, has_cctor = 1, BIT_is_blittable = 1, is_blittable = 2, BIT_is_import = 2, is_import = 4 } public unsafe Il2CppImage* image; public unsafe void* gc_desc; public unsafe byte* name; public unsafe byte* namespaze; public unsafe Il2CppTypeStruct* byval_arg; public unsafe Il2CppTypeStruct* this_arg; public unsafe Il2CppClass* element_class; public unsafe Il2CppClass* castClass; public unsafe Il2CppClass* declaringType; public unsafe Il2CppClass* parent; public unsafe void* generic_class; public unsafe void* typeDefinition; public unsafe Il2CppFieldInfo* fields; public unsafe Il2CppEventInfo* events; public unsafe Il2CppPropertyInfo* properties; public unsafe Il2CppMethodInfo** methods; public unsafe Il2CppClass** nestedTypes; public unsafe Il2CppClass** implementedInterfaces; public unsafe Il2CppMethodInfo** vtable; public unsafe Il2CppRuntimeInterfaceOffsetPair* interfaceOffsets; public unsafe void* static_fields; public unsafe void* rgctx_data; public unsafe Il2CppClass** typeHierarchy; public uint cctor_started; public uint cctor_finished; public ulong cctor_thread; public int genericContainerIndex; public int customAttributeIndex; public uint instance_size; public uint actualSize; public uint element_size; public int native_size; public uint static_fields_size; public uint thread_static_fields_size; public int thread_static_fields_offset; public uint flags; public uint token; public ushort method_count; public ushort property_count; public ushort field_count; public ushort event_count; public ushort nested_type_count; public ushort vtable_count; public ushort interfaces_count; public ushort interface_offsets_count; public byte typeHierarchyDepth; public byte rank; public byte minimumAlignment; public byte packingSize; public Bitfield0 _bitfield0; public Bitfield1 _bitfield1; } internal class NativeStructWrapper : INativeClassStruct, INativeStruct { private static int _bitfield0offset = Marshal.OffsetOf("_bitfield0").ToInt32(); private static int _bitfield1offset = Marshal.OffsetOf("_bitfield1").ToInt32(); private unsafe Il2CppClass* _klassDummy; public IntPtr Pointer { get; } private unsafe Il2CppClass_20_0* _ => (Il2CppClass_20_0*)(void*)Pointer; public unsafe IntPtr VTable => IntPtr.Add(Pointer, sizeof(Il2CppClass_20_0)); public unsafe Il2CppClass* ClassPointer => (Il2CppClass*)(void*)Pointer; public unsafe INativeTypeStruct ByValArg => UnityVersionHandler.Wrap(_->byval_arg); public unsafe INativeTypeStruct ThisArg => UnityVersionHandler.Wrap(_->this_arg); public unsafe ref uint InstanceSize => ref _->instance_size; public unsafe ref ushort VtableCount => ref _->vtable_count; public unsafe ref ushort InterfaceCount => ref _->interfaces_count; public unsafe ref ushort InterfaceOffsetsCount => ref _->interface_offsets_count; public unsafe ref byte TypeHierarchyDepth => ref _->typeHierarchyDepth; public unsafe ref int NativeSize => ref _->native_size; public unsafe ref uint ActualSize => ref _->actualSize; public unsafe ref ushort MethodCount => ref _->method_count; public unsafe ref ushort FieldCount => ref _->field_count; public unsafe ref Il2CppClassAttributes Flags => ref *(Il2CppClassAttributes*)(&_->flags); public unsafe ref IntPtr Name => ref *(IntPtr*)(&_->name); public unsafe ref IntPtr Namespace => ref *(IntPtr*)(&_->namespaze); public unsafe ref Il2CppImage* Image => ref _->image; public unsafe ref Il2CppClass* Parent => ref _->parent; public unsafe ref Il2CppClass* ElementClass => ref _->element_class; public unsafe ref Il2CppClass* CastClass => ref _->castClass; public unsafe ref Il2CppClass* DeclaringType => ref _->declaringType; public unsafe ref Il2CppClass* Class => ref _klassDummy; public unsafe ref Il2CppFieldInfo* Fields => ref _->fields; public unsafe ref Il2CppMethodInfo** Methods => ref _->methods; public unsafe ref Il2CppClass** ImplementedInterfaces => ref _->implementedInterfaces; public unsafe ref Il2CppRuntimeInterfaceOffsetPair* InterfaceOffsets => ref _->interfaceOffsets; public unsafe ref Il2CppClass** TypeHierarchy => ref _->typeHierarchy; public bool ValueType { get { return this.CheckBit(_bitfield0offset, 0); } set { this.SetBit(_bitfield0offset, 0, value); } } public bool Initialized { get { return this.CheckBit(_bitfield0offset, 1); } set { this.SetBit(_bitfield0offset, 1, value); } } public bool EnumType { get { return this.CheckBit(_bitfield0offset, 2); } set { this.SetBit(_bitfield0offset, 2, value); } } public bool IsGeneric { get { return this.CheckBit(_bitfield0offset, 3); } set { this.SetBit(_bitfield0offset, 3, value); } } public bool HasReferences { get { return this.CheckBit(_bitfield0offset, 4); } set { this.SetBit(_bitfield0offset, 4, value); } } public bool SizeInited { get { return this.CheckBit(_bitfield0offset, 6); } set { this.SetBit(_bitfield0offset, 6, value); } } public bool HasFinalize { get { return this.CheckBit(_bitfield0offset, 7); } set { this.SetBit(_bitfield0offset, 7, value); } } public bool IsVtableInitialized { get { return false; } set { } } public bool InitializedAndNoError { get { return true; } set { } } public NativeStructWrapper(IntPtr ptr) { Pointer = ptr; } } public unsafe int Size() { return sizeof(Il2CppClass_20_0); } public unsafe INativeClassStruct CreateNewStruct(int vTableSlots) { IntPtr intPtr = Marshal.AllocHGlobal(Size() + sizeof(VirtualInvokeData) * vTableSlots); Il2CppClass_20_0* ptr = (Il2CppClass_20_0*)(void*)intPtr; *ptr = default(Il2CppClass_20_0); Marshal.FreeHGlobal(intPtr); throw new NotSupportedException("The native struct 'Il2CppClass_20_0' has a vtable field which is not currently supported!"); } public unsafe INativeClassStruct Wrap(Il2CppClass* ptr) { if (ptr == null) { return null; } return new NativeStructWrapper((IntPtr)ptr); } } [ApplicableToUnityVersionsSince("5.3.6")] public class NativeClassStructHandler_21_0 : INativeClassStructHandler, INativeStructHandler { internal struct Il2CppClass_21_0 { internal enum Bitfield0 : byte { BIT_valuetype = 0, valuetype = 1, BIT_initialized = 1, initialized = 2, BIT_enumtype = 2, enumtype = 4, BIT_is_generic = 3, is_generic = 8, BIT_has_references = 4, has_references = 16, BIT_init_pending = 5, init_pending = 32, BIT_size_inited = 6, size_inited = 64, BIT_has_finalize = 7, has_finalize = 128 } internal enum Bitfield1 : byte { BIT_has_cctor = 0, has_cctor = 1, BIT_is_blittable = 1, is_blittable = 2, BIT_is_import_or_windows_runtime = 2, is_import_or_windows_runtime = 4 } public unsafe Il2CppImage* image; public unsafe void* gc_desc; public unsafe byte* name; public unsafe byte* namespaze; public unsafe Il2CppTypeStruct* byval_arg; public unsafe Il2CppTypeStruct* this_arg; public unsafe Il2CppClass* element_class; public unsafe Il2CppClass* castClass; public unsafe Il2CppClass* declaringType; public unsafe Il2CppClass* parent; public unsafe void* generic_class; public unsafe void* typeDefinition; public unsafe Il2CppFieldInfo* fields; public unsafe Il2CppEventInfo* events; public unsafe Il2CppPropertyInfo* properties; public unsafe Il2CppMethodInfo** methods; public unsafe Il2CppClass** nestedTypes; public unsafe Il2CppClass** implementedInterfaces; public unsafe VirtualInvokeData* vtable; public unsafe Il2CppRuntimeInterfaceOffsetPair* interfaceOffsets; public unsafe void* static_fields; public unsafe void* rgctx_data; public unsafe Il2CppClass** typeHierarchy; public uint cctor_started; public uint cctor_finished; public ulong cctor_thread; public int genericContainerIndex; public int customAttributeIndex; public uint instance_size; public uint actualSize; public uint element_size; public int native_size; public uint static_fields_size; public uint thread_static_fields_size; public int thread_static_fields_offset; public uint flags; public uint token; public ushort method_count; public ushort property_count; public ushort field_count; public ushort event_count; public ushort nested_type_count; public ushort vtable_count; public ushort interfaces_count; public ushort interface_offsets_count; public byte typeHierarchyDepth; public byte rank; public byte minimumAlignment; public byte packingSize; public Bitfield0 _bitfield0; public Bitfield1 _bitfield1; } internal class NativeStructWrapper : INativeClassStruct, INativeStruct { private static int _bitfield0offset = Marshal.OffsetOf("_bitfield0").ToInt32(); private static int _bitfield1offset = Marshal.OffsetOf("_bitfield1").ToInt32(); private unsafe Il2CppClass* _klassDummy; public IntPtr Pointer { get; } private unsafe Il2CppClass_21_0* _ => (Il2CppClass_21_0*)(void*)Pointer; public unsafe IntPtr VTable => IntPtr.Add(Pointer, sizeof(Il2CppClass_21_0)); public unsafe Il2CppClass* ClassPointer => (Il2CppClass*)(void*)Pointer; public unsafe INativeTypeStruct ByValArg => UnityVersionHandler.Wrap(_->byval_arg); public unsafe INativeTypeStruct ThisArg => UnityVersionHandler.Wrap(_->this_arg); public unsafe ref uint InstanceSize => ref _->instance_size; public unsafe ref ushort VtableCount => ref _->vtable_count; public unsafe ref ushort InterfaceCount => ref _->interfaces_count; public unsafe ref ushort InterfaceOffsetsCount => ref _->interface_offsets_count; public unsafe ref byte TypeHierarchyDepth => ref _->typeHierarchyDepth; public unsafe ref int NativeSize => ref _->native_size; public unsafe ref uint ActualSize => ref _->actualSize; public unsafe ref ushort MethodCount => ref _->method_count; public unsafe ref ushort FieldCount => ref _->field_count; public unsafe ref Il2CppClassAttributes Flags => ref *(Il2CppClassAttributes*)(&_->flags); public unsafe ref IntPtr Name => ref *(IntPtr*)(&_->name); public unsafe ref IntPtr Namespace => ref *(IntPtr*)(&_->namespaze); public unsafe ref Il2CppImage* Image => ref _->image; public unsafe ref Il2CppClass* Parent => ref _->parent; public unsafe ref Il2CppClass* ElementClass => ref _->element_class; public unsafe ref Il2CppClass* CastClass => ref _->castClass; public unsafe ref Il2CppClass* DeclaringType => ref _->declaringType; public unsafe ref Il2CppClass* Class => ref _klassDummy; public unsafe ref Il2CppFieldInfo* Fields => ref _->fields; public unsafe ref Il2CppMethodInfo** Methods => ref _->methods; public unsafe ref Il2CppClass** ImplementedInterfaces => ref _->implementedInterfaces; public unsafe ref Il2CppRuntimeInterfaceOffsetPair* InterfaceOffsets => ref _->interfaceOffsets; public unsafe ref Il2CppClass** TypeHierarchy => ref _->typeHierarchy; public bool ValueType { get { return this.CheckBit(_bitfield0offset, 0); } set { this.SetBit(_bitfield0offset, 0, value); } } public bool Initialized { get { return this.CheckBit(_bitfield0offset, 1); } set { this.SetBit(_bitfield0offset, 1, value); } } public bool EnumType { get { return this.CheckBit(_bitfield0offset, 2); } set { this.SetBit(_bitfield0offset, 2, value); } } public bool IsGeneric { get { return this.CheckBit(_bitfield0offset, 3); } set { this.SetBit(_bitfield0offset, 3, value); } } public bool HasReferences { get { return this.CheckBit(_bitfield0offset, 4); } set { this.SetBit(_bitfield0offset, 4, value); } } public bool SizeInited { get { return this.CheckBit(_bitfield0offset, 6); } set { this.SetBit(_bitfield0offset, 6, value); } } public bool HasFinalize { get { return this.CheckBit(_bitfield0offset, 7); } set { this.SetBit(_bitfield0offset, 7, value); } } public bool IsVtableInitialized { get { return false; } set { } } public bool InitializedAndNoError { get { return true; } set { } } public NativeStructWrapper(IntPtr ptr) { Pointer = ptr; } } public unsafe int Size() { return sizeof(Il2CppClass_21_0); } public unsafe INativeClassStruct CreateNewStruct(int vTableSlots) { IntPtr intPtr = Marshal.AllocHGlobal(Size() + sizeof(VirtualInvokeData) * vTableSlots); Il2CppClass_21_0* ptr = (Il2CppClass_21_0*)(void*)intPtr; *ptr = default(Il2CppClass_21_0); Marshal.FreeHGlobal(intPtr); throw new NotSupportedException("The native struct 'Il2CppClass_21_0' has a vtable field which is not currently supported!"); } public unsafe INativeClassStruct Wrap(Il2CppClass* ptr) { if (ptr == null) { return null; } return new NativeStructWrapper((IntPtr)ptr); } } [ApplicableToUnityVersionsSince("5.4.4")] public class NativeClassStructHandler_21_1 : INativeClassStructHandler, INativeStructHandler { internal struct Il2CppClass_21_1 { internal enum Bitfield0 : byte { BIT_valuetype = 0, valuetype = 1, BIT_initialized = 1, initialized = 2, BIT_enumtype = 2, enumtype = 4, BIT_is_generic = 3, is_generic = 8, BIT_has_references = 4, has_references = 16, BIT_init_pending = 5, init_pending = 32, BIT_size_inited = 6, size_inited = 64, BIT_has_finalize = 7, has_finalize = 128 } internal enum Bitfield1 : byte { BIT_has_cctor = 0, has_cctor = 1, BIT_is_blittable = 1, is_blittable = 2, BIT_is_import_or_windows_runtime = 2, is_import_or_windows_runtime = 4 } public unsafe Il2CppImage* image; public unsafe void* gc_desc; public unsafe byte* name; public unsafe byte* namespaze; public unsafe Il2CppTypeStruct* byval_arg; public unsafe Il2CppTypeStruct* this_arg; public unsafe Il2CppClass* element_class; public unsafe Il2CppClass* castClass; public unsafe Il2CppClass* declaringType; public unsafe Il2CppClass* parent; public unsafe void* generic_class; public unsafe void* typeDefinition; public unsafe Il2CppFieldInfo* fields; public unsafe Il2CppEventInfo* events; public unsafe Il2CppPropertyInfo* properties; public unsafe Il2CppMethodInfo** methods; public unsafe Il2CppClass** nestedTypes; public unsafe Il2CppClass** implementedInterfaces; public unsafe VirtualInvokeData* vtable; public unsafe Il2CppRuntimeInterfaceOffsetPair* interfaceOffsets; public unsafe void* static_fields; public unsafe void* rgctx_data; public unsafe Il2CppClass** typeHierarchy; public uint cctor_started; public uint cctor_finished; public ulong cctor_thread; public int genericContainerIndex; public int customAttributeIndex; public uint instance_size; public uint actualSize; public uint element_size; public int native_size; public uint static_fields_size; public uint thread_static_fields_size; public int thread_static_fields_offset; public uint flags; public uint token; public ushort method_count; public ushort property_count; public ushort field_count; public ushort event_count; public ushort nested_type_count; public ushort vtable_count; public ushort interfaces_count; public ushort interface_offsets_count; public byte typeHierarchyDepth; public byte genericRecursionDepth; public byte rank; public byte minimumAlignment; public byte packingSize; public Bitfield0 _bitfield0; public Bitfield1 _bitfield1; } internal class NativeStructWrapper : INativeClassStruct, INativeStruct { private static int _bitfield0offset = Marshal.OffsetOf("_bitfield0").ToInt32(); private static int _bitfield1offset = Marshal.OffsetOf("_bitfield1").ToInt32(); private unsafe Il2CppClass* _klassDummy; public IntPtr Pointer { get; } private unsafe Il2CppClass_21_1* _ => (Il2CppClass_21_1*)(void*)Pointer; public unsafe IntPtr VTable => IntPtr.Add(Pointer, sizeof(Il2CppClass_21_1)); public unsafe Il2CppClass* ClassPointer => (Il2CppClass*)(void*)Pointer; public unsafe INativeTypeStruct ByValArg => UnityVersionHandler.Wrap(_->byval_arg); public unsafe INativeTypeStruct ThisArg => UnityVersionHandler.Wrap(_->this_arg); public unsafe ref uint InstanceSize => ref _->instance_size; public unsafe ref ushort VtableCount => ref _->vtable_count; public unsafe ref ushort InterfaceCount => ref _->interfaces_count; public unsafe ref ushort InterfaceOffsetsCount => ref _->interface_offsets_count; public unsafe ref byte TypeHierarchyDepth => ref _->typeHierarchyDepth; public unsafe ref int NativeSize => ref _->native_size; public unsafe ref uint ActualSize => ref _->actualSize; public unsafe ref ushort MethodCount => ref _->method_count; public unsafe ref ushort FieldCount => ref _->field_count; public unsafe ref Il2CppClassAttributes Flags => ref *(Il2CppClassAttributes*)(&_->flags); public unsafe ref IntPtr Name => ref *(IntPtr*)(&_->name); public unsafe ref IntPtr Namespace => ref *(IntPtr*)(&_->namespaze); public unsafe ref Il2CppImage* Image => ref _->image; public unsafe ref Il2CppClass* Parent => ref _->parent; public unsafe ref Il2CppClass* ElementClass => ref _->element_class; public unsafe ref Il2CppClass* CastClass => ref _->castClass; public unsafe ref Il2CppClass* DeclaringType => ref _->declaringType; public unsafe ref Il2CppClass* Class => ref _klassDummy; public unsafe ref Il2CppFieldInfo* Fields => ref _->fields; public unsafe ref Il2CppMethodInfo** Methods => ref _->methods; public unsafe ref Il2CppClass** ImplementedInterfaces => ref _->implementedInterfaces; public unsafe ref Il2CppRuntimeInterfaceOffsetPair* InterfaceOffsets => ref _->interfaceOffsets; public unsafe ref Il2CppClass** TypeHierarchy => ref _->typeHierarchy; public bool ValueType { get { return this.CheckBit(_bitfield0offset, 0); } set { this.SetBit(_bitfield0offset, 0, value); } } public bool Initialized { get { return this.CheckBit(_bitfield0offset, 1); } set { this.SetBit(_bitfield0offset, 1, value); } } public bool EnumType { get { return this.CheckBit(_bitfield0offset, 2); } set { this.SetBit(_bitfield0offset, 2, value); } } public bool IsGeneric { get { return this.CheckBit(_bitfield0offset, 3); } set { this.SetBit(_bitfield0offset, 3, value); } } public bool HasReferences { get { return this.CheckBit(_bitfield0offset, 4); } set { this.SetBit(_bitfield0offset, 4, value); } } public bool SizeInited { get { return this.CheckBit(_bitfield0offset, 6); } set { this.SetBit(_bitfield0offset, 6, value); } } public bool HasFinalize { get { return this.CheckBit(_bitfield0offset, 7); } set { this.SetBit(_bitfield0offset, 7, value); } } public bool IsVtableInitialized { get { return false; } set { } } public bool InitializedAndNoError { get { return true; } set { } } public NativeStructWrapper(IntPtr ptr) { Pointer = ptr; } } public unsafe int Size() { return sizeof(Il2CppClass_21_1); } public unsafe INativeClassStruct CreateNewStruct(int vTableSlots) { IntPtr intPtr = Marshal.AllocHGlobal(Size() + sizeof(VirtualInvokeData) * vTableSlots); Il2CppClass_21_1* ptr = (Il2CppClass_21_1*)(void*)intPtr; *ptr = default(Il2CppClass_21_1); Marshal.FreeHGlobal(intPtr); throw new NotSupportedException("The native struct 'Il2CppClass_21_1' has a vtable field which is not currently supported!"); } public unsafe INativeClassStruct Wrap(Il2CppClass* ptr) { if (ptr == null) { return null; } return new NativeStructWrapper((IntPtr)ptr); } } [ApplicableToUnityVersionsSince("5.5.0")] public class NativeClassStructHandler_22_0 : INativeClassStructHandler, INativeStructHandler { internal struct Il2CppClass_22_0 { internal enum Bitfield0 : byte { BIT_valuetype = 0, valuetype = 1, BIT_initialized = 1, initialized = 2, BIT_enumtype = 2, enumtype = 4, BIT_is_generic = 3, is_generic = 8, BIT_has_references = 4, has_references = 16, BIT_init_pending = 5, init_pending = 32, BIT_size_inited = 6, size_inited = 64, BIT_has_finalize = 7, has_finalize = 128 } internal enum Bitfield1 : byte { BIT_has_cctor = 0, has_cctor = 1, BIT_is_blittable = 1, is_blittable = 2, BIT_is_import_or_windows_runtime = 2, is_import_or_windows_runtime = 4, BIT_is_vtable_initialized = 3, is_vtable_initialized = 8 } public unsafe Il2CppImage* image; public unsafe void* gc_desc; public unsafe byte* name; public unsafe byte* namespaze; public unsafe Il2CppTypeStruct* byval_arg; public unsafe Il2CppTypeStruct* this_arg; public unsafe Il2CppClass* element_class; public unsafe Il2CppClass* castClass; public unsafe Il2CppClass* declaringType; public unsafe Il2CppClass* parent; public unsafe void* generic_class; public unsafe void* typeDefinition; public unsafe Il2CppFieldInfo* fields; public unsafe Il2CppEventInfo* events; public unsafe Il2CppPropertyInfo* properties; public unsafe Il2CppMethodInfo** methods; public unsafe Il2CppClass** nestedTypes; public unsafe Il2CppClass** implementedInterfaces; public unsafe Il2CppRuntimeInterfaceOffsetPair* interfaceOffsets; public unsafe void* static_fields; public unsafe void* rgctx_data; public unsafe Il2CppClass** typeHierarchy; public uint cctor_started; public uint cctor_finished; public ulong cctor_thread; public int genericContainerIndex; public int customAttributeIndex; public uint instance_size; public uint actualSize; public uint element_size; public int native_size; public uint static_fields_size; public uint thread_static_fields_size; public int thread_static_fields_offset; public uint flags; public uint token; public ushort method_count; public ushort property_count; public ushort field_count; public ushort event_count; public ushort nested_type_count; public ushort vtable_count; public ushort interfaces_count; public ushort interface_offsets_count; public byte typeHierarchyDepth; public byte rank; public byte minimumAlignment; public byte packingSize; public Bitfield0 _bitfield0; public Bitfield1 _bitfield1; } internal class NativeStructWrapper : INativeClassStruct, INativeStruct { private static int _bitfield0offset = Marshal.OffsetOf("_bitfield0").ToInt32(); private static int _bitfield1offset = Marshal.OffsetOf("_bitfield1").ToInt32(); private unsafe Il2CppClass* _klassDummy; public IntPtr Pointer { get; } private unsafe Il2CppClass_22_0* _ => (Il2CppClass_22_0*)(void*)Pointer; public unsafe IntPtr VTable => IntPtr.Add(Pointer, sizeof(Il2CppClass_22_0)); public unsafe Il2CppClass* ClassPointer => (Il2CppClass*)(void*)Pointer; public unsafe INativeTypeStruct ByValArg => UnityVersionHandler.Wrap(_->byval_arg); public unsafe INativeTypeStruct ThisArg => UnityVersionHandler.Wrap(_->this_arg); public unsafe ref uint InstanceSize => ref _->instance_size; public unsafe ref ushort VtableCount => ref _->vtable_count; public unsafe ref ushort InterfaceCount => ref _->interfaces_count; public unsafe ref ushort InterfaceOffsetsCount => ref _->interface_offsets_count; public unsafe ref byte TypeHierarchyDepth => ref _->typeHierarchyDepth; public unsafe ref int NativeSize => ref _->native_size; public unsafe ref uint ActualSize => ref _->actualSize; public unsafe ref ushort MethodCount => ref _->method_count; public unsafe ref ushort FieldCount => ref _->field_count; public unsafe ref Il2CppClassAttributes Flags => ref *(Il2CppClassAttributes*)(&_->flags); public unsafe ref IntPtr Name => ref *(IntPtr*)(&_->name); public unsafe ref IntPtr Namespace => ref *(IntPtr*)(&_->namespaze); public unsafe ref Il2CppImage* Image => ref _->image; public unsafe ref Il2CppClass* Parent => ref _->parent; public unsafe ref Il2CppClass* ElementClass => ref _->element_class; public unsafe ref Il2CppClass* CastClass => ref _->castClass; public unsafe ref Il2CppClass* DeclaringType => ref _->declaringType; public unsafe ref Il2CppClass* Class => ref _klassDummy; public unsafe ref Il2CppFieldInfo* Fields => ref _->fields; public unsafe ref Il2CppMethodInfo** Methods => ref _->methods; public unsafe ref Il2CppClass** ImplementedInterfaces => ref _->implementedInterfaces; public unsafe ref Il2CppRuntimeInterfaceOffsetPair* InterfaceOffsets => ref _->interfaceOffsets; public unsafe ref Il2CppClass** TypeHierarchy => ref _->typeHierarchy; public bool ValueType { get { return this.CheckBit(_bitfield0offset, 0); } set { this.SetBit(_bitfield0offset, 0, value); } } public bool Initialized { get { return this.CheckBit(_bitfield0offset, 1); } set { this.SetBit(_bitfield0offset, 1, value); } } public bool EnumType { get { return this.CheckBit(_bitfield0offset, 2); } set { this.SetBit(_bitfield0offset, 2, value); } } public bool IsGeneric { get { return this.CheckBit(_bitfield0offset, 3); } set { this.SetBit(_bitfield0offset, 3, value); } } public bool HasReferences { get { return this.CheckBit(_bitfield0offset, 4); } set { this.SetBit(_bitfield0offset, 4, value); } } public bool SizeInited { get { return this.CheckBit(_bitfield0offset, 6); } set { this.SetBit(_bitfield0offset, 6, value); } } public bool HasFinalize { get { return this.CheckBit(_bitfield0offset, 7); } set { this.SetBit(_bitfield0offset, 7, value); } } public bool IsVtableInitialized { get { return this.CheckBit(_bitfield1offset, 3); } set { this.SetBit(_bitfield1offset, 3, value); } } public bool InitializedAndNoError { get { return true; } set { } } public NativeStructWrapper(IntPtr ptr) { Pointer = ptr; } } public unsafe int Size() { return sizeof(Il2CppClass_22_0); } public unsafe INativeClassStruct CreateNewStruct(int vTableSlots) { IntPtr intPtr = Marshal.AllocHGlobal(Size() + sizeof(VirtualInvokeData) * vTableSlots); Il2CppClass_22_0* ptr = (Il2CppClass_22_0*)(void*)intPtr; *ptr = default(Il2CppClass_22_0); ptr->byval_arg = UnityVersionHandler.NewType().TypePointer; ptr->this_arg = UnityVersionHandler.NewType().TypePointer; return new NativeStructWrapper(intPtr); } public unsafe INativeClassStruct Wrap(Il2CppClass* ptr) { if (ptr == null) { return null; } return new NativeStructWrapper((IntPtr)ptr); } } [ApplicableToUnityVersionsSince("5.5.1")] public class NativeClassStructHandler_22_1 : INativeClassStructHandler, INativeStructHandler { internal struct Il2CppClass_22_1 { internal enum Bitfield0 : byte { BIT_valuetype = 0, valuetype = 1, BIT_initialized = 1, initialized = 2, BIT_enumtype = 2, enumtype = 4, BIT_is_generic = 3, is_generic = 8, BIT_has_references = 4, has_references = 16, BIT_init_pending = 5, init_pending = 32, BIT_size_inited = 6, size_inited = 64, BIT_has_finalize = 7, has_finalize = 128 } internal enum Bitfield1 : byte { BIT_has_cctor = 0, has_cctor = 1, BIT_is_blittable = 1, is_blittable = 2, BIT_is_import_or_windows_runtime = 2, is_import_or_windows_runtime = 4, BIT_is_vtable_initialized = 3, is_vtable_initialized = 8 } public unsafe Il2CppImage* image; public unsafe void* gc_desc; public unsafe byte* name; public unsafe byte* namespaze; public unsafe Il2CppTypeStruct* byval_arg; public unsafe Il2CppTypeStruct* this_arg; public unsafe Il2CppClass* element_class; public unsafe Il2CppClass* castClass; public unsafe Il2CppClass* declaringType; public unsafe Il2CppClass* parent; public unsafe void* generic_class; public unsafe void* typeDefinition; public unsafe Il2CppFieldInfo* fields; public unsafe Il2CppEventInfo* events; public unsafe Il2CppPropertyInfo* properties; public unsafe Il2CppMethodInfo** methods; public unsafe Il2CppClass** nestedTypes; public unsafe Il2CppClass** implementedInterfaces; public unsafe Il2CppRuntimeInterfaceOffsetPair* interfaceOffsets; public unsafe void* static_fields; public unsafe void* rgctx_data; public unsafe Il2CppClass** typeHierarchy; public uint cctor_started; public uint cctor_finished; public ulong cctor_thread; public int genericContainerIndex; public int customAttributeIndex; public uint instance_size; public uint actualSize; public uint element_size; public int native_size; public uint static_fields_size; public uint thread_static_fields_size; public int thread_static_fields_offset; public uint flags; public uint token; public ushort method_count; public ushort property_count; public ushort field_count; public ushort event_count; public ushort nested_type_count; public ushort vtable_count; public ushort interfaces_count; public ushort interface_offsets_count; public byte typeHierarchyDepth; public byte genericRecursionDepth; public byte rank; public byte minimumAlignment; public byte packingSize; public Bitfield0 _bitfield0; public Bitfield1 _bitfield1; } internal class NativeStructWrapper : INativeClassStruct, INativeStruct { private static int _bitfield0offset = Marshal.OffsetOf("_bitfield0").ToInt32(); private static int _bitfield1offset = Marshal.OffsetOf("_bitfield1").ToInt32(); private unsafe Il2CppClass* _klassDummy; public IntPtr Pointer { get; } private unsafe Il2CppClass_22_1* _ => (Il2CppClass_22_1*)(void*)Pointer; public unsafe IntPtr VTable => IntPtr.Add(Pointer, sizeof(Il2CppClass_22_1)); public unsafe Il2CppClass* ClassPointer => (Il2CppClass*)(void*)Pointer; public unsafe INativeTypeStruct ByValArg => UnityVersionHandler.Wrap(_->byval_arg); public unsafe INativeTypeStruct ThisArg => UnityVersionHandler.Wrap(_->this_arg); public unsafe ref uint InstanceSize => ref _->instance_size; public unsafe ref ushort VtableCount => ref _->vtable_count; public unsafe ref ushort InterfaceCount => ref _->interfaces_count; public unsafe ref ushort InterfaceOffsetsCount => ref _->interface_offsets_count; public unsafe ref byte TypeHierarchyDepth => ref _->typeHierarchyDepth; public unsafe ref int NativeSize => ref _->native_size; public unsafe ref uint ActualSize => ref _->actualSize; public unsafe ref ushort MethodCount => ref _->method_count; public unsafe ref ushort FieldCount => ref _->field_count; public unsafe ref Il2CppClassAttributes Flags => ref *(Il2CppClassAttributes*)(&_->flags); public unsafe ref IntPtr Name => ref *(IntPtr*)(&_->name); public unsafe ref IntPtr Namespace => ref *(IntPtr*)(&_->namespaze); public unsafe ref Il2CppImage* Image => ref _->image; public unsafe ref Il2CppClass* Parent => ref _->parent; public unsafe ref Il2CppClass* ElementClass => ref _->element_class; public unsafe ref Il2CppClass* CastClass => ref _->castClass; public unsafe ref Il2CppClass* DeclaringType => ref _->declaringType; public unsafe ref Il2CppClass* Class => ref _klassDummy; public unsafe ref Il2CppFieldInfo* Fields => ref _->fields; public unsafe ref Il2CppMethodInfo** Methods => ref _->methods; public unsafe ref Il2CppClass** ImplementedInterfaces => ref _->implementedInterfaces; public unsafe ref Il2CppRuntimeInterfaceOffsetPair* InterfaceOffsets => ref _->interfaceOffsets; public unsafe ref Il2CppClass** TypeHierarchy => ref _->typeHierarchy; public bool ValueType { get { return this.CheckBit(_bitfield0offset, 0); } set { this.SetBit(_bitfield0offset, 0, value); } } public bool Initialized { get { return this.CheckBit(_bitfield0offset, 1); } set { this.SetBit(_bitfield0offset, 1, value); } } public bool EnumType { get { return this.CheckBit(_bitfield0offset, 2); } set { this.SetBit(_bitfield0offset, 2, value); } } public bool IsGeneric { get { return this.CheckBit(_bitfield0offset, 3); } set { this.SetBit(_bitfield0offset, 3, value); } } public bool HasReferences { get { return this.CheckBit(_bitfield0offset, 4); } set { this.SetBit(_bitfield0offset, 4, value); } } public bool SizeInited { get { return this.CheckBit(_bitfield0offset, 6); } set { this.SetBit(_bitfield0offset, 6, value); } } public bool HasFinalize { get { return this.CheckBit(_bitfield0offset, 7); } set { this.SetBit(_bitfield0offset, 7, value); } } public bool IsVtableInitialized { get { return this.CheckBit(_bitfield1offset, 3); } set { this.SetBit(_bitfield1offset, 3, value); } } public bool InitializedAndNoError { get { return true; } set { } } public NativeStructWrapper(IntPtr ptr) { Pointer = ptr; } } public unsafe int Size() { return sizeof(Il2CppClass_22_1); } public unsafe INativeClassStruct CreateNewStruct(int vTableSlots) { IntPtr intPtr = Marshal.AllocHGlobal(Size() + sizeof(VirtualInvokeData) * vTableSlots); Il2CppClass_22_1* ptr = (Il2CppClass_22_1*)(void*)intPtr; *ptr = default(Il2CppClass_22_1); ptr->byval_arg = UnityVersionHandler.NewType().TypePointer; ptr->this_arg = UnityVersionHandler.NewType().TypePointer; return new NativeStructWrapper(intPtr); } public unsafe INativeClassStruct Wrap(Il2CppClass* ptr) { if (ptr == null) { return null; } return new NativeStructWrapper((IntPtr)ptr); } } [ApplicableToUnityVersionsSince("5.6.0")] public class NativeClassStructHandler_23_0 : INativeClassStructHandler, INativeStructHandler { internal struct Il2CppClass_23_0 { internal enum Bitfield0 : byte { BIT_valuetype = 0, valuetype = 1, BIT_initialized = 1, initialized = 2, BIT_enumtype = 2, enumtype = 4, BIT_is_generic = 3, is_generic = 8, BIT_has_references = 4, has_references = 16, BIT_init_pending = 5, init_pending = 32, BIT_size_inited = 6, size_inited = 64, BIT_has_finalize = 7, has_finalize = 128 } internal enum Bitfield1 : byte { BIT_has_cctor = 0, has_cctor = 1, BIT_is_blittable = 1, is_blittable = 2, BIT_is_import_or_windows_runtime = 2, is_import_or_windows_runtime = 4, BIT_is_vtable_initialized = 3, is_vtable_initialized = 8 } public unsafe Il2CppImage* image; public unsafe void* gc_desc; public unsafe byte* name; public unsafe byte* namespaze; public unsafe Il2CppTypeStruct* byval_arg; public unsafe Il2CppTypeStruct* this_arg; public unsafe Il2CppClass* element_class; public unsafe Il2CppClass* castClass; public unsafe Il2CppClass* declaringType; public unsafe Il2CppClass* parent; public unsafe void* generic_class; public unsafe void* typeDefinition; public unsafe void* interopData; public unsafe Il2CppFieldInfo* fields; public unsafe Il2CppEventInfo* events; public unsafe Il2CppPropertyInfo* properties; public unsafe Il2CppMethodInfo** methods; public unsafe Il2CppClass** nestedTypes; public unsafe Il2CppClass** implementedInterfaces; public unsafe Il2CppRuntimeInterfaceOffsetPair* interfaceOffsets; public unsafe void* static_fields; public unsafe void* rgctx_data; public unsafe Il2CppClass** typeHierarchy; public uint cctor_started; public uint cctor_finished; public ulong cctor_thread; public int genericContainerIndex; public int customAttributeIndex; public uint instance_size; public uint actualSize; public uint element_size; public int native_size; public uint static_fields_size; public uint thread_static_fields_size; public int thread_static_fields_offset; public uint flags; public uint token; public ushort method_count; public ushort property_count; public ushort field_count; public ushort event_count; public ushort nested_type_count; public ushort vtable_count; public ushort interfaces_count; public ushort interface_offsets_count; public byte typeHierarchyDepth; public byte genericRecursionDepth; public byte rank; public byte minimumAlignment; public byte packingSize; public Bitfield0 _bitfield0; public Bitfield1 _bitfield1; } internal class NativeStructWrapper : INativeClassStruct, INativeStruct { private static int _bitfield0offset = Marshal.OffsetOf("_bitfield0").ToInt32(); private static int _bitfield1offset = Marshal.OffsetOf("_bitfield1").ToInt32(); private unsafe Il2CppClass* _klassDummy; public IntPtr Pointer { get; } private unsafe Il2CppClass_23_0* _ => (Il2CppClass_23_0*)(void*)Pointer; public unsafe IntPtr VTable => IntPtr.Add(Pointer, sizeof(Il2CppClass_23_0)); public unsafe Il2CppClass* ClassPointer => (Il2CppClass*)(void*)Pointer; public unsafe INativeTypeStruct ByValArg => UnityVersionHandler.Wrap(_->byval_arg); public unsafe INativeTypeStruct ThisArg => UnityVersionHandler.Wrap(_->this_arg); public unsafe ref uint InstanceSize => ref _->instance_size; public unsafe ref ushort VtableCount => ref _->vtable_count; public unsafe ref ushort InterfaceCount => ref _->interfaces_count; public unsafe ref ushort InterfaceOffsetsCount => ref _->interface_offsets_count; public unsafe ref byte TypeHierarchyDepth => ref _->typeHierarchyDepth; public unsafe ref int NativeSize => ref _->native_size; public unsafe ref uint ActualSize => ref _->actualSize; public unsafe ref ushort MethodCount => ref _->method_count; public unsafe ref ushort FieldCount => ref _->field_count; public unsafe ref Il2CppClassAttributes Flags => ref *(Il2CppClassAttributes*)(&_->flags); public unsafe ref IntPtr Name => ref *(IntPtr*)(&_->name); public unsafe ref IntPtr Namespace => ref *(IntPtr*)(&_->namespaze); public unsafe ref Il2CppImage* Image => ref _->image; public unsafe ref Il2CppClass* Parent => ref _->parent; public unsafe ref Il2CppClass* ElementClass => ref _->element_class; public unsafe ref Il2CppClass* CastClass => ref _->castClass; public unsafe ref Il2CppClass* DeclaringType => ref _->declaringType; public unsafe ref Il2CppClass* Class => ref _klassDummy; public unsafe ref Il2CppFieldInfo* Fields => ref _->fields; public unsafe ref Il2CppMethodInfo** Methods => ref _->methods; public unsafe ref Il2CppClass** ImplementedInterfaces => ref _->implementedInterfaces; public unsafe ref Il2CppRuntimeInterfaceOffsetPair* InterfaceOffsets => ref _->interfaceOffsets; public unsafe ref Il2CppClass** TypeHierarchy => ref _->typeHierarchy; public bool ValueType { get { return this.CheckBit(_bitfield0offset, 0); } set { this.SetBit(_bitfield0offset, 0, value); } } public bool Initialized { get { return this.CheckBit(_bitfield0offset, 1); } set { this.SetBit(_bitfield0offset, 1, value); } } public bool EnumType { get { return this.CheckBit(_bitfield0offset, 2); } set { this.SetBit(_bitfield0offset, 2, value); } } public bool IsGeneric { get { return this.CheckBit(_bitfield0offset, 3); } set { this.SetBit(_bitfield0offset, 3, value); } } public bool HasReferences { get { return this.CheckBit(_bitfield0offset, 4); } set { this.SetBit(_bitfield0offset, 4, value); } } public bool SizeInited { get { return this.CheckBit(_bitfield0offset, 6); } set { this.SetBit(_bitfield0offset, 6, value); } } public bool HasFinalize { get { return this.CheckBit(_bitfield0offset, 7); } set { this.SetBit(_bitfield0offset, 7, value); } } public bool IsVtableInitialized { get { return this.CheckBit(_bitfield1offset, 3); } set { this.SetBit(_bitfield1offset, 3, value); } } public bool InitializedAndNoError { get { return true; } set { } } public NativeStructWrapper(IntPtr ptr) { Pointer = ptr; } } public unsafe int Size() { return sizeof(Il2CppClass_23_0); } public unsafe INativeClassStruct CreateNewStruct(int vTableSlots) { IntPtr intPtr = Marshal.AllocHGlobal(Size() + sizeof(VirtualInvokeData) * vTableSlots); Il2CppClass_23_0* ptr = (Il2CppClass_23_0*)(void*)intPtr; *ptr = default(Il2CppClass_23_0); ptr->byval_arg = UnityVersionHandler.NewType().TypePointer; ptr->this_arg = UnityVersionHandler.NewType().TypePointer; return new NativeStructWrapper(intPtr); } public unsafe INativeClassStruct Wrap(Il2CppClass* ptr) { if (ptr == null) { return null; } return new NativeStructWrapper((IntPtr)ptr); } } [ApplicableToUnityVersionsSince("2018.1.0")] public class NativeClassStructHandler_24_0 : INativeClassStructHandler, INativeStructHandler { internal struct Il2CppClass_24_0 { internal enum Bitfield0 : byte { BIT_valuetype = 0, valuetype = 1, BIT_initialized = 1, initialized = 2, BIT_enumtype = 2, enumtype = 4, BIT_is_generic = 3, is_generic = 8, BIT_has_references = 4, has_references = 16, BIT_init_pending = 5, init_pending = 32, BIT_size_inited = 6, size_inited = 64, BIT_has_finalize = 7, has_finalize = 128 } internal enum Bitfield1 : byte { BIT_has_cctor = 0, has_cctor = 1, BIT_is_blittable = 1, is_blittable = 2, BIT_is_import_or_windows_runtime = 2, is_import_or_windows_runtime = 4, BIT_is_vtable_initialized = 3, is_vtable_initialized = 8 } public unsafe Il2CppImage* image; public unsafe void* gc_desc; public unsafe byte* name; public unsafe byte* namespaze; public NativeTypeStructHandler_16_0.Il2CppType_16_0 byval_arg; public NativeTypeStructHandler_16_0.Il2CppType_16_0 this_arg; public unsafe Il2CppClass* element_class; public unsafe Il2CppClass* castClass; public unsafe Il2CppClass* declaringType; public unsafe Il2CppClass* parent; public unsafe void* generic_class; public unsafe void* typeDefinition; public unsafe void* interopData; public unsafe Il2CppClass* klass; public unsafe Il2CppFieldInfo* fields; public unsafe Il2CppEventInfo* events; public unsafe Il2CppPropertyInfo* properties; public unsafe Il2CppMethodInfo** methods; public unsafe Il2CppClass** nestedTypes; public unsafe Il2CppClass** implementedInterfaces; public unsafe Il2CppRuntimeInterfaceOffsetPair* interfaceOffsets; public unsafe void* static_fields; public unsafe void* rgctx_data; public unsafe Il2CppClass** typeHierarchy; public uint cctor_started; public uint cctor_finished; public ulong cctor_thread; public int genericContainerIndex; public int customAttributeIndex; public uint instance_size; public uint actualSize; public uint element_size; public int native_size; public uint static_fields_size; public uint thread_static_fields_size; public int thread_static_fields_offset; public uint flags; public uint token; public ushort method_count; public ushort property_count; public ushort field_count; public ushort event_count; public ushort nested_type_count; public ushort vtable_count; public ushort interfaces_count; public ushort interface_offsets_count; public byte typeHierarchyDepth; public byte genericRecursionDepth; public byte rank; public byte minimumAlignment; public byte packingSize; public Bitfield0 _bitfield0; public Bitfield1 _bitfield1; } internal class NativeStructWrapper : INativeClassStruct, INativeStruct { private static int _bitfield0offset = Marshal.OffsetOf("_bitfield0").ToInt32(); private static int _bitfield1offset = Marshal.OffsetOf("_bitfield1").ToInt32(); public IntPtr Pointer { get; } private unsafe Il2CppClass_24_0* _ => (Il2CppClass_24_0*)(void*)Pointer; public unsafe IntPtr VTable => IntPtr.Add(Pointer, sizeof(Il2CppClass_24_0)); public unsafe Il2CppClass* ClassPointer => (Il2CppClass*)(void*)Pointer; public unsafe INativeTypeStruct ByValArg => UnityVersionHandler.Wrap((Il2CppTypeStruct*)(&_->byval_arg)); public unsafe INativeTypeStruct ThisArg => UnityVersionHandler.Wrap((Il2CppTypeStruct*)(&_->this_arg)); public unsafe ref uint InstanceSize => ref _->instance_size; public unsafe ref ushort VtableCount => ref _->vtable_count; public unsafe ref ushort InterfaceCount => ref _->interfaces_count; public unsafe ref ushort InterfaceOffsetsCount => ref _->interface_offsets_count; public unsafe ref byte TypeHierarchyDepth => ref _->typeHierarchyDepth; public unsafe ref int NativeSize => ref _->native_size; public unsafe ref uint ActualSize => ref _->actualSize; public unsafe ref ushort MethodCount => ref _->method_count; public unsafe ref ushort FieldCount => ref _->field_count; public unsafe ref Il2CppClassAttributes Flags => ref *(Il2CppClassAttributes*)(&_->flags); public unsafe ref IntPtr Name => ref *(IntPtr*)(&_->name); public unsafe ref IntPtr Namespace => ref *(IntPtr*)(&_->namespaze); public unsafe ref Il2CppImage* Image => ref _->image; public unsafe ref Il2CppClass* Parent => ref _->parent; public unsafe ref Il2CppClass* ElementClass => ref _->element_class; public unsafe ref Il2CppClass* CastClass => ref _->castClass; public unsafe ref Il2CppClass* DeclaringType => ref _->declaringType; public unsafe ref Il2CppClass* Class => ref _->klass; public unsafe ref Il2CppFieldInfo* Fields => ref _->fields; public unsafe ref Il2CppMethodInfo** Methods => ref _->methods; public unsafe ref Il2CppClass** ImplementedInterfaces => ref _->implementedInterfaces; public unsafe ref Il2CppRuntimeInterfaceOffsetPair* InterfaceOffsets => ref _->interfaceOffsets; public unsafe ref Il2CppClass** TypeHierarchy => ref _->typeHierarchy; public bool ValueType { get { return this.CheckBit(_bitfield0offset, 0); } set { this.SetBit(_bitfield0offset, 0, value); } } public bool Initialized { get { return this.CheckBit(_bitfield0offset, 1); } set { this.SetBit(_bitfield0offset, 1, value); } } public bool EnumType { get { return this.CheckBit(_bitfield0offset, 2); } set { this.SetBit(_bitfield0offset, 2, value); } } public bool IsGeneric { get { return this.CheckBit(_bitfield0offset, 3); } set { this.SetBit(_bitfield0offset, 3, value); } } public bool HasReferences { get { return this.CheckBit(_bitfield0offset, 4); } set { this.SetBit(_bitfield0offset, 4, value); } } public bool SizeInited { get { return this.CheckBit(_bitfield0offset, 6); } set { this.SetBit(_bitfield0offset, 6, value); } } public bool HasFinalize { get { return this.CheckBit(_bitfield0offset, 7); } set { this.SetBit(_bitfield0offset, 7, value); } } public bool IsVtableInitialized { get { return this.CheckBit(_bitfield1offset, 3); } set { this.SetBit(_bitfield1offset, 3, value); } } public bool InitializedAndNoError { get { return true; } set { } } public NativeStructWrapper(IntPtr ptr) { Pointer = ptr; } } public unsafe int Size() { return sizeof(Il2CppClass_24_0); } public unsafe INativeClassStruct CreateNewStruct(int vTableSlots) { IntPtr intPtr = Marshal.AllocHGlobal(Size() + sizeof(VirtualInvokeData) * vTableSlots); Il2CppClass_24_0* ptr = (Il2CppClass_24_0*)(void*)intPtr; *ptr = default(Il2CppClass_24_0); return new NativeStructWrapper(intPtr); } public unsafe INativeClassStruct Wrap(Il2CppClass* ptr) { if (ptr == null) { return null; } return new NativeStructWrapper((IntPtr)ptr); } } [ApplicableToUnityVersionsSince("2018.2.0")] public class NativeClassStructHandler_24_1 : INativeClassStructHandler, INativeStructHandler { internal struct Il2CppClass_24_1 { internal enum Bitfield0 : byte { BIT_valuetype = 0, valuetype = 1, BIT_initialized = 1, initialized = 2, BIT_enumtype = 2, enumtype = 4, BIT_is_generic = 3, is_generic = 8, BIT_has_references = 4, has_references = 16, BIT_init_pending = 5, init_pending = 32, BIT_size_inited = 6, size_inited = 64, BIT_has_finalize = 7, has_finalize = 128 } internal enum Bitfield1 : byte { BIT_has_cctor = 0, has_cctor = 1, BIT_is_blittable = 1, is_blittable = 2, BIT_is_import_or_windows_runtime = 2, is_import_or_windows_runtime = 4, BIT_is_vtable_initialized = 3, is_vtable_initialized = 8, BIT_has_initialization_error = 4, has_initialization_error = 16 } public unsafe Il2CppImage* image; public unsafe void* gc_desc; public unsafe byte* name; public unsafe byte* namespaze; public NativeTypeStructHandler_16_0.Il2CppType_16_0 byval_arg; public NativeTypeStructHandler_16_0.Il2CppType_16_0 this_arg; public unsafe Il2CppClass* element_class; public unsafe Il2CppClass* castClass; public unsafe Il2CppClass* declaringType; public unsafe Il2CppClass* parent; public unsafe void* generic_class; public unsafe void* typeDefinition; public unsafe void* interopData; public unsafe Il2CppClass* klass; public unsafe Il2CppFieldInfo* fields; public unsafe Il2CppEventInfo* events; public unsafe Il2CppPropertyInfo* properties; public unsafe Il2CppMethodInfo** methods; public unsafe Il2CppClass** nestedTypes; public unsafe Il2CppClass** implementedInterfaces; public unsafe Il2CppRuntimeInterfaceOffsetPair* interfaceOffsets; public unsafe void* static_fields; public unsafe void* rgctx_data; public unsafe Il2CppClass** typeHierarchy; public uint initializationExceptionGCHandle; public uint cctor_started; public uint cctor_finished; public ulong cctor_thread; public int genericContainerIndex; public int customAttributeIndex; public uint instance_size; public uint actualSize; public uint element_size; public int native_size; public uint static_fields_size; public uint thread_static_fields_size; public int thread_static_fields_offset; public uint flags; public uint token; public ushort method_count; public ushort property_count; public ushort field_count; public ushort event_count; public ushort nested_type_count; public ushort vtable_count; public ushort interfaces_count; public ushort interface_offsets_count; public byte typeHierarchyDepth; public byte genericRecursionDepth; public byte rank; public byte minimumAlignment; public byte packingSize; public Bitfield0 _bitfield0; public Bitfield1 _bitfield1; } internal class NativeStructWrapper : INativeClassStruct, INativeStruct { private static int _bitfield0offset = Marshal.OffsetOf("_bitfield0").ToInt32(); private static int _bitfield1offset = Marshal.OffsetOf("_bitfield1").ToInt32(); public IntPtr Pointer { get; } private unsafe Il2CppClass_24_1* _ => (Il2CppClass_24_1*)(void*)Pointer; public unsafe IntPtr VTable => IntPtr.Add(Pointer, sizeof(Il2CppClass_24_1)); public unsafe Il2CppClass* ClassPointer => (Il2CppClass*)(void*)Pointer; public unsafe INativeTypeStruct ByValArg => UnityVersionHandler.Wrap((Il2CppTypeStruct*)(&_->byval_arg)); public unsafe INativeTypeStruct ThisArg => UnityVersionHandler.Wrap((Il2CppTypeStruct*)(&_->this_arg)); public unsafe ref uint InstanceSize => ref _->instance_size; public unsafe ref ushort VtableCount => ref _->vtable_count; public unsafe ref ushort InterfaceCount => ref _->interfaces_count; public unsafe ref ushort InterfaceOffsetsCount => ref _->interface_offsets_count; public unsafe ref byte TypeHierarchyDepth => ref _->typeHierarchyDepth; public unsafe ref int NativeSize => ref _->native_size; public unsafe ref uint ActualSize => ref _->actualSize; public unsafe ref ushort MethodCount => ref _->method_count; public unsafe ref ushort FieldCount => ref _->field_count; public unsafe ref Il2CppClassAttributes Flags => ref *(Il2CppClassAttributes*)(&_->flags); public unsafe ref IntPtr Name => ref *(IntPtr*)(&_->name); public unsafe ref IntPtr Namespace => ref *(IntPtr*)(&_->namespaze); public unsafe ref Il2CppImage* Image => ref _->image; public unsafe ref Il2CppClass* Parent => ref _->parent; public unsafe ref Il2CppClass* ElementClass => ref _->element_class; public unsafe ref Il2CppClass* CastClass => ref _->castClass; public unsafe ref Il2CppClass* DeclaringType => ref _->declaringType; public unsafe ref Il2CppClass* Class => ref _->klass; public unsafe ref Il2CppFieldInfo* Fields => ref _->fields; public unsafe ref Il2CppMethodInfo** Methods => ref _->methods; public unsafe ref Il2CppClass** ImplementedInterfaces => ref _->implementedInterfaces; public unsafe ref Il2CppRuntimeInterfaceOffsetPair* InterfaceOffsets => ref _->interfaceOffsets; public unsafe ref Il2CppClass** TypeHierarchy => ref _->typeHierarchy; public bool ValueType { get { return this.CheckBit(_bitfield0offset, 0); } set { this.SetBit(_bitfield0offset, 0, value); } } public bool Initialized { get { return this.CheckBit(_bitfield0offset, 1); } set { this.SetBit(_bitfield0offset, 1, value); } } public bool EnumType { get { return this.CheckBit(_bitfield0offset, 2); } set { this.SetBit(_bitfield0offset, 2, value); } } public bool IsGeneric { get { return this.CheckBit(_bitfield0offset, 3); } set { this.SetBit(_bitfield0offset, 3, value); } } public bool HasReferences { get { return this.CheckBit(_bitfield0offset, 4); } set { this.SetBit(_bitfield0offset, 4, value); } } public bool SizeInited { get { return this.CheckBit(_bitfield0offset, 6); } set { this.SetBit(_bitfield0offset, 6, value); } } public bool HasFinalize { get { return this.CheckBit(_bitfield0offset, 7); } set { this.SetBit(_bitfield0offset, 7, value); } } public bool IsVtableInitialized { get { return this.CheckBit(_bitfield1offset, 3); } set { this.SetBit(_bitfield1offset, 3, value); } } public bool InitializedAndNoError { get { return true; } set { } } public NativeStructWrapper(IntPtr ptr) { Pointer = ptr; } } public unsafe int Size() { return sizeof(Il2CppClass_24_1); } public unsafe INativeClassStruct CreateNewStruct(int vTableSlots) { IntPtr intPtr = Marshal.AllocHGlobal(Size() + sizeof(VirtualInvokeData) * vTableSlots); Il2CppClass_24_1* ptr = (Il2CppClass_24_1*)(void*)intPtr; *ptr = default(Il2CppClass_24_1); return new NativeStructWrapper(intPtr); } public unsafe INativeClassStruct Wrap(Il2CppClass* ptr) { if (ptr == null) { return null; } return new NativeStructWrapper((IntPtr)ptr); } } [ApplicableToUnityVersionsSince("2018.3.0")] public class NativeClassStructHandler_24_2 : INativeClassStructHandler, INativeStructHandler { internal struct Il2CppClass_24_2 { internal enum Bitfield0 : byte { BIT_initialized_and_no_error = 0, initialized_and_no_error = 1, BIT_valuetype = 1, valuetype = 2, BIT_initialized = 2, initialized = 4, BIT_enumtype = 3, enumtype = 8, BIT_is_generic = 4, is_generic = 16, BIT_has_references = 5, has_references = 32, BIT_init_pending = 6, init_pending = 64, BIT_size_inited = 7, size_inited = 128 } internal enum Bitfield1 : byte { BIT_has_finalize = 0, has_finalize = 1, BIT_has_cctor = 1, has_cctor = 2, BIT_is_blittable = 2, is_blittable = 4, BIT_is_import_or_windows_runtime = 3, is_import_or_windows_runtime = 8, BIT_is_vtable_initialized = 4, is_vtable_initialized = 16, BIT_has_initialization_error = 5, has_initialization_error = 32 } public unsafe Il2CppImage* image; public unsafe void* gc_desc; public unsafe byte* name; public unsafe byte* namespaze; public NativeTypeStructHandler_16_0.Il2CppType_16_0 byval_arg; public NativeTypeStructHandler_16_0.Il2CppType_16_0 this_arg; public unsafe Il2CppClass* element_class; public unsafe Il2CppClass* castClass; public unsafe Il2CppClass* declaringType; public unsafe Il2CppClass* parent; public unsafe void* generic_class; public unsafe void* typeDefinition; public unsafe void* interopData; public unsafe Il2CppClass* klass; public unsafe Il2CppFieldInfo* fields; public unsafe Il2CppEventInfo* events; public unsafe Il2CppPropertyInfo* properties; public unsafe Il2CppMethodInfo** methods; public unsafe Il2CppClass** nestedTypes; public unsafe Il2CppClass** implementedInterfaces; public unsafe Il2CppRuntimeInterfaceOffsetPair* interfaceOffsets; public unsafe void* static_fields; public unsafe void* rgctx_data; public unsafe Il2CppClass** typeHierarchy; public uint initializationExceptionGCHandle; public uint cctor_started; public uint cctor_finished; public ulong cctor_thread; public int genericContainerIndex; public uint instance_size; public uint actualSize; public uint element_size; public int native_size; public uint static_fields_size; public uint thread_static_fields_size; public int thread_static_fields_offset; public uint flags; public uint token; public ushort method_count; public ushort property_count; public ushort field_count; public ushort event_count; public ushort nested_type_count; public ushort vtable_count; public ushort interfaces_count; public ushort interface_offsets_count; public byte typeHierarchyDepth; public byte genericRecursionDepth; public byte rank; public byte minimumAlignment; public byte packingSize; public Bitfield0 _bitfield0; public Bitfield1 _bitfield1; } internal class NativeStructWrapper : INativeClassStruct, INativeStruct { private static int _bitfield0offset = Marshal.OffsetOf("_bitfield0").ToInt32(); private static int _bitfield1offset = Marshal.OffsetOf("_bitfield1").ToInt32(); public IntPtr Pointer { get; } private unsafe Il2CppClass_24_2* _ => (Il2CppClass_24_2*)(void*)Pointer; public unsafe IntPtr VTable => IntPtr.Add(Pointer, sizeof(Il2CppClass_24_2)); public unsafe Il2CppClass* ClassPointer => (Il2CppClass*)(void*)Pointer; public unsafe INativeTypeStruct ByValArg => UnityVersionHandler.Wrap((Il2CppTypeStruct*)(&_->byval_arg)); public unsafe INativeTypeStruct ThisArg => UnityVersionHandler.Wrap((Il2CppTypeStruct*)(&_->this_arg)); public unsafe ref uint InstanceSize => ref _->instance_size; public unsafe ref ushort VtableCount => ref _->vtable_count; public unsafe ref ushort InterfaceCount => ref _->interfaces_count; public unsafe ref ushort InterfaceOffsetsCount => ref _->interface_offsets_count; public unsafe ref byte TypeHierarchyDepth => ref _->typeHierarchyDepth; public unsafe ref int NativeSize => ref _->native_size; public unsafe ref uint ActualSize => ref _->actualSize; public unsafe ref ushort MethodCount => ref _->method_count; public unsafe ref ushort FieldCount => ref _->field_count; public unsafe ref Il2CppClassAttributes Flags => ref *(Il2CppClassAttributes*)(&_->flags); public unsafe ref IntPtr Name => ref *(IntPtr*)(&_->name); public unsafe ref IntPtr Namespace => ref *(IntPtr*)(&_->namespaze); public unsafe ref Il2CppImage* Image => ref _->image; public unsafe ref Il2CppClass* Parent => ref _->parent; public unsafe ref Il2CppClass* ElementClass => ref _->element_class; public unsafe ref Il2CppClass* CastClass => ref _->castClass; public unsafe ref Il2CppClass* DeclaringType => ref _->declaringType; public unsafe ref Il2CppClass* Class => ref _->klass; public unsafe ref Il2CppFieldInfo* Fields => ref _->fields; public unsafe ref Il2CppMethodInfo** Methods => ref _->methods; public unsafe ref Il2CppClass** ImplementedInterfaces => ref _->implementedInterfaces; public unsafe ref Il2CppRuntimeInterfaceOffsetPair* InterfaceOffsets => ref _->interfaceOffsets; public unsafe ref Il2CppClass** TypeHierarchy => ref _->typeHierarchy; public bool ValueType { get { return this.CheckBit(_bitfield0offset, 1); } set { this.SetBit(_bitfield0offset, 1, value); } } public bool Initialized { get { return this.CheckBit(_bitfield0offset, 2); } set { this.SetBit(_bitfield0offset, 2, value); } } public bool EnumType { get { return this.CheckBit(_bitfield0offset, 3); } set { this.SetBit(_bitfield0offset, 3, value); } } public bool IsGeneric { get { return this.CheckBit(_bitfield0offset, 4); } set { this.SetBit(_bitfield0offset, 4, value); } } public bool HasReferences { get { return this.CheckBit(_bitfield0offset, 5); } set { this.SetBit(_bitfield0offset, 5, value); } } public bool SizeInited { get { return this.CheckBit(_bitfield0offset, 7); } set { this.SetBit(_bitfield0offset, 7, value); } } public bool HasFinalize { get { return this.CheckBit(_bitfield1offset, 0); } set { this.SetBit(_bitfield1offset, 0, value); } } public bool IsVtableInitialized { get { return this.CheckBit(_bitfield1offset, 4); } set { this.SetBit(_bitfield1offset, 4, value); } } public bool InitializedAndNoError { get { return this.CheckBit(_bitfield0offset, 0); } set { this.SetBit(_bitfield0offset, 0, value); } } public NativeStructWrapper(IntPtr ptr) { Pointer = ptr; } } public unsafe int Size() { return sizeof(Il2CppClass_24_2); } public unsafe INativeClassStruct CreateNewStruct(int vTableSlots) { IntPtr intPtr = Marshal.AllocHGlobal(Size() + sizeof(VirtualInvokeData) * vTableSlots); Il2CppClass_24_2* ptr = (Il2CppClass_24_2*)(void*)intPtr; *ptr = default(Il2CppClass_24_2); return new NativeStructWrapper(intPtr); } public unsafe INativeClassStruct Wrap(Il2CppClass* ptr) { if (ptr == null) { return null; } return new NativeStructWrapper((IntPtr)ptr); } } [ApplicableToUnityVersionsSince("2018.3.8")] public class NativeClassStructHandler_24_3 : INativeClassStructHandler, INativeStructHandler { internal struct Il2CppClass_24_3 { internal enum Bitfield0 : byte { BIT_initialized_and_no_error = 0, initialized_and_no_error = 1, BIT_valuetype = 1, valuetype = 2, BIT_initialized = 2, initialized = 4, BIT_enumtype = 3, enumtype = 8, BIT_is_generic = 4, is_generic = 16, BIT_has_references = 5, has_references = 32, BIT_init_pending = 6, init_pending = 64, BIT_size_inited = 7, size_inited = 128 } internal enum Bitfield1 : byte { BIT_has_finalize = 0, has_finalize = 1, BIT_has_cctor = 1, has_cctor = 2, BIT_is_blittable = 2, is_blittable = 4, BIT_is_import_or_windows_runtime = 3, is_import_or_windows_runtime = 8, BIT_is_vtable_initialized = 4, is_vtable_initialized = 16, BIT_has_initialization_error = 5, has_initialization_error = 32 } public unsafe Il2CppImage* image; public unsafe void* gc_desc; public unsafe byte* name; public unsafe byte* namespaze; public NativeTypeStructHandler_16_0.Il2CppType_16_0 byval_arg; public NativeTypeStructHandler_16_0.Il2CppType_16_0 this_arg; public unsafe Il2CppClass* element_class; public unsafe Il2CppClass* castClass; public unsafe Il2CppClass* declaringType; public unsafe Il2CppClass* parent; public unsafe void* generic_class; public unsafe void* typeDefinition; public unsafe void* interopData; public unsafe Il2CppClass* klass; public unsafe Il2CppFieldInfo* fields; public unsafe Il2CppEventInfo* events; public unsafe Il2CppPropertyInfo* properties; public unsafe Il2CppMethodInfo** methods; public unsafe Il2CppClass** nestedTypes; public unsafe Il2CppClass** implementedInterfaces; public unsafe Il2CppRuntimeInterfaceOffsetPair* interfaceOffsets; public unsafe void* static_fields; public unsafe void* rgctx_data; public unsafe Il2CppClass** typeHierarchy; public uint initializationExceptionGCHandle; public uint cctor_started; public uint cctor_finished; public ulong cctor_thread; public int genericContainerIndex; public uint instance_size; public uint actualSize; public uint element_size; public int native_size; public uint static_fields_size; public uint thread_static_fields_size; public int thread_static_fields_offset; public uint flags; public uint token; public ushort method_count; public ushort property_count; public ushort field_count; public ushort event_count; public ushort nested_type_count; public ushort vtable_count; public ushort interfaces_count; public ushort interface_offsets_count; public byte typeHierarchyDepth; public byte genericRecursionDepth; public byte rank; public byte minimumAlignment; public byte naturalAligment; public byte packingSize; public Bitfield0 _bitfield0; public Bitfield1 _bitfield1; } internal class NativeStructWrapper : INativeClassStruct, INativeStruct { private static int _bitfield0offset = Marshal.OffsetOf("_bitfield0").ToInt32(); private static int _bitfield1offset = Marshal.OffsetOf("_bitfield1").ToInt32(); public IntPtr Pointer { get; } private unsafe Il2CppClass_24_3* _ => (Il2CppClass_24_3*)(void*)Pointer; public unsafe IntPtr VTable => IntPtr.Add(Pointer, sizeof(Il2CppClass_24_3)); public unsafe Il2CppClass* ClassPointer => (Il2CppClass*)(void*)Pointer; public unsafe INativeTypeStruct ByValArg => UnityVersionHandler.Wrap((Il2CppTypeStruct*)(&_->byval_arg)); public unsafe INativeTypeStruct ThisArg => UnityVersionHandler.Wrap((Il2CppTypeStruct*)(&_->this_arg)); public unsafe ref uint InstanceSize => ref _->instance_size; public unsafe ref ushort VtableCount => ref _->vtable_count; public unsafe ref ushort InterfaceCount => ref _->interfaces_count; public unsafe ref ushort InterfaceOffsetsCount => ref _->interface_offsets_count; public unsafe ref byte TypeHierarchyDepth => ref _->typeHierarchyDepth; public unsafe ref int NativeSize => ref _->native_size; public unsafe ref uint ActualSize => ref _->actualSize; public unsafe ref ushort MethodCount => ref _->method_count; public unsafe ref ushort FieldCount => ref _->field_count; public unsafe ref Il2CppClassAttributes Flags => ref *(Il2CppClassAttributes*)(&_->flags); public unsafe ref IntPtr Name => ref *(IntPtr*)(&_->name); public unsafe ref IntPtr Namespace => ref *(IntPtr*)(&_->namespaze); public unsafe ref Il2CppImage* Image => ref _->image; public unsafe ref Il2CppClass* Parent => ref _->parent; public unsafe ref Il2CppClass* ElementClass => ref _->element_class; public unsafe ref Il2CppClass* CastClass => ref _->castClass; public unsafe ref Il2CppClass* DeclaringType => ref _->declaringType; public unsafe ref Il2CppClass* Class => ref _->klass; public unsafe ref Il2CppFieldInfo* Fields => ref _->fields; public unsafe ref Il2CppMethodInfo** Methods => ref _->methods; public unsafe ref Il2CppClass** ImplementedInterfaces => ref _->implementedInterfaces; public unsafe ref Il2CppRuntimeInterfaceOffsetPair* InterfaceOffsets => ref _->interfaceOffsets; public unsafe ref Il2CppClass** TypeHierarchy => ref _->typeHierarchy; public bool ValueType { get { return this.CheckBit(_bitfield0offset, 1); } set { this.SetBit(_bitfield0offset, 1, value); } } public bool Initialized { get { return this.CheckBit(_bitfield0offset, 2); } set { this.SetBit(_bitfield0offset, 2, value); } } public bool EnumType { get { return this.CheckBit(_bitfield0offset, 3); } set { this.SetBit(_bitfield0offset, 3, value); } } public bool IsGeneric { get { return this.CheckBit(_bitfield0offset, 4); } set { this.SetBit(_bitfield0offset, 4, value); } } public bool HasReferences { get { return this.CheckBit(_bitfield0offset, 5); } set { this.SetBit(_bitfield0offset, 5, value); } } public bool SizeInited { get { return this.CheckBit(_bitfield0offset, 7); } set { this.SetBit(_bitfield0offset, 7, value); } } public bool HasFinalize { get { return this.CheckBit(_bitfield1offset, 0); } set { this.SetBit(_bitfield1offset, 0, value); } } public bool IsVtableInitialized { get { return this.CheckBit(_bitfield1offset, 4); } set { this.SetBit(_bitfield1offset, 4, value); } } public bool InitializedAndNoError { get { return this.CheckBit(_bitfield0offset, 0); } set { this.SetBit(_bitfield0offset, 0, value); } } public NativeStructWrapper(IntPtr ptr) { Pointer = ptr; } } public unsafe int Size() { return sizeof(Il2CppClass_24_3); } public unsafe INativeClassStruct CreateNewStruct(int vTableSlots) { IntPtr intPtr = Marshal.AllocHGlobal(Size() + sizeof(VirtualInvokeData) * vTableSlots); Il2CppClass_24_3* ptr = (Il2CppClass_24_3*)(void*)intPtr; *ptr = default(Il2CppClass_24_3); return new NativeStructWrapper(intPtr); } public unsafe INativeClassStruct Wrap(Il2CppClass* ptr) { if (ptr == null) { return null; } return new NativeStructWrapper((IntPtr)ptr); } } [ApplicableToUnityVersionsSince("2019.1.0")] public class NativeClassStructHandler_24_4 : INativeClassStructHandler, INativeStructHandler { internal struct Il2CppClass_24_4 { internal enum Bitfield0 : byte { BIT_initialized_and_no_error = 0, initialized_and_no_error = 1, BIT_valuetype = 1, valuetype = 2, BIT_initialized = 2, initialized = 4, BIT_enumtype = 3, enumtype = 8, BIT_is_generic = 4, is_generic = 16, BIT_has_references = 5, has_references = 32, BIT_init_pending = 6, init_pending = 64, BIT_size_inited = 7, size_inited = 128 } internal enum Bitfield1 : byte { BIT_has_finalize = 0, has_finalize = 1, BIT_has_cctor = 1, has_cctor = 2, BIT_is_blittable = 2, is_blittable = 4, BIT_is_import_or_windows_runtime = 3, is_import_or_windows_runtime = 8, BIT_is_vtable_initialized = 4, is_vtable_initialized = 16, BIT_has_initialization_error = 5, has_initialization_error = 32 } public unsafe Il2CppImage* image; public unsafe void* gc_desc; public unsafe byte* name; public unsafe byte* namespaze; public NativeTypeStructHandler_16_0.Il2CppType_16_0 byval_arg; public NativeTypeStructHandler_16_0.Il2CppType_16_0 this_arg; public unsafe Il2CppClass* element_class; public unsafe Il2CppClass* castClass; public unsafe Il2CppClass* declaringType; public unsafe Il2CppClass* parent; public unsafe void* generic_class; public unsafe void* typeDefinition; public unsafe void* interopData; public unsafe Il2CppClass* klass; public unsafe Il2CppFieldInfo* fields; public unsafe Il2CppEventInfo* events; public unsafe Il2CppPropertyInfo* properties; public unsafe Il2CppMethodInfo** methods; public unsafe Il2CppClass** nestedTypes; public unsafe Il2CppClass** implementedInterfaces; public unsafe Il2CppRuntimeInterfaceOffsetPair* interfaceOffsets; public unsafe void* static_fields; public unsafe void* rgctx_data; public unsafe Il2CppClass** typeHierarchy; public unsafe void* unity_user_data; public uint initializationExceptionGCHandle; public uint cctor_started; public uint cctor_finished; public IntPtr cctor_thread; public int genericContainerIndex; public uint instance_size; public uint actualSize; public uint element_size; public int native_size; public uint static_fields_size; public uint thread_static_fields_size; public int thread_static_fields_offset; public uint flags; public uint token; public ushort method_count; public ushort property_count; public ushort field_count; public ushort event_count; public ushort nested_type_count; public ushort vtable_count; public ushort interfaces_count; public ushort interface_offsets_count; public byte typeHierarchyDepth; public byte genericRecursionDepth; public byte rank; public byte minimumAlignment; public byte naturalAligment; public byte packingSize; public Bitfield0 _bitfield0; public Bitfield1 _bitfield1; } internal class NativeStructWrapper : INativeClassStruct, INativeStruct { private static int _bitfield0offset = Marshal.OffsetOf("_bitfield0").ToInt32(); private static int _bitfield1offset = Marshal.OffsetOf("_bitfield1").ToInt32(); public IntPtr Pointer { get; } private unsafe Il2CppClass_24_4* _ => (Il2CppClass_24_4*)(void*)Pointer; public unsafe IntPtr VTable => IntPtr.Add(Pointer, sizeof(Il2CppClass_24_4)); public unsafe Il2CppClass* ClassPointer => (Il2CppClass*)(void*)Pointer; public unsafe INativeTypeStruct ByValArg => UnityVersionHandler.Wrap((Il2CppTypeStruct*)(&_->byval_arg)); public unsafe INativeTypeStruct ThisArg => UnityVersionHandler.Wrap((Il2CppTypeStruct*)(&_->this_arg)); public unsafe ref uint InstanceSize => ref _->instance_size; public unsafe ref ushort VtableCount => ref _->vtable_count; public unsafe ref ushort InterfaceCount => ref _->interfaces_count; public unsafe ref ushort InterfaceOffsetsCount => ref _->interface_offsets_count; public unsafe ref byte TypeHierarchyDepth => ref _->typeHierarchyDepth; public unsafe ref int NativeSize => ref _->native_size; public unsafe ref uint ActualSize => ref _->actualSize; public unsafe ref ushort MethodCount => ref _->method_count; public unsafe ref ushort FieldCount => ref _->field_count; public unsafe ref Il2CppClassAttributes Flags => ref *(Il2CppClassAttributes*)(&_->flags); public unsafe ref IntPtr Name => ref *(IntPtr*)(&_->name); public unsafe ref IntPtr Namespace => ref *(IntPtr*)(&_->namespaze); public unsafe ref Il2CppImage* Image => ref _->image; public unsafe ref Il2CppClass* Parent => ref _->parent; public unsafe ref Il2CppClass* ElementClass => ref _->element_class; public unsafe ref Il2CppClass* CastClass => ref _->castClass; public unsafe ref Il2CppClass* DeclaringType => ref _->declaringType; public unsafe ref Il2CppClass* Class => ref _->klass; public unsafe ref Il2CppFieldInfo* Fields => ref _->fields; public unsafe ref Il2CppMethodInfo** Methods => ref _->methods; public unsafe ref Il2CppClass** ImplementedInterfaces => ref _->implementedInterfaces; public unsafe ref Il2CppRuntimeInterfaceOffsetPair* InterfaceOffsets => ref _->interfaceOffsets; public unsafe ref Il2CppClass** TypeHierarchy => ref _->typeHierarchy; public bool ValueType { get { return this.CheckBit(_bitfield0offset, 1); } set { this.SetBit(_bitfield0offset, 1, value); } } public bool Initialized { get { return this.CheckBit(_bitfield0offset, 2); } set { this.SetBit(_bitfield0offset, 2, value); } } public bool EnumType { get { return this.CheckBit(_bitfield0offset, 3); } set { this.SetBit(_bitfield0offset, 3, value); } } public bool IsGeneric { get { return this.CheckBit(_bitfield0offset, 4); } set { this.SetBit(_bitfield0offset, 4, value); } } public bool HasReferences { get { return this.CheckBit(_bitfield0offset, 5); } set { this.SetBit(_bitfield0offset, 5, value); } } public bool SizeInited { get { return this.CheckBit(_bitfield0offset, 7); } set { this.SetBit(_bitfield0offset, 7, value); } } public bool HasFinalize { get { return this.CheckBit(_bitfield1offset, 0); } set { this.SetBit(_bitfield1offset, 0, value); } } public bool IsVtableInitialized { get { return this.CheckBit(_bitfield1offset, 4); } set { this.SetBit(_bitfield1offset, 4, value); } } public bool InitializedAndNoError { get { return this.CheckBit(_bitfield0offset, 0); } set { this.SetBit(_bitfield0offset, 0, value); } } public NativeStructWrapper(IntPtr ptr) { Pointer = ptr; } } public unsafe int Size() { return sizeof(Il2CppClass_24_4); } public unsafe INativeClassStruct CreateNewStruct(int vTableSlots) { IntPtr intPtr = Marshal.AllocHGlobal(Size() + sizeof(VirtualInvokeData) * vTableSlots); Il2CppClass_24_4* ptr = (Il2CppClass_24_4*)(void*)intPtr; *ptr = default(Il2CppClass_24_4); return new NativeStructWrapper(intPtr); } public unsafe INativeClassStruct Wrap(Il2CppClass* ptr) { if (ptr == null) { return null; } return new NativeStructWrapper((IntPtr)ptr); } } [ApplicableToUnityVersionsSince("2020.2.0")] public class NativeClassStructHandler_27_0 : INativeClassStructHandler, INativeStructHandler { internal struct Il2CppClass_27_0 { internal enum Bitfield0 : byte { BIT_initialized_and_no_error = 0, initialized_and_no_error = 1, BIT_valuetype = 1, valuetype = 2, BIT_initialized = 2, initialized = 4, BIT_enumtype = 3, enumtype = 8, BIT_is_generic = 4, is_generic = 16, BIT_has_references = 5, has_references = 32, BIT_init_pending = 6, init_pending = 64, BIT_size_inited = 7, size_inited = 128 } internal enum Bitfield1 : byte { BIT_has_finalize = 0, has_finalize = 1, BIT_has_cctor = 1, has_cctor = 2, BIT_is_blittable = 2, is_blittable = 4, BIT_is_import_or_windows_runtime = 3, is_import_or_windows_runtime = 8, BIT_is_vtable_initialized = 4, is_vtable_initialized = 16, BIT_has_initialization_error = 5, has_initialization_error = 32 } public unsafe Il2CppImage* image; public unsafe void* gc_desc; public unsafe byte* name; public unsafe byte* namespaze; public NativeTypeStructHandler_16_0.Il2CppType_16_0 byval_arg; public NativeTypeStructHandler_16_0.Il2CppType_16_0 this_arg; public unsafe Il2CppClass* element_class; public unsafe Il2CppClass* castClass; public unsafe Il2CppClass* declaringType; public unsafe Il2CppClass* parent; public unsafe void* generic_class; public Il2CppMetadataTypeHandle typeMetadataHandle; public unsafe void* interopData; public unsafe Il2CppClass* klass; public unsafe Il2CppFieldInfo* fields; public unsafe Il2CppEventInfo* events; public unsafe Il2CppPropertyInfo* properties; public unsafe Il2CppMethodInfo** methods; public unsafe Il2CppClass** nestedTypes; public unsafe Il2CppClass** implementedInterfaces; public unsafe Il2CppRuntimeInterfaceOffsetPair* interfaceOffsets; public unsafe void* static_fields; public unsafe void* rgctx_data; public unsafe Il2CppClass** typeHierarchy; public unsafe void* unity_user_data; public uint initializationExceptionGCHandle; public uint cctor_started; public uint cctor_finished; public IntPtr cctor_thread; public Il2CppMetadataGenericContainerHandle genericContainerHandle; public uint instance_size; public uint actualSize; public uint element_size; public int native_size; public uint static_fields_size; public uint thread_static_fields_size; public int thread_static_fields_offset; public uint flags; public uint token; public ushort method_count; public ushort property_count; public ushort field_count; public ushort event_count; public ushort nested_type_count; public ushort vtable_count; public ushort interfaces_count; public ushort interface_offsets_count; public byte typeHierarchyDepth; public byte genericRecursionDepth; public byte rank; public byte minimumAlignment; public byte naturalAligment; public byte packingSize; public Bitfield0 _bitfield0; public Bitfield1 _bitfield1; } internal class NativeStructWrapper : INativeClassStruct, INativeStruct { private static int _bitfield0offset = Marshal.OffsetOf("_bitfield0").ToInt32(); private static int _bitfield1offset = Marshal.OffsetOf("_bitfield1").ToInt32(); public IntPtr Pointer { get; } private unsafe Il2CppClass_27_0* _ => (Il2CppClass_27_0*)(void*)Pointer; public unsafe IntPtr VTable => IntPtr.Add(Pointer, sizeof(Il2CppClass_27_0)); public unsafe Il2CppClass* ClassPointer => (Il2CppClass*)(void*)Pointer; public unsafe INativeTypeStruct ByValArg => UnityVersionHandler.Wrap((Il2CppTypeStruct*)(&_->byval_arg)); public unsafe INativeTypeStruct ThisArg => UnityVersionHandler.Wrap((Il2CppTypeStruct*)(&_->this_arg)); public unsafe ref uint InstanceSize => ref _->instance_size; public unsafe ref ushort VtableCount => ref _->vtable_count; public unsafe ref ushort InterfaceCount => ref _->interfaces_count; public unsafe ref ushort InterfaceOffsetsCount => ref _->interface_offsets_count; public unsafe ref byte TypeHierarchyDepth => ref _->typeHierarchyDepth; public unsafe ref int NativeSize => ref _->native_size; public unsafe ref uint ActualSize => ref _->actualSize; public unsafe ref ushort MethodCount => ref _->method_count; public unsafe ref ushort FieldCount => ref _->field_count; public unsafe ref Il2CppClassAttributes Flags => ref *(Il2CppClassAttributes*)(&_->flags); public unsafe ref IntPtr Name => ref *(IntPtr*)(&_->name); public unsafe ref IntPtr Namespace => ref *(IntPtr*)(&_->namespaze); public unsafe ref Il2CppImage* Image => ref _->image; public unsafe ref Il2CppClass* Parent => ref _->parent; public unsafe ref Il2CppClass* ElementClass => ref _->element_class; public unsafe ref Il2CppClass* CastClass => ref _->castClass; public unsafe ref Il2CppClass* DeclaringType => ref _->declaringType; public unsafe ref Il2CppClass* Class => ref _->klass; public unsafe ref Il2CppFieldInfo* Fields => ref _->fields; public unsafe ref Il2CppMethodInfo** Methods => ref _->methods; public unsafe ref Il2CppClass** ImplementedInterfaces => ref _->implementedInterfaces; public unsafe ref Il2CppRuntimeInterfaceOffsetPair* InterfaceOffsets => ref _->interfaceOffsets; public unsafe ref Il2CppClass** TypeHierarchy => ref _->typeHierarchy; public bool ValueType { get { return this.CheckBit(_bitfield0offset, 1); } set { this.SetBit(_bitfield0offset, 1, value); } } public bool Initialized { get { return this.CheckBit(_bitfield0offset, 2); } set { this.SetBit(_bitfield0offset, 2, value); } } public bool EnumType { get { return this.CheckBit(_bitfield0offset, 3); } set { this.SetBit(_bitfield0offset, 3, value); } } public bool IsGeneric { get { return this.CheckBit(_bitfield0offset, 4); } set { this.SetBit(_bitfield0offset, 4, value); } } public bool HasReferences { get { return this.CheckBit(_bitfield0offset, 5); } set { this.SetBit(_bitfield0offset, 5, value); } } public bool SizeInited { get { return this.CheckBit(_bitfield0offset, 7); } set { this.SetBit(_bitfield0offset, 7, value); } } public bool HasFinalize { get { return this.CheckBit(_bitfield1offset, 0); } set { this.SetBit(_bitfield1offset, 0, value); } } public bool IsVtableInitialized { get { return this.CheckBit(_bitfield1offset, 4); } set { this.SetBit(_bitfield1offset, 4, value); } } public bool InitializedAndNoError { get { return this.CheckBit(_bitfield0offset, 0); } set { this.SetBit(_bitfield0offset, 0, value); } } public NativeStructWrapper(IntPtr ptr) { Pointer = ptr; } } public unsafe int Size() { return sizeof(Il2CppClass_27_0); } public unsafe INativeClassStruct CreateNewStruct(int vTableSlots) { IntPtr intPtr = Marshal.AllocHGlobal(Size() + sizeof(VirtualInvokeData) * vTableSlots); Il2CppClass_27_0* ptr = (Il2CppClass_27_0*)(void*)intPtr; *ptr = default(Il2CppClass_27_0); return new NativeStructWrapper(intPtr); } public unsafe INativeClassStruct Wrap(Il2CppClass* ptr) { if (ptr == null) { return null; } return new NativeStructWrapper((IntPtr)ptr); } } [ApplicableToUnityVersionsSince("2020.3.20")] public class NativeClassStructHandler_27_1 : INativeClassStructHandler, INativeStructHandler { internal struct Il2CppClass_27_1 { internal enum Bitfield0 : byte { BIT_initialized_and_no_error = 0, initialized_and_no_error = 1, BIT_valuetype = 1, valuetype = 2, BIT_initialized = 2, initialized = 4, BIT_enumtype = 3, enumtype = 8, BIT_is_generic = 4, is_generic = 16, BIT_has_references = 5, has_references = 32, BIT_init_pending = 6, init_pending = 64, BIT_size_init_pending = 7, size_init_pending = 128 } internal enum Bitfield1 : byte { BIT_size_inited = 0, size_inited = 1, BIT_has_finalize = 1, has_finalize = 2, BIT_has_cctor = 2, has_cctor = 4, BIT_is_blittable = 3, is_blittable = 8, BIT_is_import_or_windows_runtime = 4, is_import_or_windows_runtime = 16, BIT_is_vtable_initialized = 5, is_vtable_initialized = 32, BIT_has_initialization_error = 6, has_initialization_error = 64 } public unsafe Il2CppImage* image; public unsafe void* gc_desc; public unsafe byte* name; public unsafe byte* namespaze; public NativeTypeStructHandler_16_0.Il2CppType_16_0 byval_arg; public NativeTypeStructHandler_16_0.Il2CppType_16_0 this_arg; public unsafe Il2CppClass* element_class; public unsafe Il2CppClass* castClass; public unsafe Il2CppClass* declaringType; public unsafe Il2CppClass* parent; public unsafe void* generic_class; public Il2CppMetadataTypeHandle typeMetadataHandle; public unsafe void* interopData; public unsafe Il2CppClass* klass; public unsafe Il2CppFieldInfo* fields; public unsafe Il2CppEventInfo* events; public unsafe Il2CppPropertyInfo* properties; public unsafe Il2CppMethodInfo** methods; public unsafe Il2CppClass** nestedTypes; public unsafe Il2CppClass** implementedInterfaces; public unsafe Il2CppRuntimeInterfaceOffsetPair* interfaceOffsets; public unsafe void* static_fields; public unsafe void* rgctx_data; public unsafe Il2CppClass** typeHierarchy; public unsafe void* unity_user_data; public uint initializationExceptionGCHandle; public uint cctor_started; public uint cctor_finished; public IntPtr cctor_thread; public Il2CppMetadataGenericContainerHandle genericContainerHandle; public uint instance_size; public uint actualSize; public uint element_size; public int native_size; public uint static_fields_size; public uint thread_static_fields_size; public int thread_static_fields_offset; public uint flags; public uint token; public ushort method_count; public ushort property_count; public ushort field_count; public ushort event_count; public ushort nested_type_count; public ushort vtable_count; public ushort interfaces_count; public ushort interface_offsets_count; public byte typeHierarchyDepth; public byte genericRecursionDepth; public byte rank; public byte minimumAlignment; public byte naturalAligment; public byte packingSize; public Bitfield0 _bitfield0; public Bitfield1 _bitfield1; } internal class NativeStructWrapper : INativeClassStruct, INativeStruct { private static int _bitfield0offset = Marshal.OffsetOf("_bitfield0").ToInt32(); private static int _bitfield1offset = Marshal.OffsetOf("_bitfield1").ToInt32(); public IntPtr Pointer { get; } private unsafe Il2CppClass_27_1* _ => (Il2CppClass_27_1*)(void*)Pointer; public unsafe IntPtr VTable => IntPtr.Add(Pointer, sizeof(Il2CppClass_27_1)); public unsafe Il2CppClass* ClassPointer => (Il2CppClass*)(void*)Pointer; public unsafe INativeTypeStruct ByValArg => UnityVersionHandler.Wrap((Il2CppTypeStruct*)(&_->byval_arg)); public unsafe INativeTypeStruct ThisArg => UnityVersionHandler.Wrap((Il2CppTypeStruct*)(&_->this_arg)); public unsafe ref uint InstanceSize => ref _->instance_size; public unsafe ref ushort VtableCount => ref _->vtable_count; public unsafe ref ushort InterfaceCount => ref _->interfaces_count; public unsafe ref ushort InterfaceOffsetsCount => ref _->interface_offsets_count; public unsafe ref byte TypeHierarchyDepth => ref _->typeHierarchyDepth; public unsafe ref int NativeSize => ref _->native_size; public unsafe ref uint ActualSize => ref _->actualSize; public unsafe ref ushort MethodCount => ref _->method_count; public unsafe ref ushort FieldCount => ref _->field_count; public unsafe ref Il2CppClassAttributes Flags => ref *(Il2CppClassAttributes*)(&_->flags); public unsafe ref IntPtr Name => ref *(IntPtr*)(&_->name); public unsafe ref IntPtr Namespace => ref *(IntPtr*)(&_->namespaze); public unsafe ref Il2CppImage* Image => ref _->image; public unsafe ref Il2CppClass* Parent => ref _->parent; public unsafe ref Il2CppClass* ElementClass => ref _->element_class; public unsafe ref Il2CppClass* CastClass => ref _->castClass; public unsafe ref Il2CppClass* DeclaringType => ref _->declaringType; public unsafe ref Il2CppClass* Class => ref _->klass; public unsafe ref Il2CppFieldInfo* Fields => ref _->fields; public unsafe ref Il2CppMethodInfo** Methods => ref _->methods; public unsafe ref Il2CppClass** ImplementedInterfaces => ref _->implementedInterfaces; public unsafe ref Il2CppRuntimeInterfaceOffsetPair* InterfaceOffsets => ref _->interfaceOffsets; public unsafe ref Il2CppClass** TypeHierarchy => ref _->typeHierarchy; public bool ValueType { get { return this.CheckBit(_bitfield0offset, 1); } set { this.SetBit(_bitfield0offset, 1, value); } } public bool Initialized { get { return this.CheckBit(_bitfield0offset, 2); } set { this.SetBit(_bitfield0offset, 2, value); } } public bool EnumType { get { return this.CheckBit(_bitfield0offset, 3); } set { this.SetBit(_bitfield0offset, 3, value); } } public bool IsGeneric { get { return this.CheckBit(_bitfield0offset, 4); } set { this.SetBit(_bitfield0offset, 4, value); } } public bool HasReferences { get { return this.CheckBit(_bitfield0offset, 5); } set { this.SetBit(_bitfield0offset, 5, value); } } public bool SizeInited { get { return this.CheckBit(_bitfield1offset, 0); } set { this.SetBit(_bitfield1offset, 0, value); } } public bool HasFinalize { get { return this.CheckBit(_bitfield1offset, 1); } set { this.SetBit(_bitfield1offset, 1, value); } } public bool IsVtableInitialized { get { return this.CheckBit(_bitfield1offset, 5); } set { this.SetBit(_bitfield1offset, 5, value); } } public bool InitializedAndNoError { get { return this.CheckBit(_bitfield0offset, 0); } set { this.SetBit(_bitfield0offset, 0, value); } } public NativeStructWrapper(IntPtr ptr) { Pointer = ptr; } } public unsafe int Size() { return sizeof(Il2CppClass_27_1); } public unsafe INativeClassStruct CreateNewStruct(int vTableSlots) { IntPtr intPtr = Marshal.AllocHGlobal(Size() + sizeof(VirtualInvokeData) * vTableSlots); Il2CppClass_27_1* ptr = (Il2CppClass_27_1*)(void*)intPtr; *ptr = default(Il2CppClass_27_1); return new NativeStructWrapper(intPtr); } public unsafe INativeClassStruct Wrap(Il2CppClass* ptr) { if (ptr == null) { return null; } return new NativeStructWrapper((IntPtr)ptr); } } [ApplicableToUnityVersionsSince("2021.1.0")] public class NativeClassStructHandler_27_2 : INativeClassStructHandler, INativeStructHandler { internal struct Il2CppClass_27_2 { internal enum Bitfield0 : byte { BIT_initialized_and_no_error = 0, initialized_and_no_error = 1, BIT_initialized = 1, initialized = 2, BIT_enumtype = 2, enumtype = 4, BIT_is_generic = 3, is_generic = 8, BIT_has_references = 4, has_references = 16, BIT_init_pending = 5, init_pending = 32, BIT_size_inited = 6, size_inited = 64, BIT_has_finalize = 7, has_finalize = 128 } internal enum Bitfield1 : byte { BIT_has_cctor = 0, has_cctor = 1, BIT_is_blittable = 1, is_blittable = 2, BIT_is_import_or_windows_runtime = 2, is_import_or_windows_runtime = 4, BIT_is_vtable_initialized = 3, is_vtable_initialized = 8, BIT_has_initialization_error = 4, has_initialization_error = 16 } public unsafe Il2CppImage* image; public unsafe void* gc_desc; public unsafe byte* name; public unsafe byte* namespaze; public NativeTypeStructHandler_27_0.Il2CppType_27_0 byval_arg; public NativeTypeStructHandler_27_0.Il2CppType_27_0 this_arg; public unsafe Il2CppClass* element_class; public unsafe Il2CppClass* castClass; public unsafe Il2CppClass* declaringType; public unsafe Il2CppClass* parent; public unsafe void* generic_class; public Il2CppMetadataTypeHandle typeMetadataHandle; public unsafe void* interopData; public unsafe Il2CppClass* klass; public unsafe Il2CppFieldInfo* fields; public unsafe Il2CppEventInfo* events; public unsafe Il2CppPropertyInfo* properties; public unsafe Il2CppMethodInfo** methods; public unsafe Il2CppClass** nestedTypes; public unsafe Il2CppClass** implementedInterfaces; public unsafe Il2CppRuntimeInterfaceOffsetPair* interfaceOffsets; public unsafe void* static_fields; public unsafe void* rgctx_data; public unsafe Il2CppClass** typeHierarchy; public unsafe void* unity_user_data; public uint initializationExceptionGCHandle; public uint cctor_started; public uint cctor_finished; public IntPtr cctor_thread; public Il2CppMetadataGenericContainerHandle genericContainerHandle; public uint instance_size; public uint actualSize; public uint element_size; public int native_size; public uint static_fields_size; public uint thread_static_fields_size; public int thread_static_fields_offset; public uint flags; public uint token; public ushort method_count; public ushort property_count; public ushort field_count; public ushort event_count; public ushort nested_type_count; public ushort vtable_count; public ushort interfaces_count; public ushort interface_offsets_count; public byte typeHierarchyDepth; public byte genericRecursionDepth; public byte rank; public byte minimumAlignment; public byte naturalAligment; public byte packingSize; public Bitfield0 _bitfield0; public Bitfield1 _bitfield1; } internal class NativeStructWrapper : INativeClassStruct, INativeStruct { private static int _bitfield0offset = Marshal.OffsetOf("_bitfield0").ToInt32(); private static int _bitfield1offset = Marshal.OffsetOf("_bitfield1").ToInt32(); public IntPtr Pointer { get; } private unsafe Il2CppClass_27_2* _ => (Il2CppClass_27_2*)(void*)Pointer; public unsafe IntPtr VTable => IntPtr.Add(Pointer, sizeof(Il2CppClass_27_2)); public unsafe Il2CppClass* ClassPointer => (Il2CppClass*)(void*)Pointer; public unsafe INativeTypeStruct ByValArg => UnityVersionHandler.Wrap((Il2CppTypeStruct*)(&_->byval_arg)); public unsafe INativeTypeStruct ThisArg => UnityVersionHandler.Wrap((Il2CppTypeStruct*)(&_->this_arg)); public unsafe ref uint InstanceSize => ref _->instance_size; public unsafe ref ushort VtableCount => ref _->vtable_count; public unsafe ref ushort InterfaceCount => ref _->interfaces_count; public unsafe ref ushort InterfaceOffsetsCount => ref _->interface_offsets_count; public unsafe ref byte TypeHierarchyDepth => ref _->typeHierarchyDepth; public unsafe ref int NativeSize => ref _->native_size; public unsafe ref uint ActualSize => ref _->actualSize; public unsafe ref ushort MethodCount => ref _->method_count; public unsafe ref ushort FieldCount => ref _->field_count; public unsafe ref Il2CppClassAttributes Flags => ref *(Il2CppClassAttributes*)(&_->flags); public unsafe ref IntPtr Name => ref *(IntPtr*)(&_->name); public unsafe ref IntPtr Namespace => ref *(IntPtr*)(&_->namespaze); public unsafe ref Il2CppImage* Image => ref _->image; public unsafe ref Il2CppClass* Parent => ref _->parent; public unsafe ref Il2CppClass* ElementClass => ref _->element_class; public unsafe ref Il2CppClass* CastClass => ref _->castClass; public unsafe ref Il2CppClass* DeclaringType => ref _->declaringType; public unsafe ref Il2CppClass* Class => ref _->klass; public unsafe ref Il2CppFieldInfo* Fields => ref _->fields; public unsafe ref Il2CppMethodInfo** Methods => ref _->methods; public unsafe ref Il2CppClass** ImplementedInterfaces => ref _->implementedInterfaces; public unsafe ref Il2CppRuntimeInterfaceOffsetPair* InterfaceOffsets => ref _->interfaceOffsets; public unsafe ref Il2CppClass** TypeHierarchy => ref _->typeHierarchy; public bool ValueType { get { if (ByValArg.ValueType) { return ThisArg.ValueType; } return false; } set { } } public bool Initialized { get { return this.CheckBit(_bitfield0offset, 1); } set { this.SetBit(_bitfield0offset, 1, value); } } public bool EnumType { get { return this.CheckBit(_bitfield0offset, 2); } set { this.SetBit(_bitfield0offset, 2, value); } } public bool IsGeneric { get { return this.CheckBit(_bitfield0offset, 3); } set { this.SetBit(_bitfield0offset, 3, value); } } public bool HasReferences { get { return this.CheckBit(_bitfield0offset, 4); } set { this.SetBit(_bitfield0offset, 4, value); } } public bool SizeInited { get { return this.CheckBit(_bitfield0offset, 6); } set { this.SetBit(_bitfield0offset, 6, value); } } public bool HasFinalize { get { return this.CheckBit(_bitfield0offset, 7); } set { this.SetBit(_bitfield0offset, 7, value); } } public bool IsVtableInitialized { get { return this.CheckBit(_bitfield1offset, 3); } set { this.SetBit(_bitfield1offset, 3, value); } } public bool InitializedAndNoError { get { return this.CheckBit(_bitfield0offset, 0); } set { this.SetBit(_bitfield0offset, 0, value); } } public NativeStructWrapper(IntPtr ptr) { Pointer = ptr; } } public unsafe int Size() { return sizeof(Il2CppClass_27_2); } public unsafe INativeClassStruct CreateNewStruct(int vTableSlots) { IntPtr intPtr = Marshal.AllocHGlobal(Size() + sizeof(VirtualInvokeData) * vTableSlots); Il2CppClass_27_2* ptr = (Il2CppClass_27_2*)(void*)intPtr; *ptr = default(Il2CppClass_27_2); return new NativeStructWrapper(intPtr); } public unsafe INativeClassStruct Wrap(Il2CppClass* ptr) { if (ptr == null) { return null; } return new NativeStructWrapper((IntPtr)ptr); } } [ApplicableToUnityVersionsSince("2021.1.24")] public class NativeClassStructHandler_27_3 : INativeClassStructHandler, INativeStructHandler { internal struct Il2CppClass_27_3 { internal enum Bitfield0 : byte { BIT_initialized_and_no_error = 0, initialized_and_no_error = 1, BIT_initialized = 1, initialized = 2, BIT_enumtype = 2, enumtype = 4, BIT_is_generic = 3, is_generic = 8, BIT_has_references = 4, has_references = 16, BIT_init_pending = 5, init_pending = 32, BIT_size_init_pending = 6, size_init_pending = 64, BIT_size_inited = 7, size_inited = 128 } internal enum Bitfield1 : byte { BIT_has_finalize = 0, has_finalize = 1, BIT_has_cctor = 1, has_cctor = 2, BIT_is_blittable = 2, is_blittable = 4, BIT_is_import_or_windows_runtime = 3, is_import_or_windows_runtime = 8, BIT_is_vtable_initialized = 4, is_vtable_initialized = 16, BIT_has_initialization_error = 5, has_initialization_error = 32 } public unsafe Il2CppImage* image; public unsafe void* gc_desc; public unsafe byte* name; public unsafe byte* namespaze; public NativeTypeStructHandler_27_0.Il2CppType_27_0 byval_arg; public NativeTypeStructHandler_27_0.Il2CppType_27_0 this_arg; public unsafe Il2CppClass* element_class; public unsafe Il2CppClass* castClass; public unsafe Il2CppClass* declaringType; public unsafe Il2CppClass* parent; public unsafe void* generic_class; public Il2CppMetadataTypeHandle typeMetadataHandle; public unsafe void* interopData; public unsafe Il2CppClass* klass; public unsafe Il2CppFieldInfo* fields; public unsafe Il2CppEventInfo* events; public unsafe Il2CppPropertyInfo* properties; public unsafe Il2CppMethodInfo** methods; public unsafe Il2CppClass** nestedTypes; public unsafe Il2CppClass** implementedInterfaces; public unsafe Il2CppRuntimeInterfaceOffsetPair* interfaceOffsets; public unsafe void* static_fields; public unsafe void* rgctx_data; public unsafe Il2CppClass** typeHierarchy; public unsafe void* unity_user_data; public uint initializationExceptionGCHandle; public uint cctor_started; public uint cctor_finished; public IntPtr cctor_thread; public Il2CppMetadataGenericContainerHandle genericContainerHandle; public uint instance_size; public uint actualSize; public uint element_size; public int native_size; public uint static_fields_size; public uint thread_static_fields_size; public int thread_static_fields_offset; public uint flags; public uint token; public ushort method_count; public ushort property_count; public ushort field_count; public ushort event_count; public ushort nested_type_count; public ushort vtable_count; public ushort interfaces_count; public ushort interface_offsets_count; public byte typeHierarchyDepth; public byte genericRecursionDepth; public byte rank; public byte minimumAlignment; public byte naturalAligment; public byte packingSize; public Bitfield0 _bitfield0; public Bitfield1 _bitfield1; } internal class NativeStructWrapper : INativeClassStruct, INativeStruct { private static int _bitfield0offset = Marshal.OffsetOf("_bitfield0").ToInt32(); private static int _bitfield1offset = Marshal.OffsetOf("_bitfield1").ToInt32(); public IntPtr Pointer { get; } private unsafe Il2CppClass_27_3* _ => (Il2CppClass_27_3*)(void*)Pointer; public unsafe IntPtr VTable => IntPtr.Add(Pointer, sizeof(Il2CppClass_27_3)); public unsafe Il2CppClass* ClassPointer => (Il2CppClass*)(void*)Pointer; public unsafe INativeTypeStruct ByValArg => UnityVersionHandler.Wrap((Il2CppTypeStruct*)(&_->byval_arg)); public unsafe INativeTypeStruct ThisArg => UnityVersionHandler.Wrap((Il2CppTypeStruct*)(&_->this_arg)); public unsafe ref uint InstanceSize => ref _->instance_size; public unsafe ref ushort VtableCount => ref _->vtable_count; public unsafe ref ushort InterfaceCount => ref _->interfaces_count; public unsafe ref ushort InterfaceOffsetsCount => ref _->interface_offsets_count; public unsafe ref byte TypeHierarchyDepth => ref _->typeHierarchyDepth; public unsafe ref int NativeSize => ref _->native_size; public unsafe ref uint ActualSize => ref _->actualSize; public unsafe ref ushort MethodCount => ref _->method_count; public unsafe ref ushort FieldCount => ref _->field_count; public unsafe ref Il2CppClassAttributes Flags => ref *(Il2CppClassAttributes*)(&_->flags); public unsafe ref IntPtr Name => ref *(IntPtr*)(&_->name); public unsafe ref IntPtr Namespace => ref *(IntPtr*)(&_->namespaze); public unsafe ref Il2CppImage* Image => ref _->image; public unsafe ref Il2CppClass* Parent => ref _->parent; public unsafe ref Il2CppClass* ElementClass => ref _->element_class; public unsafe ref Il2CppClass* CastClass => ref _->castClass; public unsafe ref Il2CppClass* DeclaringType => ref _->declaringType; public unsafe ref Il2CppClass* Class => ref _->klass; public unsafe ref Il2CppFieldInfo* Fields => ref _->fields; public unsafe ref Il2CppMethodInfo** Methods => ref _->methods; public unsafe ref Il2CppClass** ImplementedInterfaces => ref _->implementedInterfaces; public unsafe ref Il2CppRuntimeInterfaceOffsetPair* InterfaceOffsets => ref _->interfaceOffsets; public unsafe ref Il2CppClass** TypeHierarchy => ref _->typeHierarchy; public bool ValueType { get { if (ByValArg.ValueType) { return ThisArg.ValueType; } return false; } set { } } public bool Initialized { get { return this.CheckBit(_bitfield0offset, 1); } set { this.SetBit(_bitfield0offset, 1, value); } } public bool EnumType { get { return this.CheckBit(_bitfield0offset, 2); } set { this.SetBit(_bitfield0offset, 2, value); } } public bool IsGeneric { get { return this.CheckBit(_bitfield0offset, 3); } set { this.SetBit(_bitfield0offset, 3, value); } } public bool HasReferences { get { return this.CheckBit(_bitfield0offset, 4); } set { this.SetBit(_bitfield0offset, 4, value); } } public bool SizeInited { get { return this.CheckBit(_bitfield0offset, 7); } set { this.SetBit(_bitfield0offset, 7, value); } } public bool HasFinalize { get { return this.CheckBit(_bitfield1offset, 0); } set { this.SetBit(_bitfield1offset, 0, value); } } public bool IsVtableInitialized { get { return this.CheckBit(_bitfield1offset, 4); } set { this.SetBit(_bitfield1offset, 4, value); } } public bool InitializedAndNoError { get { return this.CheckBit(_bitfield0offset, 0); } set { this.SetBit(_bitfield0offset, 0, value); } } public NativeStructWrapper(IntPtr ptr) { Pointer = ptr; } } public unsafe int Size() { return sizeof(Il2CppClass_27_3); } public unsafe INativeClassStruct CreateNewStruct(int vTableSlots) { IntPtr intPtr = Marshal.AllocHGlobal(Size() + sizeof(VirtualInvokeData) * vTableSlots); Il2CppClass_27_3* ptr = (Il2CppClass_27_3*)(void*)intPtr; *ptr = default(Il2CppClass_27_3); return new NativeStructWrapper(intPtr); } public unsafe INativeClassStruct Wrap(Il2CppClass* ptr) { if (ptr == null) { return null; } return new NativeStructWrapper((IntPtr)ptr); } } [ApplicableToUnityVersionsSince("2021.2.0")] public class NativeClassStructHandler_29_0 : INativeClassStructHandler, INativeStructHandler { internal struct Il2CppClass_29_0 { internal enum Bitfield0 : byte { BIT_initialized_and_no_error = 0, initialized_and_no_error = 1, BIT_initialized = 1, initialized = 2, BIT_enumtype = 2, enumtype = 4, BIT_nullabletype = 3, nullabletype = 8, BIT_is_generic = 4, is_generic = 16, BIT_has_references = 5, has_references = 32, BIT_init_pending = 6, init_pending = 64, BIT_size_init_pending = 7, size_init_pending = 128 } internal enum Bitfield1 : byte { BIT_size_inited = 0, size_inited = 1, BIT_has_finalize = 1, has_finalize = 2, BIT_has_cctor = 2, has_cctor = 4, BIT_is_blittable = 3, is_blittable = 8, BIT_is_import_or_windows_runtime = 4, is_import_or_windows_runtime = 16, BIT_is_vtable_initialized = 5, is_vtable_initialized = 32, BIT_is_byref_like = 6, is_byref_like = 64 } public unsafe Il2CppImage* image; public unsafe void* gc_desc; public unsafe byte* name; public unsafe byte* namespaze; public NativeTypeStructHandler_27_0.Il2CppType_27_0 byval_arg; public NativeTypeStructHandler_27_0.Il2CppType_27_0 this_arg; public unsafe Il2CppClass* element_class; public unsafe Il2CppClass* castClass; public unsafe Il2CppClass* declaringType; public unsafe Il2CppClass* parent; public unsafe void* generic_class; public Il2CppMetadataTypeHandle typeMetadataHandle; public unsafe void* interopData; public unsafe Il2CppClass* klass; public unsafe Il2CppFieldInfo* fields; public unsafe Il2CppEventInfo* events; public unsafe Il2CppPropertyInfo* properties; public unsafe Il2CppMethodInfo** methods; public unsafe Il2CppClass** nestedTypes; public unsafe Il2CppClass** implementedInterfaces; public unsafe Il2CppRuntimeInterfaceOffsetPair* interfaceOffsets; public unsafe void* static_fields; public unsafe void* rgctx_data; public unsafe Il2CppClass** typeHierarchy; public unsafe void* unity_user_data; public uint initializationExceptionGCHandle; public uint cctor_started; public uint cctor_finished_or_no_cctor; public IntPtr cctor_thread; public Il2CppMetadataGenericContainerHandle genericContainerHandle; public uint instance_size; public uint actualSize; public uint element_size; public int native_size; public uint static_fields_size; public uint thread_static_fields_size; public int thread_static_fields_offset; public uint flags; public uint token; public ushort method_count; public ushort property_count; public ushort field_count; public ushort event_count; public ushort nested_type_count; public ushort vtable_count; public ushort interfaces_count; public ushort interface_offsets_count; public byte typeHierarchyDepth; public byte genericRecursionDepth; public byte rank; public byte minimumAlignment; public byte naturalAligment; public byte packingSize; public Bitfield0 _bitfield0; public Bitfield1 _bitfield1; } internal class NativeStructWrapper : INativeClassStruct, INativeStruct { private static int _bitfield0offset = Marshal.OffsetOf("_bitfield0").ToInt32(); private static int _bitfield1offset = Marshal.OffsetOf("_bitfield1").ToInt32(); public IntPtr Pointer { get; } private unsafe Il2CppClass_29_0* _ => (Il2CppClass_29_0*)(void*)Pointer; public unsafe IntPtr VTable => IntPtr.Add(Pointer, sizeof(Il2CppClass_29_0)); public unsafe Il2CppClass* ClassPointer => (Il2CppClass*)(void*)Pointer; public unsafe INativeTypeStruct ByValArg => UnityVersionHandler.Wrap((Il2CppTypeStruct*)(&_->byval_arg)); public unsafe INativeTypeStruct ThisArg => UnityVersionHandler.Wrap((Il2CppTypeStruct*)(&_->this_arg)); public unsafe ref uint InstanceSize => ref _->instance_size; public unsafe ref ushort VtableCount => ref _->vtable_count; public unsafe ref ushort InterfaceCount => ref _->interfaces_count; public unsafe ref ushort InterfaceOffsetsCount => ref _->interface_offsets_count; public unsafe ref byte TypeHierarchyDepth => ref _->typeHierarchyDepth; public unsafe ref int NativeSize => ref _->native_size; public unsafe ref uint ActualSize => ref _->actualSize; public unsafe ref ushort MethodCount => ref _->method_count; public unsafe ref ushort FieldCount => ref _->field_count; public unsafe ref Il2CppClassAttributes Flags => ref *(Il2CppClassAttributes*)(&_->flags); public unsafe ref IntPtr Name => ref *(IntPtr*)(&_->name); public unsafe ref IntPtr Namespace => ref *(IntPtr*)(&_->namespaze); public unsafe ref Il2CppImage* Image => ref _->image; public unsafe ref Il2CppClass* Parent => ref _->parent; public unsafe ref Il2CppClass* ElementClass => ref _->element_class; public unsafe ref Il2CppClass* CastClass => ref _->castClass; public unsafe ref Il2CppClass* DeclaringType => ref _->declaringType; public unsafe ref Il2CppClass* Class => ref _->klass; public unsafe ref Il2CppFieldInfo* Fields => ref _->fields; public unsafe ref Il2CppMethodInfo** Methods => ref _->methods; public unsafe ref Il2CppClass** ImplementedInterfaces => ref _->implementedInterfaces; public unsafe ref Il2CppRuntimeInterfaceOffsetPair* InterfaceOffsets => ref _->interfaceOffsets; public unsafe ref Il2CppClass** TypeHierarchy => ref _->typeHierarchy; public bool ValueType { get { if (ByValArg.ValueType) { return ThisArg.ValueType; } return false; } set { } } public bool Initialized { get { return this.CheckBit(_bitfield0offset, 1); } set { this.SetBit(_bitfield0offset, 1, value); } } public bool EnumType { get { return this.CheckBit(_bitfield0offset, 2); } set { this.SetBit(_bitfield0offset, 2, value); } } public bool IsGeneric { get { return this.CheckBit(_bitfield0offset, 4); } set { this.SetBit(_bitfield0offset, 4, value); } } public bool HasReferences { get { return this.CheckBit(_bitfield0offset, 5); } set { this.SetBit(_bitfield0offset, 5, value); } } public bool SizeInited { get { return this.CheckBit(_bitfield1offset, 0); } set { this.SetBit(_bitfield1offset, 0, value); } } public bool HasFinalize { get { return this.CheckBit(_bitfield1offset, 1); } set { this.SetBit(_bitfield1offset, 1, value); } } public bool IsVtableInitialized { get { return this.CheckBit(_bitfield1offset, 5); } set { this.SetBit(_bitfield1offset, 5, value); } } public bool InitializedAndNoError { get { return this.CheckBit(_bitfield0offset, 0); } set { this.SetBit(_bitfield0offset, 0, value); } } public NativeStructWrapper(IntPtr ptr) { Pointer = ptr; } } public unsafe int Size() { return sizeof(Il2CppClass_29_0); } public unsafe INativeClassStruct CreateNewStruct(int vTableSlots) { IntPtr intPtr = Marshal.AllocHGlobal(Size() + sizeof(VirtualInvokeData) * vTableSlots); Il2CppClass_29_0* ptr = (Il2CppClass_29_0*)(void*)intPtr; *ptr = default(Il2CppClass_29_0); return new NativeStructWrapper(intPtr); } public unsafe INativeClassStruct Wrap(Il2CppClass* ptr) { if (ptr == null) { return null; } return new NativeStructWrapper((IntPtr)ptr); } } [ApplicableToUnityVersionsSince("2022.2.0")] public class NativeClassStructHandler_29_1 : INativeClassStructHandler, INativeStructHandler { internal struct Il2CppClass_29_1 { internal enum Bitfield0 : byte { BIT_initialized_and_no_error = 0, initialized_and_no_error = 1, BIT_initialized = 1, initialized = 2, BIT_enumtype = 2, enumtype = 4, BIT_nullabletype = 3, nullabletype = 8, BIT_is_generic = 4, is_generic = 16, BIT_has_references = 5, has_references = 32, BIT_init_pending = 6, init_pending = 64, BIT_size_init_pending = 7, size_init_pending = 128 } internal enum Bitfield1 : byte { BIT_size_inited = 0, size_inited = 1, BIT_has_finalize = 1, has_finalize = 2, BIT_has_cctor = 2, has_cctor = 4, BIT_is_blittable = 3, is_blittable = 8, BIT_is_import_or_windows_runtime = 4, is_import_or_windows_runtime = 16, BIT_is_vtable_initialized = 5, is_vtable_initialized = 32, BIT_is_byref_like = 6, is_byref_like = 64 } public unsafe Il2CppImage* image; public unsafe void* gc_desc; public unsafe byte* name; public unsafe byte* namespaze; public NativeTypeStructHandler_27_0.Il2CppType_27_0 byval_arg; public NativeTypeStructHandler_27_0.Il2CppType_27_0 this_arg; public unsafe Il2CppClass* element_class; public unsafe Il2CppClass* castClass; public unsafe Il2CppClass* declaringType; public unsafe Il2CppClass* parent; public unsafe void* generic_class; public Il2CppMetadataTypeHandle typeMetadataHandle; public unsafe void* interopData; public unsafe Il2CppClass* klass; public unsafe Il2CppFieldInfo* fields; public unsafe Il2CppEventInfo* events; public unsafe Il2CppPropertyInfo* properties; public unsafe Il2CppMethodInfo** methods; public unsafe Il2CppClass** nestedTypes; public unsafe Il2CppClass** implementedInterfaces; public unsafe Il2CppRuntimeInterfaceOffsetPair* interfaceOffsets; public unsafe void* static_fields; public unsafe void* rgctx_data; public unsafe Il2CppClass** typeHierarchy; public unsafe void* unity_user_data; public uint initializationExceptionGCHandle; public uint cctor_started; public uint cctor_finished_or_no_cctor; public IntPtr cctor_thread; public Il2CppMetadataGenericContainerHandle genericContainerHandle; public uint instance_size; public uint stack_slot_size; public uint actualSize; public uint element_size; public int native_size; public uint static_fields_size; public uint thread_static_fields_size; public int thread_static_fields_offset; public uint flags; public uint token; public ushort method_count; public ushort property_count; public ushort field_count; public ushort event_count; public ushort nested_type_count; public ushort vtable_count; public ushort interfaces_count; public ushort interface_offsets_count; public byte typeHierarchyDepth; public byte genericRecursionDepth; public byte rank; public byte minimumAlignment; public byte packingSize; public Bitfield0 _bitfield0; public Bitfield1 _bitfield1; } internal class NativeStructWrapper : INativeClassStruct, INativeStruct { private static int _bitfield0offset = Marshal.OffsetOf("_bitfield0").ToInt32(); private static int _bitfield1offset = Marshal.OffsetOf("_bitfield1").ToInt32(); public IntPtr Pointer { get; } private unsafe Il2CppClass_29_1* _ => (Il2CppClass_29_1*)(void*)Pointer; public unsafe IntPtr VTable => IntPtr.Add(Pointer, sizeof(Il2CppClass_29_1)); public unsafe Il2CppClass* ClassPointer => (Il2CppClass*)(void*)Pointer; public unsafe INativeTypeStruct ByValArg => UnityVersionHandler.Wrap((Il2CppTypeStruct*)(&_->byval_arg)); public unsafe INativeTypeStruct ThisArg => UnityVersionHandler.Wrap((Il2CppTypeStruct*)(&_->this_arg)); public unsafe ref uint InstanceSize => ref _->instance_size; public unsafe ref ushort VtableCount => ref _->vtable_count; public unsafe ref ushort InterfaceCount => ref _->interfaces_count; public unsafe ref ushort InterfaceOffsetsCount => ref _->interface_offsets_count; public unsafe ref byte TypeHierarchyDepth => ref _->typeHierarchyDepth; public unsafe ref int NativeSize => ref _->native_size; public unsafe ref uint ActualSize => ref _->actualSize; public unsafe ref ushort MethodCount => ref _->method_count; public unsafe ref ushort FieldCount => ref _->field_count; public unsafe ref Il2CppClassAttributes Flags => ref *(Il2CppClassAttributes*)(&_->flags); public unsafe ref IntPtr Name => ref *(IntPtr*)(&_->name); public unsafe ref IntPtr Namespace => ref *(IntPtr*)(&_->namespaze); public unsafe ref Il2CppImage* Image => ref _->image; public unsafe ref Il2CppClass* Parent => ref _->parent; public unsafe ref Il2CppClass* ElementClass => ref _->element_class; public unsafe ref Il2CppClass* CastClass => ref _->castClass; public unsafe ref Il2CppClass* DeclaringType => ref _->declaringType; public unsafe ref Il2CppClass* Class => ref _->klass; public unsafe ref Il2CppFieldInfo* Fields => ref _->fields; public unsafe ref Il2CppMethodInfo** Methods => ref _->methods; public unsafe ref Il2CppClass** ImplementedInterfaces => ref _->implementedInterfaces; public unsafe ref Il2CppRuntimeInterfaceOffsetPair* InterfaceOffsets => ref _->interfaceOffsets; public unsafe ref Il2CppClass** TypeHierarchy => ref _->typeHierarchy; public bool ValueType { get { if (ByValArg.ValueType) { return ThisArg.ValueType; } return false; } set { } } public bool Initialized { get { return this.CheckBit(_bitfield0offset, 1); } set { this.SetBit(_bitfield0offset, 1, value); } } public bool EnumType { get { return this.CheckBit(_bitfield0offset, 2); } set { this.SetBit(_bitfield0offset, 2, value); } } public bool IsGeneric { get { return this.CheckBit(_bitfield0offset, 4); } set { this.SetBit(_bitfield0offset, 4, value); } } public bool HasReferences { get { return this.CheckBit(_bitfield0offset, 5); } set { this.SetBit(_bitfield0offset, 5, value); } } public bool SizeInited { get { return this.CheckBit(_bitfield1offset, 0); } set { this.SetBit(_bitfield1offset, 0, value); } } public bool HasFinalize { get { return this.CheckBit(_bitfield1offset, 1); } set { this.SetBit(_bitfield1offset, 1, value); } } public bool IsVtableInitialized { get { return this.CheckBit(_bitfield1offset, 5); } set { this.SetBit(_bitfield1offset, 5, value); } } public bool InitializedAndNoError { get { return this.CheckBit(_bitfield0offset, 0); } set { this.SetBit(_bitfield0offset, 0, value); } } public NativeStructWrapper(IntPtr ptr) { Pointer = ptr; } } public unsafe int Size() { return sizeof(Il2CppClass_29_1); } public unsafe INativeClassStruct CreateNewStruct(int vTableSlots) { IntPtr intPtr = Marshal.AllocHGlobal(Size() + sizeof(VirtualInvokeData) * vTableSlots); Il2CppClass_29_1* ptr = (Il2CppClass_29_1*)(void*)intPtr; *ptr = default(Il2CppClass_29_1); return new NativeStructWrapper(intPtr); } public unsafe INativeClassStruct Wrap(Il2CppClass* ptr) { if (ptr == null) { return null; } return new NativeStructWrapper((IntPtr)ptr); } } [ApplicableToUnityVersionsSince("2023.1.0")] public class NativeClassStructHandler_29_2 : INativeClassStructHandler, INativeStructHandler { internal struct Il2CppClass_29_2 { internal enum Bitfield0 : byte { BIT_initialized_and_no_error = 0, initialized_and_no_error = 1, BIT_initialized = 1, initialized = 2, BIT_enumtype = 2, enumtype = 4, BIT_nullabletype = 3, nullabletype = 8, BIT_is_generic = 4, is_generic = 16, BIT_has_references = 5, has_references = 32, BIT_init_pending = 6, init_pending = 64, BIT_size_init_pending = 7, size_init_pending = 128 } internal enum Bitfield1 : byte { BIT_size_inited = 0, size_inited = 1, BIT_has_finalize = 1, has_finalize = 2, BIT_has_cctor = 2, has_cctor = 4, BIT_is_blittable = 3, is_blittable = 8, BIT_is_import_or_windows_runtime = 4, is_import_or_windows_runtime = 16, BIT_is_vtable_initialized = 5, is_vtable_initialized = 32, BIT_is_byref_like = 6, is_byref_like = 64 } public unsafe Il2CppImage* image; public unsafe void* gc_desc; public unsafe byte* name; public unsafe byte* namespaze; public NativeTypeStructHandler_27_0.Il2CppType_27_0 byval_arg; public NativeTypeStructHandler_27_0.Il2CppType_27_0 this_arg; public unsafe Il2CppClass* element_class; public unsafe Il2CppClass* castClass; public unsafe Il2CppClass* declaringType; public unsafe Il2CppClass* parent; public unsafe void* generic_class; public Il2CppMetadataTypeHandle typeMetadataHandle; public unsafe void* interopData; public unsafe Il2CppClass* klass; public unsafe Il2CppFieldInfo* fields; public unsafe Il2CppEventInfo* events; public unsafe Il2CppPropertyInfo* properties; public unsafe Il2CppMethodInfo** methods; public unsafe Il2CppClass** nestedTypes; public unsafe Il2CppClass** implementedInterfaces; public unsafe Il2CppRuntimeInterfaceOffsetPair* interfaceOffsets; public unsafe void* static_fields; public unsafe void* rgctx_data; public unsafe Il2CppClass** typeHierarchy; public unsafe void* unity_user_data; public Il2CppGCHandle initializationExceptionGCHandle; public uint cctor_started; public uint cctor_finished_or_no_cctor; public IntPtr cctor_thread; public Il2CppMetadataGenericContainerHandle genericContainerHandle; public uint instance_size; public uint stack_slot_size; public uint actualSize; public uint element_size; public int native_size; public uint static_fields_size; public uint thread_static_fields_size; public int thread_static_fields_offset; public uint flags; public uint token; public ushort method_count; public ushort property_count; public ushort field_count; public ushort event_count; public ushort nested_type_count; public ushort vtable_count; public ushort interfaces_count; public ushort interface_offsets_count; public byte typeHierarchyDepth; public byte genericRecursionDepth; public byte rank; public byte minimumAlignment; public byte packingSize; public Bitfield0 _bitfield0; public Bitfield1 _bitfield1; } internal class NativeStructWrapper : INativeClassStruct, INativeStruct { private static int _bitfield0offset = Marshal.OffsetOf("_bitfield0").ToInt32(); private static int _bitfield1offset = Marshal.OffsetOf("_bitfield1").ToInt32(); public IntPtr Pointer { get; } private unsafe Il2CppClass_29_2* _ => (Il2CppClass_29_2*)(void*)Pointer; public unsafe IntPtr VTable => IntPtr.Add(Pointer, sizeof(Il2CppClass_29_2)); public unsafe Il2CppClass* ClassPointer => (Il2CppClass*)(void*)Pointer; public unsafe INativeTypeStruct ByValArg => UnityVersionHandler.Wrap((Il2CppTypeStruct*)(&_->byval_arg)); public unsafe INativeTypeStruct ThisArg => UnityVersionHandler.Wrap((Il2CppTypeStruct*)(&_->this_arg)); public unsafe ref uint InstanceSize => ref _->instance_size; public unsafe ref ushort VtableCount => ref _->vtable_count; public unsafe ref ushort InterfaceCount => ref _->interfaces_count; public unsafe ref ushort InterfaceOffsetsCount => ref _->interface_offsets_count; public unsafe ref byte TypeHierarchyDepth => ref _->typeHierarchyDepth; public unsafe ref int NativeSize => ref _->native_size; public unsafe ref uint ActualSize => ref _->actualSize; public unsafe ref ushort MethodCount => ref _->method_count; public unsafe ref ushort FieldCount => ref _->field_count; public unsafe ref Il2CppClassAttributes Flags => ref *(Il2CppClassAttributes*)(&_->flags); public unsafe ref IntPtr Name => ref *(IntPtr*)(&_->name); public unsafe ref IntPtr Namespace => ref *(IntPtr*)(&_->namespaze); public unsafe ref Il2CppImage* Image => ref _->image; public unsafe ref Il2CppClass* Parent => ref _->parent; public unsafe ref Il2CppClass* ElementClass => ref _->element_class; public unsafe ref Il2CppClass* CastClass => ref _->castClass; public unsafe ref Il2CppClass* DeclaringType => ref _->declaringType; public unsafe ref Il2CppClass* Class => ref _->klass; public unsafe ref Il2CppFieldInfo* Fields => ref _->fields; public unsafe ref Il2CppMethodInfo** Methods => ref _->methods; public unsafe ref Il2CppClass** ImplementedInterfaces => ref _->implementedInterfaces; public unsafe ref Il2CppRuntimeInterfaceOffsetPair* InterfaceOffsets => ref _->interfaceOffsets; public unsafe ref Il2CppClass** TypeHierarchy => ref _->typeHierarchy; public bool ValueType { get { if (ByValArg.ValueType) { return ThisArg.ValueType; } return false; } set { } } public bool Initialized { get { return this.CheckBit(_bitfield0offset, 1); } set { this.SetBit(_bitfield0offset, 1, value); } } public bool EnumType { get { return this.CheckBit(_bitfield0offset, 2); } set { this.SetBit(_bitfield0offset, 2, value); } } public bool IsGeneric { get { return this.CheckBit(_bitfield0offset, 4); } set { this.SetBit(_bitfield0offset, 4, value); } } public bool HasReferences { get { return this.CheckBit(_bitfield0offset, 5); } set { this.SetBit(_bitfield0offset, 5, value); } } public bool SizeInited { get { return this.CheckBit(_bitfield1offset, 0); } set { this.SetBit(_bitfield1offset, 0, value); } } public bool HasFinalize { get { return this.CheckBit(_bitfield1offset, 1); } set { this.SetBit(_bitfield1offset, 1, value); } } public bool IsVtableInitialized { get { return this.CheckBit(_bitfield1offset, 5); } set { this.SetBit(_bitfield1offset, 5, value); } } public bool InitializedAndNoError { get { return this.CheckBit(_bitfield0offset, 0); } set { this.SetBit(_bitfield0offset, 0, value); } } public NativeStructWrapper(IntPtr ptr) { Pointer = ptr; } } public unsafe int Size() { return sizeof(Il2CppClass_29_2); } public unsafe INativeClassStruct CreateNewStruct(int vTableSlots) { IntPtr intPtr = Marshal.AllocHGlobal(Size() + sizeof(VirtualInvokeData) * vTableSlots); Il2CppClass_29_2* ptr = (Il2CppClass_29_2*)(void*)intPtr; *ptr = default(Il2CppClass_29_2); return new NativeStructWrapper(intPtr); } public unsafe INativeClassStruct Wrap(Il2CppClass* ptr) { if (ptr == null) { return null; } return new NativeStructWrapper((IntPtr)ptr); } } public interface INativeClassStructHandler : INativeStructHandler { INativeClassStruct CreateNewStruct(int vTableSlots); unsafe INativeClassStruct Wrap(Il2CppClass* classPointer); } public interface INativeClassStruct : INativeStruct { unsafe Il2CppClass* ClassPointer { get; } IntPtr VTable { get; } ref uint InstanceSize { get; } ref ushort VtableCount { get; } ref ushort InterfaceCount { get; } ref ushort InterfaceOffsetsCount { get; } ref byte TypeHierarchyDepth { get; } ref int NativeSize { get; } ref uint ActualSize { get; } ref ushort MethodCount { get; } ref ushort FieldCount { get; } ref Il2CppClassAttributes Flags { get; } bool ValueType { get; set; } bool EnumType { get; set; } bool IsGeneric { get; set; } bool Initialized { get; set; } bool InitializedAndNoError { get; set; } bool SizeInited { get; set; } bool HasFinalize { get; set; } bool IsVtableInitialized { get; set; } ref IntPtr Name { get; } ref IntPtr Namespace { get; } INativeTypeStruct ByValArg { get; } INativeTypeStruct ThisArg { get; } unsafe ref Il2CppImage* Image { get; } unsafe ref Il2CppClass* Parent { get; } unsafe ref Il2CppClass* ElementClass { get; } unsafe ref Il2CppClass* CastClass { get; } unsafe ref Il2CppClass* DeclaringType { get; } unsafe ref Il2CppClass* Class { get; } unsafe ref Il2CppFieldInfo* Fields { get; } unsafe ref Il2CppMethodInfo** Methods { get; } unsafe ref Il2CppClass** ImplementedInterfaces { get; } unsafe ref Il2CppRuntimeInterfaceOffsetPair* InterfaceOffsets { get; } unsafe ref Il2CppClass** TypeHierarchy { get; } } } namespace Il2CppInterop.Runtime.Runtime.VersionSpecific.AssemblyName { [ApplicableToUnityVersionsSince("5.2.2")] public class NativeAssemblyNameStructHandler_16_0 : INativeAssemblyNameStructHandler, INativeStructHandler { internal struct Il2CppAssemblyName_16_0 { public int nameIndex; public int cultureIndex; public int hashValueIndex; public int publicKeyIndex; public uint hash_alg; public int hash_len; public uint flags; public int major; public int minor; public int build; public int revision; public ulong publicKeyToken; } internal class NativeStructWrapper : INativeAssemblyNameStruct, INativeStruct { public IntPtr Pointer { get; } private unsafe Il2CppAssemblyName_16_0* _ => (Il2CppAssemblyName_16_0*)(void*)Pointer; public unsafe Il2CppAssemblyName* AssemblyNamePointer => (Il2CppAssemblyName*)(void*)Pointer; public unsafe ref IntPtr Name => ref *(IntPtr*)(&_->nameIndex); public unsafe ref IntPtr Culture => ref *(IntPtr*)(&_->cultureIndex); public unsafe ref IntPtr PublicKey => ref *(IntPtr*)(&_->publicKeyIndex); public unsafe ref int Major => ref _->major; public unsafe ref int Minor => ref _->minor; public unsafe ref int Build => ref _->build; public unsafe ref int Revision => ref _->revision; public unsafe ref ulong PublicKeyToken => ref _->publicKeyToken; public NativeStructWrapper(IntPtr ptr) { Pointer = ptr; } } public unsafe int Size() { return sizeof(Il2CppAssemblyName_16_0); } public unsafe INativeAssemblyNameStruct CreateNewStruct() { IntPtr intPtr = Marshal.AllocHGlobal(Size()); Il2CppAssemblyName_16_0* ptr = (Il2CppAssemblyName_16_0*)(void*)intPtr; *ptr = default(Il2CppAssemblyName_16_0); return new NativeStructWrapper(intPtr); } public unsafe INativeAssemblyNameStruct Wrap(Il2CppAssemblyName* ptr) { if (ptr == null) { return null; } return new NativeStructWrapper((IntPtr)ptr); } } [ApplicableToUnityVersionsSince("2018.1.0")] public class NativeAssemblyNameStructHandler_24_0 : INativeAssemblyNameStructHandler, INativeStructHandler { internal struct Il2CppAssemblyName_24_0 { public unsafe byte* name; public unsafe byte* culture; public unsafe byte* hash_value; public unsafe byte* public_key; public uint hash_alg; public int hash_len; public uint flags; public int major; public int minor; public int build; public int revision; public ulong public_key_token; } internal class NativeStructWrapper : INativeAssemblyNameStruct, INativeStruct { public IntPtr Pointer { get; } private unsafe Il2CppAssemblyName_24_0* _ => (Il2CppAssemblyName_24_0*)(void*)Pointer; public unsafe Il2CppAssemblyName* AssemblyNamePointer => (Il2CppAssemblyName*)(void*)Pointer; public unsafe ref IntPtr Name => ref *(IntPtr*)(&_->name); public unsafe ref IntPtr Culture => ref *(IntPtr*)(&_->culture); public unsafe ref IntPtr PublicKey => ref *(IntPtr*)(&_->public_key); public unsafe ref int Major => ref _->major; public unsafe ref int Minor => ref _->minor; public unsafe ref int Build => ref _->build; public unsafe ref int Revision => ref _->revision; public unsafe ref ulong PublicKeyToken => ref _->public_key_token; public NativeStructWrapper(IntPtr ptr) { Pointer = ptr; } } public unsafe int Size() { return sizeof(Il2CppAssemblyName_24_0); } public unsafe INativeAssemblyNameStruct CreateNewStruct() { IntPtr intPtr = Marshal.AllocHGlobal(Size()); Il2CppAssemblyName_24_0* ptr = (Il2CppAssemblyName_24_0*)(void*)intPtr; *ptr = default(Il2CppAssemblyName_24_0); return new NativeStructWrapper(intPtr); } public unsafe INativeAssemblyNameStruct Wrap(Il2CppAssemblyName* ptr) { if (ptr == null) { return null; } return new NativeStructWrapper((IntPtr)ptr); } } [ApplicableToUnityVersionsSince("2018.4.34")] public class NativeAssemblyNameStructHandler_24_1 : INativeAssemblyNameStructHandler, INativeStructHandler { internal struct Il2CppAssemblyName_24_1 { public unsafe byte* name; public unsafe byte* culture; public unsafe byte* public_key; public uint hash_alg; public int hash_len; public uint flags; public int major; public int minor; public int build; public int revision; public ulong public_key_token; } internal class NativeStructWrapper : INativeAssemblyNameStruct, INativeStruct { public IntPtr Pointer { get; } private unsafe Il2CppAssemblyName_24_1* _ => (Il2CppAssemblyName_24_1*)(void*)Pointer; public unsafe Il2CppAssemblyName* AssemblyNamePointer => (Il2CppAssemblyName*)(void*)Pointer; public unsafe ref IntPtr Name => ref *(IntPtr*)(&_->name); public unsafe ref IntPtr Culture => ref *(IntPtr*)(&_->culture); public unsafe ref IntPtr PublicKey => ref *(IntPtr*)(&_->public_key); public unsafe ref int Major => ref _->major; public unsafe ref int Minor => ref _->minor; public unsafe ref int Build => ref _->build; public unsafe ref int Revision => ref _->revision; public unsafe ref ulong PublicKeyToken => ref _->public_key_token; public NativeStructWrapper(IntPtr ptr) { Pointer = ptr; } } public unsafe int Size() { return sizeof(Il2CppAssemblyName_24_1); } public unsafe INativeAssemblyNameStruct CreateNewStruct() { IntPtr intPtr = Marshal.AllocHGlobal(Size()); Il2CppAssemblyName_24_1* ptr = (Il2CppAssemblyName_24_1*)(void*)intPtr; *ptr = default(Il2CppAssemblyName_24_1); return new NativeStructWrapper(intPtr); } public unsafe INativeAssemblyNameStruct Wrap(Il2CppAssemblyName* ptr) { if (ptr == null) { return null; } return new NativeStructWrapper((IntPtr)ptr); } } public interface INativeAssemblyNameStructHandler : INativeStructHandler { INativeAssemblyNameStruct CreateNewStruct(); unsafe INativeAssemblyNameStruct Wrap(Il2CppAssemblyName* assemblyNamePointer); } public interface INativeAssemblyNameStruct : INativeStruct { unsafe Il2CppAssemblyName* AssemblyNamePointer { get; } ref IntPtr Name { get; } ref IntPtr Culture { get; } ref IntPtr PublicKey { get; } ref int Major { get; } ref int Minor { get; } ref int Build { get; } ref int Revision { get; } ref ulong PublicKeyToken { get; } } } namespace Il2CppInterop.Runtime.Runtime.VersionSpecific.Assembly { [ApplicableToUnityVersionsSince("5.2.2")] public class NativeAssemblyStructHandler_16_0 : INativeAssemblyStructHandler, INativeStructHandler { internal struct Il2CppAssembly_16_0 { public int imageIndex; public int customAttributeIndex; public NativeAssemblyNameStructHandler_16_0.Il2CppAssemblyName_16_0 aname; } internal class NativeStructWrapper : INativeAssemblyStruct, INativeStruct { public IntPtr Pointer { get; } private unsafe Il2CppAssembly_16_0* _ => (Il2CppAssembly_16_0*)(void*)Pointer; public unsafe Il2CppAssembly* AssemblyPointer => (Il2CppAssembly*)(void*)Pointer; public unsafe INativeAssemblyNameStruct Name { get { return UnityVersionHandler.Wrap((Il2CppAssemblyName*)(&_->aname)); } set { _->aname = *(NativeAssemblyNameStructHandler_16_0.Il2CppAssemblyName_16_0*)Name.AssemblyNamePointer; } } public unsafe ref Il2CppImage* Image { get { throw new NotSupportedException(); } } public NativeStructWrapper(IntPtr ptr) { Pointer = ptr; } } public unsafe int Size() { return sizeof(Il2CppAssembly_16_0); } public unsafe INativeAssemblyStruct CreateNewStruct() { IntPtr intPtr = Marshal.AllocHGlobal(Size()); Il2CppAssembly_16_0* ptr = (Il2CppAssembly_16_0*)(void*)intPtr; *ptr = default(Il2CppAssembly_16_0); return new NativeStructWrapper(intPtr); } public unsafe INativeAssemblyStruct Wrap(Il2CppAssembly* ptr) { if (ptr == null) { return null; } return new NativeStructWrapper((IntPtr)ptr); } } [ApplicableToUnityVersionsSince("5.3.3")] public class NativeAssemblyStructHandler_20_0 : INativeAssemblyStructHandler, INativeStructHandler { internal struct Il2CppAssembly_20_0 { public int imageIndex; public int customAttributeIndex; public int referencedAssemblyStart; public int referencedAssemblyCount; public NativeAssemblyNameStructHandler_16_0.Il2CppAssemblyName_16_0 aname; } internal class NativeStructWrapper : INativeAssemblyStruct, INativeStruct { public IntPtr Pointer { get; } private unsafe Il2CppAssembly_20_0* _ => (Il2CppAssembly_20_0*)(void*)Pointer; public unsafe Il2CppAssembly* AssemblyPointer => (Il2CppAssembly*)(void*)Pointer; public unsafe INativeAssemblyNameStruct Name { get { return UnityVersionHandler.Wrap((Il2CppAssemblyName*)(&_->aname)); } set { _->aname = *(NativeAssemblyNameStructHandler_16_0.Il2CppAssemblyName_16_0*)Name.AssemblyNamePointer; } } public unsafe ref Il2CppImage* Image { get { throw new NotSupportedException(); } } public NativeStructWrapper(IntPtr ptr) { Pointer = ptr; } } public unsafe int Size() { return sizeof(Il2CppAssembly_20_0); } public unsafe INativeAssemblyStruct CreateNewStruct() { IntPtr intPtr = Marshal.AllocHGlobal(Size()); Il2CppAssembly_20_0* ptr = (Il2CppAssembly_20_0*)(void*)intPtr; *ptr = default(Il2CppAssembly_20_0); return new NativeStructWrapper(intPtr); } public unsafe INativeAssemblyStruct Wrap(Il2CppAssembly* ptr) { if (ptr == null) { return null; } return new NativeStructWrapper((IntPtr)ptr); } } [ApplicableToUnityVersionsSince("2018.1.0")] public class NativeAssemblyStructHandler_24_0 : INativeAssemblyStructHandler, INativeStructHandler { internal struct Il2CppAssembly_24_0 { public unsafe Il2CppImage* image; public int customAttributeIndex; public int referencedAssemblyStart; public int referencedAssemblyCount; public NativeAssemblyNameStructHandler_24_0.Il2CppAssemblyName_24_0 aname; } internal class NativeStructWrapper : INativeAssemblyStruct, INativeStruct { public IntPtr Pointer { get; } private unsafe Il2CppAssembly_24_0* _ => (Il2CppAssembly_24_0*)(void*)Pointer; public unsafe Il2CppAssembly* AssemblyPointer => (Il2CppAssembly*)(void*)Pointer; public unsafe INativeAssemblyNameStruct Name { get { return UnityVersionHandler.Wrap((Il2CppAssemblyName*)(&_->aname)); } set { _->aname = *(NativeAssemblyNameStructHandler_24_0.Il2CppAssemblyName_24_0*)Name.AssemblyNamePointer; } } public unsafe ref Il2CppImage* Image => ref _->image; public NativeStructWrapper(IntPtr ptr) { Pointer = ptr; } } public unsafe int Size() { return sizeof(Il2CppAssembly_24_0); } public unsafe INativeAssemblyStruct CreateNewStruct() { IntPtr intPtr = Marshal.AllocHGlobal(Size()); Il2CppAssembly_24_0* ptr = (Il2CppAssembly_24_0*)(void*)intPtr; *ptr = default(Il2CppAssembly_24_0); return new NativeStructWrapper(intPtr); } public unsafe INativeAssemblyStruct Wrap(Il2CppAssembly* ptr) { if (ptr == null) { return null; } return new NativeStructWrapper((IntPtr)ptr); } } [ApplicableToUnityVersionsSince("2018.3.0")] public class NativeAssemblyStructHandler_24_1 : INativeAssemblyStructHandler, INativeStructHandler { internal struct Il2CppAssembly_24_1 { public unsafe Il2CppImage* image; public uint token; public int referencedAssemblyStart; public int referencedAssemblyCount; public NativeAssemblyNameStructHandler_24_0.Il2CppAssemblyName_24_0 aname; } internal class NativeStructWrapper : INativeAssemblyStruct, INativeStruct { public IntPtr Pointer { get; } private unsafe Il2CppAssembly_24_1* _ => (Il2CppAssembly_24_1*)(void*)Pointer; public unsafe Il2CppAssembly* AssemblyPointer => (Il2CppAssembly*)(void*)Pointer; public unsafe INativeAssemblyNameStruct Name { get { return UnityVersionHandler.Wrap((Il2CppAssemblyName*)(&_->aname)); } set { _->aname = *(NativeAssemblyNameStructHandler_24_0.Il2CppAssemblyName_24_0*)Name.AssemblyNamePointer; } } public unsafe ref Il2CppImage* Image => ref _->image; public NativeStructWrapper(IntPtr ptr) { Pointer = ptr; } } public unsafe int Size() { return sizeof(Il2CppAssembly_24_1); } public unsafe INativeAssemblyStruct CreateNewStruct() { IntPtr intPtr = Marshal.AllocHGlobal(Size()); Il2CppAssembly_24_1* ptr = (Il2CppAssembly_24_1*)(void*)intPtr; *ptr = default(Il2CppAssembly_24_1); return new NativeStructWrapper(intPtr); } public unsafe INativeAssemblyStruct Wrap(Il2CppAssembly* ptr) { if (ptr == null) { return null; } return new NativeStructWrapper((IntPtr)ptr); } } [ApplicableToUnityVersionsSince("2018.4.34")] public class NativeAssemblyStructHandler_24_2 : INativeAssemblyStructHandler, INativeStructHandler { internal struct Il2CppAssembly_24_2 { public unsafe Il2CppImage* image; public uint token; public int referencedAssemblyStart; public int referencedAssemblyCount; public NativeAssemblyNameStructHandler_24_1.Il2CppAssemblyName_24_1 aname; } internal class NativeStructWrapper : INativeAssemblyStruct, INativeStruct { public IntPtr Pointer { get; } private unsafe Il2CppAssembly_24_2* _ => (Il2CppAssembly_24_2*)(void*)Pointer; public unsafe Il2CppAssembly* AssemblyPointer => (Il2CppAssembly*)(void*)Pointer; public unsafe INativeAssemblyNameStruct Name { get { return UnityVersionHandler.Wrap((Il2CppAssemblyName*)(&_->aname)); } set { _->aname = *(NativeAssemblyNameStructHandler_24_1.Il2CppAssemblyName_24_1*)Name.AssemblyNamePointer; } } public unsafe ref Il2CppImage* Image => ref _->image; public NativeStructWrapper(IntPtr ptr) { Pointer = ptr; } } public unsafe int Size() { return sizeof(Il2CppAssembly_24_2); } public unsafe INativeAssemblyStruct CreateNewStruct() { IntPtr intPtr = Marshal.AllocHGlobal(Size()); Il2CppAssembly_24_2* ptr = (Il2CppAssembly_24_2*)(void*)intPtr; *ptr = default(Il2CppAssembly_24_2); return new NativeStructWrapper(intPtr); } public unsafe INativeAssemblyStruct Wrap(Il2CppAssembly* ptr) { if (ptr == null) { return null; } return new NativeStructWrapper((IntPtr)ptr); } } public interface INativeAssemblyStructHandler : INativeStructHandler { INativeAssemblyStruct CreateNewStruct(); unsafe INativeAssemblyStruct Wrap(Il2CppAssembly* assemblyPointer); } public interface INativeAssemblyStruct : INativeStruct { unsafe Il2CppAssembly* AssemblyPointer { get; } unsafe ref Il2CppImage* Image { get; } INativeAssemblyNameStruct Name { get; } } } namespace Il2CppInterop.Runtime.InteropTypes { public class Il2CppObjectBase { internal static class InitializerStore { private static Func? _initializer; public static Func Initializer => _initializer ?? (_initializer = Create()); private static Func Create() { Type type = Il2CppClassPointerStore.CreatedTypeRedirect ?? typeof(T); DynamicMethod dynamicMethod = new DynamicMethod("Initializer<" + typeof(T).AssemblyQualifiedName + ">", type, _intPtrTypeArray); dynamicMethod.DefineParameter(0, ParameterAttributes.None, "pointer"); ILGenerator iLGenerator = dynamicMethod.GetILGenerator(); ConstructorInfo constructor = type.GetConstructor(new Type[1] { typeof(IntPtr) }); if ((object)constructor != null) { iLGenerator.Emit(OpCodes.Ldarg_0); iLGenerator.Emit(OpCodes.Newobj, constructor); } else { iLGenerator.Emit(OpCodes.Ldtoken, type); iLGenerator.Emit(OpCodes.Call, _getTypeFromHandle); iLGenerator.Emit(OpCodes.Call, _getUninitializedObject); iLGenerator.Emit(OpCodes.Castclass, type); iLGenerator.Emit(OpCodes.Dup); iLGenerator.Emit(OpCodes.Ldarg_0); iLGenerator.Emit(OpCodes.Callvirt, _createGCHandle); iLGenerator.Emit(OpCodes.Dup); iLGenerator.Emit(OpCodes.Ldc_I4_1); iLGenerator.Emit(OpCodes.Stsfld, _isWrapped); ConstructorInfo constructor2 = type.GetConstructor(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, Type.EmptyTypes); if (constructor2 != null) { iLGenerator.Emit(OpCodes.Dup); iLGenerator.Emit(OpCodes.Ldarg_0); iLGenerator.Emit(OpCodes.Callvirt, constructor2); } } iLGenerator.Emit(OpCodes.Ret); return dynamicMethod.CreateDelegate>(); } } private static readonly MethodInfo _unboxMethod = typeof(Il2CppObjectBase).GetMethod("Unbox"); internal bool isWrapped; internal IntPtr pooledPtr; private nint myGcHandle; private static readonly Type[] _intPtrTypeArray = new Type[1] { typeof(IntPtr) }; private static readonly MethodInfo _getUninitializedObject = typeof(RuntimeHelpers).GetMethod("GetUninitializedObject"); private static readonly MethodInfo _getTypeFromHandle = typeof(Type).GetMethod("GetTypeFromHandle"); private static readonly MethodInfo _createGCHandle = typeof(Il2CppObjectBase).GetMethod("CreateGCHandle"); private static readonly FieldInfo _isWrapped = typeof(Il2CppObjectBase).GetField("isWrapped"); public IntPtr ObjectClass => IL2CPP.il2cpp_object_get_class(Pointer); public IntPtr Pointer { get { IntPtr intPtr = IL2CPP.il2cpp_gchandle_get_target(myGcHandle); if (intPtr == IntPtr.Zero) { throw new ObjectCollectedException("Object was garbage collected in IL2CPP domain"); } return intPtr; } } public bool WasCollected { get { if (IL2CPP.il2cpp_gchandle_get_target(myGcHandle) == IntPtr.Zero) { return true; } return false; } } public Il2CppObjectBase(IntPtr pointer) { CreateGCHandle(pointer); } internal void CreateGCHandle(IntPtr objHdl) { if (objHdl == IntPtr.Zero) { throw new NullReferenceException(); } if (!isWrapped) { myGcHandle = IL2CPP.il2cpp_gchandle_new(objHdl, pinned: false); } } public T Cast() where T : Il2CppObjectBase { return TryCast() ?? throw new InvalidCastException($"Can't cast object of type {Marshal.PtrToStringAnsi(IL2CPP.il2cpp_class_get_name(IL2CPP.il2cpp_object_get_class(Pointer)))} to type {typeof(T)}"); } internal unsafe static T UnboxUnsafe(IntPtr pointer) { IntPtr nativeClassPtr = Il2CppClassPointerStore.NativeClassPtr; if (nativeClassPtr == IntPtr.Zero) { throw new ArgumentException($"{typeof(T)} is not an Il2Cpp reference type"); } IntPtr intPtr = IL2CPP.il2cpp_object_get_class(pointer); if (!IL2CPP.il2cpp_class_is_assignable_from(nativeClassPtr, intPtr)) { throw new InvalidCastException($"Can't cast object of type {Marshal.PtrToStringAnsi(IL2CPP.il2cpp_class_get_name(intPtr))} to type {typeof(T)}"); } return Unsafe.AsRef(IL2CPP.il2cpp_object_unbox(pointer).ToPointer()); } public T Unbox() where T : unmanaged { return UnboxUnsafe(Pointer); } public T? TryCast() where T : Il2CppObjectBase { IntPtr nativeClassPtr = Il2CppClassPointerStore.NativeClassPtr; if (nativeClassPtr == IntPtr.Zero) { throw new ArgumentException($"{typeof(T)} is not an Il2Cpp reference type"); } IntPtr intPtr = IL2CPP.il2cpp_object_get_class(Pointer); if (!IL2CPP.il2cpp_class_is_assignable_from(nativeClassPtr, intPtr)) { return null; } if (RuntimeSpecificsStore.IsInjected(intPtr) && ClassInjectorBase.GetMonoObjectFromIl2CppPointer(Pointer) is T result) { return result; } return InitializerStore.Initializer(Pointer); } ~Il2CppObjectBase() { IL2CPP.il2cpp_gchandle_free(myGcHandle); if (!(pooledPtr == IntPtr.Zero)) { Il2CppObjectPool.Remove(pooledPtr); } } } } namespace Il2CppInterop.Runtime.InteropTypes.Fields { public class Il2CppReferenceField where TRefObj : Il2CppObjectBase { private readonly IntPtr _fieldPtr; private readonly Il2CppObjectBase _obj; public TRefObj Value { get { return Get(); } set { Set(value); } } internal Il2CppReferenceField(Il2CppObjectBase obj, string fieldName) { _obj = obj; _fieldPtr = IL2CPP.GetIl2CppField(obj.ObjectClass, fieldName); } public unsafe TRefObj? Get() { IntPtr pointerToData = *GetPointerToData(); if (!(pointerToData == IntPtr.Zero)) { return Il2CppObjectPool.Get(pointerToData); } return null; } public unsafe void Set(TRefObj value) { *GetPointerToData() = value?.Pointer ?? IntPtr.Zero; } public static implicit operator TRefObj(Il2CppReferenceField _this) { return _this.Get(); } public static implicit operator Il2CppReferenceField(TRefObj _) { throw null; } private unsafe IntPtr* GetPointerToData() { return (IntPtr*)(void*)(IL2CPP.Il2CppObjectBaseToPtrNotNull(_obj) + (int)IL2CPP.il2cpp_field_get_offset(_fieldPtr)); } } public class Il2CppStringField { private readonly IntPtr _fieldPtr; private readonly Il2CppObjectBase _obj; public string Value { get { return Get(); } set { Set(value); } } internal Il2CppStringField(Il2CppObjectBase obj, string fieldName) { _obj = obj; _fieldPtr = IL2CPP.GetIl2CppField(obj.ObjectClass, fieldName); } public unsafe string? Get() { IntPtr pointerToData = *GetPointerToData(); if (pointerToData == IntPtr.Zero) { return null; } return IL2CPP.Il2CppStringToManaged(pointerToData); } public unsafe void Set(string value) { *GetPointerToData() = IL2CPP.ManagedStringToIl2Cpp(value); } public static implicit operator string(Il2CppStringField _this) { return _this.Get(); } public static implicit operator Il2CppStringField(string _) { throw null; } public override string ToString() { return Get(); } private unsafe IntPtr* GetPointerToData() { return (IntPtr*)(void*)(IL2CPP.Il2CppObjectBaseToPtrNotNull(_obj) + (int)IL2CPP.il2cpp_field_get_offset(_fieldPtr)); } } public class Il2CppValueField where T : unmanaged { private readonly IntPtr _fieldPtr; private readonly Il2CppObjectBase _obj; public T Value { get { return Get(); } set { Set(value); } } internal Il2CppValueField(Il2CppObjectBase obj, string fieldName) { _obj = obj; _fieldPtr = IL2CPP.GetIl2CppField(obj.ObjectClass, fieldName); } public unsafe T Get() { return *GetPointerToData(); } public unsafe void Set(T value) { *GetPointerToData() = value; } public static implicit operator T(Il2CppValueField _this) { return _this.Get(); } public static implicit operator Il2CppValueField(T _) { throw null; } private unsafe T* GetPointerToData() { return (T*)(void*)(IL2CPP.Il2CppObjectBaseToPtrNotNull(_obj) + (int)IL2CPP.il2cpp_field_get_offset(_fieldPtr)); } } } namespace Il2CppInterop.Runtime.InteropTypes.Arrays { public abstract class Il2CppArrayBase : Il2CppObjectBase, IList, ICollection, IEnumerable, IEnumerable { private class IndexEnumerator : IEnumerator, IEnumerator, IDisposable { private Il2CppArrayBase myArray; private int myIndex = -1; object IEnumerator.Current => Current; public T Current => myArray[myIndex]; public IndexEnumerator(Il2CppArrayBase array) { myArray = array; } public void Dispose() { myArray = null; } public bool MoveNext() { return ++myIndex < myArray.Count; } public void Reset() { myIndex = -1; } } public int Length => (int)IL2CPP.il2cpp_array_length(base.Pointer); public int Count => Length; public bool IsReadOnly => false; public abstract T this[int index] { get; set; } protected Il2CppArrayBase(IntPtr pointer) : base(pointer) { } IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } public IEnumerator GetEnumerator() { return new IndexEnumerator(this); } void ICollection.Add(T item) { ThrowImmutableLength(); } void ICollection.Clear() { ThrowImmutableLength(); } public bool Contains(T item) { return IndexOf(item) != -1; } public void CopyTo(T[] array, int arrayIndex) { if (array == null) { throw new ArgumentNullException("array"); } if (arrayIndex < 0) { throw new ArgumentOutOfRangeException("arrayIndex"); } if (array.Length - arrayIndex < Length) { throw new ArgumentException($"Not enough space in target array: need {Length} slots, have {array.Length - arrayIndex}"); } for (int i = 0; i < Length; i++) { array[i + arrayIndex] = this[i]; } } bool ICollection.Remove(T item) { return ThrowImmutableLength(); } public int IndexOf(T item) { for (int i = 0; i < Length; i++) { if (object.Equals(item, this[i])) { return i; } } return -1; } void IList.Insert(int index, T item) { ThrowImmutableLength(); } void IList.RemoveAt(int index) { ThrowImmutableLength(); } protected static void StaticCtorBody(Type ownType) { IntPtr nativeClassPtr = Il2CppClassPointerStore.NativeClassPtr; if (!(nativeClassPtr == IntPtr.Zero)) { IntPtr intPtr = IL2CPP.il2cpp_array_class_get(nativeClassPtr, 1u); if (!(intPtr == IntPtr.Zero)) { Il2CppClassPointerStore.SetNativeClassPointer(ownType, intPtr); Il2CppClassPointerStore.SetNativeClassPointer(typeof(Il2CppArrayBase), intPtr); Il2CppClassPointerStore>.CreatedTypeRedirect = ownType; } } } private static bool ThrowImmutableLength() { throw new NotSupportedException("Arrays have immutable length"); } public static implicit operator T[](Il2CppArrayBase il2CppArray) { if (il2CppArray == null) { return null; } T[] array = new T[il2CppArray.Length]; for (int i = 0; i < array.Length; i++) { array[i] = il2CppArray[i]; } return array; } public static Il2CppArrayBase? WrapNativeGenericArrayPointer(IntPtr pointer) { if (pointer == IntPtr.Zero) { return null; } if (typeof(T) == typeof(string)) { return new Il2CppStringArray(pointer) as Il2CppArrayBase; } if (typeof(T).IsValueType) { return Activator.CreateInstance(typeof(Il2CppStructArray<>).MakeGenericType(typeof(T)), pointer) as Il2CppArrayBase; } if (typeof(Il2CppObjectBase).IsAssignableFrom(typeof(T))) { return Activator.CreateInstance(typeof(Il2CppReferenceArray<>).MakeGenericType(typeof(T)), pointer) as Il2CppArrayBase; } throw new ArgumentException($"{typeof(T)} is not a value type, not a string and not an IL2CPP object; it can't be used in IL2CPP arrays"); } } public class Il2CppReferenceArray : Il2CppArrayBase where T : Il2CppObjectBase { private static ConstructorInfo ourCachedInstanceCtor; private static readonly int ourElementTypeSize; private static readonly bool ourElementIsValueType; public override T this[int index] { get { if (index < 0 || index >= base.Length) { throw new ArgumentOutOfRangeException("index", "Array index may not be negative or above length of the array"); } return WrapElement(IntPtr.Add(IntPtr.Add(base.Pointer, 4 * IntPtr.Size), index * ourElementTypeSize)); } set { if (index < 0 || index >= base.Length) { throw new ArgumentOutOfRangeException("index", "Array index may not be negative or above length of the array"); } StoreValue(IntPtr.Add(IntPtr.Add(base.Pointer, 4 * IntPtr.Size), index * ourElementTypeSize), value?.Pointer ?? IntPtr.Zero); } } static Il2CppReferenceArray() { ourElementTypeSize = IntPtr.Size; IntPtr nativeClassPtr = Il2CppClassPointerStore.NativeClassPtr; if (!(nativeClassPtr == IntPtr.Zero)) { uint align = 0u; if (IL2CPP.il2cpp_class_is_valuetype(nativeClassPtr)) { ourElementIsValueType = true; ourElementTypeSize = IL2CPP.il2cpp_class_value_size(nativeClassPtr, ref align); } Il2CppArrayBase.StaticCtorBody(typeof(Il2CppReferenceArray)); } } public Il2CppReferenceArray(IntPtr nativeObject) : base(nativeObject) { } public Il2CppReferenceArray(long size) : base(AllocateArray(size)) { } public Il2CppReferenceArray(T[] arr) : base(AllocateArray(arr.Length)) { for (int i = 0; i < arr.Length; i++) { this[i] = arr[i]; } } public static implicit operator Il2CppReferenceArray(T[] arr) { if (arr == null) { return null; } return new Il2CppReferenceArray(arr); } private unsafe static void StoreValue(IntPtr targetPointer, IntPtr valuePointer) { if (ourElementIsValueType) { if (valuePointer == IntPtr.Zero) { throw new NullReferenceException(); } byte* ptr = (byte*)(void*)IL2CPP.il2cpp_object_unbox(valuePointer); byte* ptr2 = (byte*)(void*)targetPointer; for (int i = 0; i < ourElementTypeSize; i++) { ptr2[i] = ptr[i]; } } else { *(IntPtr*)(void*)targetPointer = valuePointer; } } private unsafe static T? WrapElement(IntPtr memberPointer) { if (ourCachedInstanceCtor == null) { ourCachedInstanceCtor = typeof(T).GetConstructor(new Type[1] { typeof(IntPtr) }); } if (ourElementIsValueType) { return (T)ourCachedInstanceCtor.Invoke(new object[1] { IL2CPP.il2cpp_value_box(Il2CppClassPointerStore.NativeClassPtr, memberPointer) }); } IntPtr intPtr = *(IntPtr*)(void*)memberPointer; if (intPtr == IntPtr.Zero) { return null; } if (typeof(Il2CppObjectBase).IsAssignableFrom(typeof(T))) { IntPtr nativeClassPtr = Il2CppClassPointerStore.NativeClassPtr; IntPtr oklass = IL2CPP.il2cpp_object_get_class(intPtr); if (RuntimeSpecificsStore.IsInjected(nativeClassPtr) && IL2CPP.il2cpp_class_is_assignable_from(nativeClassPtr, oklass)) { return ClassInjectorBase.GetMonoObjectFromIl2CppPointer(intPtr) as T; } } return (T)ourCachedInstanceCtor.Invoke(new object[1] { intPtr }); } private static IntPtr AllocateArray(long size) { if (size < 0) { throw new ArgumentOutOfRangeException("size", "Array size must not be negative"); } IntPtr nativeClassPtr = Il2CppClassPointerStore.NativeClassPtr; if (nativeClassPtr == IntPtr.Zero) { throw new ArgumentException($"{"Il2CppReferenceArray"} requires an Il2Cpp reference type, which {typeof(T)} isn't"); } return IL2CPP.il2cpp_array_new(nativeClassPtr, (ulong)size); } } public class Il2CppStringArray : Il2CppArrayBase { public unsafe override string this[int index] { get { if (index < 0 || index >= base.Length) { throw new ArgumentOutOfRangeException("index", "Array index may not be negative or above length of the array"); } return IL2CPP.Il2CppStringToManaged(*(IntPtr*)(void*)IntPtr.Add(IntPtr.Add(base.Pointer, 4 * IntPtr.Size), index * IntPtr.Size)); } set { if (index < 0 || index >= base.Length) { throw new ArgumentOutOfRangeException("index", "Array index may not be negative or above length of the array"); } *(IntPtr*)(void*)IntPtr.Add(IntPtr.Add(base.Pointer, 4 * IntPtr.Size), index * IntPtr.Size) = IL2CPP.ManagedStringToIl2Cpp(value); } } static Il2CppStringArray() { Il2CppArrayBase.StaticCtorBody(typeof(Il2CppStringArray)); } public Il2CppStringArray(IntPtr pointer) : base(pointer) { } public Il2CppStringArray(long size) : base(AllocateArray(size)) { } public Il2CppStringArray(string[] arr) : base(AllocateArray(arr.Length)) { for (int i = 0; i < arr.Length; i++) { this[i] = arr[i]; } } public static implicit operator Il2CppStringArray(string[] arr) { if (arr == null) { return null; } return new Il2CppStringArray(arr); } private static IntPtr AllocateArray(long size) { if (size < 0) { throw new ArgumentOutOfRangeException("size", "Array size must not be negative"); } IntPtr nativeClassPtr = Il2CppClassPointerStore.NativeClassPtr; if (nativeClassPtr == IntPtr.Zero) { throw new ArgumentException("String class pointer is missing, something is very wrong"); } return IL2CPP.il2cpp_array_new(nativeClassPtr, (ulong)size); } } public class Il2CppStructArray : Il2CppArrayBase where T : unmanaged { public unsafe override T this[int index] { get { if (index < 0 || index >= base.Length) { throw new ArgumentOutOfRangeException("index", "Array index may not be negative or above length of the array"); } return *(T*)((byte*)IntPtr.Add(base.Pointer, 4 * IntPtr.Size).ToPointer() + (nint)index * (nint)sizeof(T)); } set { if (index < 0 || index >= base.Length) { throw new ArgumentOutOfRangeException("index", "Array index may not be negative or above length of the array"); } *(T*)((byte*)IntPtr.Add(base.Pointer, 4 * IntPtr.Size).ToPointer() + (nint)index * (nint)sizeof(T)) = value; } } static Il2CppStructArray() { Il2CppArrayBase.StaticCtorBody(typeof(Il2CppStructArray)); } public Il2CppStructArray(IntPtr nativeObject) : base(nativeObject) { } public Il2CppStructArray(long size) : base(AllocateArray(size)) { } public Il2CppStructArray(T[] arr) : base(AllocateArray(arr.Length)) { for (int i = 0; i < arr.Length; i++) { this[i] = arr[i]; } } public static implicit operator Il2CppStructArray(T[] arr) { if (arr == null) { return null; } return new Il2CppStructArray(arr); } private static IntPtr AllocateArray(long size) { if (size < 0) { throw new ArgumentOutOfRangeException("size", "Array size must not be negative"); } IntPtr nativeClassPtr = Il2CppClassPointerStore.NativeClassPtr; if (nativeClassPtr == IntPtr.Zero) { throw new ArgumentException($"{"Il2CppStructArray"} requires an Il2Cpp reference type, which {typeof(T)} isn't"); } return IL2CPP.il2cpp_array_new(nativeClassPtr, (ulong)size); } } } namespace Il2CppInterop.Runtime.Injection { public class Il2CppInterfaceCollection : List { public Il2CppInterfaceCollection(IEnumerable interfaces) : base(interfaces) { } public Il2CppInterfaceCollection(IEnumerable interfaces) : base(ResolveNativeInterfaces(interfaces)) { } private unsafe static IEnumerable ResolveNativeInterfaces(IEnumerable interfaces) { return interfaces.Select(delegate(Type it) { IntPtr nativeClassPointer = Il2CppClassPointerStore.GetNativeClassPointer(it); if (nativeClassPointer == IntPtr.Zero) { throw new ArgumentException($"Type {it} doesn't have an IL2CPP class pointer, which means it's not an IL2CPP interface"); } return UnityVersionHandler.Wrap((Il2CppClass*)(void*)nativeClassPointer); }); } public static implicit operator Il2CppInterfaceCollection(INativeClassStruct[] interfaces) { return new Il2CppInterfaceCollection(interfaces); } public static implicit operator Il2CppInterfaceCollection(Type[] interfaces) { return new Il2CppInterfaceCollection(interfaces); } } public class RegisterTypeOptions { public static readonly RegisterTypeOptions Default = new RegisterTypeOptions(); public bool LogSuccess { get; init; } = true; public Func? InterfacesResolver { get; init; } public Il2CppInterfaceCollection? Interfaces { get; init; } } public static class ClassInjector { [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private unsafe delegate void InvokerDelegateMetadataV29(IntPtr methodPointer, Il2CppMethodInfo* methodInfo, IntPtr obj, IntPtr* args, IntPtr* returnValue); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private unsafe delegate IntPtr InvokerDelegate(IntPtr methodPointer, Il2CppMethodInfo* methodInfo, IntPtr obj, IntPtr* args); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void VoidCtorDelegate(IntPtr objectPointer); private static readonly HashSet InjectedTypes = new HashSet(); internal static readonly Dictionary)> InflatedMethodFromContextDictionary = new Dictionary)>(); private static readonly ConcurrentDictionary InvokerCache = new ConcurrentDictionary(); private static readonly ConcurrentDictionary<(Type type, FieldAttributes attrs), IntPtr> _injectedFieldTypes = new ConcurrentDictionary<(Type, FieldAttributes), IntPtr>(); private static readonly VoidCtorDelegate FinalizeDelegate = Finalize; public static void ProcessNewObject(Il2CppObjectBase obj) { IntPtr pointer = obj.Pointer; GCHandle gcHandle = GCHandle.Alloc(obj, GCHandleType.Normal); AssignGcHandle(pointer, gcHandle); } public static IntPtr DerivedConstructorPointer() { return IL2CPP.il2cpp_object_new(Il2CppClassPointerStore.NativeClassPtr); } public static void DerivedConstructorBody(Il2CppObjectBase objectBase) { if (!objectBase.isWrapped) { FieldInfo[] array = objectBase.GetType().GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).Where(IsFieldEligible) .ToArray(); foreach (FieldInfo fieldInfo in array) { fieldInfo.SetValue(objectBase, fieldInfo.FieldType.GetConstructor(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[2] { typeof(Il2CppObjectBase), typeof(string) }, Array.Empty()).Invoke(new object[2] { objectBase, fieldInfo.Name })); } GCHandle gcHandle = GCHandle.Alloc(objectBase, GCHandleType.Normal); AssignGcHandle(objectBase.Pointer, gcHandle); } } public unsafe static void AssignGcHandle(IntPtr pointer, GCHandle gcHandle) { GCHandle.ToIntPtr(gcHandle); if (pointer == IntPtr.Zero) { throw new NullReferenceException("pointer"); } ClassInjectorBase.GetInjectedData(pointer)->managedGcHandle = GCHandle.ToIntPtr(gcHandle); } public static bool IsTypeRegisteredInIl2Cpp() where T : class { return IsTypeRegisteredInIl2Cpp(typeof(T)); } public static bool IsTypeRegisteredInIl2Cpp(Type type) { if (Il2CppClassPointerStore.GetNativeClassPointer(type) != IntPtr.Zero) { return true; } if (IsManagedTypeInjected(type)) { return true; } return false; } internal static bool IsManagedTypeInjected(Type type) { lock (InjectedTypes) { if (InjectedTypes.Contains(type.FullName)) { return true; } } return false; } public static void RegisterTypeInIl2Cpp() where T : class { RegisterTypeInIl2Cpp(typeof(T)); } public static void RegisterTypeInIl2Cpp(Type type) { RegisterTypeInIl2Cpp(type, RegisterTypeOptions.Default); } public static void RegisterTypeInIl2Cpp(RegisterTypeOptions options) where T : class { RegisterTypeInIl2Cpp(typeof(T), options); } public unsafe static void RegisterTypeInIl2Cpp(Type type, RegisterTypeOptions options) { Il2CppInterfaceCollection il2CppInterfaceCollection = options.Interfaces; if (il2CppInterfaceCollection == null) { il2CppInterfaceCollection = type.GetCustomAttribute()?.Interfaces ?? options.InterfacesResolver?.Invoke(type) ?? Array.Empty(); } if (type == null) { throw new ArgumentException("Type argument cannot be null"); } if (type.IsGenericType || type.IsGenericTypeDefinition) { throw new ArgumentException($"Type {type} is generic and can't be used in il2cpp"); } if (Il2CppClassPointerStore.GetNativeClassPointer(type) != IntPtr.Zero) { return; } Type baseType = type.BaseType; if (baseType == null) { throw new ArgumentException($"Class {type} does not inherit from a class registered in il2cpp"); } INativeClassStruct nativeClassStruct = UnityVersionHandler.Wrap((Il2CppClass*)(void*)Il2CppClassPointerStore.GetNativeClassPointer(baseType)); if (nativeClassStruct == null) { RegisterTypeInIl2Cpp(baseType, new RegisterTypeOptions { LogSuccess = options.LogSuccess }); nativeClassStruct = UnityVersionHandler.Wrap((Il2CppClass*)(void*)Il2CppClassPointerStore.GetNativeClassPointer(baseType)); } InjectorHelpers.Setup(); InjectorHelpers.ClassInit(nativeClassStruct.ClassPointer); if (nativeClassStruct.ValueType || nativeClassStruct.EnumType) { throw new ArgumentException($"Base class {baseType} is value type and can't be inherited from"); } if (nativeClassStruct.IsGeneric) { throw new ArgumentException($"Base class {baseType} is generic and can't be inherited from"); } if ((nativeClassStruct.Flags & Il2CppClassAttributes.TYPE_ATTRIBUTE_SEALED) != 0) { throw new ArgumentException($"Base class {baseType} is sealed and can't be inherited from"); } if ((nativeClassStruct.Flags & Il2CppClassAttributes.TYPE_ATTRIBUTE_CLASS_SEMANTIC_MASK) != 0) { throw new ArgumentException($"Base class {baseType} is an interface and can't be inherited from"); } if (il2CppInterfaceCollection.Any((INativeClassStruct i) => (i.Flags & Il2CppClassAttributes.TYPE_ATTRIBUTE_CLASS_SEMANTIC_MASK) == 0)) { throw new ArgumentException($"Some of the interfaces in {il2CppInterfaceCollection} are not interfaces"); } lock (InjectedTypes) { if (!InjectedTypes.Add(type.FullName)) { throw new ArgumentException("Type with FullName " + type.FullName + " is already injected. Don't inject the same type twice, or use a different namespace"); } } int num = il2CppInterfaceCollection.Sum((INativeClassStruct i) => i.MethodCount); INativeClassStruct nativeClassStruct2 = UnityVersionHandler.NewClass(nativeClassStruct.VtableCount + num); nativeClassStruct2.Image = InjectorHelpers.InjectedImage.ImagePointer; nativeClassStruct2.Parent = nativeClassStruct.ClassPointer; nativeClassStruct2.ElementClass = (nativeClassStruct2.Class = (nativeClassStruct2.CastClass = nativeClassStruct2.ClassPointer)); nativeClassStruct2.NativeSize = -1; nativeClassStruct2.ActualSize = (nativeClassStruct2.InstanceSize = nativeClassStruct.InstanceSize); nativeClassStruct2.Initialized = true; nativeClassStruct2.InitializedAndNoError = true; nativeClassStruct2.SizeInited = true; nativeClassStruct2.HasFinalize = true; nativeClassStruct2.IsVtableInitialized = true; nativeClassStruct2.Name = Marshal.StringToHGlobalAnsi(type.Name); nativeClassStruct2.Namespace = Marshal.StringToHGlobalAnsi(type.Namespace ?? string.Empty); nativeClassStruct2.ThisArg.Type = (nativeClassStruct2.ByValArg.Type = Il2CppTypeEnum.IL2CPP_TYPE_CLASS); nativeClassStruct2.ThisArg.ByRef = true; nativeClassStruct2.Flags = nativeClassStruct.Flags; if (!type.IsAbstract) { nativeClassStruct2.Flags &= ~Il2CppClassAttributes.TYPE_ATTRIBUTE_ABSTRACT; } FieldInfo[] array = type.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).Where(IsFieldEligible).ToArray(); nativeClassStruct2.FieldCount = (ushort)array.Length; Il2CppFieldInfo* ptr = (Il2CppFieldInfo*)(void*)Marshal.AllocHGlobal(nativeClassStruct2.FieldCount * UnityVersionHandler.FieldInfoSize()); int num2 = (int)nativeClassStruct2.InstanceSize; for (int j = 0; j < nativeClassStruct2.FieldCount; j++) { INativeFieldInfoStruct nativeFieldInfoStruct = UnityVersionHandler.Wrap(ptr + j * UnityVersionHandler.FieldInfoSize()); nativeFieldInfoStruct.Name = Marshal.StringToHGlobalAnsi(array[j].Name); nativeFieldInfoStruct.Parent = nativeClassStruct2.ClassPointer; nativeFieldInfoStruct.Offset = num2; Type type2 = ((array[j].FieldType == typeof(Il2CppStringField)) ? typeof(string) : array[j].FieldType.GenericTypeArguments[0]); FieldAttributes attributes = array[j].Attributes; IntPtr nativeClassPointer = Il2CppClassPointerStore.GetNativeClassPointer(type2); if (!_injectedFieldTypes.TryGetValue((type2, attributes), out var value)) { INativeTypeStruct nativeTypeStruct = UnityVersionHandler.Wrap((Il2CppTypeStruct*)(void*)IL2CPP.il2cpp_class_get_type(nativeClassPointer)); INativeTypeStruct nativeTypeStruct2 = UnityVersionHandler.NewType(); nativeTypeStruct2.Data = nativeTypeStruct.Data; nativeTypeStruct2.Attrs = (ushort)attributes; nativeTypeStruct2.Type = nativeTypeStruct.Type; nativeTypeStruct2.ByRef = nativeTypeStruct.ByRef; nativeTypeStruct2.Pinned = nativeTypeStruct.Pinned; _injectedFieldTypes[(type2, attributes)] = nativeTypeStruct2.Pointer; value = nativeTypeStruct2.Pointer; } nativeFieldInfoStruct.Type = (Il2CppTypeStruct*)(void*)value; if (nativeClassPointer == IntPtr.Zero) { throw new Exception($"Type {type2} in {type}.{array[j].Name} doesn't exist in Il2Cpp"); } if (IL2CPP.il2cpp_class_is_valuetype(nativeClassPointer)) { uint align = 0u; int num3 = IL2CPP.il2cpp_class_value_size(nativeClassPointer, ref align); num2 += num3; } else { num2 += sizeof(Il2CppObject*); } } nativeClassStruct2.Fields = ptr; nativeClassStruct2.InstanceSize = (uint)(num2 + sizeof(InjectedClassData)); nativeClassStruct2.ActualSize = nativeClassStruct2.InstanceSize; MethodInfo[] array2 = type.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).Where(IsMethodEligible).ToArray(); int num4 = (type.IsAbstract ? 1 : 2); int num5 = num4 + array2.Length; nativeClassStruct2.MethodCount = (ushort)num5; Il2CppMethodInfo** ptr2 = (Il2CppMethodInfo**)(void*)Marshal.AllocHGlobal(num5 * IntPtr.Size); nativeClassStruct2.Methods = ptr2; *ptr2 = ConvertStaticMethod(FinalizeDelegate, "Finalize", nativeClassStruct2); INativeMethodInfoStruct nativeMethodInfoStruct = UnityVersionHandler.Wrap(*ptr2); FieldInfo[] fieldsToInitialize = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).Where(IsFieldEligible).ToArray(); if (!type.IsAbstract) { ptr2[1] = ConvertStaticMethod(CreateEmptyCtor(type, fieldsToInitialize), ".ctor", nativeClassStruct2); } Dictionary<(string, int, bool), int> dictionary = new Dictionary<(string, int, bool), int>(array2.Length); for (int k = 0; k < array2.Length; k++) { MethodInfo methodInfo = array2[k]; Il2CppMethodInfo* ptr3 = (ptr2[k + num4] = ConvertMethodInfo(methodInfo, nativeClassStruct2)); if (methodInfo.IsGenericMethod && !methodInfo.IsAbstract) { InflatedMethodFromContextDictionary.Add((IntPtr)ptr3, (methodInfo, new Dictionary())); } dictionary[(methodInfo.Name, methodInfo.GetParameters().Length, methodInfo.IsGenericMethod)] = k + num4; } MethodInfo[] array3 = array2.Where((MethodInfo x) => x.IsAbstract).ToArray(); VirtualInvokeData* vTablePointer = (VirtualInvokeData*)(void*)nativeClassStruct2.VTable; VirtualInvokeData* ptr4 = (VirtualInvokeData*)(void*)nativeClassStruct.VTable; nativeClassStruct2.VtableCount = (ushort)(nativeClassStruct.VtableCount + num + array3.Length); bool extendsAbstract = nativeClassStruct.Flags.HasFlag(Il2CppClassAttributes.TYPE_ATTRIBUTE_ABSTRACT); List abstractBaseMethods = new List(); if (extendsAbstract) { FindAbstractMethods(abstractBaseMethods, nativeClassStruct); } int abstractV = 0; for (int l = 0; l < nativeClassStruct.VtableCount; l++) { vTablePointer[l] = ptr4[l]; INativeMethodInfoStruct nativeMethodInfoStruct2 = ((ptr4[l].method != null) ? UnityVersionHandler.Wrap(vTablePointer[l].method) : HandleAbstractMethod(l)); if (nativeMethodInfoStruct2.Name == IntPtr.Zero) { nativeMethodInfoStruct2 = HandleAbstractMethod(l); } string text = Marshal.PtrToStringAnsi(nativeMethodInfoStruct2.Name); if (text == "Finalize") { vTablePointer[l].method = *ptr2; vTablePointer[l].methodPtr = nativeMethodInfoStruct.MethodPointer; continue; } Type[] array4 = new Type[nativeMethodInfoStruct2.ParametersCount]; for (int n = 0; n < nativeMethodInfoStruct2.ParametersCount; n++) { Type type3 = SystemTypeFromIl2CppType(UnityVersionHandler.Wrap(nativeMethodInfoStruct2.Parameters, n).ParameterType); array4[n] = type3; } MethodInfo method = type.GetMethod(text, BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, array4); if (!(method != null) || !method.IsAbstract) { int num6 = Array.IndexOf(array2, method); if (num6 >= 0) { INativeMethodInfoStruct nativeMethodInfoStruct3 = UnityVersionHandler.Wrap(ptr2[num6 + num4]); vTablePointer[l].method = ptr2[num6 + num4]; vTablePointer[l].methodPtr = nativeMethodInfoStruct3.MethodPointer; } if (vTablePointer[l].method == null || vTablePointer[l].methodPtr == IntPtr.Zero) { throw new Exception("No method found for vtable entry " + text); } } } int[] array5 = new int[il2CppInterfaceCollection.Count]; ushort num7 = nativeClassStruct.VtableCount; for (int num8 = 0; num8 < il2CppInterfaceCollection.Count; num8++) { array5[num8] = num7; for (int num9 = 0; num9 < il2CppInterfaceCollection[num8].MethodCount; num9++) { INativeMethodInfoStruct nativeMethodInfoStruct4 = UnityVersionHandler.Wrap(il2CppInterfaceCollection[num8].Methods[num9]); string item = Marshal.PtrToStringAnsi(nativeMethodInfoStruct4.Name); if (!dictionary.TryGetValue((item, nativeMethodInfoStruct4.ParametersCount, nativeMethodInfoStruct4.IsGeneric), out var value2)) { num7++; continue; } Il2CppMethodInfo* ptr5 = ptr2[value2]; vTablePointer[(int)num7].method = ptr5; vTablePointer[(int)num7].methodPtr = UnityVersionHandler.Wrap(ptr5).MethodPointer; num7++; } } int num10 = nativeClassStruct.InterfaceCount + il2CppInterfaceCollection.Count; nativeClassStruct2.InterfaceCount = (ushort)num10; nativeClassStruct2.ImplementedInterfaces = (Il2CppClass**)(void*)Marshal.AllocHGlobal(num10 * IntPtr.Size); for (int num11 = 0; num11 < nativeClassStruct.InterfaceCount; num11++) { nativeClassStruct2.ImplementedInterfaces[num11] = nativeClassStruct.ImplementedInterfaces[num11]; } for (int num12 = nativeClassStruct.InterfaceCount; num12 < num10; num12++) { nativeClassStruct2.ImplementedInterfaces[num12] = il2CppInterfaceCollection[num12 - nativeClassStruct.InterfaceCount].ClassPointer; } int num13 = nativeClassStruct.InterfaceOffsetsCount + il2CppInterfaceCollection.Count; nativeClassStruct2.InterfaceOffsetsCount = (ushort)num13; nativeClassStruct2.InterfaceOffsets = (Il2CppRuntimeInterfaceOffsetPair*)(void*)Marshal.AllocHGlobal(num13 * Marshal.SizeOf()); for (int num14 = 0; num14 < nativeClassStruct.InterfaceOffsetsCount; num14++) { nativeClassStruct2.InterfaceOffsets[num14] = nativeClassStruct.InterfaceOffsets[num14]; } for (int num15 = nativeClassStruct.InterfaceOffsetsCount; num15 < num13; num15++) { nativeClassStruct2.InterfaceOffsets[num15] = new Il2CppRuntimeInterfaceOffsetPair { interfaceType = il2CppInterfaceCollection[num15 - nativeClassStruct.InterfaceOffsetsCount].ClassPointer, offset = array5[num15 - nativeClassStruct.InterfaceOffsetsCount] }; } for (int num16 = 0; num16 < array3.Length; num16++) { vTablePointer[(int)num7++] = default(VirtualInvokeData); } int num17 = 1 + nativeClassStruct.TypeHierarchyDepth; nativeClassStruct2.TypeHierarchyDepth = (byte)num17; nativeClassStruct2.TypeHierarchy = (Il2CppClass**)(void*)Marshal.AllocHGlobal(num17 * IntPtr.Size); for (int num18 = 0; num18 < num17; num18++) { nativeClassStruct2.TypeHierarchy[num18] = nativeClassStruct.TypeHierarchy[num18]; } nativeClassStruct2.TypeHierarchy[num17 - 1] = nativeClassStruct2.ClassPointer; nativeClassStruct2.ByValArg.Data = (nativeClassStruct2.ThisArg.Data = (IntPtr)InjectorHelpers.CreateClassToken(nativeClassStruct2.Pointer)); RuntimeSpecificsStore.SetClassInfo(nativeClassStruct2.Pointer, wasInjected: true); Il2CppClassPointerStore.SetNativeClassPointer(type, nativeClassStruct2.Pointer); InjectorHelpers.AddTypeToLookup(type, nativeClassStruct2.Pointer); if (options.LogSuccess) { Logger.Instance.LogInformation("Registered mono type {Type} in il2cpp domain", type); } unsafe static void FindAbstractMethods(List list, INativeClassStruct klass) { if (klass.Parent != null) { FindAbstractMethods(list, UnityVersionHandler.Wrap(klass.Parent)); } for (int num19 = 0; num19 < klass.MethodCount; num19++) { INativeMethodInfoStruct baseMethod = UnityVersionHandler.Wrap(klass.Methods[num19]); string name = Marshal.PtrToStringAnsi(baseMethod.Name); if (baseMethod.Flags.HasFlag(Il2CppMethodFlags.METHOD_ATTRIBUTE_ABSTRACT)) { list.Add(baseMethod); } else { INativeMethodInfoStruct nativeMethodInfoStruct6 = list.SingleOrDefault(delegate(INativeMethodInfoStruct m) { if (Marshal.PtrToStringAnsi(m.Name) != name) { return false; } if (m.ParametersCount != baseMethod.ParametersCount) { return false; } for (int num20 = 0; num20 < m.ParametersCount; num20++) { INativeParameterInfoStruct nativeParameterInfoStruct = UnityVersionHandler.Wrap(baseMethod.Parameters, num20); INativeParameterInfoStruct nativeParameterInfoStruct2 = UnityVersionHandler.Wrap(m.Parameters, num20); if (Marshal.PtrToStringAnsi(nativeParameterInfoStruct.Name) != Marshal.PtrToStringAnsi(nativeParameterInfoStruct2.Name)) { return false; } if (GetIl2CppTypeFullName(nativeParameterInfoStruct.ParameterType) != GetIl2CppTypeFullName(nativeParameterInfoStruct2.ParameterType)) { return false; } } return true; }); if (nativeMethodInfoStruct6 != null) { list.Remove(nativeMethodInfoStruct6); } } } } unsafe INativeMethodInfoStruct HandleAbstractMethod(int position) { if (!extendsAbstract) { throw new NullReferenceException("VTable method was null even though base type isn't abstract"); } INativeMethodInfoStruct nativeMethodInfoStruct5 = abstractBaseMethods[abstractV++]; vTablePointer[position].method = nativeMethodInfoStruct5.MethodInfoPointer; vTablePointer[position].methodPtr = nativeMethodInfoStruct5.MethodPointer; return nativeMethodInfoStruct5; } } private static bool IsTypeSupported(Type type) { if (type.IsValueType || type == typeof(string) || type.IsGenericParameter) { return true; } if (type.IsByRef) { return IsTypeSupported(type.GetElementType()); } return typeof(Il2CppObjectBase).IsAssignableFrom(type); } private static bool IsFieldEligible(FieldInfo field) { if (!field.FieldType.IsGenericType) { return field.FieldType == typeof(Il2CppStringField); } Type genericTypeDefinition = field.FieldType.GetGenericTypeDefinition(); if (genericTypeDefinition != typeof(Il2CppReferenceField<>) && genericTypeDefinition != typeof(Il2CppValueField<>)) { return false; } return IsTypeSupported(field.FieldType.GenericTypeArguments[0]); } private static bool IsMethodEligible(MethodInfo method) { if (method.Name == "Finalize") { return false; } if (method.IsStatic) { return false; } if (method.CustomAttributes.Any((CustomAttributeData it) => typeof(HideFromIl2CppAttribute).IsAssignableFrom(it.AttributeType))) { return false; } if (method.DeclaringType != null) { if ((from property in method.DeclaringType.GetProperties(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) where property.GetAccessors(nonPublic: true).Contains(method) select property).Any((PropertyInfo property) => property.CustomAttributes.Any((CustomAttributeData it) => typeof(HideFromIl2CppAttribute).IsAssignableFrom(it.AttributeType)))) { return false; } EventInfo[] events = method.DeclaringType.GetEvents(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (EventInfo eventInfo in events) { if ((eventInfo.GetAddMethod(nonPublic: true) == method || eventInfo.GetRemoveMethod(nonPublic: true) == method) && eventInfo.GetCustomAttribute() != null) { return false; } } } if (!IsTypeSupported(method.ReturnType)) { Logger.Instance.LogWarning("Method {Method} on type {DeclaringType} has unsupported return type {ReturnType}", method.ToString(), method.DeclaringType, method.ReturnType); return false; } ParameterInfo[] parameters = method.GetParameters(); foreach (ParameterInfo parameterInfo in parameters) { Type parameterType = parameterInfo.ParameterType; if (!IsTypeSupported(parameterType)) { Logger.Instance.LogWarning("Method {Method} on type {DeclaringType} has unsupported parameter {Parameter} of type {ParameterType}", method.ToString(), method.DeclaringType, parameterInfo, parameterType); return false; } } return true; } private unsafe static Il2CppMethodInfo* ConvertStaticMethod(VoidCtorDelegate voidCtor, string methodName, INativeClassStruct declaringClass) { INativeMethodInfoStruct nativeMethodInfoStruct = UnityVersionHandler.NewMethod(); nativeMethodInfoStruct.Name = Marshal.StringToHGlobalAnsi(methodName); nativeMethodInfoStruct.Class = declaringClass.ClassPointer; Delegate @delegate = ((!UnityVersionHandler.IsMetadataV29OrHigher) ? ((MulticastDelegate)new InvokerDelegate(StaticVoidIntPtrInvoker)) : ((MulticastDelegate)new InvokerDelegateMetadataV29(StaticVoidIntPtrInvoker_MetadataV29))); GCHandle.Alloc(@delegate); nativeMethodInfoStruct.InvokerMethod = Marshal.GetFunctionPointerForDelegate(@delegate); nativeMethodInfoStruct.MethodPointer = Marshal.GetFunctionPointerForDelegate(voidCtor); nativeMethodInfoStruct.Slot = ushort.MaxValue; nativeMethodInfoStruct.ReturnType = (Il2CppTypeStruct*)(void*)IL2CPP.il2cpp_class_get_type(Il2CppClassPointerStore.NativeClassPtr); nativeMethodInfoStruct.Flags = Il2CppMethodFlags.METHOD_ATTRIBUTE_PUBLIC | Il2CppMethodFlags.METHOD_ATTRIBUTE_HIDE_BY_SIG | Il2CppMethodFlags.METHOD_ATTRIBUTE_SPECIAL_NAME | Il2CppMethodFlags.METHOD_ATTRIBUTE_RT_SPECIAL_NAME; return nativeMethodInfoStruct.MethodInfoPointer; } internal unsafe static Il2CppMethodInfo* ConvertMethodInfo(MethodInfo monoMethod, INativeClassStruct declaringClass) { INativeMethodInfoStruct nativeMethodInfoStruct = UnityVersionHandler.NewMethod(); nativeMethodInfoStruct.Name = Marshal.StringToHGlobalAnsi(monoMethod.Name); nativeMethodInfoStruct.Class = declaringClass.ClassPointer; ParameterInfo[] parameters = monoMethod.GetParameters(); if (parameters.Length != 0) { nativeMethodInfoStruct.ParametersCount = (byte)parameters.Length; Il2CppParameterInfo*[] array = UnityVersionHandler.NewMethodParameterArray(parameters.Length); nativeMethodInfoStruct.Parameters = array[0]; for (int i = 0; i < parameters.Length; i++) { ParameterInfo parameterInfo = parameters[i]; INativeParameterInfoStruct nativeParameterInfoStruct = UnityVersionHandler.Wrap(array[i]); if (UnityVersionHandler.ParameterInfoHasNamePosToken()) { nativeParameterInfoStruct.Name = Marshal.StringToHGlobalAnsi(parameterInfo.Name); nativeParameterInfoStruct.Position = i; nativeParameterInfoStruct.Token = 0u; } Type parameterType = parameterInfo.ParameterType; if (!parameterType.IsGenericParameter) { if (parameterType.IsByRef) { Type elementType = parameterType.GetElementType(); if (!elementType.IsGenericParameter) { INativeTypeStruct nativeTypeStruct = UnityVersionHandler.Wrap((Il2CppTypeStruct*)(void*)IL2CPP.il2cpp_class_get_type(Il2CppClassPointerStore.GetNativeClassPointer(elementType))); INativeTypeStruct nativeTypeStruct2 = UnityVersionHandler.NewType(); nativeTypeStruct2.Data = nativeTypeStruct.Data; nativeTypeStruct2.Attrs = nativeTypeStruct.Attrs; nativeTypeStruct2.Type = nativeTypeStruct.Type; nativeTypeStruct2.ByRef = true; nativeTypeStruct2.Pinned = nativeTypeStruct.Pinned; nativeParameterInfoStruct.ParameterType = nativeTypeStruct2.TypePointer; } else { INativeTypeStruct nativeTypeStruct3 = UnityVersionHandler.NewType(); nativeTypeStruct3.Type = Il2CppTypeEnum.IL2CPP_TYPE_MVAR; nativeTypeStruct3.ByRef = true; nativeParameterInfoStruct.ParameterType = nativeTypeStruct3.TypePointer; } } else { nativeParameterInfoStruct.ParameterType = (Il2CppTypeStruct*)(void*)IL2CPP.il2cpp_class_get_type(Il2CppClassPointerStore.GetNativeClassPointer(parameterType)); } } else { INativeTypeStruct nativeTypeStruct4 = UnityVersionHandler.NewType(); nativeTypeStruct4.Type = Il2CppTypeEnum.IL2CPP_TYPE_MVAR; nativeParameterInfoStruct.ParameterType = nativeTypeStruct4.TypePointer; } } } if (monoMethod.IsGenericMethod) { if (monoMethod.ContainsGenericParameters) { nativeMethodInfoStruct.IsGeneric = true; } else { nativeMethodInfoStruct.IsInflated = true; } } if (!monoMethod.ContainsGenericParameters && !monoMethod.IsAbstract) { nativeMethodInfoStruct.InvokerMethod = Marshal.GetFunctionPointerForDelegate(GetOrCreateInvoker(monoMethod)); nativeMethodInfoStruct.MethodPointer = Marshal.GetFunctionPointerForDelegate(GetOrCreateTrampoline(monoMethod)); nativeMethodInfoStruct.VirtualMethodPointer = nativeMethodInfoStruct.MethodPointer; } nativeMethodInfoStruct.Slot = ushort.MaxValue; if (!monoMethod.ReturnType.IsGenericParameter) { nativeMethodInfoStruct.ReturnType = (Il2CppTypeStruct*)(void*)IL2CPP.il2cpp_class_get_type(Il2CppClassPointerStore.GetNativeClassPointer(monoMethod.ReturnType)); } else { INativeTypeStruct nativeTypeStruct5 = UnityVersionHandler.NewType(); nativeTypeStruct5.Type = Il2CppTypeEnum.IL2CPP_TYPE_MVAR; nativeMethodInfoStruct.ReturnType = nativeTypeStruct5.TypePointer; } nativeMethodInfoStruct.Flags = Il2CppMethodFlags.METHOD_ATTRIBUTE_PUBLIC | Il2CppMethodFlags.METHOD_ATTRIBUTE_HIDE_BY_SIG; if (monoMethod.IsAbstract) { nativeMethodInfoStruct.Flags |= Il2CppMethodFlags.METHOD_ATTRIBUTE_ABSTRACT; } return nativeMethodInfoStruct.MethodInfoPointer; } private static VoidCtorDelegate CreateEmptyCtor(Type targetType, FieldInfo[] fieldsToInitialize) { DynamicMethod dynamicMethod = new DynamicMethod("FromIl2CppCtorDelegate", MethodAttributes.Public | MethodAttributes.Static, CallingConventions.Standard, typeof(void), new Type[1] { typeof(IntPtr) }, targetType, skipVisibility: true); ILGenerator iLGenerator = dynamicMethod.GetILGenerator(); ConstructorInfo constructor = targetType.GetConstructor(new Type[1] { typeof(IntPtr) }); if (constructor != null) { iLGenerator.Emit(OpCodes.Ldarg_0); iLGenerator.Emit(OpCodes.Newobj, constructor); } else { LocalBuilder local = iLGenerator.DeclareLocal(targetType); iLGenerator.Emit(OpCodes.Ldtoken, targetType); iLGenerator.Emit(OpCodes.Call, typeof(Type).GetMethod("GetTypeFromHandle", BindingFlags.Static | BindingFlags.Public)); iLGenerator.Emit(OpCodes.Call, typeof(FormatterServices).GetMethod("GetUninitializedObject", BindingFlags.Static | BindingFlags.Public)); iLGenerator.Emit(OpCodes.Stloc, local); iLGenerator.Emit(OpCodes.Ldloc, local); iLGenerator.Emit(OpCodes.Ldarg_0); iLGenerator.Emit(OpCodes.Call, typeof(Il2CppObjectBase).GetMethod("CreateGCHandle", BindingFlags.Instance | BindingFlags.NonPublic)); iLGenerator.Emit(OpCodes.Ldloc, local); iLGenerator.Emit(OpCodes.Ldc_I4_1); iLGenerator.Emit(OpCodes.Stfld, typeof(Il2CppObjectBase).GetField("isWrapped", BindingFlags.Instance | BindingFlags.NonPublic)); iLGenerator.Emit(OpCodes.Ldloc, local); iLGenerator.Emit(OpCodes.Call, targetType.GetConstructor(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, Array.Empty())); iLGenerator.Emit(OpCodes.Ldloc, local); } foreach (FieldInfo fieldInfo in fieldsToInitialize) { iLGenerator.Emit(OpCodes.Dup); iLGenerator.Emit(OpCodes.Dup); iLGenerator.Emit(OpCodes.Ldstr, fieldInfo.Name); iLGenerator.Emit(OpCodes.Newobj, fieldInfo.FieldType.GetConstructor(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[2] { typeof(Il2CppObjectBase), typeof(string) }, Array.Empty())); iLGenerator.Emit(OpCodes.Stfld, fieldInfo); } iLGenerator.Emit(OpCodes.Call, typeof(ClassInjector).GetMethod("ProcessNewObject")); iLGenerator.Emit(OpCodes.Ret); VoidCtorDelegate obj = (VoidCtorDelegate)dynamicMethod.CreateDelegate(typeof(VoidCtorDelegate)); GCHandle.Alloc(obj); return obj; } public static void Finalize(IntPtr ptr) { GCHandle.FromIntPtr(ClassInjectorBase.GetGcHandlePtrFromIl2CppObject(ptr)).Free(); } private static Delegate GetOrCreateInvoker(MethodInfo monoMethod) { return InvokerCache.GetOrAdd(ExtractSignature(monoMethod), (string _, MethodInfo monoMethodInner) => CreateInvoker(monoMethodInner), monoMethod); } private static Delegate GetOrCreateTrampoline(MethodInfo monoMethod) { return CreateTrampoline(monoMethod); } private unsafe static Delegate CreateInvoker(MethodInfo monoMethod) { DynamicMethod dynamicMethod; if (UnityVersionHandler.IsMetadataV29OrHigher) { Type[] parameterTypes = new Type[5] { typeof(IntPtr), typeof(Il2CppMethodInfo*), typeof(IntPtr), typeof(IntPtr*), typeof(IntPtr*) }; dynamicMethod = new DynamicMethod("Invoker_" + ExtractSignature(monoMethod), MethodAttributes.Public | MethodAttributes.Static, CallingConventions.Standard, typeof(void), parameterTypes, monoMethod.DeclaringType, skipVisibility: true); } else { Type[] parameterTypes2 = new Type[4] { typeof(IntPtr), typeof(Il2CppMethodInfo*), typeof(IntPtr), typeof(IntPtr*) }; dynamicMethod = new DynamicMethod("Invoker_" + ExtractSignature(monoMethod), MethodAttributes.Public | MethodAttributes.Static, CallingConventions.Standard, typeof(IntPtr), parameterTypes2, monoMethod.DeclaringType, skipVisibility: true); } ILGenerator iLGenerator = dynamicMethod.GetILGenerator(); iLGenerator.Emit(OpCodes.Ldarg_2); for (int i = 0; i < monoMethod.GetParameters().Length; i++) { ParameterInfo parameterInfo = monoMethod.GetParameters()[i]; iLGenerator.Emit(OpCodes.Ldarg_3); iLGenerator.Emit(OpCodes.Ldc_I4, i * IntPtr.Size); iLGenerator.Emit(OpCodes.Add_Ovf_Un); Type type = parameterInfo.ParameterType.NativeType(); iLGenerator.Emit(OpCodes.Ldobj, typeof(IntPtr)); if (type != typeof(IntPtr)) { iLGenerator.Emit(OpCodes.Ldobj, type); } } iLGenerator.Emit(OpCodes.Ldarg_0); iLGenerator.EmitCalli(OpCodes.Calli, CallingConvention.Cdecl, monoMethod.ReturnType.NativeType(), new Type[1] { typeof(IntPtr) }.Concat(from it in monoMethod.GetParameters() select it.ParameterType.NativeType()).ToArray()); if (UnityVersionHandler.IsMetadataV29OrHigher) { if (monoMethod.ReturnType != typeof(void)) { LocalBuilder localBuilder = iLGenerator.DeclareLocal(monoMethod.ReturnType.NativeType()); iLGenerator.Emit(OpCodes.Stloc, localBuilder); iLGenerator.Emit(OpCodes.Ldarg_S, (byte)4); iLGenerator.Emit(OpCodes.Ldloc, localBuilder); iLGenerator.Emit(OpCodes.Stobj, localBuilder.LocalType); } } else if (monoMethod.ReturnType == typeof(void)) { iLGenerator.Emit(OpCodes.Ldc_I4_0); iLGenerator.Emit(OpCodes.Conv_I); } else if (monoMethod.ReturnType.IsValueType) { LocalBuilder local = iLGenerator.DeclareLocal(monoMethod.ReturnType); iLGenerator.Emit(OpCodes.Stloc, local); FieldInfo field = typeof(Il2CppClassPointerStore<>).MakeGenericType(monoMethod.ReturnType).GetField("NativeClassPtr"); iLGenerator.Emit(OpCodes.Ldsfld, field); iLGenerator.Emit(OpCodes.Ldloca, local); iLGenerator.Emit(OpCodes.Call, typeof(IL2CPP).GetMethod("il2cpp_value_box")); } iLGenerator.Emit(OpCodes.Ret); GCHandle.Alloc(dynamicMethod); Delegate @delegate = dynamicMethod.CreateDelegate(GetInvokerDelegateType()); GCHandle.Alloc(@delegate); return @delegate; } private static Type GetInvokerDelegateType() { if (UnityVersionHandler.IsMetadataV29OrHigher) { return typeof(InvokerDelegateMetadataV29); } return typeof(InvokerDelegate); } private unsafe static IntPtr StaticVoidIntPtrInvoker(IntPtr methodPointer, Il2CppMethodInfo* methodInfo, IntPtr obj, IntPtr* args) { Marshal.GetDelegateForFunctionPointer(methodPointer)(obj); return IntPtr.Zero; } private unsafe static void StaticVoidIntPtrInvoker_MetadataV29(IntPtr methodPointer, Il2CppMethodInfo* methodInfo, IntPtr obj, IntPtr* args, IntPtr* returnValue) { Marshal.GetDelegateForFunctionPointer(methodPointer)(obj); } private unsafe static Delegate CreateTrampoline(MethodInfo monoMethod) { Type[] parameterTypes = new Type[1] { typeof(IntPtr) }.Concat((from it in monoMethod.GetParameters() select it.ParameterType.NativeType()).Concat(new Type[1] { typeof(Il2CppMethodInfo*) })).ToArray(); Type[] array = new Type[1] { monoMethod.DeclaringType }.Concat(from it in monoMethod.GetParameters() select it.ParameterType).ToArray(); DynamicMethod dynamicMethod = new DynamicMethod("Trampoline_" + ExtractSignature(monoMethod) + monoMethod.DeclaringType?.ToString() + monoMethod.Name, MethodAttributes.Public | MethodAttributes.Static, CallingConventions.Standard, monoMethod.ReturnType.NativeType(), parameterTypes, monoMethod.DeclaringType, skipVisibility: true); Type orCreateDelegateType = DelegateSupport.GetOrCreateDelegateType(new DelegateSupport.MethodSignature(monoMethod, hasThis: true), monoMethod); ILGenerator body = dynamicMethod.GetILGenerator(); body.BeginExceptionBlock(); body.Emit(OpCodes.Ldarg_0); body.Emit(OpCodes.Call, typeof(ClassInjectorBase).GetMethod("GetMonoObjectFromIl2CppPointer")); body.Emit(OpCodes.Castclass, monoMethod.DeclaringType); LocalBuilder[] array2 = new LocalBuilder[array.Length]; for (int i = 1; i < array.Length; i++) { Type type2 = array[i]; if (type2.IsSubclassOf(typeof(ValueType))) { body.Emit(OpCodes.Ldc_I8, Il2CppClassPointerStore.GetNativeClassPointer(type2).ToInt64()); body.Emit(OpCodes.Conv_I); body.Emit(Environment.Is64BitProcess ? OpCodes.Ldarg : OpCodes.Ldarga_S, i); body.Emit(OpCodes.Call, typeof(IL2CPP).GetMethod("il2cpp_value_box")); } else { body.Emit(OpCodes.Ldarg, i); } if (!type2.IsValueType) { if (type2.IsByRef) { Type elementType = type2.GetElementType(); array2[i] = body.DeclareLocal(elementType); body.Emit(OpCodes.Ldind_I); HandleTypeConversion(elementType); body.Emit(OpCodes.Stloc, array2[i]); body.Emit(OpCodes.Ldloca, array2[i]); } else { HandleTypeConversion(type2); } } } body.Emit(OpCodes.Call, monoMethod); LocalBuilder localBuilder = null; if (monoMethod.ReturnType != typeof(void)) { localBuilder = body.DeclareLocal(monoMethod.ReturnType); body.Emit(OpCodes.Stloc, localBuilder); } for (int j = 1; j < array.Length; j++) { LocalBuilder localBuilder2 = array2[j]; if (localBuilder2 != null) { body.Emit(OpCodes.Ldarg_S, j); body.Emit(OpCodes.Ldloc, localBuilder2); Type elementType2 = array[j].GetElementType(); if (elementType2 == typeof(string)) { body.Emit(OpCodes.Call, typeof(IL2CPP).GetMethod("ManagedStringToIl2Cpp")); } else if (!elementType2.IsValueType) { body.Emit(OpCodes.Call, typeof(IL2CPP).GetMethod("Il2CppObjectBaseToPtr")); } body.Emit(InjectorHelpers.StIndOpcodes.TryGetValue(elementType2, out var value) ? value : OpCodes.Stind_I); } } LocalBuilder local = body.DeclareLocal(typeof(Exception)); body.BeginCatchBlock(typeof(Exception)); body.Emit(OpCodes.Stloc, local); body.Emit(OpCodes.Ldstr, "Exception in IL2CPP-to-Managed trampoline, not passing it to il2cpp: "); body.Emit(OpCodes.Ldloc, local); body.Emit(OpCodes.Callvirt, typeof(object).GetMethod("ToString")); body.Emit(OpCodes.Call, typeof(string).GetMethod("Concat", new Type[2] { typeof(string), typeof(string) })); body.Emit(OpCodes.Call, typeof(ClassInjector).GetMethod("LogError", BindingFlags.Static | BindingFlags.NonPublic)); body.EndExceptionBlock(); if (localBuilder != null) { body.Emit(OpCodes.Ldloc, localBuilder); if (monoMethod.ReturnType == typeof(string)) { body.Emit(OpCodes.Call, typeof(IL2CPP).GetMethod("ManagedStringToIl2Cpp")); } else if (!monoMethod.ReturnType.IsValueType) { body.Emit(OpCodes.Call, typeof(IL2CPP).GetMethod("Il2CppObjectBaseToPtr")); } } body.Emit(OpCodes.Ret); Delegate @delegate = dynamicMethod.CreateDelegate(orCreateDelegateType); GCHandle.Alloc(@delegate); return @delegate; void HandleTypeConversion(Type type) { if (type == typeof(string)) { body.Emit(OpCodes.Call, typeof(IL2CPP).GetMethod("Il2CppStringToManaged")); } else if (type.IsSubclassOf(typeof(Il2CppObjectBase))) { Label label = body.DefineLabel(); Label label2 = body.DefineLabel(); body.Emit(OpCodes.Dup); body.Emit(OpCodes.Brfalse, label); body.Emit(OpCodes.Newobj, type.GetConstructors().FirstOrDefault(delegate(ConstructorInfo ci) { ParameterInfo[] parameters = ci.GetParameters(); return parameters.Length == 1 && parameters[0].ParameterType == typeof(IntPtr); })); body.Emit(OpCodes.Br, label2); body.MarkLabel(label); body.Emit(OpCodes.Pop); body.Emit(OpCodes.Ldnull); body.MarkLabel(label2); } } } private static void LogError(string message) { Logger.Instance.LogError("{Message}", message); } private static string ExtractSignature(MethodInfo monoMethod) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(monoMethod.ReturnType.NativeType().Name); stringBuilder.Append(monoMethod.IsStatic ? "" : "This"); ParameterInfo[] parameters = monoMethod.GetParameters(); foreach (ParameterInfo parameterInfo in parameters) { stringBuilder.Append(parameterInfo.ParameterType.NativeType().Name); } return stringBuilder.ToString(); } private static Type RewriteType(Type type) { if (type.IsValueType && !type.IsEnum) { return type; } if (type.IsArray) { Type elementType = type.GetElementType(); if (elementType.FullName == "System.String") { return typeof(Il2CppStringArray); } Type type2 = RewriteType(elementType); if (elementType.IsGenericParameter) { return typeof(Il2CppArrayBase<>).MakeGenericType(type2); } return (type2.IsValueType ? typeof(Il2CppStructArray<>) : typeof(Il2CppReferenceArray<>)).MakeGenericType(type2); } if (type.FullName.StartsWith("System")) { string fullName = "Il2Cpp" + type.FullName; Type type3 = Type.GetType(fullName + ", Il2Cpp" + type.Assembly.GetName().Name, throwOnError: false); if (type3 != null) { return type3; } return (from a in AppDomain.CurrentDomain.GetAssemblies() select a.GetType(fullName, throwOnError: false)).First((Type t) => t != null); } return type; } private unsafe static string GetIl2CppTypeFullName(Il2CppTypeStruct* typePointer) { INativeClassStruct nativeClassStruct = UnityVersionHandler.Wrap((Il2CppClass*)(void*)IL2CPP.il2cpp_class_from_type((IntPtr)typePointer)); INativeAssemblyStruct nativeAssemblyStruct = UnityVersionHandler.Wrap(UnityVersionHandler.Wrap(nativeClassStruct.Image).Assembly); StringBuilder stringBuilder = new StringBuilder(); string value = Marshal.PtrToStringAnsi(nativeClassStruct.Namespace); if (!string.IsNullOrEmpty(value)) { stringBuilder.Append(value); stringBuilder.Append('.'); } INativeClassStruct nativeClassStruct2 = nativeClassStruct; while ((nativeClassStruct2 = UnityVersionHandler.Wrap(nativeClassStruct2.DeclaringType)) != null) { stringBuilder.Append(Marshal.PtrToStringAnsi(nativeClassStruct2.Name)); stringBuilder.Append('+'); } stringBuilder.Append(Marshal.PtrToStringAnsi(nativeClassStruct.Name)); string text = Marshal.PtrToStringAnsi(nativeAssemblyStruct.Name.Name); if (text != "mscorlib") { stringBuilder.Append(", "); stringBuilder.Append(text); } return stringBuilder.ToString(); } internal unsafe static Type SystemTypeFromIl2CppType(Il2CppTypeStruct* typePointer) { string il2CppTypeFullName = GetIl2CppTypeFullName(typePointer); return RewriteType(Type.GetType(il2CppTypeFullName) ?? throw new NullReferenceException("Couldn't find System.Type for Il2Cpp type: " + il2CppTypeFullName)); } public unsafe static void Dump() { Dump((Il2CppClass*)(void*)Il2CppClassPointerStore.NativeClassPtr); } private unsafe static string ToString(Il2CppClass* il2CppClass) { if (il2CppClass == null) { return "null"; } INativeClassStruct nativeClassStruct = UnityVersionHandler.Wrap(il2CppClass); return Marshal.PtrToStringUTF8(nativeClassStruct.Namespace) + "." + Marshal.PtrToStringUTF8(nativeClassStruct.Name); } private unsafe static string ToString(Il2CppTypeStruct* il2CppType) { if (il2CppType == null) { return "null"; } return Marshal.PtrToStringAnsi(IL2CPP.il2cpp_type_get_name((IntPtr)il2CppType)); } public unsafe static void Dump(Il2CppClass* il2CppClass) { if (il2CppClass == null) { throw new ArgumentNullException("il2CppClass"); } InjectorHelpers.Setup(); InjectorHelpers.ClassInit(il2CppClass); INativeClassStruct nativeClassStruct = UnityVersionHandler.Wrap(il2CppClass); Logger.Instance.LogDebug("Dumping {Pointer:X}", nativeClassStruct.Pointer); Logger.Instance.LogDebug(" Namespace = {Namespace}", Marshal.PtrToStringUTF8(nativeClassStruct.Namespace)); Logger.Instance.LogDebug(" Name = {Name}", Marshal.PtrToStringUTF8(nativeClassStruct.Name)); Logger.Instance.LogDebug(" Parent = {Parent}", ToString(nativeClassStruct.Parent)); Logger.Instance.LogDebug(" InstanceSize = {InstanceSize}", nativeClassStruct.InstanceSize); Logger.Instance.LogDebug(" NativeSize = {NativeSize}", nativeClassStruct.NativeSize); Logger.Instance.LogDebug(" ActualSize = {ActualSize}", nativeClassStruct.ActualSize); Logger.Instance.LogDebug(" Flags = {Flags}", nativeClassStruct.Flags); Logger.Instance.LogDebug(" ValueType = {ValueType}", nativeClassStruct.ValueType); Logger.Instance.LogDebug(" EnumType = {EnumType}", nativeClassStruct.EnumType); Logger.Instance.LogDebug(" IsGeneric = {IsGeneric}", nativeClassStruct.IsGeneric); Logger.Instance.LogDebug(" Initialized = {Initialized}", nativeClassStruct.Initialized); Logger.Instance.LogDebug(" InitializedAndNoError = {InitializedAndNoError}", nativeClassStruct.InitializedAndNoError); Logger.Instance.LogDebug(" SizeInited = {SizeInited}", nativeClassStruct.SizeInited); Logger.Instance.LogDebug(" HasFinalize = {HasFinalize}", nativeClassStruct.HasFinalize); Logger.Instance.LogDebug(" IsVtableInitialized = {IsVtableInitialized}", nativeClassStruct.IsVtableInitialized); VirtualInvokeData* ptr = (VirtualInvokeData*)(void*)nativeClassStruct.VTable; Logger.Instance.LogDebug(" VTable ({VtableCount}):", nativeClassStruct.VtableCount); for (int i = 0; i < nativeClassStruct.VtableCount; i++) { VirtualInvokeData virtualInvokeData = ptr[i]; string text = ((virtualInvokeData.method == null) ? "" : Marshal.PtrToStringUTF8(UnityVersionHandler.Wrap(virtualInvokeData.method).Name)); Logger.Instance.LogDebug(" [{I}] {MethodName} - {MethodPtr}", i, text, (virtualInvokeData.methodPtr == (IntPtr)0) ? "" : ((object)virtualInvokeData.methodPtr)); } Logger.Instance.LogDebug(" Fields ({FieldCount}):", nativeClassStruct.FieldCount); for (int j = 0; j < nativeClassStruct.FieldCount; j++) { INativeFieldInfoStruct nativeFieldInfoStruct = UnityVersionHandler.Wrap(nativeClassStruct.Fields + j * UnityVersionHandler.FieldInfoSize()); Logger.Instance.LogDebug($" [{j}] {ToString(nativeFieldInfoStruct.Type)} {Marshal.PtrToStringUTF8(nativeFieldInfoStruct.Name)} - {nativeFieldInfoStruct.Offset}"); } Logger.Instance.LogDebug(" Methods ({MethodCount}):", nativeClassStruct.MethodCount); for (int k = 0; k < nativeClassStruct.MethodCount; k++) { INativeMethodInfoStruct nativeMethodInfoStruct = UnityVersionHandler.Wrap(nativeClassStruct.Methods[k]); Logger.Instance.LogDebug(" [{I}] {ReturnType} {Name}({ParametersCount}), {Flags}, {Slot}", k, ToString(nativeMethodInfoStruct.ReturnType), Marshal.PtrToStringUTF8(nativeMethodInfoStruct.Name), nativeMethodInfoStruct.ParametersCount, nativeMethodInfoStruct.Flags, nativeMethodInfoStruct.Slot); } Logger.Instance.LogDebug(" ImplementedInterfaces ({InterfaceCount}):", nativeClassStruct.InterfaceCount); for (int l = 0; l < nativeClassStruct.InterfaceCount; l++) { INativeClassStruct nativeClassStruct2 = UnityVersionHandler.Wrap(nativeClassStruct.ImplementedInterfaces[l]); Logger.Instance.LogDebug(" [{I}] {Name}", l, Marshal.PtrToStringUTF8(nativeClassStruct2.Name)); } Logger.Instance.LogDebug(" InterfaceOffsets ({InterfaceOffsetsCount}):", nativeClassStruct.InterfaceOffsetsCount); for (int m = 0; m < nativeClassStruct.InterfaceOffsetsCount; m++) { Il2CppRuntimeInterfaceOffsetPair il2CppRuntimeInterfaceOffsetPair = nativeClassStruct.InterfaceOffsets[m]; INativeClassStruct nativeClassStruct3 = UnityVersionHandler.Wrap(il2CppRuntimeInterfaceOffsetPair.interfaceType); Logger.Instance.LogDebug(" [{I}] {Offset} - {Name}", m, il2CppRuntimeInterfaceOffsetPair.offset, Marshal.PtrToStringUTF8(nativeClassStruct3.Name)); } Logger.Instance.LogDebug(" TypeHierarchy ({TypeHierarchyDepth}):", nativeClassStruct.TypeHierarchyDepth); for (int n = 0; n < nativeClassStruct.TypeHierarchyDepth; n++) { INativeClassStruct nativeClassStruct4 = UnityVersionHandler.Wrap(nativeClassStruct.TypeHierarchy[n]); Logger.Instance.LogDebug(" [{I}] {Name}", n, Marshal.PtrToStringUTF8(nativeClassStruct4.Name)); } } } public interface IDetour : IDisposable { nint Target { get; } nint Detour { get; } nint OriginalTrampoline { get; } void Apply(); T GenerateTrampoline() where T : Delegate; } public interface IDetourProvider { IDetour Create(nint original, TDelegate target) where TDelegate : Delegate; } internal static class Detour { public static IDetour Apply(nint original, T target, out T trampoline) where T : Delegate { IDetour detour = Il2CppInteropRuntime.Instance.DetourProvider.Create(original, target); trampoline = detour.GenerateTrampoline(); detour.Apply(); return detour; } } public static class EnumInjector { private static readonly ConcurrentDictionary s_DefaultValueOverrides = new ConcurrentDictionary(); private static readonly IntPtr value__Cached = Marshal.StringToHGlobalAnsi("value__"); internal unsafe static bool GetDefaultValueOverride(Il2CppFieldInfo* fieldInfo, out IntPtr defaultValueBlob) { return s_DefaultValueOverrides.TryGetValue((IntPtr)fieldInfo, out defaultValueBlob); } public static void InjectEnumValues(Dictionary valuesToAdd) where TEnum : Enum { InjectEnumValues(typeof(TEnum), valuesToAdd); } public unsafe static void InjectEnumValues(Type type, Dictionary valuesToAdd) { if (type == null) { throw new ArgumentException("Type argument cannot be null"); } if (!type.IsEnum) { throw new ArgumentException("Type argument needs to be an enum"); } IntPtr nativeClassPointer = Il2CppClassPointerStore.GetNativeClassPointer(type); if (nativeClassPointer == IntPtr.Zero) { throw new ArgumentException("Type needs to be an Il2Cpp enum"); } InjectorHelpers.Setup(); InjectorHelpers.ClassInit((Il2CppClass*)(void*)nativeClassPointer); INativeClassStruct nativeClassStruct = UnityVersionHandler.Wrap((Il2CppClass*)(void*)nativeClassPointer); int num = nativeClassStruct.FieldCount + valuesToAdd.Count; Il2CppFieldInfo* ptr = (Il2CppFieldInfo*)(void*)Marshal.AllocHGlobal(num * UnityVersionHandler.FieldInfoSize()); int i; for (i = 0; i < nativeClassStruct.FieldCount; i++) { int num2 = i * UnityVersionHandler.FieldInfoSize(); INativeFieldInfoStruct nativeFieldInfoStruct = UnityVersionHandler.Wrap(nativeClassStruct.Fields + num2); INativeFieldInfoStruct nativeFieldInfoStruct2 = UnityVersionHandler.Wrap(ptr + num2); nativeFieldInfoStruct2.Name = nativeFieldInfoStruct.Name; nativeFieldInfoStruct2.Type = nativeFieldInfoStruct.Type; nativeFieldInfoStruct2.Parent = nativeFieldInfoStruct.Parent; nativeFieldInfoStruct2.Offset = nativeFieldInfoStruct.Offset; if (s_DefaultValueOverrides.TryRemove((IntPtr)nativeFieldInfoStruct.FieldInfoPointer, out var value)) { s_DefaultValueOverrides[(IntPtr)nativeFieldInfoStruct2.FieldInfoPointer] = value; } } INativeTypeStruct byValArg = UnityVersionHandler.Wrap(nativeClassStruct.ElementClass).ByValArg; foreach (KeyValuePair item in valuesToAdd) { int num3 = i * UnityVersionHandler.FieldInfoSize(); INativeFieldInfoStruct nativeFieldInfoStruct3 = UnityVersionHandler.Wrap(ptr + num3); nativeFieldInfoStruct3.Name = Marshal.StringToHGlobalAnsi(item.Key); nativeFieldInfoStruct3.Type = byValArg.TypePointer; nativeFieldInfoStruct3.Parent = nativeClassStruct.ClassPointer; nativeFieldInfoStruct3.Offset = 0; CreateOrUpdateFieldDefaultValue(nativeFieldInfoStruct3.FieldInfoPointer, byValArg.TypePointer, item.Value); i++; } nativeClassStruct.FieldCount = (ushort)num; nativeClassStruct.Fields = ptr; RuntimeType val = ((Il2CppObjectBase)(object)Il2CppType.TypeFromPointer(nativeClassPointer)).TryCast(); if (val != (RuntimeType)null) { val.GenericCache = null; } } private static int GetEnumElementSize(Il2CppTypeEnum type) { return type switch { Il2CppTypeEnum.IL2CPP_TYPE_I1 => 1, Il2CppTypeEnum.IL2CPP_TYPE_U1 => 1, Il2CppTypeEnum.IL2CPP_TYPE_CHAR => 2, Il2CppTypeEnum.IL2CPP_TYPE_I2 => 2, Il2CppTypeEnum.IL2CPP_TYPE_U2 => 2, Il2CppTypeEnum.IL2CPP_TYPE_I4 => 4, Il2CppTypeEnum.IL2CPP_TYPE_U4 => 4, Il2CppTypeEnum.IL2CPP_TYPE_I8 => 8, Il2CppTypeEnum.IL2CPP_TYPE_U8 => 8, _ => throw new ArgumentException($"The type provided {type} is invalid"), }; } private static IntPtr AllocateNewDefaultValueBlob(Il2CppTypeEnum type) { int enumElementSize = GetEnumElementSize(type); IntPtr result = Marshal.AllocHGlobal(enumElementSize); Logger.Instance.LogTrace("Allocated default value blob at 0x{Blob} of {Size} for {Type}", result.ToInt64().ToString("X2"), enumElementSize, type); return result; } private unsafe static IntPtr CreateOrUpdateFieldDefaultValue(Il2CppFieldInfo* field, Il2CppTypeStruct* type, object value) { Il2CppTypeEnum type2 = UnityVersionHandler.Wrap(type).Type; if (!GetDefaultValueOverride(field, out var defaultValueBlob)) { defaultValueBlob = AllocateNewDefaultValueBlob(type2); s_DefaultValueOverrides[(IntPtr)field] = defaultValueBlob; } SetFieldDefaultValue(defaultValueBlob, type2, value); return defaultValueBlob; } private unsafe static void SetFieldDefaultValue(IntPtr blob, Il2CppTypeEnum type, object value) { long num = Convert.ToInt64(value); switch (type) { case Il2CppTypeEnum.IL2CPP_TYPE_I1: *(sbyte*)(void*)blob = (sbyte)num; return; case Il2CppTypeEnum.IL2CPP_TYPE_U1: *(byte*)(void*)blob = (byte)num; return; case Il2CppTypeEnum.IL2CPP_TYPE_CHAR: *(ushort*)(void*)blob = (ushort)num; return; case Il2CppTypeEnum.IL2CPP_TYPE_I2: *(short*)(void*)blob = (short)num; return; case Il2CppTypeEnum.IL2CPP_TYPE_U2: *(ushort*)(void*)blob = (ushort)num; return; case Il2CppTypeEnum.IL2CPP_TYPE_I4: *(int*)(void*)blob = (int)num; return; case Il2CppTypeEnum.IL2CPP_TYPE_U4: *(int*)(void*)blob = (int)num; return; case Il2CppTypeEnum.IL2CPP_TYPE_I8: *(long*)(void*)blob = num; return; case Il2CppTypeEnum.IL2CPP_TYPE_U8: *(long*)(void*)blob = num; return; } throw new ArgumentException($"The type provided {type} is invalid"); } public static void RegisterEnumInIl2Cpp(bool logSuccess = true) where TEnum : Enum { RegisterEnumInIl2Cpp(typeof(TEnum), logSuccess); } public unsafe static void RegisterEnumInIl2Cpp(Type type, bool logSuccess = true) { if (type == null) { throw new ArgumentException("Type argument cannot be null"); } if (!type.IsEnum) { throw new ArgumentException("Type argument needs to be an enum"); } if (!(Il2CppClassPointerStore.GetNativeClassPointer(type) != IntPtr.Zero)) { InjectorHelpers.Setup(); INativeClassStruct nativeClassStruct = UnityVersionHandler.Wrap((Il2CppClass*)(void*)Il2CppClassPointerStore.NativeClassPtr); InjectorHelpers.ClassInit(nativeClassStruct.ClassPointer); INativeClassStruct nativeClassStruct2 = UnityVersionHandler.NewClass(nativeClassStruct.VtableCount); INativeClassStruct nativeClassStruct3 = UnityVersionHandler.Wrap((Il2CppClass*)(void*)Il2CppClassPointerStore.GetNativeClassPointer(Enum.GetUnderlyingType(type))); nativeClassStruct2.Image = InjectorHelpers.InjectedImage.ImagePointer; nativeClassStruct2.Class = (nativeClassStruct2.CastClass = (nativeClassStruct2.ElementClass = nativeClassStruct3.ClassPointer)); nativeClassStruct2.Parent = nativeClassStruct.ClassPointer; nativeClassStruct2.ActualSize = (nativeClassStruct2.InstanceSize = (uint)(nativeClassStruct.InstanceSize + GetEnumElementSize(nativeClassStruct3.ByValArg.Type))); nativeClassStruct2.NativeSize = -1; nativeClassStruct2.ValueType = true; nativeClassStruct2.EnumType = true; nativeClassStruct2.Initialized = true; nativeClassStruct2.InitializedAndNoError = true; nativeClassStruct2.SizeInited = true; nativeClassStruct2.HasFinalize = true; nativeClassStruct2.IsVtableInitialized = true; nativeClassStruct2.Name = Marshal.StringToHGlobalAnsi(type.Name); nativeClassStruct2.Namespace = Marshal.StringToHGlobalAnsi(type.Namespace ?? string.Empty); long num = InjectorHelpers.CreateClassToken(nativeClassStruct2.Pointer); nativeClassStruct2.ThisArg.Data = (nativeClassStruct2.ByValArg.Data = (IntPtr)num); nativeClassStruct2.ThisArg.Type = (nativeClassStruct2.ByValArg.Type = Il2CppTypeEnum.IL2CPP_TYPE_VALUETYPE); nativeClassStruct2.Flags = (Il2CppClassAttributes)type.Attributes; nativeClassStruct2.VtableCount = nativeClassStruct.VtableCount; VirtualInvokeData* ptr = (VirtualInvokeData*)(void*)nativeClassStruct2.VTable; VirtualInvokeData* ptr2 = (VirtualInvokeData*)(void*)nativeClassStruct.VTable; for (int i = 0; i < nativeClassStruct.VtableCount; i++) { ptr[i] = ptr2[i]; } Array values = Enum.GetValues(type); string[] names = Enum.GetNames(type); nativeClassStruct2.FieldCount = (ushort)(values.Length + 1); Il2CppFieldInfo* ptr3 = (Il2CppFieldInfo*)(void*)Marshal.AllocHGlobal(nativeClassStruct2.FieldCount * UnityVersionHandler.FieldInfoSize()); INativeFieldInfoStruct nativeFieldInfoStruct = UnityVersionHandler.Wrap(ptr3); nativeFieldInfoStruct.Name = value__Cached; nativeFieldInfoStruct.Parent = nativeClassStruct2.ClassPointer; nativeFieldInfoStruct.Offset = (int)nativeClassStruct.InstanceSize; INativeTypeStruct nativeTypeStruct = UnityVersionHandler.NewType(); nativeTypeStruct.Data = nativeClassStruct3.ThisArg.Data; nativeTypeStruct.Attrs = 1541; nativeTypeStruct.Type = nativeClassStruct3.ThisArg.Type; nativeTypeStruct.ByRef = nativeClassStruct3.ThisArg.ByRef; nativeTypeStruct.Pinned = nativeClassStruct3.ThisArg.Pinned; nativeFieldInfoStruct.Type = nativeTypeStruct.TypePointer; INativeTypeStruct nativeTypeStruct2 = UnityVersionHandler.NewType(); nativeTypeStruct2.Data = nativeClassStruct2.ThisArg.Data; nativeTypeStruct2.Attrs = 32869; nativeTypeStruct2.Type = Il2CppTypeEnum.IL2CPP_TYPE_VALUETYPE; nativeTypeStruct2.ByRef = false; nativeTypeStruct2.Pinned = false; for (int j = 1; j < nativeClassStruct2.FieldCount; j++) { object value = values.GetValue(j - 1); INativeFieldInfoStruct nativeFieldInfoStruct2 = UnityVersionHandler.Wrap(ptr3 + j * UnityVersionHandler.FieldInfoSize()); nativeFieldInfoStruct2.Name = Marshal.StringToHGlobalAnsi(names[j - 1]); nativeFieldInfoStruct2.Type = nativeTypeStruct2.TypePointer; nativeFieldInfoStruct2.Parent = nativeClassStruct2.ClassPointer; nativeFieldInfoStruct2.Offset = 0; CreateOrUpdateFieldDefaultValue(nativeFieldInfoStruct2.FieldInfoPointer, nativeClassStruct3.ThisArg.TypePointer, value); } nativeClassStruct2.Fields = ptr3; nativeClassStruct2.TypeHierarchyDepth = (byte)(1 + nativeClassStruct.TypeHierarchyDepth); nativeClassStruct2.TypeHierarchy = (Il2CppClass**)(void*)Marshal.AllocHGlobal(nativeClassStruct2.TypeHierarchyDepth * sizeof(void*)); for (int k = 0; k < nativeClassStruct2.TypeHierarchyDepth; k++) { nativeClassStruct2.TypeHierarchy[k] = nativeClassStruct.TypeHierarchy[k]; } nativeClassStruct2.TypeHierarchy[nativeClassStruct2.TypeHierarchyDepth - 1] = nativeClassStruct2.ClassPointer; RuntimeSpecificsStore.SetClassInfo(nativeClassStruct2.Pointer, wasInjected: true); Il2CppClassPointerStore.SetNativeClassPointer(type, nativeClassStruct2.Pointer); InjectorHelpers.AddTypeToLookup(type, nativeClassStruct2.Pointer); if (logSuccess) { Logger.Instance.LogInformation("Registered managed enum {Type} in il2cpp domain", type); } } } } internal abstract class Hook where T : Delegate { private bool _isApplied; private T _detour; private T _method; private T _original; public T Original => _original; public abstract string TargetMethodName { get; } public abstract T GetDetour(); public abstract IntPtr FindTargetMethod(); public virtual void TargetMethodNotFound() { throw new Exception("Required target method " + TargetMethodName + " not found"); } public void ApplyHook() { if (!_isApplied) { nint num = FindTargetMethod(); if (num == IntPtr.Zero) { TargetMethodNotFound(); return; } Logger.Instance.LogTrace("{MethodName} found: 0x{MethodPtr}", TargetMethodName, ((IntPtr)num).ToInt64().ToString("X2")); _detour = GetDetour(); Detour.Apply(num, _detour, out _original); _method = Marshal.GetDelegateForFunctionPointer(num); _isApplied = true; } } } internal static class InjectorHelpers { [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal unsafe delegate void d_ClassInit(Il2CppClass* klass); internal static Assembly Il2CppMscorlib = typeof(Type).Assembly; internal static INativeAssemblyStruct InjectedAssembly; internal static INativeImageStruct InjectedImage; internal static ProcessModule Il2CppModule = ((IEnumerable)Process.GetCurrentProcess().Modules).OfType().Single(delegate(ProcessModule x) { string moduleName = x.ModuleName; return moduleName == "GameAssembly.dll" || moduleName == "GameAssembly.so" || moduleName == "UserAssembly.dll"; }); internal static IntPtr Il2CppHandle = NativeLibrary.Load("GameAssembly", typeof(InjectorHelpers).Assembly, null); internal static readonly Dictionary StIndOpcodes = new Dictionary { [typeof(byte)] = OpCodes.Stind_I1, [typeof(sbyte)] = OpCodes.Stind_I1, [typeof(bool)] = OpCodes.Stind_I1, [typeof(short)] = OpCodes.Stind_I2, [typeof(ushort)] = OpCodes.Stind_I2, [typeof(int)] = OpCodes.Stind_I4, [typeof(uint)] = OpCodes.Stind_I4, [typeof(long)] = OpCodes.Stind_I8, [typeof(ulong)] = OpCodes.Stind_I8, [typeof(float)] = OpCodes.Stind_R4, [typeof(double)] = OpCodes.Stind_R8 }; private static readonly GenericMethod_GetMethod_Hook GenericMethodGetMethodHook = new GenericMethod_GetMethod_Hook(); private static readonly MetadataCache_GetTypeInfoFromTypeDefinitionIndex_Hook GetTypeInfoFromTypeDefinitionIndexHook = new MetadataCache_GetTypeInfoFromTypeDefinitionIndex_Hook(); private static readonly Class_GetFieldDefaultValue_Hook GetFieldDefaultValueHook = new Class_GetFieldDefaultValue_Hook(); private static readonly Class_FromIl2CppType_Hook FromIl2CppTypeHook = new Class_FromIl2CppType_Hook(); private static readonly Class_FromName_Hook FromNameHook = new Class_FromName_Hook(); private static readonly GarbageCollector_RunFinalizer_Patch RunFinalizerPatch = new GarbageCollector_RunFinalizer_Patch(); private static long s_LastInjectedToken = -2L; internal static readonly ConcurrentDictionary s_InjectedClasses = new ConcurrentDictionary(); internal static readonly Dictionary<(string _namespace, string _class, IntPtr imagePtr), IntPtr> s_ClassNameLookup = new Dictionary<(string, string, IntPtr), IntPtr>(); internal static d_ClassInit ClassInit; private static readonly MemoryUtils.SignatureDefinition[] s_ClassInitSignatures = new MemoryUtils.SignatureDefinition[2] { new MemoryUtils.SignatureDefinition { pattern = "è\0\0\0\0\u000f·G(\u0083", mask = "x????xxxxx", xref = true }, new MemoryUtils.SignatureDefinition { pattern = "è\0\0\0\0\u000f·GHH", mask = "x????xxxxx", xref = true } }; private unsafe static void CreateInjectedAssembly() { InjectedAssembly = UnityVersionHandler.NewAssembly(); InjectedImage = UnityVersionHandler.NewImage(); InjectedAssembly.Name.Name = Marshal.StringToHGlobalAnsi("InjectedMonoTypes"); InjectedImage.Assembly = InjectedAssembly.AssemblyPointer; InjectedImage.Dynamic = 1; InjectedImage.Name = InjectedAssembly.Name.Name; if (InjectedImage.HasNameNoExt) { InjectedImage.NameNoExt = InjectedAssembly.Name.Name; } } internal static void Setup() { if (InjectedAssembly == null) { CreateInjectedAssembly(); } GenericMethodGetMethodHook.ApplyHook(); GetTypeInfoFromTypeDefinitionIndexHook.ApplyHook(); GetFieldDefaultValueHook.ApplyHook(); if (ClassInit == null) { ClassInit = FindClassInit(); } FromIl2CppTypeHook.ApplyHook(); FromNameHook.ApplyHook(); RunFinalizerPatch.ApplyHook(); } internal static long CreateClassToken(IntPtr classPointer) { long num = Interlocked.Decrement(ref s_LastInjectedToken); s_InjectedClasses[num] = classPointer; return num; } internal static void AddTypeToLookup(IntPtr typePointer) where T : class { AddTypeToLookup(typeof(T), typePointer); } internal static void AddTypeToLookup(Type type, IntPtr typePointer) { string name = type.Name; if (name != null) { string item = type.Namespace ?? string.Empty; IntPtr[] array = ((!(Attribute.GetCustomAttribute(type, typeof(ClassInjectionAssemblyTargetAttribute)) is ClassInjectionAssemblyTargetAttribute classInjectionAssemblyTargetAttribute)) ? IL2CPP.GetIl2CppImages() : classInjectionAssemblyTargetAttribute.GetImagePointers()); foreach (IntPtr item2 in array) { s_ClassNameLookup.Add((item, name, item2), typePointer); } } } internal static IntPtr GetIl2CppExport(string name) { if (!TryGetIl2CppExport(name, out var address)) { throw new NotSupportedException($"Couldn't find {name} in {Il2CppModule.ModuleName}'s exports"); } return address; } internal static bool TryGetIl2CppExport(string name, out IntPtr address) { return NativeLibrary.TryGetExport(Il2CppHandle, name, out address); } internal unsafe static IntPtr GetIl2CppMethodPointer(MethodBase proxyMethod) { if (proxyMethod == null) { return IntPtr.Zero; } FieldInfo il2CppMethodInfoPointerFieldForGeneratedMethod = Il2CppInteropUtils.GetIl2CppMethodInfoPointerFieldForGeneratedMethod(proxyMethod); if (il2CppMethodInfoPointerFieldForGeneratedMethod == null) { throw new ArgumentException("Couldn't find the generated method info pointer for " + proxyMethod.Name); } Il2CppClassPointerStore.GetNativeClassPointer(proxyMethod.DeclaringType); IntPtr intPtr = (IntPtr)il2CppMethodInfoPointerFieldForGeneratedMethod.GetValue(null); if (intPtr == IntPtr.Zero) { throw new ArgumentException("Generated method info pointer for " + proxyMethod.Name + " doesn't point to any il2cpp method info"); } return UnityVersionHandler.Wrap((Il2CppMethodInfo*)(void*)intPtr).MethodPointer; } private static d_ClassInit FindClassInit() { nint num = s_ClassInitSignatures.Select((MemoryUtils.SignatureDefinition s) => MemoryUtils.FindSignatureInModule(Il2CppModule, s)).FirstOrDefault((nint p) => p != 0); if (num == 0) { Logger.Instance.LogWarning("Class::Init signatures have been exhausted, using a substitute!"); num = GetClassInitSubstitute(); } Logger.Instance.LogTrace("Class::Init: 0x{PClassInitAddress}", ((IntPtr)num).ToString("X2")); return Marshal.GetDelegateForFunctionPointer(num); static nint GetClassInitSubstitute() { if (TryGetIl2CppExport("mono_class_instance_size", out var address)) { Logger.Instance.LogTrace("Picked mono_class_instance_size as a Class::Init substitute"); return address; } if (TryGetIl2CppExport("mono_class_setup_vtable", out address)) { Logger.Instance.LogTrace("Picked mono_class_setup_vtable as a Class::Init substitute"); return address; } if (TryGetIl2CppExport("il2cpp_class_has_references", out address)) { Logger.Instance.LogTrace("Picked il2cpp_class_has_references as a Class::Init substitute"); return address; } Logger.Instance.LogTrace("GameAssembly.dll: 0x{Il2CppModuleAddress}", Il2CppModule.BaseAddress.ToInt64().ToString("X2")); throw new NotSupportedException("Failed to use signature for Class::Init and a substitute cannot be found, please create an issue and report your unity version & game"); } } } internal static class TrampolineHelpers { private static AssemblyBuilder _fixedStructAssembly; private static ModuleBuilder _fixedStructModuleBuilder; private static readonly Dictionary _fixedStructCache = new Dictionary(); private static Type GetFixedSizeStructType(int size) { if (_fixedStructCache.TryGetValue(size, out var value)) { return value; } if ((object)_fixedStructAssembly == null) { _fixedStructAssembly = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("FixedSizeStructAssembly"), AssemblyBuilderAccess.Run); } if ((object)_fixedStructModuleBuilder == null) { _fixedStructModuleBuilder = _fixedStructAssembly.DefineDynamicModule("FixedSizeStructAssembly"); } Type type = _fixedStructModuleBuilder.DefineType($"IL2CPPDetour_FixedSizeStruct_{size}b", TypeAttributes.ExplicitLayout, typeof(ValueType), size).CreateType(); return _fixedStructCache[size] = type; } internal unsafe static Type NativeType(this Type managedType) { if (managedType.IsByRef) { Type elementType = managedType.GetElementType(); if (elementType == typeof(bool)) { return typeof(byte).MakeByRefType(); } if (elementType == typeof(string) || elementType.IsSubclassOf(typeof(Il2CppObjectBase))) { return typeof(IntPtr*); } } else { if (managedType.IsSubclassOf(typeof(ValueType)) && !Environment.Is64BitProcess) { uint align = 0u; return GetFixedSizeStructType(IL2CPP.il2cpp_class_value_size(Il2CppClassPointerStore.GetNativeClassPointer(managedType), ref align)); } if (managedType == typeof(string) || managedType.IsSubclassOf(typeof(Il2CppObjectBase))) { return typeof(IntPtr); } if (managedType == typeof(bool)) { return typeof(byte); } } return managedType; } } } namespace Il2CppInterop.Runtime.Injection.Hooks { internal class Class_FromIl2CppType_Hook : Hook { internal readonly struct Il2CppType { public unsafe readonly void* data; public readonly ushort attrs; public readonly Il2CppTypeEnum type; private readonly byte _bitfield; } [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal unsafe delegate Il2CppClass* MethodDelegate(Il2CppType* type, bool throwOnError); public override string TargetMethodName => "Class::FromIl2CppType"; public unsafe override MethodDelegate GetDetour() { return Hook; } private unsafe Il2CppClass* Hook(Il2CppType* type, bool throwOnError) { if ((nint)type->data < unchecked((nint)null) && (type->type == Il2CppTypeEnum.IL2CPP_TYPE_CLASS || type->type == Il2CppTypeEnum.IL2CPP_TYPE_VALUETYPE)) { InjectorHelpers.s_InjectedClasses.TryGetValue((nint)type->data, out var value); return (Il2CppClass*)(void*)value; } return base.Original(type, throwOnError); } public override IntPtr FindTargetMethod() { IntPtr il2CppExport = InjectorHelpers.GetIl2CppExport("il2cpp_class_from_il2cpp_type"); Logger.Instance.LogTrace("il2cpp_class_from_il2cpp_type: 0x{ClassFromTypeApiAddress}", il2CppExport.ToInt64().ToString("X2")); return XrefScannerLowLevel.JumpTargets(il2CppExport, false).Single(); } } internal class Class_FromName_Hook : Hook { [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal unsafe delegate Il2CppClass* MethodDelegate(Il2CppImage* image, IntPtr _namespace, IntPtr name); public override string TargetMethodName => "Class::FromName"; public unsafe override MethodDelegate GetDetour() { return Hook; } private unsafe Il2CppClass* Hook(Il2CppImage* image, IntPtr _namespace, IntPtr name) { Il2CppClass* ptr = base.Original(image, _namespace, name); if (ptr == null) { string item = Marshal.PtrToStringAnsi(_namespace); string item2 = Marshal.PtrToStringAnsi(name); InjectorHelpers.s_ClassNameLookup.TryGetValue((item, item2, (IntPtr)image), out var value); ptr = (Il2CppClass*)(void*)value; } return ptr; } public override IntPtr FindTargetMethod() { IntPtr il2CppExport = InjectorHelpers.GetIl2CppExport("il2cpp_class_from_name"); Logger.Instance.LogTrace("il2cpp_class_from_name: 0x{ClassFromNameApiAddress}", il2CppExport.ToInt64().ToString("X2")); return XrefScannerLowLevel.JumpTargets(il2CppExport, false).Single(); } } internal class Class_GetFieldDefaultValue_Hook : Hook { [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal unsafe delegate byte* MethodDelegate(Il2CppFieldInfo* field, out Il2CppTypeStruct* type); private static readonly MemoryUtils.SignatureDefinition[] s_Signatures = new MemoryUtils.SignatureDefinition[4] { new MemoryUtils.SignatureDefinition { pattern = "H\u0089\\$\bH\u0089t$\u0010WH\u0083ì H\u008by\u0010H\u008bÙH\u008bòH+\u009f", mask = "xxxxxxxxxxxxxx?xxxxxxxxxxxxx", xref = false }, new MemoryUtils.SignatureDefinition { pattern = "H\u0089\\$\bWH\u0083ì H\u008bA\u0010H\u008bÙH\u008b", mask = "xxxxxxxxxxxxxxxxxxx", xref = false }, new MemoryUtils.SignatureDefinition { pattern = "@SH\u0083ì H\u008bÚè\0\0\0\0L\u008bÈH\u0085À", mask = "xxxxxxxxxx????xxxxxx", xref = false }, new MemoryUtils.SignatureDefinition { pattern = "U\u008bìVÿu\bè\0\0\0\0\u008bð\u0083Ä\u0004\u0085ö", mask = "xxxxxxxx????xxxxxxx", xref = false } }; public override string TargetMethodName => "Class::GetDefaultFieldValue"; public unsafe override MethodDelegate GetDetour() { return Hook; } private unsafe byte* Hook(Il2CppFieldInfo* field, out Il2CppTypeStruct* type) { if (EnumInjector.GetDefaultValueOverride(field, out var defaultValueBlob)) { INativeClassStruct nativeClassStruct = UnityVersionHandler.Wrap(UnityVersionHandler.Wrap(UnityVersionHandler.Wrap(field).Parent).ElementClass); type = nativeClassStruct.ByValArg.TypePointer; return (byte*)(void*)defaultValueBlob; } return base.Original(field, out type); } private static nint FindClassGetFieldDefaultValueXref(bool forceICallMethod = false) { nint num = 0; if (forceICallMethod) { Type? type = AssemblyExtensions.GetTypesSafe(InjectorHelpers.Il2CppMscorlib).SingleOrDefault((Type x) => x.Name == "MonoField"); if (type == null) { throw new Exception($"Unity {Il2CppInteropRuntime.Instance.UnityVersion} is not supported at the moment: MonoField isn't present in Il2Cppmscorlib.dll for unity version, unable to fetch icall"); } IntPtr il2CppMethodPointer = InjectorHelpers.GetIl2CppMethodPointer(type.GetMethod("GetValueInternal")); Logger.Instance.LogTrace("Il2CppSystem.Reflection.MonoField::thunk_GetValueInternal: 0x{MonoFieldGetValueInternalThunkAddress}", il2CppMethodPointer.ToInt64().ToString("X2")); IntPtr intPtr = XrefScannerLowLevel.JumpTargets(il2CppMethodPointer, false).Single(); Logger.Instance.LogTrace("Il2CppSystem.Reflection.MonoField::GetValueInternal: 0x{MonoFieldGetValueInternalAddress}", intPtr.ToInt64().ToString("X2")); IntPtr intPtr2 = XrefScannerLowLevel.JumpTargets(intPtr, false).Single(); Logger.Instance.LogTrace("Field::GetValueObject: 0x{FieldGetValueObjectAddress}", intPtr2.ToInt64().ToString("X2")); IntPtr intPtr3 = XrefScannerLowLevel.JumpTargets(intPtr2, false).Last(); Logger.Instance.LogTrace("Field::GetValueObjectForThread: 0x{FieldGetValueObjectForThreadAddress}", intPtr3.ToInt64().ToString("X2")); return XrefScannerLowLevel.JumpTargets(intPtr3, false).ElementAt(2); } IntPtr il2CppExport = InjectorHelpers.GetIl2CppExport("il2cpp_field_static_get_value"); Logger.Instance.LogTrace("il2cpp_field_static_get_value: 0x{GetStaticFieldValueApiAddress}", il2CppExport.ToInt64().ToString("X2")); IntPtr intPtr4 = XrefScannerLowLevel.JumpTargets(il2CppExport, false).Single(); Logger.Instance.LogTrace("Field::StaticGetValue: 0x{GetStaticFieldValueAddress}", intPtr4.ToInt64().ToString("X2")); IntPtr intPtr5 = XrefScannerLowLevel.JumpTargets(intPtr4, false).Last(); Logger.Instance.LogTrace("Field::StaticGetValueInternal: 0x{GetStaticFieldValueInternalAddress}", intPtr5.ToInt64().ToString("X2")); IntPtr[] array = XrefScannerLowLevel.JumpTargets(intPtr5, false).ToArray(); if (array.Length == 0) { return FindClassGetFieldDefaultValueXref(forceICallMethod: true); } return (array.Length == 3) ? array.Last() : array.First(); } public override IntPtr FindTargetMethod() { nint num = s_Signatures.Select((MemoryUtils.SignatureDefinition s) => MemoryUtils.FindSignatureInModule(InjectorHelpers.Il2CppModule, s)).FirstOrDefault((nint p) => p != 0); if (num == 0) { Logger.Instance.LogTrace("Couldn't fetch Class::GetDefaultFieldValue with signatures, using method traversal"); num = FindClassGetFieldDefaultValueXref(); } return num; } } internal class GarbageCollector_RunFinalizer_Patch : Hook { [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate void MethodDelegate(IntPtr obj, IntPtr data); private static readonly MemoryUtils.SignatureDefinition[] s_signatures = new MemoryUtils.SignatureDefinition[2] { new MemoryUtils.SignatureDefinition { pattern = "U\u008bìQV\u008bu\bÇE\0\0\0\0\0", mask = "xxxxxxxxxx?????", xref = false }, new MemoryUtils.SignatureDefinition { pattern = "@SH\u0083ì H\u008bÙHÇD$0\0\0\0\0H\u008b", mask = "xxxxxxxxxxxxxxxxxxxx", xref = false } }; public override string TargetMethodName => "GarbageCollector::RunFinalizer"; public override MethodDelegate GetDetour() { return Hook; } private unsafe void Hook(IntPtr obj, IntPtr data) { if (UnityVersionHandler.Wrap((Il2CppClass*)(void*)IL2CPP.il2cpp_object_get_class(obj)).HasFinalize) { base.Original(obj, data); } Il2CppObjectPool.Remove(obj); } public override IntPtr FindTargetMethod() { return s_signatures.Select((MemoryUtils.SignatureDefinition s) => MemoryUtils.FindSignatureInModule(InjectorHelpers.Il2CppModule, s)).FirstOrDefault((nint p) => p != 0); } public override void TargetMethodNotFound() { Il2CppObjectPool.DisableCaching = true; Logger.Instance.LogWarning("{MethodName} not found, disabling Il2CppObjectPool", TargetMethodName); } } internal class GenericMethod_GetMethod_Hook : Hook { [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal unsafe delegate Il2CppMethodInfo* MethodDelegate(Il2CppGenericMethod* gmethod, bool copyMethodPtr); private static readonly MemoryUtils.SignatureDefinition[] s_Signatures = new MemoryUtils.SignatureDefinition[1] { new MemoryUtils.SignatureDefinition { pattern = "H\u0089\\$\bH\u0089l$\u0010VWATAVAWH\u0081ì°\0", mask = "xxxxxxxxxxxxxxxxxxxxxxx", xref = false } }; public override string TargetMethodName => "GenericMethod::GetMethod"; public unsafe override MethodDelegate GetDetour() { return Hook; } private unsafe Il2CppMethodInfo* Hook(Il2CppGenericMethod* gmethod, bool copyMethodPtr) { if (ClassInjector.InflatedMethodFromContextDictionary.TryGetValue((IntPtr)gmethod->methodDefinition, out var value)) { Il2CppGenericInst* method_inst = gmethod->context.method_inst; if (value.Item2.TryGetValue((IntPtr)method_inst, out var value2)) { return (Il2CppMethodInfo*)(void*)value2; } Type[] array = new Type[method_inst->type_argc]; for (int i = 0; i < method_inst->type_argc; i++) { array[i] = ClassInjector.SystemTypeFromIl2CppType(method_inst->type_argv[i]); } MethodInfo methodInfo = value.Item1.MakeGenericMethod(array); Logger.Instance.LogTrace("Inflated method: {InflatedMethod}", methodInfo.Name); value2 = (IntPtr)ClassInjector.ConvertMethodInfo(methodInfo, UnityVersionHandler.Wrap(UnityVersionHandler.Wrap(gmethod->methodDefinition).Class)); value.Item2.Add((IntPtr)method_inst, value2); return (Il2CppMethodInfo*)(void*)value2; } return base.Original(gmethod, copyMethodPtr); } public override IntPtr FindTargetMethod() { IntPtr intPtr = s_Signatures.Select((MemoryUtils.SignatureDefinition s) => MemoryUtils.FindSignatureInModule(InjectorHelpers.Il2CppModule, s)).FirstOrDefault((nint p) => p != 0); if (intPtr == (IntPtr)0) { IntPtr il2CppExport = InjectorHelpers.GetIl2CppExport("il2cpp_object_get_virtual_method"); Logger.Instance.LogTrace("il2cpp_object_get_virtual_method: 0x{GetVirtualMethodApiAddress}", il2CppExport.ToInt64().ToString("X2")); IntPtr intPtr2 = XrefScannerLowLevel.JumpTargets(il2CppExport, false).Single(); Logger.Instance.LogTrace("Object::GetVirtualMethod: 0x{GetVirtualMethodAddress}", intPtr2.ToInt64().ToString("X2")); IntPtr[] array = XrefScannerLowLevel.JumpTargets(intPtr2, false).ToArray(); if (array.Length == 0) { intPtr = XrefScannerLowLevel.JumpTargets(intPtr2, true).Last(); } else if (UnityVersionHandler.HasShimForGetMethod) { IntPtr intPtr3 = array.Last(); IntPtr[] array2 = XrefScannerLowLevel.JumpTargets(intPtr3, false).ToArray(); if (Il2CppInteropRuntime.Instance.UnityVersion.Major == 2020 && array2.Length == 1) { array2 = XrefScannerLowLevel.JumpTargets(intPtr3, true).ToArray(); } intPtr = array2.Take(2).Last(); } else { intPtr = array.Last(); } } return intPtr; } } internal class MetadataCache_GetTypeInfoFromTypeDefinitionIndex_Hook : Hook { [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal unsafe delegate Il2CppClass* MethodDelegate(int index); public override string TargetMethodName => "MetadataCache::GetTypeInfoFromTypeDefinitionIndex"; public unsafe override MethodDelegate GetDetour() { return Hook; } private unsafe Il2CppClass* Hook(int index) { if (InjectorHelpers.s_InjectedClasses.TryGetValue(index, out var value)) { return (Il2CppClass*)(void*)value; } return base.Original(index); } private IntPtr FindGetTypeInfoFromTypeDefinitionIndex(bool forceICallMethod = false) { IntPtr zero = IntPtr.Zero; if (Il2CppInteropRuntime.Instance.UnityVersion < new Version(2018, 3, 0) || forceICallMethod) { IntPtr il2CppMethodPointer = InjectorHelpers.GetIl2CppMethodPointer(typeof(RuntimeHelpers).GetMethod("InitializeArray", new Type[2] { typeof(Array), typeof(IntPtr) })); Logger.Instance.LogTrace("Il2CppSystem.Runtime.CompilerServices.RuntimeHelpers::InitializeArray: 0x{RuntimeHelpersInitializeArrayAddress}", il2CppMethodPointer.ToInt64().ToString("X2")); IntPtr intPtr = XrefScannerLowLevel.JumpTargets(il2CppMethodPointer, false).Last(); if (XrefScannerLowLevel.JumpTargets(intPtr, false).Count() == 1) { Logger.Instance.LogTrace("RuntimeHelpers::thunk_InitializeArray: 0x{RuntimeHelpersInitializeArrayICallAddress}", intPtr.ToInt64().ToString("X2")); intPtr = XrefScannerLowLevel.JumpTargets(intPtr, false).Single(); } Logger.Instance.LogTrace("RuntimeHelpers::InitializeArray: 0x{RuntimeHelpersInitializeArrayICallAddress}", intPtr.ToInt64().ToString("X2")); IntPtr intPtr2 = XrefScannerLowLevel.JumpTargets(intPtr, false).ElementAt(1); Logger.Instance.LogTrace("Type::GetUnderlyingType: 0x{TypeGetUnderlyingTypeAddress}", intPtr2.ToInt64().ToString("X2")); zero = XrefScannerLowLevel.JumpTargets(intPtr2, false).First(); } else { IntPtr il2CppExport = InjectorHelpers.GetIl2CppExport("il2cpp_image_get_class"); Logger.Instance.LogTrace("il2cpp_image_get_class: 0x{ImageGetClassApiAddress}", il2CppExport.ToInt64().ToString("X2")); IntPtr intPtr3 = XrefScannerLowLevel.JumpTargets(il2CppExport, false).Single(); Logger.Instance.LogTrace("Image::GetType: 0x{ImageGetTypeAddress}", intPtr3.ToInt64().ToString("X2")); IntPtr[] array = XrefScannerLowLevel.JumpTargets(intPtr3, false).ToArray(); zero = ((array.Length != 0) ? array[0] : intPtr3); if ((zero.ToInt64() & 0xF) != 0L) { Logger.Instance.LogTrace("Image::GetType xref wasn't aligned, attempting to resolve from icall"); return FindGetTypeInfoFromTypeDefinitionIndex(forceICallMethod: true); } if (array.Count() > 1 && UnityVersionHandler.IsMetadataV29OrHigher) { Logger.Instance.LogTrace($"imageGetTypeXrefs.Length: {array.Length}"); IntPtr intPtr4 = ((array.Length == 2) ? array.Last() : array.First()); Logger.Instance.LogTrace($"getTypeInfoFromHandle: {intPtr4:X2}"); IntPtr[] array2 = XrefScannerLowLevel.JumpTargets(intPtr4, false).ToArray(); if (array2.Length != 1) { zero = intPtr4; Logger.Instance.LogTrace($"Xrefs length was not 1, getTypeInfoFromTypeDefinitionIndex: {zero:X2}"); } else { zero = array2.Single(); while (XrefScannerLowLevel.JumpTargets(zero, false).ToArray().Length == 1) { zero = XrefScannerLowLevel.JumpTargets(zero, false).Single(); } } } } return zero; } public override IntPtr FindTargetMethod() { return FindGetTypeInfoFromTypeDefinitionIndex(); } } } namespace Il2CppInterop.Runtime.Attributes { [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface)] public class AlsoInitializeAttribute : Attribute { public readonly Type LinkedType; public AlsoInitializeAttribute(Type linkedType) { LinkedType = linkedType; } } [AttributeUsage(AttributeTargets.Class)] public class ClassInjectionAssemblyTargetAttribute : Attribute { private readonly string[] assemblies; public ClassInjectionAssemblyTargetAttribute(string assembly) { if (string.IsNullOrWhiteSpace(assembly)) { assemblies = new string[0]; return; } assemblies = new string[1] { assembly }; } public ClassInjectionAssemblyTargetAttribute(string[] assemblies) { if (assemblies == null) { this.assemblies = new string[0]; } else { this.assemblies = assemblies; } } internal IntPtr[] GetImagePointers() { List list = new List(); string[] array = assemblies; for (int i = 0; i < array.Length; i++) { IntPtr il2CppImage = IL2CPP.GetIl2CppImage(array[i]); if (il2CppImage != IntPtr.Zero) { list.Add(il2CppImage); } } return list.ToArray(); } } [AttributeUsage(AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Event)] public class HideFromIl2CppAttribute : Attribute { } [AttributeUsage(AttributeTargets.Class)] public class Il2CppImplementsAttribute : Attribute { public Type[] Interfaces { get; } public Il2CppImplementsAttribute(params Type[] interfaces) { Interfaces = interfaces; } } }