No Recoil

Posts 1–6 of 6 · Page 1 of 1
No Recoil
Ok, so I can't get no recoil to work with my current code. Can anyone help? I don't know what value to set the address and I also don't know if the address is correct. This is fourDeltaOne by the way. Another problem I have is checking if the value is correct, there's an if statement on line 43. Here's the current code:

Code:
// MW2_NoRecoil.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <Windows.h>
#include <iostream>

void pauseScreen();		// prototype

int _tmain(int argc, _TCHAR* argv[])		// main method
{
	int recoilAmount = 0;		// a variable to disable recoil, takes effect in WriteProcessMemory()

	SetConsoleTitle(L"MW2 fourDeltaOne No Recoil - by LEGiiTxCHAOTiiC / Piggy");			// title of CMD window

	HWND hWnd = FindWindow(NULL, TEXT("Modern Warfare 2"));	// find the 4D1 window

	if(hWnd == NULL)	// if unable to find window
	{
		std::cerr << "\n\n\nERROR :: Cannot find fourDeltaOne window" << std::endl;		// print error
	}

	else				// if able to find window
	{
		std::cout << "Welcome to MW2 fourDeltaOne No Recoil!" << std::endl;		// intro message

		DWORD pId;		// process id

		GetWindowThreadProcessId(hWnd, &pId);	// get the window's process id

		HANDLE hProc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pId);		// open 4D1 process

		if(!hProc)		// if can't open 4D1 process
		{
			std::cerr << "\n\n\nERROR :: Cannot open process" << std::endl;		// print error
		}

		else		// if it works
		{
			// [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
			}

			else	// if fail
			{
				std::cerr << "\n\n\nERROR :: Process write failure - Cannot change your stats" << std::endl;	// print error
			}
			CloseHandle(hProc);		// unhook from mw2
		}
	}
	pauseScreen();

	return 0;
}

void pauseScreen()		// pause console to allow user to see output
{
	std::cout << "\n\n\nPress <Enter> to continue..." << std::endl;
	std::cin.clear();
	std::cin.ignore();
}
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 );
}
Can't think of any OS where the base + offset would result in that address..
Quote Originally Posted by aIW|Convery View Post
Can't think of any OS where the base + offset would result in that address..
How should it work then, without typing it out for me, explain? I'm a C#/Java/Python/Ruby programmer, I don't use C++ alot, only C when I need to.
Use C#/Java/Python/Ruby then..
Also the offset your patching is recoil angles, youd have to put in a loop and constantly overwrite 0 to get no recoil. Its probably detected aswell. There are easier ways to do no recoil, go analyse.
Posts 1–6 of 6 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

Talk with us