This is a module to help read values in memory from a chosen process.
VB Code:
Module Module1 Public Const PROCESS_ALL_ACCESS = &H1F0FFF 'This above code makes it work on Windows XP Public Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hWnd As Long, ByVal lpdwProcessId As Long) As Long Public Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long Public Declare Function WriteProcessMemory Lib "kernel32" (ByVal hProcess As Long, ByVal lpBaseAddress As Integer, ByVal lpBuffer As Integer, ByVal nSize As Long, ByVal lpNumberOfBytesWritten As Long) As Long Public Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal Classname As String, ByVal WindowName As String) As Long Public Declare Function ReadProcessMem Lib "kernel32" Alias "ReadProcessMemory" (ByVal hProcess As Long, ByVal lpBaseAddress As Integer, ByRef lpBuffer As Integer, ByVal nSize As Long, ByVal lpNumberOfBytesWritten As Long) As Long Public Function ReadFour(ByVal GameClass As String, ByVal Address As Long, ByVal valbuffer As Long) Dim hWnd As Long Dim pId As Long Dim phandle As Long hWnd = FindWindow(GameClass, vbNullString) If (hWnd = 0) Then [COLOR=red]frmmain[/COLOR].lbl_debug.Caption = "Debug: Please Run x and restart the application." Exit Function End If GetWindowThreadProcessId(hWnd, pId) phandle = OpenProcess(PROCESS_ALL_ACCESS, False, pId) If (phandle = 0) Then MsgBox("Can't get ProcessId", vbCritical, "Error") Exit Function End If ReadProcessMem(phandle, Address, valbuffer, 4, 0&) CloseHandle([COLOR=red]hProcess[/COLOR]) End Function End Module
I put in red the places that Visual studio is reporting errors. Anyone have any ideas? (I'm using VS.NET 2003)
The author then suggest a possible use for this module:
Get the CLASS NAME of your game.. and now ..
go to your form.
Add a timer and a textbox or label. I suggest label.. its cleaner..
we are going to call our timer Timer1
Timer1_Timer()
Call Module1.ReadMorph("Game Class Name", &HAddress, variable)
'Im using a label for this example
Label1.caption = variable
End Sub
There you go!
Simple code so that you can read an address and put its value in a label or textbox ect ect.
Hope that was educational/helpful.




Reply With Quote