I need help for console trainer. When I open the process to inject the trainer, it hides but doesn't change the values. If I suspend the process and I open the trainer, change the value, but If I don't suspend the process doesn't change the values...
This is the code, thank's for your help anybody answer...
PHP Code:
#include <Windows.h>
#include <stdio.h>
#include <cstdlib>
#include <iostream>
#include <tlhelp32.h>
#include <string>
#include <Psapi.h>
#pragma comment(lib,"psapi.lib")
using namespace std;
DWORD GetProcessIdByName(WCHAR* szExeName);
bool isRunning(string pName);
DWORD VARIABLE1 = 0x123456; // HIDDEN
DWORD VARIABLE2 = 0x123456; //HIDDEN
HANDLE hProcess = NULL;
DWORD dwProcessId = 0;
DWORD GetProcessIdByName(WCHAR* szExeName)
{
PROCESSENTRY32 pe = { sizeof(PROCESSENTRY32) };
HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if(Process32First(hSnapshot, &pe))
{
while(Process32Next(hSnapshot, &pe))
{
if(!wcscmp(pe.szExeFile, szExeName))
{
return pe.th32ProcessID;
}
}
}
return NULL;
}
bool isRunning(string pName)
{
unsigned long aProcesses[1024], cbNeeded, cProcesses;
if(!EnumProcesses(aProcesses, sizeof(aProcesses), &cbNeeded))
return false;
cProcesses = cbNeeded / sizeof(unsigned long);
for(unsigned int i = 0; i < cProcesses; i++)
{
if(aProcesses[i] == 0)
continue;
HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, 0, aProcesses[i]);
char buffer[50];
GetModuleBaseNameA(hProcess, 0, buffer, 50);
CloseHandle(hProcess);
if(pName == string(buffer))
return true;
}
return false;
}
int main()
{
system("color a");
cout << "**************************\n"
"Welcome to Unknown Project\n"
"**************************\n\n"
"Waiting for S4Client.exe...\n";
while(isRunning("S4Client.exe")==false){}
cout << "S4Client found\n";
cout << "Writing...";
Sleep(500);
dwProcessId = GetProcessIdByName(L"S4Client.exe");
if(dwProcessId == 0) { return 0; }
hProcess = OpenProcess(PROCESS_ALL_ACCESS, false, dwProcessId);
DWORD Value1 = /* HIDDEN */;
DWORD Value2 = /* HIDDEN */;
WriteProcessMemory(hProcess,(LPVOID)VARIABLE1,(LPVOID)&Value1,sizeof(&Value1),NULL);
WriteProcessMemory(hProcess,(LPVOID)VARIABLE2,(LPVOID)&Value2,sizeof(&Value2),NULL);
}