internal static void onLoad() { domain = IL2Import.il2cpp_domain_get(); uint count = 0; IntPtr assemblies = IL2Import.il2cpp_domain_get_assemblies(domain, ref count); IntPtr[] assembliesarr = IL2Tools.IntPtrToStructureArray <IntPtr>(assemblies, count); foreach (IntPtr assembly in assembliesarr) { if (assembly != IntPtr.Zero) { listAssemblies.Add(new IL2Assembly(IL2Import.il2cpp_assembly_get_image(assembly))); } } }
unsafe private static T Unbox <T>(this IntPtr ptr) where T : unmanaged => *(T *)IL2Import.il2cpp_object_unbox(ptr).ToPointer();
public static T MonoCast <T>(this IntPtr ptr) { #region MonoCast [IntPtr to Object] if (typeof(T) == typeof(string)) { return((T)(object)IL2Import.IntPtrToString(ptr)); } else if (BlazeTools.Types.unmanagedTypes.Contains(typeof(T))) { unsafe { // SByte if (typeof(T) == typeof(sbyte)) { return((T)(object)ptr.Unbox <sbyte>()); } // Byte if (typeof(T) == typeof(byte)) { return((T)(object)ptr.Unbox <byte>()); } // Short if (typeof(T) == typeof(short)) { return((T)(object)ptr.Unbox <short>()); } // UShort if (typeof(T) == typeof(ushort)) { return((T)(object)ptr.Unbox <ushort>()); } // Int if (typeof(T) == typeof(int)) { return((T)(object)ptr.Unbox <int>()); } // UInt if (typeof(T) == typeof(uint)) { return((T)(object)ptr.Unbox <uint>()); } // Long if (typeof(T) == typeof(long)) { return((T)(object)ptr.Unbox <long>()); } // ULong if (typeof(T) == typeof(ulong)) { return((T)(object)ptr.Unbox <ulong>()); } // Char if (typeof(T) == typeof(char)) { return((T)(object)ptr.Unbox <char>()); } // Float if (typeof(T) == typeof(float)) { return((T)(object)ptr.Unbox <float>()); } // Double if (typeof(T) == typeof(double)) { return((T)(object)ptr.Unbox <double>()); } // Decimal if (typeof(T) == typeof(decimal)) { return((T)(object)ptr.Unbox <decimal>()); } // Bool if (typeof(T) == typeof(bool)) { return((T)(object)ptr.Unbox <bool>()); } } } else if (BlazeTools.Types.otherUnmanagedTypes.Contains(typeof(T))) { unsafe { // UnityEngine.Color if (typeof(T) == typeof(UnityEngine.Color)) { return((T)(object)ptr.Unbox <UnityEngine.Color>()); } // UnityEngine.Mathf if (typeof(T) == typeof(UnityEngine.Mathf)) { return((T)(object)ptr.Unbox <UnityEngine.Mathf>()); } // UnityEngine.Quaternion if (typeof(T) == typeof(UnityEngine.Quaternion)) { return((T)(object)ptr.Unbox <UnityEngine.Quaternion>()); } // UnityEngine.Ray if (typeof(T) == typeof(UnityEngine.Ray)) { return((T)(object)ptr.Unbox <UnityEngine.Ray>()); } // UnityEngine.RaycastHit if (typeof(T) == typeof(UnityEngine.RaycastHit)) { return((T)(object)ptr.Unbox <UnityEngine.RaycastHit>()); } // UnityEngine.Rect if (typeof(T) == typeof(UnityEngine.Rect)) { return((T)(object)ptr.Unbox <UnityEngine.Rect>()); } // UnityEngine.Vector2 if (typeof(T) == typeof(UnityEngine.Vector2)) { return((T)(object)ptr.Unbox <UnityEngine.Vector2>()); } // UnityEngine.Vector3 if (typeof(T) == typeof(UnityEngine.Vector3)) { return((T)(object)ptr.Unbox <UnityEngine.Vector3>()); } // UnityEngine.Vector4 if (typeof(T) == typeof(UnityEngine.Vector4)) { return((T)(object)ptr.Unbox <UnityEngine.Vector4>()); } } } else if (typeof(T).IsEnum) { return((T)(object)ptr.Unbox <int>()); } InvocationDelegate fastInvoke = GetMethodInvoker(typeof(T).GetConstructors().First(x => x.GetParameters().Length == 1)); return((T)fastInvoke(null, new object[] { ptr })); #endregion }