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.

56 lines
2.4KB

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