A stable modding interface between Techblox and mods https://mod.exmods.org/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
2.6KB

  1. using System;
  2. using System.Collections.Generic;
  3. using HarmonyLib;
  4. using Svelto.Tasks;
  5. using Techblox.Anticheat.Client;
  6. namespace TechbloxModdingAPI.App
  7. {
  8. public static class AntiAntiCheatPatch
  9. {
  10. private delegate bool AntiAnticheatDelegate(ref object __result);
  11. private delegate bool AntiAnticheatDelegateBool(ref bool __result);
  12. private delegate bool AntiAnticheatDelegateTask(ref IEnumerator<TaskContract> __result);
  13. public static void Init(Harmony harmony)
  14. {
  15. var type = AccessTools.TypeByName("Techblox.Services.Eos.Anticheat.Client.Services.AnticheatClientService");
  16. harmony.Patch(type.GetConstructors()[0], new HarmonyMethod(((Func<bool>) AntiAntiCheat).Method));
  17. harmony.Patch(AccessTools.Method(type, "Shutdown"), new HarmonyMethod(((Func<bool>) AntiAntiCheat).Method));
  18. harmony.Patch(AccessTools.Method(type, "StartProtectedSession"), new HarmonyMethod(((AntiAnticheatDelegate) AntiAntiCheat).Method));
  19. harmony.Patch(AccessTools.Method(type, "StopProtectedSession"), new HarmonyMethod(((AntiAnticheatDelegateBool) AntiAntiCheat).Method));
  20. harmony.Patch(AccessTools.Method("Techblox.Services.Eos.Anticheat.Client.EosGetPendingMessagesToSendServiceRequest:Execute"), new HarmonyMethod(((AntiAnticheatDelegateTask)AntiAntiCheatTask).Method));
  21. harmony.Patch(AccessTools.Method("Techblox.Anticheat.Client.Engines.ProcessEACViolationEngine:PollAnticheatStatus"), new HarmonyMethod(((AntiAnticheatDelegateTask)AntiAntiCheatTask).Method));
  22. harmony.Patch(AccessTools.Method(typeof(AnticheatClientCompositionRoot), "ClientComposeTimeRunning"), new HarmonyMethod(((Func<bool>)AntiAntiCheat).Method));
  23. }
  24. private static bool AntiAntiCheat() => false;
  25. private static bool AntiAntiCheat(ref object __result)
  26. {
  27. var targetType =
  28. AccessTools.TypeByName("Techblox.Services.Eos.Anticheat.Client.Services.StartProtectedSessionResult");
  29. var target = Activator.CreateInstance(targetType);
  30. targetType.GetField("Success").SetValue(target, true);
  31. __result = target;
  32. return false;
  33. }
  34. private static bool AntiAntiCheat(ref bool __result)
  35. {
  36. __result = true;
  37. return false;
  38. }
  39. private static bool AntiAntiCheatTask(ref IEnumerator<TaskContract> __result)
  40. {
  41. IEnumerator<TaskContract> Func()
  42. {
  43. yield return Yield.It;
  44. }
  45. __result = Func();
  46. return false;
  47. }
  48. }
  49. }