Code:
// [iw4mp.exe+0x1AABE1]
WriteProcessMemory(hProc, (LPVOID)0xB35980, &recoilAmount, (DWORD)sizeof (recoilAmount), NULL); // this is where we write the memory to prevent recoil effect
if(recoilAmount == 0) // if success
{
std::clog << "\n\n\nSUCCESS :: Process memory written - Your stats should be changed" << std::endl; // print succes
}
hmm ? recoilAmount is the buffer which contains the data that will be written to the process & address you specify.
WriteProcessMemory() returns zero if it failed else sucess. So to check whether it failed or succeeded you gotta check its return value.
Quick example( keep debug privilages in mind aswell ):
Code:
void main()
{
SetConsoleTitleA("Example");
HWND hWnd;
while( !( hWnd = FindWindow( "IW4", NULL ) ) )
Sleep( 100 );
printf( "MW2 Found\n" );
DWORD PID;
while( !( GetWindowThreadProcessId( hWnd, &PID ) ) )
Sleep( 100 );
printf( "Process ID Acquired\n" );
HANDLE hProcess;
while( !( hProcess = OpenProcess( PROCESS_ALL_ACCESS, 0, PID ) ) )
Sleep( 100 );
printf( "Handle Acquired\n" );
int Buffer = 0;
if( WriteProcessMemory( (HANDLE)hProcess, (PVOID)0xB35980, &Buffer, 4, 0 ) )
{
printf( "Success\n" );
}
else
{
LPVOID ErrorMessage;
FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), LANG_USER_DEFAULT, (LPSTR)&ErrorMessage, 0, NULL );
printf( "Error: %s\n", ErrorMessage );
}
CloseHandle( hProcess );
}