|
- using System;
- using System.Collections.Generic;
- using HarmonyLib;
- using Svelto.Tasks;
-
- namespace TechbloxModdingAPI.App
- {
- public static class AntiAntiCheatPatch
- {
- private delegate bool AntiAnticheatDelegate(ref object __result);
-
- private delegate bool AntiAnticheatDelegateBool(ref bool __result);
-
- private delegate bool AntiAnticheatDelegateTask(ref IEnumerator<TaskContract> __result);
-
- public static void Init(Harmony harmony)
- {
- var type = AccessTools.TypeByName("Techblox.Services.Eos.Anticheat.Client.Services.AnticheatClientService");
- harmony.Patch(type.GetConstructors()[0], new HarmonyMethod(((Func<bool>) AntiAntiCheat).Method));
- harmony.Patch(AccessTools.Method(type, "Shutdown"), new HarmonyMethod(((Func<bool>) AntiAntiCheat).Method));
- harmony.Patch(AccessTools.Method(type, "StartProtectedSession"), new HarmonyMethod(((AntiAnticheatDelegate) AntiAntiCheat).Method));
- harmony.Patch(AccessTools.Method(type, "StopProtectedSession"), new HarmonyMethod(((AntiAnticheatDelegateBool) AntiAntiCheat).Method));
- harmony.Patch(AccessTools.Method("Techblox.Services.Eos.Anticheat.Client.EosGetPendingMessagesToSendServiceRequest:Execute"), new HarmonyMethod(((AntiAnticheatDelegateTask)AntiAntiCheatTask).Method));
- }
-
- private static bool AntiAntiCheat() => false;
-
- private static bool AntiAntiCheat(ref object __result)
- {
- var targetType =
- AccessTools.TypeByName("Techblox.Services.Eos.Anticheat.Client.Services.StartProtectedSessionResult");
- var target = Activator.CreateInstance(targetType);
- targetType.GetField("Success").SetValue(target, true);
- __result = target;
- return false;
- }
-
- private static bool AntiAntiCheat(ref bool __result)
- {
- __result = true;
- return false;
- }
-
- private static bool AntiAntiCheatTask(ref IEnumerator<TaskContract> __result)
- {
- IEnumerator<TaskContract> Func()
- {
- yield return Yield.It;
- }
-
- __result = Func();
- return false;
- }
- }
- }
|