diff --git a/CannedNet.Client/Patches/PhotonPatches.cs b/CannedNet.Client/Patches/PhotonPatches.cs new file mode 100644 index 0000000..48e61c8 --- /dev/null +++ b/CannedNet.Client/Patches/PhotonPatches.cs @@ -0,0 +1,69 @@ +using System; +using System.Reflection; +using ExitGames.Client.Photon; +using HarmonyLib; +using Photon.Realtime; + +namespace CannedNet.Client.Patches; + +[HarmonyPatch] +public class Photon_AppSettings_Patch +{ + private static bool Prepare() + { + var type = Type.GetType("PUNNetworkManager"); + if (type == null) + { + foreach (var asm in AppDomain.CurrentDomain.GetAssemblies()) + { + type = asm.GetType("PUNNetworkManager"); + if (type != null) break; + } + } + + if (type == null) + { + Plugin.Log.LogError("Could not find PUNNetworkManager type"); + return false; + } + + var method = type.GetMethod("FJOLIPKKIBE", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance); + if (method == null) + { + Plugin.Log.LogError("Could not find FJOLIPKKIBE method"); + return false; + } + + return true; + } + + private static MethodBase TargetMethod() + { + var type = Type.GetType("PUNNetworkManager"); + if (type == null) + { + foreach (var asm in AppDomain.CurrentDomain.GetAssemblies()) + { + type = asm.GetType("PUNNetworkManager"); + if (type != null) break; + } + } + + return type?.GetMethod("FJOLIPKKIBE", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance); + } + + private static void Postfix(ref AppSettings __result) + { + Plugin.Log.LogInfo("okay im patching now"); + __result = new() + { + AppVersion = __result?.AppVersion, + AppIdRealtime = "c74d22b7-6665-41cf-9ce8-fc70b625caa6", + AppIdVoice = "f7adbf03-edae-4a7d-bb4b-9e06de75bd96", + AppIdChat = "4538ca46-903b-48d9-bf33-247ea468a29d", + FixedRegion = "us", + UseNameServer = true, + Protocol = ConnectionProtocol.Udp, + }; + } +} diff --git a/CannedNet.Client/Plugin.cs b/CannedNet.Client/Plugin.cs index 30db0f6..f22e98d 100644 --- a/CannedNet.Client/Plugin.cs +++ b/CannedNet.Client/Plugin.cs @@ -1,4 +1,4 @@ -using BepInEx; +using BepInEx; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using HarmonyLib; @@ -8,13 +8,18 @@ namespace CannedNet.Client; [BepInPlugin("lapis.cannednet.client", "CannedNet Client", "1.0.0")] public class Plugin : BasePlugin { + private const string PhotonDataUrl = "https://ns.lapis.codes/photon"; + internal static new ManualLogSource Log; + public static string appIdRT; + public static string appIdVoice; + public static string appIdChat; + public override void Load() { Log = base.Log; Log.LogInfo($"I JUST HIT THE JACKPOTTTT!!!!! YUH YUH YUH!"); - Harmony.CreateAndPatchAll(typeof(Plugin).Assembly); } -} \ No newline at end of file +}