Originally Posted by
oclipper
use blackd source to try to teach urself, i suggest blackd safe cheats. its also vb6
I did, but I want to give this one last chance. I noticed by studdying some other examples that I was missing the base address, so I added that accordingly.
But still it seems I can't get the correct values.
I added some debuging lines;
simpleBot.vb
Code:
Public Class simpleBot
' Memory adresses from Blackd, http://www.blackdtools.net/showthread.php?61954-10-72-Blackd-Tibia-addresses-10-72
Private xorAdr As Int32 = &H838090 ' xor
Private healthAdr As Int32 = &H9D5000 ' current health
Private manaAdr As Int32 = &H8380E4 ' current mana
Private Memory As New Memory
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Console.WriteLine("XOR:")
Dim valueXOR As Long = Memory.ReadLong(xorAdr)
Console.WriteLine("HEALTH:")
Dim health As Long = Memory.ReadLong(healthAdr)
Console.WriteLine("MANA:")
Dim mana As Long = Memory.ReadLong(manaAdr)
healthL.Text = valueXOR Xor health
manaL.Text = valueXOR Xor mana
End Sub
End Class
Memory.vb
Code:
Imports System.Diagnostics
Public Class Memory
'API declarations
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Int32, ByVal bInheritHandle As Int32, ByVal dwProcessId As Int32) As Int32
Private Declare Function ReadProcessMemory Lib "kernel32" Alias "ReadProcessMemory" (ByVal hProcess As Int32, ByVal lpBaseAddress As Int32, ByRef lpBuffer As Int32, ByVal nSize As Int32, ByRef lpNumberOfBytesWritten As Int32) As Int32
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Int32) As Int32
'Constants
Public Const PROCESS_VM_READ = &H10
Private baseAddress As Int32
Public Function Tibia_Hwnd() As Long
Dim TibiaWindows As Process() = Process.GetProcessesByName("tibia")
If TibiaWindows.Length = 0 Then
'No tibiaclients open, return 0
Return 0
Exit Function
End If
' we need the base address
baseAddress = TibiaWindows(0).MainModule.BaseAddress.ToInt32()
Return TibiaWindows(0).Id ' 0 is the first tibia-client. 1 is the second one, and so on..
End Function
Public Function ReadLong(ByVal Address As Int32) As Long
Dim vBuffer As Long
Dim processHandle As IntPtr = OpenProcess(PROCESS_VM_READ, 0, Tibia_Hwnd)
' join address and baseAddress to get correct memory location
Dim newAddress As Int32 = Address + baseAddress
ReadProcessMemory(processHandle, newAddress, vBuffer, 4, 0)
Console.WriteLine("addr: " & Address)
Console.WriteLine("baseAddr: " & baseAddress)
Console.WriteLine("newAddr: " & newAddress)
Console.WriteLine("return: " & vBuffer)
Console.WriteLine("----------------")
Return vBuffer
CloseHandle(processHandle)
End Function
End Class
And I'm getting the following values,
XOR:
addr: 8618128
baseAddr: 8847360
newAddr: 17465488
return: 0
----------------
HEALTH:
addr: 10309632
baseAddr: 8847360
newAddr: 19156992
return: 0
----------------
MANA:
addr: 8618212
baseAddr: 8847360
newAddr: 17465572
return: 0
----------------
IDK why the return value gets passed back as 0, suggestions?