internal static void Create() { Main.obj = new GameObject("MelonLoader"); DontDestroyOnLoad(Main.obj); Main.comp = Main.obj.AddComponent <MelonLoaderComponent>(); Main.SetAsLastSiblingDelegateField(IL2CPP.Il2CppObjectBaseToPtrNotNull(Main.obj.transform)); Main.SetAsLastSiblingDelegateField(IL2CPP.Il2CppObjectBaseToPtrNotNull(Main.comp.transform)); }
internal static void Create() { Main.obj = new GameObject(); DontDestroyOnLoad(Main.obj); Main.comp = new MelonLoaderComponent(Main.obj.AddComponent(UnhollowerRuntimeLib.Il2CppType.Of <MelonLoaderComponent>()).Pointer); Main.SetAsLastSiblingDelegateField(IL2CPP.Il2CppObjectBaseToPtrNotNull(Main.obj.transform)); Main.SetAsLastSiblingDelegateField(IL2CPP.Il2CppObjectBaseToPtrNotNull(Main.comp.transform)); }
private void SiblingFix() { #if SM_Il2Cpp SetAsLastSiblingDelegateField(IL2CPP.Il2CppObjectBaseToPtrNotNull(gameObject.transform)); SetAsLastSiblingDelegateField(IL2CPP.Il2CppObjectBaseToPtrNotNull(transform)); #else SetAsLastSiblingMethod?.Invoke(gameObject.transform, new object[0]); SetAsLastSiblingMethod?.Invoke(transform, new object[0]); #endif }
public static AssetBundleCreateRequest LoadFromMemoryAsync(Il2CppStructArray <byte> binary, uint crc) { if (binary == null) { throw new System.ArgumentException("The binary cannot be null or empty."); } if (LoadFromMemoryAsync_InternalDelegateField == null) { throw new System.NullReferenceException("The LoadFromMemoryAsync_InternalDelegateField cannot be null."); } System.IntPtr intPtr = LoadFromMemoryAsync_InternalDelegateField(IL2CPP.Il2CppObjectBaseToPtrNotNull(binary), crc); return((intPtr != System.IntPtr.Zero) ? new AssetBundleCreateRequest(intPtr) : null); }
public static AssetBundleCreateRequest LoadFromStreamAsync(Stream stream, uint crc, uint managedReadBufferSize) { if (stream == null) { throw new System.ArgumentException("The stream cannot be null or empty."); } if (LoadFromStreamAsyncInternalDelegateField == null) { throw new System.NullReferenceException("The LoadFromStreamAsyncInternalDelegateField cannot be null."); } System.IntPtr intPtr = LoadFromStreamAsyncInternalDelegateField(IL2CPP.Il2CppObjectBaseToPtrNotNull(stream), crc, managedReadBufferSize); return((intPtr != System.IntPtr.Zero) ? new AssetBundleCreateRequest(intPtr) : null); }
public static Il2CppAssetBundle[] GetAllLoadedAssetBundles() { if (GetAllLoadedAssetBundles_NativeDelegateField == null) { throw new System.NullReferenceException("The GetAllLoadedAssetBundles_NativeDelegateField cannot be null."); } System.IntPtr intPtr = GetAllLoadedAssetBundles_NativeDelegateField(); Il2CppReferenceArray <Object> refarr = ((intPtr != System.IntPtr.Zero) ? new Il2CppReferenceArray <Object>(intPtr) : null); if (refarr == null) { throw new System.NullReferenceException("The refarr cannot be null."); } System.Collections.Generic.List <Il2CppAssetBundle> bundlelist = new System.Collections.Generic.List <Il2CppAssetBundle>(); for (int i = 0; i < refarr.Length; i++) { bundlelist.Add(new Il2CppAssetBundle(IL2CPP.Il2CppObjectBaseToPtrNotNull(refarr[i]))); } return(bundlelist.ToArray()); }
public void ApplyTo(ConfBaseItem item) { if (!record.ItemType.IsInstanceOfType(item)) { throw new ArgumentException("Unexcepted instance", nameof(item)); } foreach (var(ofs, value) in values.Zip(record.FieldsInfo, (v, info) => (info.Item2, v))) { if (value.IsNone) { continue; } var ptr = IL2CPP.Il2CppObjectBaseToPtrNotNull(item) + ofs; unsafe { value.Switch( string1 => *(IntPtr *)ptr = string1, bool1 => *(bool *)ptr = bool1, byte1 => *(byte *)ptr = byte1, sbyte1 => *(sbyte *)ptr = sbyte1, short1 => *(short *)ptr = short1, ushort1 => *(ushort *)ptr = ushort1, int1 => *(int *)ptr = int1, uint1 => *(uint *)ptr = uint1, long1 => *(long *)ptr = long1, ulong1 => *(ulong *)ptr = ulong1, char1 => *(char *)ptr = char1, double1 => *(double *)ptr = double1, float1 => *(float *)ptr = float1, intArray => *(IntPtr *)ptr = intArray.Pointer, stringArray => *(IntPtr *)ptr = stringArray.Pointer, float2D => *(IntPtr *)ptr = float2D.Pointer, int2D => *(IntPtr *)ptr = int2D.Pointer, string2D => *(IntPtr *)ptr = string2D.Pointer ); } } }
public ConfBaseItem Construct() { var o = IL2CPP.il2cpp_object_new(record.NativeItemClassPtr); var obj = (ConfBaseItem)record.ItemType .GetConstructor(new[] { typeof(IntPtr) })? .Invoke(new object[] { o }); var paramLen = values.Length + 1; unsafe { var args = stackalloc IntPtr[paramLen]; var id = Id; args[0] = (IntPtr)(&id); fixed(Value *arr = values) { for (var i = 1; i < paramLen; i++) { var j = i - 1; var v = &arr[j]; if (v->IsNone) { Logger.Warn($"Required field({record.FieldsInfo[j].Item1}) does not exsit in item(id: {Id}, @ {Source}), set to default."); } // FIXME: Is it REALLY safe? args[i] = v->Ptr(); } var exc = IntPtr.Zero; IL2CPP.il2cpp_runtime_invoke(record.ItemCtor.Item2, IL2CPP.Il2CppObjectBaseToPtrNotNull(obj), (void **)args, ref exc); Il2CppException.RaiseExceptionIfNecessary(exc); } } return(obj); }
internal static void Create() { //MelonLogger.Log("create in"); Main.obj = new GameObject(); //MelonLogger.Log("new GameObject()"); DontDestroyOnLoad(Main.obj); //MelonLogger.Log("DontDestroyOnLoad"); var tp = UnhollowerRuntimeLib.Il2CppType.Of <MelonLoaderComponent>(); //MelonLogger.Log("UnhollowerRuntimeLib.Il2CppType.Of<MelonLoaderComponent>"); //MelonLogger.Log("start"); var compo = Main.obj.AddComponent(tp); //MelonLogger.Log("AddComponent"); var ptr = compo.Pointer; //MelonLogger.Log("ptr: 0x" + ptr.ToString("x2")); Main.comp = new MelonLoaderComponent(ptr); //MelonLogger.Log("new MelonLoaderComponent"); Main.SetAsLastSiblingDelegateField(IL2CPP.Il2CppObjectBaseToPtrNotNull(Main.obj.transform)); //MelonLogger.Log("Main.SetAsLastSiblingDelegateField 1"); Main.SetAsLastSiblingDelegateField(IL2CPP.Il2CppObjectBaseToPtrNotNull(Main.comp.transform)); //MelonLogger.Log("Main.SetAsLastSiblingDelegateField 2"); }
private static IntPtr KeyAddr(UILocalize localize) { ulong ptr = (ulong)IL2CPP.Il2CppObjectBaseToPtrNotNull(localize) + IL2CPP.il2cpp_field_get_offset((IntPtr)AccessTools.Field(typeof(UILocalize), "NativeFieldInfoPtr_key").GetValue(null)); return((IntPtr)ptr); }
public static Object ResourcesLoad(string path, Il2CppSystem.Type systemTypeInstance) { var ptr = _load(IL2CPP.ManagedStringToIl2Cpp(path), IL2CPP.Il2CppObjectBaseToPtrNotNull(systemTypeInstance)); return(ptr != IntPtr.Zero ? new Object(ptr) : null); }
private T *GetPointerToData() => (T *)(IL2CPP.Il2CppObjectBaseToPtrNotNull(_obj) + (int)IL2CPP.il2cpp_field_get_offset(_fieldPtr));
static IntPtr getFieldAddress(Il2CppObjectBase obj, string fieldName) => IL2CPP.Il2CppObjectBaseToPtrNotNull(obj) + (int)IL2CPP.il2cpp_field_get_offset((IntPtr)obj.GetType().field("NativeFieldInfoPtr_" + fieldName).GetValue(null));