I have been learning about memory. Slowly it is coming together but I am still have problems. I made a simple app that stores a value in a variable. A loop then starts and in that loop I use Bool to switch back and forth adding 1 to variable and then changing it back by subtract 1. I made it continue to switch so I could find its location in memory. I found it with no problems.
Its location:
Hex 0014E618
Dec 1369624
Just so you can check me if needed here is simple app:
VB Code:
Dim trigger As Boolean Dim looper As Boolean Dim counter As Integer Private Sub Command1_Click() Wait 4 trigger = False looper = False counter = 9022 'store value Do While trigger = False If looper = False Then counter = counter + 1 ' now is 9023 Me.Print counter ' show me looper = True Else counter = counter - 1 ' next value back to original Me.Print counter ' show me looper = False End If Wait 5 Form1.Cls Loop End Sub
Now I know the location of this variable in memory. I try to use CopyMemory to change the value like so...
VB Code:
Option Explicit Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (dest As Any, source As Any, ByVal bytes As Long) Dim intValue As Long Private Sub Command1_Click() Wait 4 Dim address As Long address = 1369624 'decimal form intValue = 4444 ' new value CopyMemory address, intValue, 4 End Sub
I have tried..
VB Code:
CopyMemory byval address, intValue, 4
but all I get is a crash.
Any suggestions would be great! TY^^




Reply With Quote