2022-02-27 07:53:44 -05:00
|
|
|
#include <STDInclude.hpp>
|
2017-05-30 08:29:09 -04:00
|
|
|
|
|
|
|
namespace Components
|
|
|
|
{
|
2017-06-04 08:21:02 -04:00
|
|
|
std::unordered_map<std::int32_t, Utils::Slot<bool(Command::Params*)>> ServerCommands::Commands;
|
2017-05-30 08:29:09 -04:00
|
|
|
|
2017-06-04 08:21:02 -04:00
|
|
|
void ServerCommands::OnCommand(std::int32_t cmd, Utils::Slot<bool(Command::Params*)> cb)
|
2017-05-30 08:29:09 -04:00
|
|
|
{
|
2017-05-31 04:42:43 -04:00
|
|
|
ServerCommands::Commands[cmd] = cb;
|
2017-05-30 08:29:09 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ServerCommands::OnServerCommand()
|
|
|
|
{
|
2022-03-17 14:50:20 -04:00
|
|
|
Command::ClientParams params;
|
2017-05-30 08:29:09 -04:00
|
|
|
|
2022-03-17 14:50:20 -04:00
|
|
|
for (const auto& serverCommandCB : ServerCommands::Commands)
|
2017-05-30 08:29:09 -04:00
|
|
|
{
|
2022-03-17 14:50:20 -04:00
|
|
|
if (params.size() >= 1)
|
2017-05-30 08:29:09 -04:00
|
|
|
{
|
2017-05-31 04:42:43 -04:00
|
|
|
if (params.get(0)[0] == serverCommandCB.first)
|
2017-05-30 08:29:09 -04:00
|
|
|
{
|
2017-05-31 04:42:43 -04:00
|
|
|
return serverCommandCB.second(¶ms);
|
2017-05-30 08:29:09 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-05-31 04:42:43 -04:00
|
|
|
__declspec(naked) void ServerCommands::OnServerCommandStub()
|
2017-05-30 08:29:09 -04:00
|
|
|
{
|
|
|
|
__asm
|
|
|
|
{
|
2017-05-31 04:42:43 -04:00
|
|
|
push eax
|
|
|
|
pushad
|
|
|
|
call ServerCommands::OnServerCommand
|
2017-06-14 06:06:04 -04:00
|
|
|
mov [esp + 20h], eax
|
2017-05-31 04:42:43 -04:00
|
|
|
popad
|
|
|
|
pop eax
|
2017-05-30 08:29:09 -04:00
|
|
|
|
2017-05-31 04:42:43 -04:00
|
|
|
test al, al
|
|
|
|
jnz jumpback
|
|
|
|
|
2017-06-01 08:26:38 -04:00
|
|
|
test eax, eax
|
|
|
|
jle error
|
|
|
|
|
|
|
|
mov eax, DWORD PTR[edx * 4 + 1AAC634h]
|
|
|
|
mov eax, [eax]
|
|
|
|
|
|
|
|
push 5944B3h
|
|
|
|
retn
|
|
|
|
|
|
|
|
error:
|
2017-05-31 04:42:43 -04:00
|
|
|
push 5944AEh
|
|
|
|
retn
|
2017-05-30 08:29:09 -04:00
|
|
|
|
|
|
|
jumpback:
|
2017-05-31 04:42:43 -04:00
|
|
|
push 594536h
|
|
|
|
retn
|
2017-05-30 08:29:09 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ServerCommands::ServerCommands()
|
|
|
|
{
|
2017-06-01 16:23:26 -04:00
|
|
|
// Server command receive hook
|
|
|
|
Utils::Hook(0x59449F, ServerCommands::OnServerCommandStub).install()->quick();
|
2017-05-30 08:29:09 -04:00
|
|
|
}
|
|
|
|
}
|