Adding more GM Commands

Zhein

Member
Joined
Dec 17, 2023
Messages
21
Hi, as the title says, is it possible to modify the game.exe and add more GM commands or commands for players to use just like /wings on and /wings off.
 
yeah. pass the chat text to a function and create an argument vector. then, use the size() method to get the argument count. figure out how to check authorization client-side and server-side. i would check both and dc them if the server-side check fails.

i'm sure this could be better, but it's a simple enough example to get anyone started. the game.exe version is 0x16021200. if it's just an on/off command you can evaluate the whole string if you want.

C++:
#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);
}
 
does this send a packet to the server as well? I am actually planning to add "/call" similar to EG but in EP4.5 to EP6 clients.
 
Back
Top