Accessing an Address in memory

Elsys

Member
Joined
Jan 7, 2007
Messages
11
Programming Experience
Beginner
I had previously used another basic like programing language that combined delphi and vb but it was not multi threaded so I began to rewrite the application in VB.NET because I heard it was fairly easy to pick up and implement. I do not intend to develop web applications though the prospect of doing such might entice me to develop such an application in the future.

My question is my program is intended to modify another program send keystrokes and such its a macro utility designed for an internet game. I previously had used pixel detection in my utility though this method isn't as reliable as reading memory directly.

I would like to know how I can read the value of an address in the memory of my target process and based on that information perform a task. I want to read the address and have the value that is searched for be defined by an input box such as.

If Address's current value is X then perform said action. X being the variable I set as the value to look for. Put this into a loop so that it is checked often. I have hotkeys set up for my functions.

I would also like to know how to save a variable's current value into an ini file the filename being defined by a save as dialog so as to make several different configuration files for my program based on the users options

Say user puts a said function to send a key the key being the variable and I would like to save these keys and delay values for my timer functions to an ini file as a form of configuration save proceedure and then open the file and read from it when they restart the application as all variable values will be lost on exit.
 
I found some code from an open source game cheater program that might help me if I cut down the fat so to speak.

VB.NET:
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Long, ByVal lpBaseAddress As Any, ByVal lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long

Public myHandle As Long

Function InitProcessCheater(pid As Long)

pHandle = OpenProcess(&H1F0FFF, False, pid)

If (pHandle = 0) Then
    InitProcessCheater = False
    myHandle = 0
Else
    InitProcessCheater = True
    myHandle = pHandle
End If

End Function

Dim addr As Long
Dim buffer As String * 5000
Dim readlen As Long

Call ReadProcessMemory(myHandle, addr * 5000, buffer, 5000, readlen)

I do not need to have the address stored as a variable it can go straight into the call as I already know what address's I would like to read. Same with the process I already know what process I would like to read still need to grab the pid of course but this is all the code from the project which looked useful to my needs with a little modification of course.
 
Back
Top