2021-02-27 15:40:51 -05:00
|
|
|
/*
|
|
|
|
Simple injector
|
|
|
|
Taken from GuidedHacking
|
|
|
|
*/
|
|
|
|
#include <Windows.h>
|
|
|
|
#include <TlHelp32.h>
|
|
|
|
|
|
|
|
DWORD GetProcId(const char* procName)
|
|
|
|
{
|
|
|
|
DWORD procId = 0;
|
|
|
|
HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
|
|
|
|
|
|
|
|
if (hSnap != INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
PROCESSENTRY32 procEntry;
|
|
|
|
procEntry.dwSize = sizeof(procEntry);
|
|
|
|
|
|
|
|
if (Process32First(hSnap, &procEntry))
|
|
|
|
{
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if (!_stricmp((const char*)procEntry.szExeFile, procName))
|
|
|
|
{
|
|
|
|
procId = procEntry.th32ProcessID;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} while (Process32Next(hSnap, &procEntry));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
CloseHandle(hSnap);
|
|
|
|
return procId;
|
|
|
|
}
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
const char* dllPath = "./CheatMenu.asi";
|
|
|
|
const char* procName = "gta_sa.exe";
|
|
|
|
DWORD procId = 0;
|
|
|
|
|
|
|
|
while (!procId)
|
|
|
|
{
|
|
|
|
procId = GetProcId(procName);
|
|
|
|
Sleep(30);
|
|
|
|
}
|
2021-03-14 16:54:55 -04:00
|
|
|
|
2021-02-27 15:40:51 -05:00
|
|
|
HANDLE hProc = OpenProcess(PROCESS_ALL_ACCESS, 0, procId);
|
|
|
|
|
|
|
|
if (hProc && hProc != INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
void* loc = VirtualAllocEx(hProc, 0, MAX_PATH, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
|
|
|
|
|
|
|
|
WriteProcessMemory(hProc, loc, dllPath, strlen(dllPath) + 1, 0);
|
|
|
|
|
|
|
|
HANDLE hThread = CreateRemoteThread(hProc, 0, 0, (LPTHREAD_START_ROUTINE)LoadLibraryA, loc, 0, 0);
|
|
|
|
|
|
|
|
if (hThread)
|
|
|
|
CloseHandle(hThread);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hProc)
|
|
|
|
CloseHandle(hProc);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|