Hello,
Im trying to read a value of a multi-level pointer using Vb.net but my result in VB comes out much different than the one in CE. I have tried this same method on other games ( SaintsRowTheThird, Titan Quest) and it works perfectly but not on Tera. The value is either something negative like (-621185984) or 0.
Code:
Declare Function ReadProcessMemory Lib "kernel32" Alias "ReadProcessMemory" (ByVal hProcess As Integer, ByVal lpBaseAddress As Integer, ByRef lpBuffer As Integer, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As Integer
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Integer) As Integer
Public phandle As Integer
Public gbaseid As Int32
Public GAMEEXE As String = "Tera"
Private m_hProcess As IntPtr = IntPtr.Zero
Public Function ReadMemANdOffset()
Dim TeraProcess As Process = Process.GetProcessesByName(GAMEEXE)(0)
Dim TeraProcessMainIndex As Integer = 0
For i = 0 To TeraProcess.Modules.Count - 1
If TeraProcess.Modules.Item(i).ModuleName.ToLower = GAMEEXE Then
TeraProcessMainIndex = i
Exit For
End If
Next
phandle = TeraProcess.Handle
gbaseid = TeraProcess.Modules.Item(TeraProcessMainIndex).BaseAddress.ToInt32()
Dim OFFSETS As String() = {"01716B5C", "29c", "724", "30", "c", "48"}
Dim CurMem As Integer = 0
Dim CurAdd As Integer = gbaseid
For i As Integer = 0 To OFFSETS.Length - 1
Dim CurOFFset As Int32 = Int32.Parse(OFFSETS(i), System.Globalization.NumberStyles.HexNumber)
If i = 0 Then
ReadProcessMemory(phandle, CurAdd + CurOFFset, CurMem, 4, 0)
Else
ReadProcessMemory(phandle, CurMem + CurOFFset, CurMem, 4, 0)
End If
Next
Dim FinalResult As Integer = CurMem
Return FinalResult
End Function
Pointer For HP:
<Address>"TERA.exe"+01716B5C</Address>
<Offset>48</Offset>
<Offset>C</Offset>
<Offset>30</Offset>
<Offset>724</Offset>
<Offset>29C</Offset>
What am I doing wrong here?
Please advise, im stuck.