Code:
'module
Option Explicit
Public Const PROCESS_ALL_ACCESS = &H1F0FFF
Public Declare Function GetWindowThreadProcessId Lib "user32" (ByVal SomeValueIsStoredHere As Long, 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 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 Any, ByRef lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
Public Declare Function WriteProcessMemory Lib "KERNEL32" (ByVal hProcess As Long, ByVal lpBaseAddress As Any, lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
Global ProcessHandle As Long
Global WindowHandle As Long
' $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
' $$$ Read_DMA_Address |Pointer & Offset| $$$
' $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
Public Function Read_DMA_Byte(Address As Long, Offset As Long) As Byte
Dim ProcessId As Long
WindowHandle = FindWindow(vbNullString, "Age of Conan")
If (WindowHandle = 0) Then
MsgBox "We got no WindowHandle"
Exit Function
End If
GetWindowThreadProcessId WindowHandle, ProcessId
ProcessHandle = OpenProcess(PROCESS_ALL_ACCESS, False, ProcessId)
If (ProcessHandle = 0) Then
MsgBox "We got no ProcessHandle"
Exit Function
End If
ReadProcessMem ProcessHandle, Address + Offset, Read_DMA_Byte, 1&, 0&
CloseHandle ProcessHandle
End Function
Public Function Read_DMA_Integer(Address As Long, Offset As Long) As Integer
Dim ProcessId As Long
WindowHandle = FindWindow(vbNullString, "Age of Conan")
If (WindowHandle = 0) Then
MsgBox "We got no WindowHandle"
Exit Function
End If
GetWindowThreadProcessId WindowHandle, ProcessId
ProcessHandle = OpenProcess(PROCESS_ALL_ACCESS, False, ProcessId)
If (ProcessHandle = 0) Then
MsgBox "We got no ProcessHandle"
Exit Function
End If
ReadProcessMem ProcessHandle, Address + Offset, Read_DMA_Integer, 2&, 0&
CloseHandle ProcessHandle
End Function
Public Function Read_DMA_Long(Address As Long, Offset As Long, Optional offset2 As Long, Optional offset3 As Long) As Long
Dim ProcessId As Long
WindowHandle = FindWindow(vbNullString, "Age of Conan")
If (WindowHandle = 0) Then
MsgBox "We got no WindowHandle"
Exit Function
End If
GetWindowThreadProcessId WindowHandle, ProcessId
ProcessHandle = OpenProcess(PROCESS_ALL_ACCESS, False, ProcessId)
If (ProcessHandle = 0) Then
MsgBox "We got no ProcessHandle"
Exit Function
End If
ReadProcessMem ProcessHandle, Address + Offset, Read_DMA_Long, 4&, 0&
CloseHandle ProcessHandle
End Function
Public Function Read_DMA_Single(Address As Long, Offset As Long) As Single
Dim ProcessId As Long
WindowHandle = FindWindow(vbNullString, "Age of Conan")
If (WindowHandle = 0) Then
MsgBox "We got no WindowHandle"
Exit Function
End If
GetWindowThreadProcessId WindowHandle, ProcessId
ProcessHandle = OpenProcess(PROCESS_ALL_ACCESS, False, ProcessId)
If (ProcessHandle = 0) Then
MsgBox "We got no ProcessHandle"
Exit Function
End If
ReadProcessMem ProcessHandle, Address + Offset, Read_DMA_Single, 4&, 0&
CloseHandle ProcessHandle
End Function
Public Function Read_DMA_Double(Address As Long, Offset As Long) As Double
Dim ProcessId As Long
WindowHandle = FindWindow(vbNullString, "Age of Conan")
If (WindowHandle = 0) Then
MsgBox "We got no WindowHandle"
Exit Function
End If
GetWindowThreadProcessId WindowHandle, ProcessId
ProcessHandle = OpenProcess(PROCESS_ALL_ACCESS, False, ProcessId)
If (ProcessHandle = 0) Then
MsgBox "We got no ProcessHandle"
Exit Function
End If
ReadProcessMem ProcessHandle, Address + Offset, Read_DMA_Double, 8&, 0&
CloseHandle ProcessHandle
End Function
'-------
'Form1
Private Sub Command1_Click()
Dim x As Single
Dim y As Single
x = Read_DMA_Single(&H2097BA4, &H124)
y = Read_DMA_Single(&H2097BA4, &H12C)
List1.Clear
List1.AddItem "Window: 'Age of Conan'"
List1.AddItem "WindowHandle: " & WindowHandle
List1.AddItem "ProcessHandle: " & ProcessHandle
List1.AddItem " "
List1.AddItem "Player X: " & x
List1.AddItem "Player Y: " & y
End Sub