From 94f0869ad453a3598f42ec78832a4bd6c4273e6c Mon Sep 17 00:00:00 2001 From: ineedbots Date: Mon, 28 Jun 2021 21:00:41 -0600 Subject: [PATCH] Hooking script funcs and meths --- src/Components/Loader.cpp | 2 ++ src/Components/Modules/Script.cpp | 25 +++++++++++++++++++++++++ src/Components/Modules/Script.hpp | 14 ++++++++++++++ src/Game/Game.cpp | 8 ++++++++ src/Game/Game.hpp | 9 +++++++-- 5 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 src/Components/Modules/Script.cpp create mode 100644 src/Components/Modules/Script.hpp diff --git a/src/Components/Loader.cpp b/src/Components/Loader.cpp index 827812d..3f814e0 100644 --- a/src/Components/Loader.cpp +++ b/src/Components/Loader.cpp @@ -4,6 +4,7 @@ #include "Modules/Flags.hpp" #include "Modules/HelloWorld.hpp" #include "Modules/Logger.hpp" +#include "Modules/Script.hpp" namespace Components { @@ -39,6 +40,7 @@ namespace Components Loader::Register(new HelloWorld()); Loader::Register(new Logger()); Loader::Register(new Bots()); + Loader::Register(new Script()); Loader::Pregame = false; } diff --git a/src/Components/Modules/Script.cpp b/src/Components/Modules/Script.cpp new file mode 100644 index 0000000..7527ece --- /dev/null +++ b/src/Components/Modules/Script.cpp @@ -0,0 +1,25 @@ +#include "STDInclude.hpp" +#include "Script.hpp" + +namespace Components +{ + Game::xmethod_t* Script::Player_GetMethod_Hook(const char** name) + { + return Game::Player_GetMethod(name); + } + + Game::xfunction_t* Script::Scr_GetFunction_Hook(const char** name, int* isDev) + { + return Game::Scr_GetFunction(name, isDev); + } + + Script::Script() + { + Utils::Hook(0x46E9CB, Player_GetMethod_Hook, HOOK_CALL).install()->quick(); + Utils::Hook(0x46E7BF, Scr_GetFunction_Hook, HOOK_CALL).install()->quick(); + } + + Script::~Script() + { + } +} diff --git a/src/Components/Modules/Script.hpp b/src/Components/Modules/Script.hpp new file mode 100644 index 0000000..4b35023 --- /dev/null +++ b/src/Components/Modules/Script.hpp @@ -0,0 +1,14 @@ +#pragma once + +namespace Components +{ + class Script : public Component + { + public: + Script(); + ~Script(); + private: + static Game::xmethod_t* Player_GetMethod_Hook(const char**); + static Game::xfunction_t* Scr_GetFunction_Hook(const char**, int*); + }; +} diff --git a/src/Game/Game.cpp b/src/Game/Game.cpp index 24ce6e2..423f57b 100644 --- a/src/Game/Game.cpp +++ b/src/Game/Game.cpp @@ -27,9 +27,17 @@ namespace Game stringIndex_t* scr_const; bgs_s** bgs_ptr; + + + Player_GetMethod_t* Player_GetMethod; + Scr_GetFunction_t* Scr_GetFunction; void Init(GAMEEXE) { + Player_GetMethod = ASSIGN(Player_GetMethod_t*, 0x52E050); + Scr_GetFunction = ASSIGN(Scr_GetFunction_t*, 0x50D280); + + cls = ASSIGN(clientStatic_t*, 0x68A408); svs = ASSIGN(serverStatic_t*, 0xD35700); sv = ASSIGN(server_t*, 0xCD6180); diff --git a/src/Game/Game.hpp b/src/Game/Game.hpp index 6ca460c..d0c7c8e 100644 --- a/src/Game/Game.hpp +++ b/src/Game/Game.hpp @@ -32,8 +32,13 @@ namespace Game extern stringIndex_t* scr_const; extern bgs_s** bgs_ptr; + + typedef Game::xmethod_t* (Player_GetMethod_t)(const char**); + extern Player_GetMethod_t* Player_GetMethod; + typedef Game::xfunction_t* (Scr_GetFunction_t)(const char**, int*); + extern Scr_GetFunction_t* Scr_GetFunction; - void SV_ClientThink(Game::usercmd_s*, Game::client_t*); - void SV_DropClient(Game::client_t*, const char*); + extern void SV_ClientThink(Game::usercmd_s*, Game::client_t*); + extern void SV_DropClient(Game::client_t*, const char*); }