上传文件至 Fix
This commit is contained in:
89
Fix/DisableEncryption.cs
Normal file
89
Fix/DisableEncryption.cs
Normal file
@@ -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<VOSerializer, VOSerializer>)
|
||||
.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<MethodBase> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
41
Fix/DisableEnvironmentCheck.cs
Normal file
41
Fix/DisableEnvironmentCheck.cs
Normal file
@@ -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<CodeInstruction> OnStart(IEnumerable<CodeInstruction> 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);
|
||||
}
|
||||
}
|
||||
14
Fix/DisableIniClear.cs
Normal file
14
Fix/DisableIniClear.cs
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
77
Fix/DisableReboot.cs
Normal file
77
Fix/DisableReboot.cs
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
20
Fix/FixCheckAuth.cs
Normal file
20
Fix/FixCheckAuth.cs
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
79
Fix/FixDebugInput.cs
Normal file
79
Fix/FixDebugInput.cs
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
23
Fix/ForceAsServer.cs
Normal file
23
Fix/ForceAsServer.cs
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
16
Fix/RestoreCertificateValidation.cs
Normal file
16
Fix/RestoreCertificateValidation.cs
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
21
Fix/RewriteNoteJudgeTiming.cs
Normal file
21
Fix/RewriteNoteJudgeTiming.cs
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
19
Fix/SkipCakeHashCheck.cs
Normal file
19
Fix/SkipCakeHashCheck.cs
Normal file
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
22
Fix/SkipSpecialNumCheck.cs
Normal file
22
Fix/SkipSpecialNumCheck.cs
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
30
Fix/SkipVersionCheck.cs
Normal file
30
Fix/SkipVersionCheck.cs
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user