From 9f5eb531b6a5b57826f515797c02866b6342930b Mon Sep 17 00:00:00 2001 From: zombieb Date: Tue, 23 Sep 2025 23:10:24 -0400 Subject: [PATCH] Linux fix w/ config. Might implement properly later. --- Core/Config/Config.cs | 2 ++ Core/Init.cs | 2 ++ Patches/Internals/DeviceIdBuilder.cs | 29 ++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 Patches/Internals/DeviceIdBuilder.cs diff --git a/Core/Config/Config.cs b/Core/Config/Config.cs index b45ccac..df26cb3 100644 --- a/Core/Config/Config.cs +++ b/Core/Config/Config.cs @@ -23,6 +23,7 @@ namespace undead_universal_patch_il2cpp.Core.Config public static ConfigEntry RegistrationPatch; public static ConfigEntry AFKPatch; public static ConfigEntry RefreshTokenFix; + public static ConfigEntry ProtonDeviceIdFix; } public static class PatchConfigDefaults { @@ -33,6 +34,7 @@ namespace undead_universal_patch_il2cpp.Core.Config public static bool RegistrationPatch = false; public static bool AFKPatch = false; public static bool RefreshTokenFix = false; + public static bool ProtonDeviceIdFix = false; } public static class ServerPatchesConfig { diff --git a/Core/Init.cs b/Core/Init.cs index fd21a30..38ccf05 100644 --- a/Core/Init.cs +++ b/Core/Init.cs @@ -95,6 +95,8 @@ public class Initialization PatchConfig.RefreshTokenFix = UniversalPatchPlugin.Instance.Config.Bind("Patches", "RefreshTokenFix", PatchConfigDefaults.RefreshTokenFix, "Fix for the game needlessly requesting a refresh token in a loop. Cause for this issue is unknown." + "\nDon't enable unless you know what this does."); + PatchConfig.ProtonDeviceIdFix = UniversalPatchPlugin.Instance.Config.Bind("Patches", "ProtonDeviceIdFix", PatchConfigDefaults.ProtonDeviceIdFix, + "Fix for device IDs on Wine/Proton. Enable if you get a null reference exception related to cryptography APIs during connect/token."); ServerPatchesConfig.CustomEmotes = UniversalPatchPlugin.Instance.Config.Bind("ServerPatches", "CustomEmotes", ServerPatchesConfigDefaults.CustomEmotes, "Modify the game's emote text with a configuration from the server."); diff --git a/Patches/Internals/DeviceIdBuilder.cs b/Patches/Internals/DeviceIdBuilder.cs new file mode 100644 index 0000000..e835aa7 --- /dev/null +++ b/Patches/Internals/DeviceIdBuilder.cs @@ -0,0 +1,29 @@ +using System.Reflection; +using System.Text; +using HarmonyLib; +using Il2CppInterop.Runtime.InteropTypes.Arrays; +using undead_universal_patch_il2cpp.Core; +using undead_universal_patch_il2cpp.Core.Config; + +namespace undead_universal_patch_il2cpp.Patches.Internals; + +[HarmonyPatch] +public class DeviceIdBuilder +{ + static PatchTypesResult typesResult = Util.ConfigPreparePatchTypes( + PatchConfig.ProtonDeviceIdFix, + "Proton quickfix for device ID errors", + "RecRoom.Utils.DeviceIdBuilder", + "CalculateOtherDeviceId" + ); + + static MethodBase TargetMethod() => typesResult.Method; + static bool Prepare() => typesResult.Success; + + static bool Prefix(ref Il2CppStructArray __result) + { + Util.ConditionalDebug("Device ID patched"); + __result = new Il2CppStructArray(Encoding.UTF8.GetBytes("Wine/Proton")); + return false; + } +} \ No newline at end of file