[ServerCommands] Fail hooks installed.
This commit is contained in:
parent
dcb6c2b9e8
commit
150790a279
@ -166,12 +166,12 @@ namespace Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CardTitles::ParseCustomTitles(char* msg)
|
void CardTitles::ParseCustomTitles(const char* msg)
|
||||||
{
|
{
|
||||||
char* playerTitle;
|
const char* playerTitle;
|
||||||
for (int i = 0; i < 18; i++)
|
for (int i = 0; i < 18; i++)
|
||||||
{
|
{
|
||||||
playerTitle = msg; // nullptr; // (msg, std::to_string(i).c_str());
|
playerTitle = Utils::Hook::Call<const char*(const char*, const char*)>(0x47C820)(msg, std::to_string(i).c_str());
|
||||||
|
|
||||||
if (playerTitle != nullptr)
|
if (playerTitle != nullptr)
|
||||||
{
|
{
|
||||||
|
@ -60,7 +60,7 @@ namespace Components
|
|||||||
public:
|
public:
|
||||||
static Game::dvar_t* CustomTitleDvar;
|
static Game::dvar_t* CustomTitleDvar;
|
||||||
|
|
||||||
static void ParseCustomTitles(char * msg);
|
static void ParseCustomTitles(const char * msg);
|
||||||
|
|
||||||
CardTitles();
|
CardTitles();
|
||||||
~CardTitles();
|
~CardTitles();
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
namespace Components
|
namespace Components
|
||||||
{
|
{
|
||||||
std::unordered_map < std::int32_t, std::function < bool(Command::Params*) > > ServerCommands::Commands;
|
std::unordered_map < std::int32_t, std::function < bool(Command::Params*) > > ServerCommands::Commands;
|
||||||
|
std::uint32_t ServerCommands::lastServerCommand;
|
||||||
|
|
||||||
void ServerCommands::OnCommand(std::int32_t cmd, std::function < bool(Command::Params*) > cb)
|
void ServerCommands::OnCommand(std::int32_t cmd, std::function < bool(Command::Params*) > cb)
|
||||||
{
|
{
|
||||||
@ -44,32 +45,55 @@ namespace Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*void __declspec(naked) OnServerCommandPreFailStub()
|
void __declspec(naked) ServerCommands::OnServerCommandPreFailStub()
|
||||||
{
|
{
|
||||||
static DWORD jmpAbove = 0x0059449F;
|
__asm
|
||||||
static DWORD jmpContinue = 0x00593C28;
|
{
|
||||||
|
mov lastServerCommand, ecx;
|
||||||
|
cmp ecx, 0x79;
|
||||||
|
|
||||||
__asm mov lastServerCommand, ecx;
|
jl above;
|
||||||
|
|
||||||
if (lastServerCommand > 0x79)
|
push 0x59449F;
|
||||||
__asm jmp jmpAbove;
|
retn;
|
||||||
else
|
|
||||||
__asm jmp jmpContinue;
|
above:
|
||||||
|
push 0x593C28;
|
||||||
|
retn;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnServerCommandFailPrint(int type, const char *trash, ...)
|
void ServerCommands::OnServerCommandFailPrint(int type, const char *trash, ...)
|
||||||
{
|
{
|
||||||
|
Command::ClientParams params(*Game::cmd_id);
|
||||||
const char *cmd = "";
|
const char *cmd = "";
|
||||||
|
|
||||||
for (int i = 1; i < Cmd_Argc(); i++)
|
for (int i = 1; i < params.length(); i++)
|
||||||
cmd = va("%s %s", cmd, Cmd_Argv(i));
|
cmd = Utils::String::VA("%s %s", cmd, params.get(i));
|
||||||
|
|
||||||
Com_Printf(type, "Unknown client game command: %i %s\n", lastServerCommand, cmd);
|
Game::Com_Printf(type, "Unknown client game command: %i %s\n", lastServerCommand, cmd);
|
||||||
}*/
|
}
|
||||||
|
|
||||||
|
void __declspec(naked) ServerCommands::OnServerCommandFailPrintStub()
|
||||||
|
{
|
||||||
|
__asm
|
||||||
|
{
|
||||||
|
call OnServerCommandFailPrint;
|
||||||
|
|
||||||
|
push 0x5944C0;
|
||||||
|
retn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ServerCommands::ServerCommands()
|
ServerCommands::ServerCommands()
|
||||||
{
|
{
|
||||||
|
// Server command receive hook
|
||||||
Utils::Hook(0x59449F, OnServerCommandStub).install()->quick();
|
Utils::Hook(0x59449F, OnServerCommandStub).install()->quick();
|
||||||
|
|
||||||
|
// Server command fail hooks
|
||||||
|
Utils::Hook(0x593C1F, OnServerCommandPreFailStub).install()->quick();
|
||||||
|
Utils::Hook(0x5944BB, OnServerCommandFailPrintStub).install()->quick();
|
||||||
|
Utils::Hook::Set(0x5944D3, 0xEB);
|
||||||
}
|
}
|
||||||
|
|
||||||
ServerCommands::~ServerCommands()
|
ServerCommands::~ServerCommands()
|
||||||
|
@ -14,5 +14,9 @@ namespace Components
|
|||||||
static std::unordered_map < std::int32_t, std::function < bool(Command::Params*) > > Commands;
|
static std::unordered_map < std::int32_t, std::function < bool(Command::Params*) > > Commands;
|
||||||
static bool OnServerCommand();
|
static bool OnServerCommand();
|
||||||
static void OnServerCommandStub();
|
static void OnServerCommandStub();
|
||||||
|
static void OnServerCommandPreFailStub();
|
||||||
|
static void OnServerCommandFailPrint(int type, const char * trash, ...);
|
||||||
|
static void OnServerCommandFailPrintStub();
|
||||||
|
static std::uint32_t lastServerCommand;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user