From 1a75436303fbd85fc3cefedd501de7fad8ca26ab Mon Sep 17 00:00:00 2001 From: xiaoxin <2932869213@qq.com> Date: Mon, 13 Oct 2025 18:19:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6=E8=87=B3?= =?UTF-8?q?=20Fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Fix/DisableEncryption.cs | 89 +++++++++++++++++++++++++++++ Fix/DisableEnvironmentCheck.cs | 41 +++++++++++++ Fix/DisableIniClear.cs | 14 +++++ Fix/DisableReboot.cs | 77 +++++++++++++++++++++++++ Fix/FixCheckAuth.cs | 20 +++++++ Fix/FixDebugInput.cs | 79 +++++++++++++++++++++++++ Fix/ForceAsServer.cs | 23 ++++++++ Fix/RestoreCertificateValidation.cs | 16 ++++++ Fix/RewriteNoteJudgeTiming.cs | 21 +++++++ Fix/SkipCakeHashCheck.cs | 19 ++++++ Fix/SkipSpecialNumCheck.cs | 22 +++++++ Fix/SkipVersionCheck.cs | 30 ++++++++++ 12 files changed, 451 insertions(+) create mode 100644 Fix/DisableEncryption.cs create mode 100644 Fix/DisableEnvironmentCheck.cs create mode 100644 Fix/DisableIniClear.cs create mode 100644 Fix/DisableReboot.cs create mode 100644 Fix/FixCheckAuth.cs create mode 100644 Fix/FixDebugInput.cs create mode 100644 Fix/ForceAsServer.cs create mode 100644 Fix/RestoreCertificateValidation.cs create mode 100644 Fix/RewriteNoteJudgeTiming.cs create mode 100644 Fix/SkipCakeHashCheck.cs create mode 100644 Fix/SkipSpecialNumCheck.cs create mode 100644 Fix/SkipVersionCheck.cs diff --git a/Fix/DisableEncryption.cs b/Fix/DisableEncryption.cs new file mode 100644 index 0000000..1f083f3 --- /dev/null +++ b/Fix/DisableEncryption.cs @@ -0,0 +1,89 @@ +using System; +using HarmonyLib; +using Net.Packet; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using AMDaemon.Allnet; +using Main; +using Manager; +using Manager.Operation; +using MelonLoader; +using Net; +using Net.VO; + +namespace SinmaiAssist.Fix; + +public class DisableEncryption +{ + // codes from AquaMai [https://github.com/MewoLab/AquaMai/blob/main/AquaMai.Core] + private static string apiSuffix = ""; + + [HarmonyPostfix] + [HarmonyPatch(typeof(GameMain), "LateInitialize")] + public static void GetApiSuffix() + { + try + { + var baseNetQueryConstructor = typeof(NetQuery) + .GetConstructors() + .First(); + apiSuffix = ((INetQuery)baseNetQueryConstructor.Invoke( + [.. baseNetQueryConstructor + .GetParameters() + .Select((parameter, i) => i == 0 ? "" : parameter.DefaultValue)])).Api; + MelonLogger.Msg($"API suffix: {apiSuffix}"); + } + catch (Exception e) + { + MelonLogger.Error($"Failed to resolve the API suffix: {e}"); + apiSuffix = null; + } + } + + [HarmonyPrefix] + [HarmonyPatch(typeof(Packet), "Obfuscator", typeof(string))] + public static bool PreObfuscator(string srcStr, ref string __result) + { + if (string.IsNullOrEmpty(apiSuffix)) return false; + if (srcStr.EndsWith(apiSuffix)) + { + __result = srcStr.Substring(0, srcStr.Length - apiSuffix.Length); + } + // __result = srcStr.Replace("MaimaiExp", "").Replace("MaimaiChn", ""); + return false; + } + + [HarmonyPatch] + public class EncryptDecrypt + { + public static IEnumerable TargetMethods() + { + var methods = AccessTools.TypeByName("Net.CipherAES").GetMethods(); + return + [ + methods.FirstOrDefault(it => it.Name == "Encrypt" && it.IsPublic), + methods.FirstOrDefault(it => it.Name == "Decrypt" && it.IsPublic) + ]; + } + + public static bool Prefix(object[] __args, ref object __result) + { + if (!SinmaiAssist.MainConfig.Fix.DisableEncryption) return true; + if (__args.Length == 1) + { + // public static byte[] Encrypt(byte[] data) + // public static byte[] Decrypt(byte[] encryptData) + __result = __args[0]; + } + else if (__args.Length == 2) + { + // public static bool Encrypt(byte[] data, out byte[] encryptData) + // public static bool Decrypt(byte[] encryptData, out byte[] plainData) + __args[1] = __args[0]; + __result = true; + } + return false; + } + } +} \ No newline at end of file diff --git a/Fix/DisableEnvironmentCheck.cs b/Fix/DisableEnvironmentCheck.cs new file mode 100644 index 0000000..99d9dec --- /dev/null +++ b/Fix/DisableEnvironmentCheck.cs @@ -0,0 +1,41 @@ +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Reflection.Emit; +using HarmonyLib; +using MelonLoader; +using Process; +using SinmaiAssist.Attributes; + +namespace SinmaiAssist.Fix; + +[EnableGameVersion(25000)] +public class DisableEnvironmentCheck +{ + [HarmonyTranspiler] + [HarmonyPatch(typeof(WarningProcess), "OnStart")] + public static IEnumerable OnStart(IEnumerable instructions) + { + var codes = instructions.ToList(); + var onceDispIndex = codes.FindIndex( + inst => + inst.opcode == OpCodes.Ldsfld && + inst.operand is FieldInfo field && + field.Name == "OnceDisp"); + if (onceDispIndex == -1) + { + MelonLogger.Warning("[Disable Environment Check] Failed to patch DisableEnvironmentCheck, Method Not Found!"); + return codes; + } + +#if DEBUG + var skippedInstructions = codes.Take(onceDispIndex).ToList(); + MelonLogger.Msg("Disable Environment Check Skipped Code Output:"); + foreach (var inst in skippedInstructions) + { + MelonLogger.Msg($"[Disable Environment Check] Opcode: {inst.opcode}, Operand: {inst.operand}"); + } +#endif + return codes.Skip(onceDispIndex); + } +} \ No newline at end of file diff --git a/Fix/DisableIniClear.cs b/Fix/DisableIniClear.cs new file mode 100644 index 0000000..3657199 --- /dev/null +++ b/Fix/DisableIniClear.cs @@ -0,0 +1,14 @@ +using HarmonyLib; +using MAI2System; + +namespace SinmaiAssist.Fix; + +public class DisableIniClear +{ + [HarmonyPrefix] + [HarmonyPatch(typeof(IniFile), "clear")] + public static bool DisableClearMethod(IniFile __instance) + { + return false; + } +} \ No newline at end of file diff --git a/Fix/DisableReboot.cs b/Fix/DisableReboot.cs new file mode 100644 index 0000000..603e3b5 --- /dev/null +++ b/Fix/DisableReboot.cs @@ -0,0 +1,77 @@ +using HarmonyLib; +using Manager.Operation; + +namespace SinmaiAssist.Fix; + +public class DisableReboot +{ + [HarmonyPrefix] + [HarmonyPatch(typeof(MaintenanceTimer), "IsAutoRebootNeeded")] + public static bool IsAutoRebootNeeded(ref bool __result) + { + __result = false; + return false; + } + + [HarmonyPrefix] + [HarmonyPatch(typeof(MaintenanceTimer), "IsUnderServerMaintenance")] + public static bool IsUnderServerMaintenance(ref bool __result) + { + __result = false; + return false; + } + + [HarmonyPrefix] + [HarmonyPatch(typeof(MaintenanceTimer), "get_RemainingMinutes")] + public static bool dsds(ref int __result) + { + __result = 600; + return false; + } + + [HarmonyPrefix] + [HarmonyPatch(typeof(MaintenanceTimer), "GetAutoRebootSec")] + public static bool GetAutoRebootSec(ref int __result) + { + __result = 60 * 60 * 10; + return false; + } + + [HarmonyPrefix] + [HarmonyPatch(typeof(MaintenanceTimer), "GetServerMaintenanceSec")] + public static bool GetServerMaintenanceSec(ref int __result) + { + __result = 60 * 60 * 10; + return false; + } + + [HarmonyPrefix] + [HarmonyPatch(typeof(MaintenanceTimer), "Execute")] + public static bool Execute(MaintenanceTimer __instance) + { + return false; + } + + [HarmonyPrefix] + [HarmonyPatch(typeof(MaintenanceTimer), "UpdateTimes")] + public static bool UpdateTimes(MaintenanceTimer __instance) + { + return false; + } + + [HarmonyPrefix] + [HarmonyPatch(typeof(ClosingTimer), "IsShowRemainingMinutes")] + public static bool IsShowRemainingMinutes(ref bool __result) + { + __result = false; + return false; + } + + [HarmonyPrefix] + [HarmonyPatch(typeof(ClosingTimer), "IsClosed")] + public static bool IsClosed(ref bool __result) + { + __result = false; + return false; + } +} \ No newline at end of file diff --git a/Fix/FixCheckAuth.cs b/Fix/FixCheckAuth.cs new file mode 100644 index 0000000..276ddbb --- /dev/null +++ b/Fix/FixCheckAuth.cs @@ -0,0 +1,20 @@ +using AMDaemon.Allnet; +using HarmonyLib; +using Manager; +using Manager.Operation; + +namespace SinmaiAssist.Fix; + +public class FixCheckAuth +{ + // codes from AquaMai [https://github.com/MewoLab/AquaMai/blob/main/AquaMai.Mods/Fix/FixCheckAuth.cs] + [HarmonyPostfix] + [HarmonyPatch(typeof(OperationManager), "CheckAuth_Proc")] + private static void PostCheckAuthProc(ref OperationData ____operationData) + { + if (Auth.GameServerUri.StartsWith("http://") || Auth.GameServerUri.StartsWith("https://")) + { + ____operationData.ServerUri = Auth.GameServerUri; + } + } +} \ No newline at end of file diff --git a/Fix/FixDebugInput.cs b/Fix/FixDebugInput.cs new file mode 100644 index 0000000..3d53658 --- /dev/null +++ b/Fix/FixDebugInput.cs @@ -0,0 +1,79 @@ +using HarmonyLib; +using UnityEngine; + +namespace SinmaiAssist.Fix; + +public class FixDebugInput +{ + [HarmonyPrefix] + [HarmonyPatch(typeof(DebugInput), "GetKey")] + public static bool GetKey(ref bool __result, KeyCode name) + { + __result = Input.GetKey(name); + return false; + } + + [HarmonyPrefix] + [HarmonyPatch(typeof(DebugInput), "GetKeyDown")] + public static bool GetKeyDown(ref bool __result, KeyCode name) + { + __result = Input.GetKeyDown(name); + return false; + } + + [HarmonyPrefix] + [HarmonyPatch(typeof(DebugInput), "GetKeyUp")] + public static bool GetKeyUp(ref bool __result, KeyCode name) + { + __result = Input.GetKeyUp(name); + return false; + } + + [HarmonyPrefix] + [HarmonyPatch(typeof(DebugInput), "GetButton")] + public static bool GetButton(ref bool __result, string name) + { + __result = Input.GetButton(name); + return false; + } + + [HarmonyPrefix] + [HarmonyPatch(typeof(DebugInput), "GetButtonDown")] + public static bool GetButtonDown(ref bool __result, string name) + { + __result = Input.GetButtonDown(name); + return false; + } + + [HarmonyPrefix] + [HarmonyPatch(typeof(DebugInput), "GetButtonUp")] + public static bool GetButtonUp(ref bool __result, string name) + { + __result = Input.GetButton(name); + return false; + } + + [HarmonyPrefix] + [HarmonyPatch(typeof(DebugInput), "GetMouseButton")] + public static bool GetMouseButton(ref bool __result, int button) + { + __result = Input.GetMouseButton(button); + return false; + } + + [HarmonyPrefix] + [HarmonyPatch(typeof(DebugInput), "GetMouseButtonDown")] + public static bool GetMouseButtonDown(ref bool __result, int button) + { + __result = Input.GetMouseButtonDown(button); + return false; + } + + [HarmonyPrefix] + [HarmonyPatch(typeof(DebugInput), "GetMouseButtonUp")] + public static bool GetMouseButtonUp(ref bool __result, int button) + { + __result = Input.GetMouseButtonUp(button); + return false; + } +} \ No newline at end of file diff --git a/Fix/ForceAsServer.cs b/Fix/ForceAsServer.cs new file mode 100644 index 0000000..4fabb19 --- /dev/null +++ b/Fix/ForceAsServer.cs @@ -0,0 +1,23 @@ +using AMDaemon; +using HarmonyLib; + +namespace SinmaiAssist.Fix; + +public class ForceAsServer +{ + [HarmonyPrefix] + [HarmonyPatch(typeof(Network), "get_IsLanAvailable")] + private static bool IsLanAvailable(ref bool __result) + { + __result = false; + return false; + } + + [HarmonyPrefix] + [HarmonyPatch(typeof(LanInstall), "get_IsServer")] + private static bool IsServer(ref bool __result) + { + __result = true; + return false; + } +} \ No newline at end of file diff --git a/Fix/RestoreCertificateValidation.cs b/Fix/RestoreCertificateValidation.cs new file mode 100644 index 0000000..d22b874 --- /dev/null +++ b/Fix/RestoreCertificateValidation.cs @@ -0,0 +1,16 @@ +using System.Net; +using HarmonyLib; +using Net; + +namespace SinmaiAssist.Fix; + +public class RestoreCertificateValidation +{ + // codes from AquaMai [https://github.com/MewoLab/AquaMai/blob/main/AquaMai.Mods/Fix/Common.cs] + [HarmonyPostfix] + [HarmonyPatch(typeof(NetHttpClient), "Create")] + private static void OnNetHttpClientCreate() + { + ServicePointManager.ServerCertificateValidationCallback = null; + } +} \ No newline at end of file diff --git a/Fix/RewriteNoteJudgeTiming.cs b/Fix/RewriteNoteJudgeTiming.cs new file mode 100644 index 0000000..564b64c --- /dev/null +++ b/Fix/RewriteNoteJudgeTiming.cs @@ -0,0 +1,21 @@ +using HarmonyLib; +using Manager.UserDatas; + +namespace SinmaiAssist.Fix; + +public class RewriteNoteJudgeTiming +{ + [HarmonyPostfix] + [HarmonyPatch(typeof(UserOption), "GetAdjustMSec")] + public static void GetAdjustMSec(ref float __result) + { + __result = SinmaiAssist.MainConfig.Fix.RewriteNoteJudgeTiming.AdjustTiming; + } + + [HarmonyPostfix] + [HarmonyPatch(typeof(UserOption), "GetJudgeTimingFrame")] + public static void GetJudgeTimingFrame(ref float __result) + { + __result = SinmaiAssist.MainConfig.Fix.RewriteNoteJudgeTiming.JudgeTiming; + } +} \ No newline at end of file diff --git a/Fix/SkipCakeHashCheck.cs b/Fix/SkipCakeHashCheck.cs new file mode 100644 index 0000000..a7017d7 --- /dev/null +++ b/Fix/SkipCakeHashCheck.cs @@ -0,0 +1,19 @@ +using HarmonyLib; +using Net; + +namespace SinmaiAssist.Fix; + +public class SkipCakeHashCheck +{ + // codes from AquaMai [https://github.com/MewoLab/AquaMai/blob/main/AquaMai.Mods/Fix/Common.cs] + [HarmonyPostfix] + [HarmonyPatch(typeof(NetHttpClient), MethodType.Constructor)] + private static void OnNetHttpClientConstructor(NetHttpClient __instance) + { + var tInstance = Traverse.Create(__instance).Field("isTrueDll"); + if (tInstance.FieldExists()) + { + tInstance.SetValue(true); + } + } +} \ No newline at end of file diff --git a/Fix/SkipSpecialNumCheck.cs b/Fix/SkipSpecialNumCheck.cs new file mode 100644 index 0000000..1c58bbf --- /dev/null +++ b/Fix/SkipSpecialNumCheck.cs @@ -0,0 +1,22 @@ +using System; +using HarmonyLib; +using Manager; +using MelonLoader; + +namespace SinmaiAssist.Fix; + +public class SkipSpecialNumCheck +{ + // codes from AquaMai [https://github.com/MewoLab/AquaMai/blob/main/AquaMai.Mods/Fix/Common.cs] + [HarmonyPostfix] + [HarmonyPatch(typeof(GameManager), "CalcSpecialNum")] + private static void CalcSpecialNum(ref int __result) + { +#if DEBUG + MelonLogger.Warning($"[SkipSpecialNumCheck] OriginalSpecialNum:{__result.ToString()}, {Convert.ToString(__result, 2)}"); +#endif + var num = 0; + num |= 1024; + __result = num; + } +} \ No newline at end of file diff --git a/Fix/SkipVersionCheck.cs b/Fix/SkipVersionCheck.cs new file mode 100644 index 0000000..7396dc1 --- /dev/null +++ b/Fix/SkipVersionCheck.cs @@ -0,0 +1,30 @@ +using DB; +using HarmonyLib; +using MAI2System; +using Net.VO.Mai2; +using Process.Entry.State; +using SinmaiAssist.Utils; + +namespace SinmaiAssist.Fix; + +public class SkipVersionCheck +{ + [HarmonyPrefix] + [HarmonyPatch(typeof(ConfirmPlay), "IsValidVersion")] + public static bool IsValidVersion(ref bool __result,ref UserPreviewResponseVO vo) + { + VersionNo lastRomVersion = new VersionNo(); + VersionNo lastDataVersion = new VersionNo(); + + lastRomVersion.tryParse(vo.lastRomVersion, true); + lastDataVersion.tryParse(vo.lastDataVersion, true); + + GameMessageManager.SendMessage(0, + $"RomVersion: {lastRomVersion.versionString}\n" + + $"DataVersion: {lastDataVersion.versionString}" + ,"Account Version" + , WindowPositionID.Upper); + __result = true; + return false; + } +} \ No newline at end of file