Currently I'm writing a game trainer using C# (note that I'm only making one for fun, for a private server, and NOT for hacking the game to become the "best player ever") and it's working smoothly, but not the string.
When I write the string for the first time and I have 10 chars, it's working (it'll write for example: hellolady!). When I type 8 chars (for example hellolol) it will automatically write 10 chars, so the new string would be hellololy!.
I don't know why I get the problem, this is my WriteString:
public static bool WriteString(IntPtr handle, int address, string value)
{
int written;
byte[] data = Encoding.Default.GetBytes(value);
return WriteProcessMemory(handle, address, data, data.Length, out written);
}
My WriteProcessMemory:
[DllImport("Kernel32.dll")]
static extern bool WriteProcessMemory(IntPtr handle, int lpBaseAddress, byte[] lpBuffer, int nSize, out int lpNumberOfBytesWritten);
Hopefully somebody can help me with it.