-
Автор темы
- #1
C:
#include <windows.h>
#include <shellapi.h>
#include <psapi.h>
char lua_script[] = "setGameSpeed(6.9)outputChatBox('simpl dimpl net popit',0,255,0)--[[";
char res_trigger[] = "...\\MTA\\mods\\deathmatch\\resources\\helpmanager\\\0";
char res_inject[] = "...\\MTA\\mods\\deathmatch\\resources\\votemanager\\\0";
#define SCRIPT_LENGTH sizeof(lua_script) - 1
char lua_pattern[] = "--[[\n SERVER AND CLIENT.\n\n Code for allowing this syntax: exports.resourceName:exportedFunctionName (...)";
SHFILEOPSTRUCT zalupa;
DWORD InjectLua()
{
if (sizeof(lua_pattern) - 1 < SCRIPT_LENGTH) return 0;
zalupa.pFrom = res_trigger;
SHFileOperation(&zalupa);
zalupa.pFrom = res_inject;
SHFileOperation(&zalupa);
HMODULE mh;
do { mh = GetModuleHandle("client.dll"); Sleep(69); } while (!mh);
MODULEINFO mi;
if (!GetModuleInformation((HANDLE)-1, mh, &mi, sizeof(mi))) return 0;
char* addr = mi.lpBaseOfDll;
int i = mi.SizeOfImage + 1;
int j = 0;
while (--i) { if (*(addr++) == lua_pattern[j]) { if (++j == SCRIPT_LENGTH) { addr -= SCRIPT_LENGTH; break; } } else j = 0; }
if (!i) return 0;
DWORD russia_win;
while (GetFileAttributes(res_trigger) == INVALID_FILE_ATTRIBUTES) { if (mh != GetModuleHandle("client.dll")) return 69; Sleep(1); }
VirtualProtect(addr, SCRIPT_LENGTH, PAGE_WRITECOPY, &russia_win);
memcpy(addr, lua_script, SCRIPT_LENGTH);
VirtualProtect(addr, SCRIPT_LENGTH, russia_win, &russia_win);
while (GetFileAttributes(res_inject) == INVALID_FILE_ATTRIBUTES) { if (mh != GetModuleHandle("client.dll")) return 69; Sleep(1); }
VirtualProtect(addr, SCRIPT_LENGTH, PAGE_WRITECOPY, &russia_win);
memcpy(addr, lua_pattern, SCRIPT_LENGTH);
VirtualProtect(addr, SCRIPT_LENGTH, russia_win, &russia_win);
while (mh == GetModuleHandle("client.dll")) Sleep(69);
return 69;
}
DWORD WINAPI Thread(LPVOID zv)
{
SetThreadPriority((HANDLE)-2, THREAD_PRIORITY_HIGHEST);
ZeroMemory(&zalupa, sizeof(zalupa));
zalupa.wFunc = FO_DELETE;
zalupa.fFlags = FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_SILENT;
zalupa.fAnyOperationsAborted = FALSE;
Sleep(6969);
while (InjectLua()) Sleep(69);
return 69;
}
BOOL WINAPI DllMain(HINSTANCE Xy, DWORD et, LPVOID a)
{ if (et == DLL_PROCESS_ATTACH) CreateThread(0, 0, Thread, Xy, 0, 0); return 1; }