public static IntPtr CreateNewObject <T>(T value, IL2Type type) where T : unmanaged { IntPtr result = il2cpp_object_new(type.ptr); *(T *)(result + 0x10) = value; return(result); }
public static bool Constructor(Func <IL2Constructor, bool> func, IL2Type il2type, ref IL2Constructor il2constructor) { if (il2constructor == null) { il2constructor = il2type.GetConstructor(func); } return(il2constructor != null); }
public static bool Field(string name, IL2Type il2type, ref IL2Field il2field) { if (il2field == null) { il2field = il2type.GetField(name); } return(il2field != null); }
public static bool Method(string name, IL2Type il2type, ref IL2Method il2method) { if (il2method == null) { il2method = il2type.GetMethod(name); } return(il2method != null); }
public static bool Property(string name, IL2Type il2type, ref IL2Property il2property) { if (il2property == null) { il2property = il2type.GetProperty(name); } return(il2property != null); }
public static bool Constructor(IL2Type il2type, ref IL2Constructor il2constructor) { if (il2constructor == null) { il2constructor = il2type.GetConstructors()[0]; } return(il2constructor != null); }
public static IntPtr ArrayToIntPtr(this IntPtr[] array, IL2Type typeobject = null) { if (typeobject == null) { typeobject = BlazeTools.IL2SystemClass.Object; } int length = array.Length; IntPtr result = IL2Import.il2cpp_array_new(typeobject.ptr, length); for (int i = 0; i < length; i++) { *(IntPtr *)((IntPtr)((long *)result + 4) + i * IntPtr.Size) = array[i]; } return(result); }
internal static IL2TypeObject IL2Typeof(IL2Type klass) { IntPtr ptr = IL2Import.il2cpp_class_get_type(klass.ptr); if (ptr == IntPtr.Zero) { return(null); } IntPtr result = IL2Import.il2cpp_type_get_object(ptr); if (ptr == IntPtr.Zero) { return(null); } return(result.MonoCast <IL2TypeObject>()); }
public static IL2Type GetClass(IntPtr findPtr) { if (findPtr == IntPtr.Zero) { return(null); } IL2Type returnval = null; foreach (IL2Assembly asm in GetAssemblies()) { returnval = asm.GetClass(findPtr); if (returnval != null) { break; } } return(returnval); }
public static IL2Type GetClass(string fullname) { if (string.IsNullOrEmpty(fullname)) { return(null); } string name = string.Empty; string name_space = string.Empty; int idx = fullname.LastIndexOf('.'); if (idx != -1) { name_space = fullname.Substring(0, idx); name = fullname.Substring(idx + 1); } else { name = fullname; } IL2Type returnval = null; foreach (IL2Assembly asm in GetAssemblies()) { if (idx != -1) { returnval = asm.GetClass(name, name_space); } else { returnval = asm.GetClass(name); } if (returnval != null) { break; } } return(returnval); }
public unsafe static IntPtr CreateDelegate <T>(Delegate function, T instance, IL2Type klass = null) { if (klass == null) { klass = Instance_Class; } var obj = IL2Import.il2cpp_object_new(klass.ptr); if (instance == null || (typeof(T) == typeof(IntPtr) && (IntPtr)(object)instance == IntPtr.Zero)) { var runtimeStaticMethod = Marshal.AllocHGlobal(8); *(IntPtr *)runtimeStaticMethod = function.Method.MethodHandle.GetFunctionPointer(); *((IntPtr *)obj + 2) = function.Method.MethodHandle.GetFunctionPointer(); *((IntPtr *)obj + 4) = IntPtr.Zero; *((IntPtr *)obj + 5) = runtimeStaticMethod; return(obj); } IL2Method ctor = klass.GetMethod(".ctor"); GCHandle handle1 = GCHandle.Alloc(instance); var runtimeMethod = Marshal.AllocHGlobal(80); //methodPtr *((IntPtr *)runtimeMethod) = function.Method.MethodHandle.GetFunctionPointer(); byte paramCount = (byte)(function.Method.GetParameters()?.Length ?? 0); //Parameter count *((byte *)runtimeMethod + 75) = 0; // 0 parameter_count //Slot (65535) *((byte *)runtimeMethod + 74) = 0xFF; *((byte *)runtimeMethod + 73) = 0xFF; *((IntPtr *)obj + 2) = function.Method.MethodHandle.GetFunctionPointer(); *((IntPtr *)obj + 4) = obj; *((IntPtr *)obj + 5) = runtimeMethod; *((IntPtr *)obj + 7) = GCHandle.ToIntPtr(handle1); return(obj); }