[F] RemoveEncryption error with SDEZ

pull/55/head
Clansty 2024-09-11 01:35:17 +08:00
parent b7c5d18df1
commit 776c08e605
No known key found for this signature in database
GPG Key ID: 3A6BE8BAF2EDE134
1 changed files with 35 additions and 17 deletions

View File

@ -1,6 +1,8 @@
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using HarmonyLib;
using MelonLoader;
using Net.Packet;
namespace AquaMai.Fix;
@ -8,7 +10,7 @@ namespace AquaMai.Fix;
public class RemoveEncryption
{
[HarmonyPrefix]
[HarmonyPatch(typeof(Packet), "Obfuscator")]
[HarmonyPatch(typeof(Packet), "Obfuscator", typeof(string))]
private static bool PreObfuscator(string srcStr, ref string __result)
{
__result = srcStr.Replace("MaimaiExp", "").Replace("MaimaiChn", "");
@ -20,19 +22,27 @@ public class RemoveEncryption
{
public static IEnumerable<MethodBase> TargetMethods()
{
return new[] { AccessTools.Method("Net.CipherAES:Encrypt") };
# if SDGA145
return [AccessTools.Method("Net.CipherAES:Encrypt", [typeof(byte[])])];
# else
return [AccessTools.TypeByName("Net.CipherAES").GetMethods().FirstOrDefault(it => it.Name == "Encrypt")];
# endif
}
# if SDGA145
public static bool Prefix(byte[] data, ref byte[] __result)
{
if (AquaMai.AppConfig.Fix.RemoveEncryption)
{
__result = data;
return false;
}
return true;
__result = data;
return false;
}
# else
public static bool Prefix(byte[] data, out byte[] encryptData, ref bool __result)
{
encryptData = data;
__result = true;
return false;
}
# endif
}
[HarmonyPatch]
@ -40,18 +50,26 @@ public class RemoveEncryption
{
public static IEnumerable<MethodBase> TargetMethods()
{
return new[] { AccessTools.Method("Net.CipherAES:Decrypt") };
# if SDGA145
return [AccessTools.Method("Net.CipherAES:Decrypt", [typeof(byte[])])];
# else
return [AccessTools.TypeByName("Net.CipherAES").GetMethods().FirstOrDefault(it => it.Name == "Decrypt")];
# endif
}
# if SDGA145
public static bool Prefix(byte[] encryptData, ref byte[] __result)
{
if (AquaMai.AppConfig.Fix.RemoveEncryption)
{
__result = encryptData;
return false;
}
return true;
__result = encryptData;
return false;
}
# else
public static bool Prefix(byte[] encryptData, out byte[] plainData, ref bool __result)
{
plainData = encryptData;
__result = true;
return false;
}
# endif
}
}