WriteProcessMemory() on keystroke?
Hey guys, again another newb question, search it a ton, but can't find an answer i want to know how to writeprocessmemory() on a keystroke i tried GetAsyncKeyState() from a tutorial here at MPGH.
This is my code:
Code:
#include <iostream>
#include <windows.h>
using namespace std;
DWORD proc_id;
HANDLE hProcess;
int main()
{
void CALLBACK PollKeys (HWND hWnd,UINT uMsg,UINT idEvent,DWORD dwTime);
{
if (GetAsyncKeyState(VK_F4)) // if F12 is down or was down since the last call
{
int ammo(); // call the trainer engine
}
}
void CALLBACK PollKeys (HWND hWnd,UINT uMsg,UINT idEvent,DWORD dwTime);
{
if (GetAsyncKeyState(VK_F5)) // if F12 is down or was down since the last call
{
int health(); // call the trainer engine
}
}
}
int ammo()
{
HWND hWnd = FindWindow(0, "Modern Warfare 2");
GetWindowThreadProcessId(hWnd, &proc_id);
hProcess = OpenProcess(PROCESS_ALL_ACCESS|PROCESS_VM_OPERATION|PROCESS_VM_READ|PROCESS_VM_WRITE|PROCESS_QUERY_INFORMATION, FALSE, proc_id);
BYTE Nop[] = {0x90, 0x90, 0x90, 0x90};
WriteProcessMemory(hProcess, (LPVOID*)(DWORD) (0x004C6E0D), &Nop, sizeof(Nop), NULL); //health 0048286b
}
int health()
{
HWND hWnd = FindWindow(0, "Modern Warfare 2");
GetWindowThreadProcessId(hWnd, &proc_id);
hProcess = OpenProcess(PROCESS_ALL_ACCESS|PROCESS_VM_OPERATION|PROCESS_VM_READ|PROCESS_VM_WRITE|PROCESS_QUERY_INFORMATION, FALSE, proc_id);
BYTE Nop2[] = {0x90, 0x90, 0x90, 0x90, 0x90};
WriteProcessMemory(hProcess, (LPVOID*)(DWORD) (0x0048286b), &Nop2, sizeof(Nop2), NULL);
}
WTF? WOOT FIRST POST. And. the anwer to that question is... ASK SOMEONE ELSE!
C&P -.-'' you guys never learn
It's called a loop. C++ 101.