[ServerCommands] Fail hooks installed.

This commit is contained in:
RektInator 2017-05-30 15:37:50 +02:00
parent dcb6c2b9e8
commit 150790a279
4 changed files with 45 additions and 17 deletions

View File

@ -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++)
{
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)
{

View File

@ -60,7 +60,7 @@ namespace Components
public:
static Game::dvar_t* CustomTitleDvar;
static void ParseCustomTitles(char * msg);
static void ParseCustomTitles(const char * msg);
CardTitles();
~CardTitles();

View File

@ -3,6 +3,7 @@
namespace Components
{
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)
{
@ -44,32 +45,55 @@ namespace Components
}
}
/*void __declspec(naked) OnServerCommandPreFailStub()
void __declspec(naked) ServerCommands::OnServerCommandPreFailStub()
{
static DWORD jmpAbove = 0x0059449F;
static DWORD jmpContinue = 0x00593C28;
__asm
{
mov lastServerCommand, ecx;
cmp ecx, 0x79;
__asm mov lastServerCommand, ecx;
jl above;
if (lastServerCommand > 0x79)
__asm jmp jmpAbove;
else
__asm jmp jmpContinue;
push 0x59449F;
retn;
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 = "";
for (int i = 1; i < Cmd_Argc(); i++)
cmd = va("%s %s", cmd, Cmd_Argv(i));
for (int i = 1; i < params.length(); 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()
{
// Server command receive hook
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()

View File

@ -14,5 +14,9 @@ namespace Components
static std::unordered_map < std::int32_t, std::function < bool(Command::Params*) > > Commands;
static bool OnServerCommand();
static void OnServerCommandStub();
static void OnServerCommandPreFailStub();
static void OnServerCommandFailPrint(int type, const char * trash, ...);
static void OnServerCommandFailPrintStub();
static std::uint32_t lastServerCommand;
};
}