using MelonLoader; using UnityEngine; using HarmonyLib; using UnityEngine.Networking; using System; using System.Threading.Tasks; using System.Collections.Generic; using System.Linq; using System.Text; using System.Net.Sockets; using UnityEngine.Analytics; using UnityEngine.SceneManagement; using Il2CppConcertXR; namespace TestMod{ [HarmonyPatch(typeof(SceneManager))] [HarmonyPatch("LoadScene", new Type[] { typeof(string) })] class PatchSceneManagerLoadScene { static void Prefix(string sceneName) { Debug.Log($"Loading scene: {sceneName}"); } } /* [HarmonyPatch(typeof(Analytics))] [HarmonyPatch("CustomEvent", new Type[] { typeof(string), typeof(object) })] class PatchAnalyticsCustomEvent { static void Prefix(string eventName, object eventData) { Debug.Log($"Analytics event: {eventName}, Data: {eventData}"); } }*/ [HarmonyPatch(typeof(Input))] [HarmonyPatch("GetKeyDown", new Type[] { typeof(KeyCode) })] public class InputGetKeyDownPatch { [HarmonyPrefix] static void Prefix(KeyCode key) { MelonLogger.Msg($"Key Down Detected: {key}"); } } /* [HarmonyPatch(typeof(System.Net.Dns))] [HarmonyPatch("GetHostAddresses")] public class DnsGetHostAddressesPatch { [HarmonyPrefix] static void Prefix(string hostNameOrAddress) { MelonLogger.Msg($"Resolving domain name to IP addresses: {hostNameOrAddress}"); } }*/ [HarmonyPatch(typeof(System.Net.Sockets.Socket))] [HarmonyPatch("Send", new Type[] { typeof(byte[]), typeof(int), typeof(int), typeof(System.Net.Sockets.SocketFlags) })] public class SocketSendPatch { [HarmonyPrefix] static void Prefix(byte[] buffer, int offset, int size, System.Net.Sockets.SocketFlags socketFlags) { // Convert the first few bytes of the buffer to a readable format (e.g., for logging) string dataPreview = BitConverter.ToString(buffer, offset, Math.Min(size, 16)); MelonLogger.Msg($"Socket sending data (first 16 bytes): {dataPreview} with flags {socketFlags}"); } } [HarmonyPatch(typeof(System.Net.HttpWebRequest))] [HarmonyPatch("GetResponse")] public class HttpWebRequestGetResponsePatch { [HarmonyPrefix] static void Prefix(System.Net.HttpWebRequest __instance) { // Log the request URL and method MelonLogger.Msg($"Getting response for HTTP request to {__instance.RequestUri} with method {__instance.Method}"); } } /* [HarmonyPatch(typeof(JsonUtility))] public class JsonPatches { // Patching the non-generic wrapper of FromJson [HarmonyPatch("FromJson", new[] { typeof(string), typeof(System.Type) })] [HarmonyPrefix] public static bool FromJsonPrefix(string json, System.Type type) { MelonLogger.Msg($"Deserializing JSON to {type.Name}: {json}"); // Return true to continue with the original method return true; } // Patching the ToJson method [HarmonyPatch("ToJson", new[] { typeof(object), typeof(bool) })] [HarmonyPrefix] public static bool ToJsonPrefix(object obj, bool prettyPrint) { string jsonRepresentation = JsonUtility.ToJson(obj, prettyPrint); MelonLogger.Msg($"Serializing object of type {obj.GetType().Name} to JSON: {jsonRepresentation}"); // Return true to continue with the original method return true; } } */ [HarmonyPatch(typeof(AppLauncher))] public class AppLauncherPatches { [HarmonyPatch("Start"), HarmonyPostfix] public static void StartPostfix() { MelonLogger.Msg("Start method called in AppLauncher"); } [HarmonyPatch("StopShowingSlidingScreen"), HarmonyPostfix] public static void StopShowingSlidingScreenPostfix() { MelonLogger.Msg("StopShowingSlidingScreen method called in AppLauncher"); } } [HarmonyPatch(typeof(DownloadHandler))] [HarmonyPatch("ReceiveData")] public class DownloadHandlerReceiveDataPatch { [HarmonyPrefix] static void Prefix(DownloadHandler __instance) { // Log the data received (be mindful of logging sensitive data) byte[] data = __instance.data; MelonLogger.Msg("Received data of length: " + data.Length); } } [HarmonyPatch(typeof(WWW))] [HarmonyPatch("get_text")] // Assuming get_text is used immediately after the WWW object is created public class WWWGetTextPatch { static void Prefix(WWW __instance) { // Log the URL and other data at the point of use MelonLogger.Msg($"WWW request to {__instance.url}"); // Add more logging as needed } } [HarmonyPatch(typeof(UnityWebRequest))] [HarmonyPatch("SendWebRequest")] // Target the SendWebRequest method of UnityWebRequest public class UnityWebRequestPatch { static void Prefix(UnityWebRequest __instance) { // This is a prefix patch, which means it runs before the method it's patching. // Log the request details MelonLogger.Msg($"Sending request to {__instance.url}"); if (__instance.uploadHandler != null) { MelonLogger.Msg($"Data being sent: {__instance.uploadHandler.data}"); } // Add more logging or manipulation as needed } } /* [HarmonyPatch(typeof(System.Net.ServicePointManager))] [HarmonyPatch("ServerCertificateValidationCallback")] public class ServicePointManagerPatch { [HarmonyPostfix] static void Postfix(ref System.Net.Security.RemoteCertificateValidationCallback __result) { // Store the original validation callback var originalCallback = __result; // Define a new callback that wraps the original one System.Net.Security.RemoteCertificateValidationCallback newCallback = (sender, certificate, chain, sslPolicyErrors) => { MelonLogger.Msg("Inspecting SSL/TLS certificate"); // Add your inspection logic here // Call the original callback return originalCallback(sender, certificate, chain, sslPolicyErrors); }; // Replace the callback with the new one __result = newCallback; } } */ public static class BuildInfo { public const string Name = "TestMod"; // Name of the Mod. (MUST BE SET) public const string Description = "Mod for Testing"; // Description for the Mod. (Set as null if none) public const string Author = "TestAuthor"; // Author of the Mod. (MUST BE SET) public const string Company = null; // Company that made the Mod. (Set as null if none) public const string Version = "1.0.0"; // Version of the Mod. (MUST BE SET) public const string DownloadLink = null; // Download Link for the Mod. (Set as null if none) } public class TestMod : MelonMod { public override void OnInitializeMelon() { MelonLogger.Msg("OnApplicationStart"); var harmony = new HarmonyLib.Harmony("com.yourname.modname"); harmony.PatchAll(); // This applies all [HarmonyPatch] attributed classes/methods MelonLogger.Msg("Patches applied!"); } public override void OnLateInitializeMelon() // Runs after OnApplicationStart. { MelonLogger.Msg("OnApplicationLateStart"); } public override void OnSceneWasLoaded(int buildindex, string sceneName) // Runs when a Scene has Loaded and is passed the Scene's Build Index and Name. { MelonLogger.Msg("OnSceneWasLoaded: " + buildindex.ToString() + " | " + sceneName); } public override void OnSceneWasInitialized(int buildindex, string sceneName) // Runs when a Scene has Initialized and is passed the Scene's Build Index and Name. { MelonLogger.Msg("OnSceneWasInitialized: " + buildindex.ToString() + " | " + sceneName); } public override void OnSceneWasUnloaded(int buildIndex, string sceneName) { MelonLogger.Msg("OnSceneWasUnloaded: " + buildIndex.ToString() + " | " + sceneName); } public override void OnApplicationQuit() // Runs when the Game is told to Close. { MelonLogger.Msg("OnApplicationQuit"); } public override void OnPreferencesSaved() // Runs when Melon Preferences get saved. { MelonLogger.Msg("OnPreferencesSaved"); } public override void OnPreferencesLoaded() // Runs when Melon Preferences get loaded. { MelonLogger.Msg("OnPreferencesLoaded"); } } }