This is my first tutorial for Unknown Cheats, the people here are so nice.
So heres me giving back.
http://www.codeproject.com/KB/trace/...oryreader.aspx
That is a good read to get you started with the MemoryProcessReaderLib
It has a hook and its pre-setup to call the Win32 C++ WriteProcessMemory and ReadProcessMemory.
Now for the start of your class. You will need to add these using Statements.
Code:
using System.Diagnostics;
using ProcessMemoryReaderLib;
At the beginning of your partial class (if you are doing this in a windows form) add these:
Code:
ProcessMemoryReader Reader = new ProcessMemoryReader();
Process[] MyProcess = Process.GetProcessesByName("GAME");// Do Not Include the .exe part
ProcessModule mainModule;
int GAMEBaseAddress; // Base Address
int bytesReadSize; // out Value not used
Where ever you have your C# dll or Form in my case loaded add code like this.
Code:
private void Form1_Load(object sender, EventArgs e)
{
try
{
mainModule = MyProcess[0].MainModule;
GAMEBaseAddress = (int)mainModule.BaseAddress;//get base address
Reader.ReadProcess = MyProcess[0];
Reader.OpenProcess();
}
catch (Exception)
{
MessageBox.Show("Please Start GAMENAME\nBefore running this hack.", "Error: 120");//dont run unles the game is running
Application.Exit();
}
}
Now you are able to do what ever you would nomally do in C++, just with a twist.
For something like a loop on its own thread I would reccomend Timers set to around 100-200ms.
For an example I will just use a button to make things simpler:
Code:
byte[] health;
health = Reader.ReadProcessMemory((IntPtr)(GAMEBaseAddress + 0xA3DA3C), 4, out bytesReadSize);
It follows this, ReadProcessMemory((IntPtr)(Address), sizeof, out bytesReadSize);
For Writeprocessmemory its simple the same.
Code:
Reader.WriteProcessMemory((IntPtr)(GAMEBaseAddress + 0x75D534), BitConverter.GetBytes((float)10), out bytesReadSize); // Writes a int32, BitConverter Converts it to a byte array which can be writen.
WriteProcessMemory Follows this ((IntPtr)Address, Value2Write, out BytesReadSize)
You can do many diffrent types of pointers with this simple method aswell, I am not 100% sure how to do pointers but this method works just fine.
Code:
int pointer1 = BitConverter.ToInt32(Reader.ReadProcessMemory((IntPtr)(GAMEBaseAddress + 0xA3DA3C), 4, out bytesReadSize), 0);
Reader.WriteProcessMemory((IntPtr)(pointer1 + 0x75D5E8), BitConverter.GetBytes((float)8), out bytesReadSize);
I hope this helps someone, Thank you Unknown-Cheats for helping me with an assortment of C++ problems (I'm not too perfect with C++ like I am with C#)