From c6e471323f74b7b36cc9b67d26308c6ead1e1f67 Mon Sep 17 00:00:00 2001 From: Clansty Date: Tue, 9 Jul 2024 18:11:06 +0800 Subject: [PATCH] [+] Fixes required to run SDGA --- AquaMai/AquaMai.csproj | 7 +++- AquaMai/AquaMai.toml | 1 + AquaMai/Config.cs | 1 + AquaMai/Fix/BasicFix.cs | 45 +++++++++++++++++++++++ AquaMai/Fix/RemoveEncryption.cs | 47 +++++++++++++++++++++++++ AquaMai/{UX => Fix}/SkipVersionCheck.cs | 2 +- AquaMai/Main.cs | 1 + 7 files changed, 102 insertions(+), 2 deletions(-) create mode 100644 AquaMai/Fix/BasicFix.cs create mode 100644 AquaMai/Fix/RemoveEncryption.cs rename AquaMai/{UX => Fix}/SkipVersionCheck.cs (93%) diff --git a/AquaMai/AquaMai.csproj b/AquaMai/AquaMai.csproj index 4e94006d..0c89f1ce 100644 --- a/AquaMai/AquaMai.csproj +++ b/AquaMai/AquaMai.csproj @@ -33,6 +33,9 @@ Libs\0Harmony.dll + + Libs\AMDaemon.NET.dll + Libs\Assembly-CSharp.dll @@ -271,7 +274,10 @@ + + + @@ -288,7 +294,6 @@ - diff --git a/AquaMai/AquaMai.toml b/AquaMai/AquaMai.toml index 0ff953d4..c532ab29 100644 --- a/AquaMai/AquaMai.toml +++ b/AquaMai/AquaMai.toml @@ -50,3 +50,4 @@ ImproveLoadSpeed=false [Fix] # Allow login with higher data version SkipVersionCheck=true +RemoveEncryption=true diff --git a/AquaMai/Config.cs b/AquaMai/Config.cs index 1a4a3dbb..8b2be814 100644 --- a/AquaMai/Config.cs +++ b/AquaMai/Config.cs @@ -44,6 +44,7 @@ namespace AquaMai public class FixConfig { public bool SkipVersionCheck { get; set; } + public bool RemoveEncryption { get; set; } } } } diff --git a/AquaMai/Fix/BasicFix.cs b/AquaMai/Fix/BasicFix.cs new file mode 100644 index 00000000..3b9ef824 --- /dev/null +++ b/AquaMai/Fix/BasicFix.cs @@ -0,0 +1,45 @@ +using AMDaemon; +using AMDaemon.Allnet; +using HarmonyLib; +using Manager; +using Manager.Operation; +using IniFile = MAI2System.IniFile; +using Network = AMDaemon.Network; + +namespace AquaMai.Fix; + +public class BasicFix +{ + [HarmonyPrefix] + [HarmonyPatch(typeof(IniFile), "clear")] + private static bool PreIniFileClear() + { + return false; + } + + [HarmonyPrefix] + [HarmonyPatch(typeof(LanInstall), "IsServer", MethodType.Getter)] + private static bool PreIsServer(ref bool __result) + { + __result = true; + return false; + } + + [HarmonyPrefix] + [HarmonyPatch(typeof(Network), "IsLanAvailable", MethodType.Getter)] + private static bool PreIsLanAvailable(ref bool __result) + { + __result = false; + return false; + } + + [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; + } + } +} diff --git a/AquaMai/Fix/RemoveEncryption.cs b/AquaMai/Fix/RemoveEncryption.cs new file mode 100644 index 00000000..ab09736c --- /dev/null +++ b/AquaMai/Fix/RemoveEncryption.cs @@ -0,0 +1,47 @@ +using System.Collections.Generic; +using System.Reflection; +using HarmonyLib; +using Net.Packet; + +namespace AquaMai.Fix; + +public class RemoveEncryption +{ + [HarmonyPrefix] + [HarmonyPatch(typeof(Packet), "Obfuscator")] + private static bool PreObfuscator(string srcStr, ref string __result) + { + __result = srcStr.Replace("MaimaiExp", "").Replace("MaimaiChn", ""); + return false; + } + + [HarmonyPatch] + public class Encrypt + { + public static IEnumerable TargetMethods() + { + return new[] { AccessTools.Method("Net.CipherAES:Encrypt") }; + } + + public static bool Prefix(byte[] data, ref byte[] __result) + { + __result = data; + return false; + } + } + + [HarmonyPatch] + public class Decrypt + { + public static IEnumerable TargetMethods() + { + return new[] { AccessTools.Method("Net.CipherAES:Decrypt") }; + } + + public static bool Prefix(byte[] encryptData, ref byte[] __result) + { + __result = encryptData; + return false; + } + } +} diff --git a/AquaMai/UX/SkipVersionCheck.cs b/AquaMai/Fix/SkipVersionCheck.cs similarity index 93% rename from AquaMai/UX/SkipVersionCheck.cs rename to AquaMai/Fix/SkipVersionCheck.cs index 6adc0391..1d1c2933 100644 --- a/AquaMai/UX/SkipVersionCheck.cs +++ b/AquaMai/Fix/SkipVersionCheck.cs @@ -1,7 +1,7 @@ using HarmonyLib; using Process.Entry.State; -namespace AquaMai.UX +namespace AquaMai.Fix { public class SkipVersionCheck { diff --git a/AquaMai/Main.cs b/AquaMai/Main.cs index eaead5bb..b28dd39f 100644 --- a/AquaMai/Main.cs +++ b/AquaMai/Main.cs @@ -81,6 +81,7 @@ namespace AquaMai Patch(typeof(CustomVersionString)); Patch(typeof(DisableReboot)); Patch(typeof(RunCommandOnEvents)); + Patch(typeof(BasicFix)); MelonLogger.Msg("Loaded!"); }