Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define WIN32_LEAN_AND_MEAN
- #define VC_EXTRALEAN
- #include <Windows.h>
- #include <string>
- #define GMMODULE
- #include "Interface.h"
- void *sigscan(const char *sig, void *_base)
- {
- char *base = (char *)_base;
- while (!IsBadCodePtr((FARPROC)base))
- {
- const char *cursig = sig;
- char *curbase = base;
- while (!IsBadCodePtr((FARPROC)curbase))
- {
- if (*cursig == 0)
- return base;
- if (*cursig != '?' && *cursig != *curbase)
- break;
- cursig++;
- curbase++;
- }
- base++;
- }
- return 0;
- }
- char newmessage[128] = "Disconnect by user.";
- int SetDisconnectMessage(lua_State *state)
- {
- strcpy_s(newmessage, sizeof(newmessage), LUA->GetString(1));
- return 0;
- }
- GMOD_MODULE_OPEN()
- {
- // search for "Disconnect by user" xrefs for the sig
- const char ** message = reinterpret_cast<const char **>(
- reinterpret_cast<char *>(sigscan("\x68????\xFF\xD2\x89\x7E\x10\x5F\x5E\x8B\xE5\x5D\xC2\x08\x00", GetModuleHandleA("engine.dll"))) + 1
- );
- DWORD old_prot;
- VirtualProtect(message, sizeof(*message), PAGE_EXECUTE_READWRITE, &old_prot);
- *message = newmessage;
- VirtualProtect(message, sizeof(*message), old_prot, &old_prot);
- LUA->PushCFunction(&SetDisconnectMessage);
- LUA->SetField(-10002, "SetDisconnectMessage");
- return 0;
- }
- GMOD_MODULE_CLOSE() { return 0; }
Advertisement
Add Comment
Please, Sign In to add comment