From 171a3815b8829eba89d9e6665092af78f76affe7 Mon Sep 17 00:00:00 2001 From: TotallyNotElite <1yourexperiment@protonmail.com> Date: Sun, 17 Mar 2019 18:36:31 +0100 Subject: [PATCH] sv_pure bypass is now separated into module --- src/hacks/CMakeLists.txt | 1 + src/hacks/PureBypass.cpp | 37 ++++++++++++++++++++++++++++++ src/hooks/visual/PaintTraverse.cpp | 20 +--------------- 3 files changed, 39 insertions(+), 19 deletions(-) create mode 100644 src/hacks/PureBypass.cpp diff --git a/src/hacks/CMakeLists.txt b/src/hacks/CMakeLists.txt index 53cdd096..60fc9468 100755 --- a/src/hacks/CMakeLists.txt +++ b/src/hacks/CMakeLists.txt @@ -32,6 +32,7 @@ target_sources(cathook PRIVATE "${CMAKE_CURRENT_LIST_DIR}/MiscPlayerInfo.cpp" "${CMAKE_CURRENT_LIST_DIR}/NavBot.cpp" "${CMAKE_CURRENT_LIST_DIR}/Noisemaker.cpp" + "${CMAKE_CURRENT_LIST_DIR}/PureBypass.cpp" "${CMAKE_CURRENT_LIST_DIR}/Trigger.cpp" "${CMAKE_CURRENT_LIST_DIR}/UberSpam.cpp" "${CMAKE_CURRENT_LIST_DIR}/Walkbot.cpp" diff --git a/src/hacks/PureBypass.cpp b/src/hacks/PureBypass.cpp new file mode 100644 index 00000000..fdf81d2d --- /dev/null +++ b/src/hacks/PureBypass.cpp @@ -0,0 +1,37 @@ +#include +#include "common.hpp" + +static settings::Bool enabled{ "pure-bypass.enable", "false" }; +static void *pure_orig, **pure_addr; + +static void toggle(bool on) +{ + if (on) + { + if (!pure_addr) + { + pure_addr = *reinterpret_cast(gSignatures.GetEngineSignature("A1 ? ? ? ? 85 C0 74 ? C7 44 24 ? ? ? ? ? 89 04 24") + 1); + if (!pure_addr) + { + logging::InfoConsole("Pure bypass broken, failed to find signature"); + return; + } + } + if (*pure_addr) + pure_orig = *pure_addr; + + *pure_addr = nullptr; + } + else if (pure_orig) + { + *pure_addr = pure_orig; + pure_orig = nullptr; + } +} + +static InitRoutine init([] { + toggle(*enabled); + enabled.installChangeCallback([](settings::VariableBase &, bool on) { + toggle(on); + }); +}); diff --git a/src/hooks/visual/PaintTraverse.cpp b/src/hooks/visual/PaintTraverse.cpp index 387472f5..78cabec8 100644 --- a/src/hooks/visual/PaintTraverse.cpp +++ b/src/hooks/visual/PaintTraverse.cpp @@ -8,7 +8,6 @@ #include "HookedMethods.hpp" #include "CatBot.hpp" -static settings::Bool pure_bypass{ "visual.sv-pure-bypass", "false" }; static settings::Int software_cursor_mode{ "visual.software-cursor-mode", "0" }; static settings::Int waittime{ "debug.join-wait-time", "2500" }; @@ -25,11 +24,9 @@ CatCommand join_spam("join_spam", "Spam joins server for X seconds", [](const CC }); CatCommand join("mm_join", "Join mm Match", []() { auto gc = re::CTFGCClientSystem::GTFGCClientSystem(); - if (gc) gc->JoinMMMatch(); + if (gc) }); -void *pure_orig = nullptr; -void **pure_addr = nullptr; bool replaced = false; namespace hooked_methods @@ -90,21 +87,6 @@ DEFINE_HOOKED_METHOD(PaintTraverse, void, vgui::IPanel *this_, unsigned int pane no_report_limit.Patch(); replaced = true; } - if (pure_bypass) - { - if (!pure_addr) - { - pure_addr = *reinterpret_cast(gSignatures.GetEngineSignature("A1 ? ? ? ? 85 C0 74 ? C7 44 24 ? ? ? ? ? 89 04 24") + 1); - } - if (*pure_addr) - pure_orig = *pure_addr; - *pure_addr = (void *) 0; - } - else if (pure_orig) - { - *pure_addr = pure_orig; - pure_orig = (void *) 0; - } call_default = true; if (isHackActive() && (panel_scope || motd_panel || motd_panel_sd) && ((no_zoom && panel == panel_scope) || (hacks::shared::catbot::catbotmode && hacks::shared::catbot::anti_motd && (panel == motd_panel || panel == motd_panel_sd)))) call_default = false;