Reputation: 1148
I've successfully implemented the WriteProcessMemory function in vb.net (WOOP!). However when I try and change a value it sometimes is automatically changed back to it's previous value. I'd like a way to lock and unlock these values if possible.
Here's the code the changes the values:
_memManager.TryAttachToProcess("SomeAPP")
Dim bytes() As Byte = _memManager.ReadBytes(xpos(0), 4)
Dim currentx As Double = BitConverter.ToSingle(bytes, 0)
Dim targetx As Double = currentx + 2
bytes = BitConverter.GetBytes(targetx)
For i = 0 To xpos.GetLength(0) - 1
_memManager.WriteBytes(xpos(i), bytes.Length, bytes)
Next
_memManager.DetachFromProcess()
RichTextBox1.AppendText("compleate" & Chr(13))
Any help/advice or links would be great!
Upvotes: 1
Views: 238
Reputation: 6375
I believe what those "gamehack" - programs usually do is just changing the values on a timer. Say the memory value gets set to the new values every 100ms or so. The program you are trying to target may have anti-temper mechanics in it that uses for example multiple variables for 1 value. it can't reset to the previous value if that value isn't stored somewhere else, maybe you should find this location and change the value there as well. I don't believe you can really permanently lock write-access to part of some other programs memory, but i may be wrong there. I guess the target would just instantly crash with a memory corruption error.
Upvotes: 2