« on: December 19, 2009, 10:55:40 PM »
first things first; you need an address ( position in the memory of the game ) where a value is stored. You can use memory scanners like Cheat Engine to get this address.
Let's start.
first you need some code to get access to the process. Here's a function you can use. Remember to change the FindWindow parameter to the correct window name. ( This code should be placed above all other cores or declared in the header file. )
DWORD pID;
HANDLE hProcess;
void OpenMemory()
{
HWND hWindow = FindWindow(0, "AirRivals_R");
GetWindowThreadProcessId(hWindow, &pID);
hProcess = OpenProcess(PROCESS_VM_READ|PROCESS_VM_WRITE|PROCESS_VM_OPERATION, false, pID);
}
Now you can add some buttons on your form and double click on one, you'll see the code which will occur on an event.
void __fastcall TForm1::Button1Click(TObject *Sender)
{
}
Between the codeblock( { -> } ) you can place your specified code which will be executed while pressing the button.
to write a value into the game memory we will have to know what type of value and declare a variable of that type. Here's an example of an integer / float value.
void __fastcall TForm1::Button1Click(TObject *Sender)
{
//declare variables + assign values
float value1 = Edit1->Textc.ToDouble( );
int value2 = Edit2->Textc.ToInt( );
unsigned short value3 = Edit3->Textc.ToInt( );
unsigned char value4 = Edit4->Textc.ToInt( );
//open our target process
OpenProcessMemory( );
//write values to target process
// WriteProcessMemory( Process handle, address, value, bytes of value ( sizeof or actual bytes ), NULL );
//Float value
WriteProcessMemory( hProcess, (LPVOID*)(DWORD)0x400000, &value1, sizeof(value1), NULL ); //bytes of valuetype => 4
//Integer Value
WriteProcessMemory( hProcess, (LPVOID*)(DWORD)0x400000, &value2, sizeof(value2), NULL ); //bytes of valuetype => 4
//2 Bytes
WriteProcessMemory( hProcess, (LPVOID*)(DWORD)0x400000, &value3, 2, NULL ); //bytes of valuetype => 2
//1 Byte
WriteProcessMemory( hProcess, (LPVOID*)(DWORD)0x400000, &value4, 1, NULL ); //bytes of valuetype => 1
}
It's not a noob friendly tutorial, so ask questions if you got some, I am too lazy to type a nice tutorial....