public static AssetBundle LoadFromFile(string path) { var iCall = ICallManager.GetICall <d_LoadFromFile>("UnityEngine.AssetBundle::LoadFromFile_Internal"); var ptr = iCall.Invoke(IL2CPP.ManagedStringToIl2Cpp(path), 0u, 0UL); return(new AssetBundle(ptr)); }
private unsafe static IntPtr OurGetInputString() { string input = IL2CPP.Il2CppStringToManaged(originalInputStringGetter()); IntPtr vr_input = IL2CPP.ManagedStringToIl2Cpp(VRKeyboard.GetKeyboardInput() + input); return(vr_input); }
public static Font CreateDynamicFontFromOSFont(string fontname, int size) { if (string.IsNullOrEmpty(fontname)) { throw new System.ArgumentNullException(nameof(fontname), "The path cannot be null or empty."); } IntPtr ptr = CreateDynamicFontFromOSFont_InternalDelegateField(IL2CPP.ManagedStringToIl2Cpp(fontname), size); return(ptr != IntPtr.Zero ? new Font(ptr) : null); }
public UnityEngine.Object[] LoadAllAssets() { var ptr = i_LoadAssetWithSubAssets_Internal.Invoke(Pointer, IL2CPP.ManagedStringToIl2Cpp(string.Empty), Il2CppType.Of <UnityEngine.Object>().Pointer); if (ptr == IntPtr.Zero) { return(new UnityEngine.Object[0]); } return(new Il2CppReferenceArray <UnityEngine.Object>(ptr)); }
public static AssetBundleProxy LoadFromFile(string path, uint crc, ulong offset) { if (string.IsNullOrEmpty(path)) { throw new System.ArgumentException(nameof(path), "The path cannot be null or empty."); } IntPtr ptr = LoadFromFile_InternalDelegateField(IL2CPP.ManagedStringToIl2Cpp(path), crc, offset); return(ptr != IntPtr.Zero ? new AssetBundleProxy(ptr) : null); }
public T LoadAsset <T>(string name) where T : UnityEngine.Object { var iCall = ICallHelper.GetICall <d_LoadAsset_Internal>("UnityEngine.AssetBundle::LoadAsset_Internal"); var ptr = iCall.Invoke(m_bundlePtr, IL2CPP.ManagedStringToIl2Cpp(name), Il2CppType.Of <T>().Pointer); if (ptr == IntPtr.Zero) { return(null); } return(new UnityEngine.Object(ptr).TryCast <T>()); }
public UnityEngine.Object[] LoadAllAssets() { var iCall = ICallHelper.GetICall <d_LoadAssetWithSubAssets_Internal>("UnityEngine.AssetBundle::LoadAssetWithSubAssets_Internal"); var ptr = iCall.Invoke(m_bundlePtr, IL2CPP.ManagedStringToIl2Cpp(""), Il2CppType.Of <UnityEngine.Object>().Pointer); if (ptr == IntPtr.Zero) { return(new UnityEngine.Object[0]); } return(new Il2CppReferenceArray <UnityEngine.Object>(ptr)); }
public static AssetBundleCreateRequest LoadFromFileAsync(string path, uint crc, ulong offset) { if (string.IsNullOrEmpty(path)) { throw new System.ArgumentException("The input asset bundle path cannot be null or empty."); } if (LoadFromFileAsync_InternalDelegateField == null) { throw new System.NullReferenceException("The LoadFromFileAsync_InternalDelegateField cannot be null."); } System.IntPtr intPtr = LoadFromFileAsync_InternalDelegateField(IL2CPP.ManagedStringToIl2Cpp(path), crc, offset); return((intPtr != System.IntPtr.Zero) ? new AssetBundleCreateRequest(intPtr) : null); }
public IntPtr LoadAssetWithSubAssets(string name, IntPtr typePointer) { if (_instancePointer == IntPtr.Zero) { throw new NullReferenceException(); } if (typePointer == IntPtr.Zero) { throw new ArgumentNullException(nameof(typePointer)); } return(LoadAssetWithSubAssets_InternalDelegateField(_instancePointer, IL2CPP.ManagedStringToIl2Cpp(name), typePointer)); }
private IntPtr GetString(IntPtr keyPtr, IntPtr defaultValuePtr) { var key = IL2CPP.Il2CppStringToManaged(keyPtr); if (myPrefs.TryGetValue(key, out var result)) { if (result is string resultString) { return(IL2CPP.ManagedStringToIl2Cpp(resultString)); } } return(defaultValuePtr); }
public bool Contains(string name) { if (bundleptr == System.IntPtr.Zero) { throw new System.NullReferenceException("The bundleptr cannot be IntPtr.Zero"); } if (string.IsNullOrEmpty(name)) { throw new System.ArgumentException("The input asset name cannot be null or empty."); } if (ContainsDelegateField == null) { throw new System.NullReferenceException("The ContainsDelegateField cannot be null."); } return(ContainsDelegateField(bundleptr, IL2CPP.ManagedStringToIl2Cpp(name))); }
public System.IntPtr LoadAssetWithSubAssetsAsync(string name, System.IntPtr typeptr) { if (bundleptr == System.IntPtr.Zero) { throw new System.NullReferenceException("The bundleptr cannot be IntPtr.Zero"); } if (string.IsNullOrEmpty(name)) { throw new System.ArgumentException("The input asset name cannot be null or empty."); } if (typeptr == System.IntPtr.Zero) { throw new System.NullReferenceException("The input type cannot be IntPtr.Zero"); } if (LoadAssetWithSubAssetsAsync_InternalDelegateField == null) { throw new System.NullReferenceException("The LoadAssetWithSubAssetsAsync_InternalDelegateField cannot be null."); } return(LoadAssetWithSubAssetsAsync_InternalDelegateField(bundleptr, IL2CPP.ManagedStringToIl2Cpp(name), typeptr)); }
public override unsafe void OnApplicationStart() { try { var settingsCategory = "HWIDPatch"; MelonPrefs.RegisterCategory(settingsCategory, "HWID Patch"); MelonPrefs.RegisterString(settingsCategory, "HWID", "", hideFromList: true); var newId = MelonPrefs.GetString(settingsCategory, "HWID"); if (newId.Length != SystemInfo.deviceUniqueIdentifier.Length) { var random = new System.Random(Environment.TickCount); var bytes = new byte[SystemInfo.deviceUniqueIdentifier.Length / 2]; random.NextBytes(bytes); newId = string.Join("", bytes.Select(it => it.ToString("x2"))); MelonPrefs.SetString(settingsCategory, "HWID", newId); } ourGeneratedHwidString = new Il2CppSystem.Object(IL2CPP.ManagedStringToIl2Cpp(newId)); var icallName = "UnityEngine.SystemInfo::GetDeviceUniqueIdentifier"; var icallAddress = IL2CPP.il2cpp_resolve_icall(icallName); if (icallAddress == IntPtr.Zero) { MelonLogger.LogError("Can't resolve the icall, not patching"); return; } CompatHook((IntPtr)(&icallAddress), typeof(HWIDPatchMod).GetMethod(nameof(GetDeviceIdPatch), BindingFlags.Static | BindingFlags.NonPublic) !.MethodHandle.GetFunctionPointer()); MelonLogger.Log("Patched HWID; below two should match:"); MelonLogger.Log($"Current: {SystemInfo.deviceUniqueIdentifier}"); MelonLogger.Log($"Target: {newId}"); } catch (Exception ex) { MelonLogger.LogError(ex.ToString()); } }
public Value(Type type, JValue value) { IsNone = value == null; @bool = default; @byte = default; @sbyte = default; @short = default; @ushort = default; @int = default; @uint = default; @long = default; @ulong = default; @char = default; @double = default; @float = default; @string = IL2CPP.ManagedStringToIl2Cpp(""); if (type == typeof(string)) { tag = ValueType.String; if (value == null) { return; } // FIXME: // The purpose of intern is to prevent GC from freeing our string to avoid UAF. // But intern will run into some performance problems sometimes. // Maybe making a reference circle is another solution. @string = Il2CppHelper.il2cpp_string_intern( IL2CPP.ManagedStringToIl2Cpp(value.Value <string>())); } else if (type == typeof(bool)) { tag = ValueType.Boolean; if (value == null) { return; } @bool = value.Value <bool>(); } else if (type == typeof(byte)) { tag = ValueType.Byte; if (value == null) { return; } @byte = value.Value <byte>(); } else if (type == typeof(sbyte)) { tag = ValueType.SByte; if (value == null) { return; } @sbyte = value.Value <sbyte>(); } else if (type == typeof(short)) { tag = ValueType.Int16; if (value == null) { return; } @short = value.Value <short>(); } else if (type == typeof(ushort)) { tag = ValueType.UInt16; if (value == null) { return; } @ushort = value.Value <ushort>(); } else if (type == typeof(int)) { tag = ValueType.Int32; if (value == null) { return; } @int = value.Value <int>(); } else if (type == typeof(uint)) { tag = ValueType.UInt32; if (value == null) { return; } @uint = value.Value <uint>(); } else if (type == typeof(long)) { tag = ValueType.Int64; if (value == null) { return; } @long = value.Value <long>(); } else if (type == typeof(ulong)) { tag = ValueType.UInt64; if (value == null) { return; } @ulong = value.Value <ulong>(); } else if (type == typeof(char)) { tag = ValueType.Char; if (value == null) { return; } @char = value.Value <char>(); } else if (type == typeof(double)) { tag = ValueType.Double; if (value == null) { return; } @double = value.Value <double>(); } else if (type == typeof(float)) { tag = ValueType.Single; if (value == null) { return; } @float = value.Value <float>(); } else { throw new NotSupportedException($"Type {type} is not supported"); } }
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); }
public static AssetBundle LoadFromFile(string path, uint crc = 0, ulong offset = 0) { return(new AssetBundle(i_LoadFromFile.Invoke(IL2CPP.ManagedStringToIl2Cpp(path), crc, offset))); }
public static void SetKey(UILocalize localize, string value) { il2cpp_gc_wbarrier_set_field(localize.Pointer, KeyAddr(localize), IL2CPP.ManagedStringToIl2Cpp(value)); }
public T LoadAsset <T>(string name) where T : UnityEngine.Object { var ptr = i_LoadAsset_Internal.Invoke(Pointer, IL2CPP.ManagedStringToIl2Cpp(name), Il2CppType.Of <T>().Pointer); return(ptr == IntPtr.Zero ? null : new UnityEngine.Object(ptr).TryCast <T>()); }
public unsafe void Set(TOwner owner, string value) => *(IntPtr *)GetPointer(owner.Pointer) = IL2CPP.ManagedStringToIl2Cpp(value);