Hooking script funcs and meths

This commit is contained in:
ineedbots 2021-06-28 21:00:41 -06:00
parent a9fe1047bd
commit 94f0869ad4
5 changed files with 56 additions and 2 deletions

View File

@ -4,6 +4,7 @@
#include "Modules/Flags.hpp" #include "Modules/Flags.hpp"
#include "Modules/HelloWorld.hpp" #include "Modules/HelloWorld.hpp"
#include "Modules/Logger.hpp" #include "Modules/Logger.hpp"
#include "Modules/Script.hpp"
namespace Components namespace Components
{ {
@ -39,6 +40,7 @@ namespace Components
Loader::Register(new HelloWorld()); Loader::Register(new HelloWorld());
Loader::Register(new Logger()); Loader::Register(new Logger());
Loader::Register(new Bots()); Loader::Register(new Bots());
Loader::Register(new Script());
Loader::Pregame = false; Loader::Pregame = false;
} }

View File

@ -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()
{
}
}

View File

@ -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*);
};
}

View File

@ -28,8 +28,16 @@ namespace Game
bgs_s** bgs_ptr; bgs_s** bgs_ptr;
Player_GetMethod_t* Player_GetMethod;
Scr_GetFunction_t* Scr_GetFunction;
void Init(GAMEEXE) void Init(GAMEEXE)
{ {
Player_GetMethod = ASSIGN(Player_GetMethod_t*, 0x52E050);
Scr_GetFunction = ASSIGN(Scr_GetFunction_t*, 0x50D280);
cls = ASSIGN(clientStatic_t*, 0x68A408); cls = ASSIGN(clientStatic_t*, 0x68A408);
svs = ASSIGN(serverStatic_t*, 0xD35700); svs = ASSIGN(serverStatic_t*, 0xD35700);
sv = ASSIGN(server_t*, 0xCD6180); sv = ASSIGN(server_t*, 0xCD6180);

View File

@ -33,7 +33,12 @@ namespace Game
extern bgs_s** bgs_ptr; extern bgs_s** bgs_ptr;
typedef Game::xmethod_t* (Player_GetMethod_t)(const char**);
extern Player_GetMethod_t* Player_GetMethod;
void SV_ClientThink(Game::usercmd_s*, Game::client_t*); typedef Game::xfunction_t* (Scr_GetFunction_t)(const char**, int*);
void SV_DropClient(Game::client_t*, const char*); extern Scr_GetFunction_t* Scr_GetFunction;
extern void SV_ClientThink(Game::usercmd_s*, Game::client_t*);
extern void SV_DropClient(Game::client_t*, const char*);
} }