Locking WriteProcessMemory with a TickBox

06/11/2007 05:08 *M*#1
This is the code for one of the buttons in my app:

Code:
 Private Sub Command8_Click()
If Hooked = True Then
  WriteProcessMemory ProcessHandle, &580316, 386, 2, 0&
End If
End Sub
The problem is the memory address that I write to resets itself after a while and I have to click the button again, is there anyway to lock the memory address that I write to? Or just have the code refresh itself at a set interval?
I would like to achieve this with a tick box if possible
*M*
06/11/2007 07:45 Lowfyr#2
Quote:
Or just have the code refresh itself at a set interval?
this is how I freeze values, should work.
06/11/2007 08:32 neji#3
If you are familiar with API Hooking you can do a Hook on the WriteProcessMemory function and check if it is your Address that someone wants to write to.
If so, just block it.
06/11/2007 09:25 *M*#4
Thanks for you replies, I did a little more digging and came up with this

A timer which locks the code on:
Code:
Private Sub Timer2_Timer()
If Timer2.Enabled = True Then
Call Command8_Click
End If
End Sub
and Option buttons for on:

Code:
Private Sub Option2_Click()
Timer2.Enabled = True
End Sub
And Off

Code:
Private Sub Option1_Click()
Timer2.Enabled = False
If Hooked = True Then
  WriteProcessMemory ProcessHandle, &H555216, 0, 4, 0&
End If
End Sub
The off button turns off the timer and then sets the code back to its default value :D

You can lock this thread now if you see no use for it being open.
06/11/2007 09:55 wiz#5
That's lame. If you want a value to be frozen, then make the code (of the target) reflect it. Use code caves, hijack/nop/whatever the command that changes it.
06/11/2007 11:16 *M*#6
Quote:
Originally posted by wiz@Jun 11 2007, 09:55
That's lame. If you want a value to be frozen, then make the code (of the target) reflect it. Use code caves, hijack/nop/whatever the command that changes it.
w/e, I've only just started VB.