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.

55 lines
2.2KB

  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. }
  21. private static bool AntiAntiCheat() => false;
  22. private static bool AntiAntiCheat(ref object __result)
  23. {
  24. var targetType =
  25. AccessTools.TypeByName("Techblox.Services.Eos.Anticheat.Client.Services.StartProtectedSessionResult");
  26. var target = Activator.CreateInstance(targetType);
  27. targetType.GetField("Success").SetValue(target, true);
  28. __result = target;
  29. return false;
  30. }
  31. private static bool AntiAntiCheat(ref bool __result)
  32. {
  33. __result = true;
  34. return false;
  35. }
  36. private static bool AntiAntiCheatTask(ref IEnumerator<TaskContract> __result)
  37. {
  38. IEnumerator<TaskContract> Func()
  39. {
  40. yield return Yield.It;
  41. }
  42. __result = Func();
  43. return false;
  44. }
  45. }
  46. }