#include <sstream>
#include <string>
#include <vector>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <include/main.h>
#include <include/util.h>
using namespace shaiya;
int command_handler(char* text)
{
std::istringstream iss(text);
std::vector<std::string> argv;
for (std::string str; std::getline(iss, str, ' '); )
argv.push_back(str);
if (argv.empty())
return 0;
auto argc = argv.size();
if (iss.str() == "/example on")
{
// do something
return 0;
}
if (iss.str() == "/example off")
{
// do something
return 0;
}
if (argv[0] == "/example")
{
if (argc != 2)
{
// wrong number of arguments
return 0;
}
auto arg1 = argv[1];
// do something
return 0;
}
return 1;
}
unsigned u0x4867A6 = 0x4867A6;
unsigned u0x487532 = 0x487532;
void __declspec(naked) naked_0x4867A1()
{
__asm
{
pushad
push edi // text
call command_handler
add esp,0x4
test eax,eax
popad
je _0x487532
// original
push 0x13D4
jmp u0x4867A6
_0x487532:
jmp u0x487532
}
}
void hook::chat()
{
// command handler
util::detour((void*)0x4867A1, naked_0x4867A1, 5);
}