From ae627d5f8f230aeb5f12cd093199ceabcd423f02 Mon Sep 17 00:00:00 2001 From: FutureRave Date: Mon, 29 Nov 2021 12:26:53 +0000 Subject: [PATCH 1/5] Elevators for trickshotting --- src/Components/Loader.cpp | 1 + src/Components/Loader.hpp | 1 + src/Components/Modules/Elevators.cpp | 81 ++++++++++++++++++++++++++++ src/Components/Modules/Elevators.hpp | 17 ++++++ 4 files changed, 100 insertions(+) create mode 100644 src/Components/Modules/Elevators.cpp create mode 100644 src/Components/Modules/Elevators.hpp diff --git a/src/Components/Loader.cpp b/src/Components/Loader.cpp index fea7625e..3217dcd4 100644 --- a/src/Components/Loader.cpp +++ b/src/Components/Loader.cpp @@ -105,6 +105,7 @@ namespace Components Loader::Register(new Chat()); Loader::Register(new TextRenderer()); Loader::Register(new Movement()); + Loader::Register(new Elevators()); Loader::Register(new Client()); diff --git a/src/Components/Loader.hpp b/src/Components/Loader.hpp index dd948b09..f9d1e6ed 100644 --- a/src/Components/Loader.hpp +++ b/src/Components/Loader.hpp @@ -133,6 +133,7 @@ namespace Components #include "Modules/Chat.hpp" #include "Modules/TextRenderer.hpp" #include "Modules/Movement.hpp" +#include "Modules/Elevators.hpp" #include "Modules/Gamepad.hpp" #include "Modules/Client.hpp" diff --git a/src/Components/Modules/Elevators.cpp b/src/Components/Modules/Elevators.cpp new file mode 100644 index 00000000..c8f5a14a --- /dev/null +++ b/src/Components/Modules/Elevators.cpp @@ -0,0 +1,81 @@ +#include "STDInclude.hpp" + +namespace Components +{ + Game::dvar_t* Elevators::SV_EnableEasyElevators; + + __declspec(naked) void Elevators::PM_CorrectAllSolidStub() + { + __asm + { + push ecx + mov ecx, Elevators::SV_EnableEasyElevators + cmp byte ptr [ecx + 16], 1 + pop ecx + + // Always elevate if SV_EnableEasyElevators is set to 1 + je elevate + + // Original code + cmp byte ptr [eax + 0x29], 0 + + // Original code flow + jz elevate + + push 0x5734FF + retn + + elevate: + push 0x57353D + retn + } + } + + __declspec(naked) void Elevators::PM_CheckDuckStub() + { + __asm + { + push eax + mov eax, Elevators::SV_EnableEasyElevators + cmp byte ptr [eax + 16], 1 + pop eax + + // Always stand if SV_EnableEasyElevators is set to 1 + je stand + + // Original code + cmp byte ptr [esp + 0x38], 0 + + // Original code flow + jnz noStand + + stand: + + push 0x570ED4 + retn + + noStand: + push 0x570EF4 + retn + } + } + + Elevators::Elevators() + { + Dvar::OnInit([] + { + Elevators::SV_EnableEasyElevators = Game::Dvar_RegisterBool("sv_enableEasyElevators", + false, Game::DVAR_FLAG_CHEAT | Game::DVAR_FLAG_REPLICATED, + "Enable easy elevators for trickshotting"); + }); + + Utils::Hook(0x5734F9, Elevators::PM_CorrectAllSolidStub, HOOK_JUMP).install()->quick(); + Utils::Hook::Nop(0x5734FE, 1); + + Utils::Hook(0x570ECD, Elevators::PM_CheckDuckStub, HOOK_JUMP).install()->quick(); + } + + Elevators::~Elevators() + { + } +} diff --git a/src/Components/Modules/Elevators.hpp b/src/Components/Modules/Elevators.hpp new file mode 100644 index 00000000..f5af25fd --- /dev/null +++ b/src/Components/Modules/Elevators.hpp @@ -0,0 +1,17 @@ +#pragma once + +namespace Components +{ + class Elevators : public Component + { + public: + Elevators(); + ~Elevators(); + + private: + static Game::dvar_t* SV_EnableEasyElevators; + + static void PM_CorrectAllSolidStub(); + static void PM_CheckDuckStub(); + }; +} From ed53211400d847ccdc88f04c142de3303ec848b5 Mon Sep 17 00:00:00 2001 From: FutureRave Date: Mon, 29 Nov 2021 14:08:44 +0000 Subject: [PATCH 2/5] Comments as requested --- src/Components/Modules/Elevators.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Components/Modules/Elevators.cpp b/src/Components/Modules/Elevators.cpp index c8f5a14a..cd71382a 100644 --- a/src/Components/Modules/Elevators.cpp +++ b/src/Components/Modules/Elevators.cpp @@ -22,10 +22,12 @@ namespace Components // Original code flow jz elevate + // Go to conditional check for the loop push 0x5734FF retn elevate: + // Continue with loop execution push 0x57353D retn } @@ -50,11 +52,12 @@ namespace Components jnz noStand stand: - + // Player is allowed to stand push 0x570ED4 retn noStand: + // Player will remain ducked push 0x570EF4 retn } @@ -69,9 +72,11 @@ namespace Components "Enable easy elevators for trickshotting"); }); + // Place hook PM_CorrectAllSolid so we may skip PM_Trace check Utils::Hook(0x5734F9, Elevators::PM_CorrectAllSolidStub, HOOK_JUMP).install()->quick(); Utils::Hook::Nop(0x5734FE, 1); + // Place hook PM_CheckDuck so we may skip PM_Trace check Utils::Hook(0x570ECD, Elevators::PM_CheckDuckStub, HOOK_JUMP).install()->quick(); } From 79be9e12d5971308d8571b29428af6dd53ed94a0 Mon Sep 17 00:00:00 2001 From: FutureRave Date: Mon, 29 Nov 2021 17:16:18 +0000 Subject: [PATCH 3/5] Add dvar to disable elevators entirely --- src/Components/Modules/Elevators.cpp | 44 ++++++++++++++++++++++++++-- src/Components/Modules/Elevators.hpp | 2 ++ 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/src/Components/Modules/Elevators.cpp b/src/Components/Modules/Elevators.cpp index cd71382a..a932782c 100644 --- a/src/Components/Modules/Elevators.cpp +++ b/src/Components/Modules/Elevators.cpp @@ -3,6 +3,7 @@ namespace Components { Game::dvar_t* Elevators::SV_EnableEasyElevators; + Game::dvar_t* Elevators::SV_DisableElevators; __declspec(naked) void Elevators::PM_CorrectAllSolidStub() { @@ -63,6 +64,39 @@ namespace Components } } + __declspec(naked) void Elevators::PM_GroundTraceStub() + { + __asm + { + push eax + mov eax, Elevators::SV_DisableElevators + cmp byte ptr [eax + 16], 1 + pop eax + + // Always skip PM_CorrectAllSolid if SV_DisableElevators is set to 1 + je noElevators + + // Original code + cmp byte ptr [esp + 0x50], 0 + rep movsd + mov esi, [esp + 0x58] + + // Original code flow + push 0x573694 + retn + + noElevators: + + // Original code + rep movsd + mov esi, [esp + 0x58] + + // Jump over call to PM_CorrectAllSolid + push 0x5736AE + retn + } + } + Elevators::Elevators() { Dvar::OnInit([] @@ -70,14 +104,20 @@ namespace Components Elevators::SV_EnableEasyElevators = Game::Dvar_RegisterBool("sv_enableEasyElevators", false, Game::DVAR_FLAG_CHEAT | Game::DVAR_FLAG_REPLICATED, "Enable easy elevators for trickshotting"); + Elevators::SV_DisableElevators = Game::Dvar_RegisterBool("sv_disableElevators", + false, Game::DVAR_FLAG_CHEAT | Game::DVAR_FLAG_REPLICATED, + "Disable elevators"); }); - // Place hook PM_CorrectAllSolid so we may skip PM_Trace check + // Hook PM_CorrectAllSolid so we may skip PM_Trace check Utils::Hook(0x5734F9, Elevators::PM_CorrectAllSolidStub, HOOK_JUMP).install()->quick(); Utils::Hook::Nop(0x5734FE, 1); - // Place hook PM_CheckDuck so we may skip PM_Trace check + // Hook PM_CheckDuck so we may skip PM_Trace check Utils::Hook(0x570ECD, Elevators::PM_CheckDuckStub, HOOK_JUMP).install()->quick(); + + // Hook PM_GroundTrace so me way skip PM_CorrectAllSolid (disable elevators) + Utils::Hook(0x573689, Elevators::PM_GroundTraceStub, HOOK_JUMP).install()->quick(); } Elevators::~Elevators() diff --git a/src/Components/Modules/Elevators.hpp b/src/Components/Modules/Elevators.hpp index f5af25fd..c01b2c98 100644 --- a/src/Components/Modules/Elevators.hpp +++ b/src/Components/Modules/Elevators.hpp @@ -10,8 +10,10 @@ namespace Components private: static Game::dvar_t* SV_EnableEasyElevators; + static Game::dvar_t* SV_DisableElevators; static void PM_CorrectAllSolidStub(); static void PM_CheckDuckStub(); + static void PM_GroundTraceStub(); }; } From bf9ea143333b9829925328e738f5b5778a18cf46 Mon Sep 17 00:00:00 2001 From: FutureRave Date: Mon, 29 Nov 2021 18:22:21 +0000 Subject: [PATCH 4/5] One feature at the time --- src/Components/Modules/Elevators.cpp | 70 ---------------------------- src/Components/Modules/Elevators.hpp | 3 -- 2 files changed, 73 deletions(-) diff --git a/src/Components/Modules/Elevators.cpp b/src/Components/Modules/Elevators.cpp index a932782c..38c69282 100644 --- a/src/Components/Modules/Elevators.cpp +++ b/src/Components/Modules/Elevators.cpp @@ -2,68 +2,8 @@ namespace Components { - Game::dvar_t* Elevators::SV_EnableEasyElevators; Game::dvar_t* Elevators::SV_DisableElevators; - __declspec(naked) void Elevators::PM_CorrectAllSolidStub() - { - __asm - { - push ecx - mov ecx, Elevators::SV_EnableEasyElevators - cmp byte ptr [ecx + 16], 1 - pop ecx - - // Always elevate if SV_EnableEasyElevators is set to 1 - je elevate - - // Original code - cmp byte ptr [eax + 0x29], 0 - - // Original code flow - jz elevate - - // Go to conditional check for the loop - push 0x5734FF - retn - - elevate: - // Continue with loop execution - push 0x57353D - retn - } - } - - __declspec(naked) void Elevators::PM_CheckDuckStub() - { - __asm - { - push eax - mov eax, Elevators::SV_EnableEasyElevators - cmp byte ptr [eax + 16], 1 - pop eax - - // Always stand if SV_EnableEasyElevators is set to 1 - je stand - - // Original code - cmp byte ptr [esp + 0x38], 0 - - // Original code flow - jnz noStand - - stand: - // Player is allowed to stand - push 0x570ED4 - retn - - noStand: - // Player will remain ducked - push 0x570EF4 - retn - } - } - __declspec(naked) void Elevators::PM_GroundTraceStub() { __asm @@ -101,21 +41,11 @@ namespace Components { Dvar::OnInit([] { - Elevators::SV_EnableEasyElevators = Game::Dvar_RegisterBool("sv_enableEasyElevators", - false, Game::DVAR_FLAG_CHEAT | Game::DVAR_FLAG_REPLICATED, - "Enable easy elevators for trickshotting"); Elevators::SV_DisableElevators = Game::Dvar_RegisterBool("sv_disableElevators", false, Game::DVAR_FLAG_CHEAT | Game::DVAR_FLAG_REPLICATED, "Disable elevators"); }); - // Hook PM_CorrectAllSolid so we may skip PM_Trace check - Utils::Hook(0x5734F9, Elevators::PM_CorrectAllSolidStub, HOOK_JUMP).install()->quick(); - Utils::Hook::Nop(0x5734FE, 1); - - // Hook PM_CheckDuck so we may skip PM_Trace check - Utils::Hook(0x570ECD, Elevators::PM_CheckDuckStub, HOOK_JUMP).install()->quick(); - // Hook PM_GroundTrace so me way skip PM_CorrectAllSolid (disable elevators) Utils::Hook(0x573689, Elevators::PM_GroundTraceStub, HOOK_JUMP).install()->quick(); } diff --git a/src/Components/Modules/Elevators.hpp b/src/Components/Modules/Elevators.hpp index c01b2c98..73af502a 100644 --- a/src/Components/Modules/Elevators.hpp +++ b/src/Components/Modules/Elevators.hpp @@ -9,11 +9,8 @@ namespace Components ~Elevators(); private: - static Game::dvar_t* SV_EnableEasyElevators; static Game::dvar_t* SV_DisableElevators; - static void PM_CorrectAllSolidStub(); - static void PM_CheckDuckStub(); static void PM_GroundTraceStub(); }; } From a54d83945d3ee27eb6527fad4518e340b7c3488d Mon Sep 17 00:00:00 2001 From: FutureRave Date: Mon, 29 Nov 2021 18:36:23 +0000 Subject: [PATCH 5/5] Match sv_enableBounces dvar flags --- src/Components/Modules/Elevators.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Components/Modules/Elevators.cpp b/src/Components/Modules/Elevators.cpp index 38c69282..f297f48a 100644 --- a/src/Components/Modules/Elevators.cpp +++ b/src/Components/Modules/Elevators.cpp @@ -42,8 +42,7 @@ namespace Components Dvar::OnInit([] { Elevators::SV_DisableElevators = Game::Dvar_RegisterBool("sv_disableElevators", - false, Game::DVAR_FLAG_CHEAT | Game::DVAR_FLAG_REPLICATED, - "Disable elevators"); + false, Game::DVAR_FLAG_REPLICATED, "Disable elevators"); }); // Hook PM_GroundTrace so me way skip PM_CorrectAllSolid (disable elevators)