mirror of
https://github.com/MewoLab/AquaDX.git
synced 2026-02-11 15:37:27 +08:00
[O] Support SDGA and other game version in one binary
Merge pull request #61 * Merge targets * Merge branch 'v1-dev' into fork/Menci/merge-targets * [O] Move Shim to AquaMai.Helpers --------- Co-authored-by: Clansty <i@gao4.pw>
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using HarmonyLib;
|
||||
using MelonLoader;
|
||||
using Net.Packet;
|
||||
|
||||
namespace AquaMai.Fix;
|
||||
@@ -11,65 +10,41 @@ public class RemoveEncryption
|
||||
{
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(Packet), "Obfuscator", typeof(string))]
|
||||
private static bool PreObfuscator(string srcStr, ref string __result)
|
||||
public static bool PreObfuscator(string srcStr, ref string __result)
|
||||
{
|
||||
__result = srcStr.Replace("MaimaiExp", "").Replace("MaimaiChn", "");
|
||||
return false;
|
||||
}
|
||||
|
||||
[HarmonyPatch]
|
||||
public class Encrypt
|
||||
public class EncryptDecrypt
|
||||
{
|
||||
public static IEnumerable<MethodBase> TargetMethods()
|
||||
{
|
||||
# if SDGA145
|
||||
return [AccessTools.Method("Net.CipherAES:Encrypt", [typeof(byte[])])];
|
||||
# else
|
||||
return [AccessTools.TypeByName("Net.CipherAES").GetMethods().FirstOrDefault(it => it.Name == "Encrypt")];
|
||||
# endif
|
||||
var methods = AccessTools.TypeByName("Net.CipherAES").GetMethods();
|
||||
return
|
||||
[
|
||||
methods.FirstOrDefault(it => it.Name == "Encrypt" && it.IsPublic),
|
||||
methods.FirstOrDefault(it => it.Name == "Decrypt" && it.IsPublic)
|
||||
];
|
||||
}
|
||||
|
||||
# if SDGA145
|
||||
public static bool Prefix(byte[] data, ref byte[] __result)
|
||||
public static bool Prefix(object[] __args, ref object __result)
|
||||
{
|
||||
__result = data;
|
||||
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;
|
||||
}
|
||||
# else
|
||||
public static bool Prefix(byte[] data, out byte[] encryptData, ref bool __result)
|
||||
{
|
||||
encryptData = data;
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
# endif
|
||||
}
|
||||
|
||||
[HarmonyPatch]
|
||||
public class Decrypt
|
||||
{
|
||||
public static IEnumerable<MethodBase> TargetMethods()
|
||||
{
|
||||
# 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)
|
||||
{
|
||||
__result = encryptData;
|
||||
return false;
|
||||
}
|
||||
# else
|
||||
public static bool Prefix(byte[] encryptData, out byte[] plainData, ref bool __result)
|
||||
{
|
||||
plainData = encryptData;
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
# endif
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user