diff --git a/src/component/cheats.cpp b/src/component/cheats.cpp new file mode 100644 index 0000000..0f684da --- /dev/null +++ b/src/component/cheats.cpp @@ -0,0 +1,90 @@ +#include + +#include +#include + +#include "key_catcher.hpp" + +namespace cheats +{ + game::dvar_t* cl_wallhack; + + __declspec(naked) void draw_red_box_stub() + { + __asm + { + push eax + mov eax, cl_wallhack + cmp byte ptr [eax + 12], 1 + pop eax + + je draw + + test byte ptr ds:0x8FF110, 0x10 + + push 0x430568 + retn + + draw: + push 0x43056A + retn + } + } + + __declspec(naked) void blind_eye_check_stub() + { + __asm + { + push eax + mov eax, cl_wallhack + cmp byte ptr [eax + 12], 1 + pop eax + + je draw + + test byte ptr [esi], 0x20 + jnz skipBecauseBlindeye + + jmp draw + + skipBecauseBlindeye: + push 0x5AA5A2 + retn + + draw: + push 0x05AA529 + retn + } + } + + class component final : public component_interface + { + public: + void post_unpack() override + { + cl_wallhack = game::Dvar_RegisterBool("cl_EnableCheats", false, game::DVAR_FLAG_NONE, "Enable FoF wallhack"); + + utils::hook::jump(0x430561, draw_red_box_stub); + utils::hook::nop(0x430566, 2); + + utils::hook::jump(0x5AA524, blind_eye_check_stub); + + add_cheat_commands(); + } + private: + static void add_cheat_commands() + { + key_catcher::on_key_press("Z", [](const game::LocalClientNum_t&) + { + game::Dvar_SetBool(cl_wallhack, true); + }); + + key_catcher::on_key_press("X", [](const game::LocalClientNum_t&) + { + game::Dvar_SetBool(cl_wallhack, false); + }); + } + }; +} + +REGISTER_COMPONENT(cheats::component) diff --git a/src/component/exploit.cpp b/src/component/exploit.cpp index db7f15b..ee96def 100644 --- a/src/component/exploit.cpp +++ b/src/component/exploit.cpp @@ -8,11 +8,11 @@ namespace exploit { - bool exploit = false; + game::dvar_t* cl_exploit; void cl_netchan_transmit_stub(int a1, unsigned char* data, int size) { - if (exploit) + if (cl_exploit->current.enabled) { data[1] = 0xAA; data[8] = 0x80; @@ -26,6 +26,8 @@ namespace exploit public: void post_unpack() override { + cl_exploit = game::Dvar_RegisterBool("cl_exploit", false, game::DVAR_FLAG_NONE, "Enable server freezer"); + add_exploit_commands(); add_key_hooks(); @@ -55,12 +57,12 @@ namespace exploit { command::add("exploit", [](const command::params&) { - exploit = true; + game::Dvar_SetBool(cl_exploit, true); }); command::add("undo_exploit", [](const command::params&) { - exploit = false; + game::Dvar_SetBool(cl_exploit, false); }); } }; diff --git a/src/component/key_catcher.cpp b/src/component/key_catcher.cpp index a37c074..5f8c17f 100644 --- a/src/component/key_catcher.cpp +++ b/src/component/key_catcher.cpp @@ -54,6 +54,11 @@ namespace key_catcher { cl_key_event_hook.create(0x4CD840, &cl_key_event_stub); } + + void pre_destroy() override + { + cl_key_event_hook.clear(); + } }; } diff --git a/src/game/symbols.hpp b/src/game/symbols.hpp index 7865ff3..7aca8d7 100644 --- a/src/game/symbols.hpp +++ b/src/game/symbols.hpp @@ -22,6 +22,8 @@ namespace game Dvar_RegisterString{0x4157E0}; WEAK symbol Dvar_RegisterFloat{0x4A5CF0}; + WEAK symbol Dvar_SetBool{0x46DD70}; + WEAK symbol Dvar_SetBoolByName{0x48C7D0}; WEAK symbol Key_GetBindingForCmd{0x47D300}; WEAK symbol Key_StringToKeynum{0x50A710}; // Virtual-Key Code @@ -29,10 +31,11 @@ namespace game WEAK symbol SV_Cmd_ArgvBuffer{0x4F6B00}; - WEAK symbol NET_OutOfBandPrint{0x496230}; + WEAK symbol NET_OutOfBandPrint{0x496230}; WEAK symbol Com_Quit_f{0x556060}; // Variables WEAK symbol cmd_args{0x1C96850}; WEAK symbol playerKeys{0xB3A38C}; + WEAK symbol server_remote{0xB3D370}; }