killemal
10-28-2009, 08:36
Well this was just a fast little bot I made for the current tutor test server:
Memory module...
'//All API declarations we will need to make these functions useful:
'Thanks to Robert Meffe for pointing out this API line because he didn't get it
'to work properly in his Win XP. Greets!
Private Const PROCESS_ALL_ACCESS As Long = &H1F0FFF
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private 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
Private 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
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal Classname As String, ByVal WindowName As String) As Long
Private 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
'||-------------------------------------------------------------------------------------------------||
'|| The two next functions read\write LONG values. ||
'|| LONG is a 32-bit(4 byte) datatype and can store values from -2,147,483,648 to 2,147,483,647 ||
'||-------------------------------------------------------------------------------------------------||
Public Function ReadLong(Offset As Long, WindowName As String) As Long
Dim hwnd As Long
Dim ProcessID As Long
Dim ProcessHandle As Long
Dim value As Long
'Try to find the window that was passed in the variable WindowName to this function.
hwnd = FindWindow(vbNullString, WindowName)
If hwnd = 0 Then
'This is executed if the window cannot be found.
'You can add or write your own code here to customize your program.
MsgBox "Run The Game First!", vbOKOnly, "Error Reading Game"
Exit Function
End If
'Get the window's process ID.
GetWindowThreadProcessId hwnd, ProcessID
'Get a process handle
ProcessHandle = OpenProcess(PROCESS_ALL_ACCESS, False, ProcessID)
If ProcessHandle = 0 Then
'This is executed if a process handle cannot be found.
'You can add or write your own code here to customize your program.
MsgBox "Could not get a process handle!", vbCritical, "Read error"
Exit Function
End If
'Read a LONG from the specified memory offset.
ReadProcessMem ProcessHandle, Offset, value, 4, 0&
'Return the found memory value.
ReadLong = value
'It is important to close the current process handle.
CloseHandle ProcessHandle
End Function
Public Function WriteLong(Offset As Long, WindowName As String, value As Long) As Boolean
Dim hwnd As Long
Dim ProcessID As Long
Dim ProcessHandle As Long
'Try to find the window that was passed in the variable WindowName to this function.
hwnd = FindWindow(vbNullString, WindowName)
If hwnd = 0 Then
'This is executed if the window cannot be found.
'You can add or write your own code here to customize your program.
MsgBox "Run The Game First!", vbOKOnly, "Write error"
Exit Function
End If
'Get the window's process ID.
GetWindowThreadProcessId hwnd, ProcessID
'Get a process handle
ProcessHandle = OpenProcess(PROCESS_ALL_ACCESS, False, ProcessID)
If ProcessHandle = 0 Then
'This is executed if a process handle cannot be found.
'You can add or write your own code here to customize your program.
MsgBox "Could not get a process handle!", vbCritical, "Write error"
Exit Function
End If
'Read a LONG from the specified memory offset.
WriteProcessMemory ProcessHandle, Offset, value, 4, 0&
'It is important to close the current process handle.
CloseHandle ProcessHandle
End Function
in a timer
Dim manavalue As Long
Dim hpvalue As Long
Dim thehpadress As Long
Dim thempadress As Long
'///////
Dim refillatmana As Long
Dim healathealth As Long
refillatmana = 1500
healathealth = 1300
'//////////
thehpadress = "&H635F0C"
thempadress = "&H635EF0"
manavalue = ReadLong(thempadress, "Tibia Testserver")
hpvalue = ReadLong(thehpadress, "Tibia Testserver")
lblmana.Caption = "Mana: " & manavalue
lblhealth.Caption = "Health: " & hpvalue
If manavalue < refillatmana Then
SendKeys ("{F10}")
End If
If hpvalue < healathealth Then
SendKeys ("{F11}")
End If
All this does is send my hotkeys to the game when my mana or health drops below a value. Its kind of a cheap mans auto heal / mana restore made for test server :P.
But it got me to thinking , if this was implemented into a bot like blackd (using postmessage api instead of send keys so it worked when tibia was out of focus) then surely no bot detector can see this.It is simulating a human 100% by pressing the hotkey and not changing any data at all within tibia.
Of course with massive progs like blackd theres other methods that can get you banned but i see no disadvantage to this code , on test server I have been to poi , pharoes , demons and all sorts with this little bot running , it works fine I feel just as safe as blackds auto heal (with the exception of it not working out of focus due to my own lazyness in using sendkeys and not postmessage)
Memory module...
'//All API declarations we will need to make these functions useful:
'Thanks to Robert Meffe for pointing out this API line because he didn't get it
'to work properly in his Win XP. Greets!
Private Const PROCESS_ALL_ACCESS As Long = &H1F0FFF
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private 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
Private 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
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal Classname As String, ByVal WindowName As String) As Long
Private 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
'||-------------------------------------------------------------------------------------------------||
'|| The two next functions read\write LONG values. ||
'|| LONG is a 32-bit(4 byte) datatype and can store values from -2,147,483,648 to 2,147,483,647 ||
'||-------------------------------------------------------------------------------------------------||
Public Function ReadLong(Offset As Long, WindowName As String) As Long
Dim hwnd As Long
Dim ProcessID As Long
Dim ProcessHandle As Long
Dim value As Long
'Try to find the window that was passed in the variable WindowName to this function.
hwnd = FindWindow(vbNullString, WindowName)
If hwnd = 0 Then
'This is executed if the window cannot be found.
'You can add or write your own code here to customize your program.
MsgBox "Run The Game First!", vbOKOnly, "Error Reading Game"
Exit Function
End If
'Get the window's process ID.
GetWindowThreadProcessId hwnd, ProcessID
'Get a process handle
ProcessHandle = OpenProcess(PROCESS_ALL_ACCESS, False, ProcessID)
If ProcessHandle = 0 Then
'This is executed if a process handle cannot be found.
'You can add or write your own code here to customize your program.
MsgBox "Could not get a process handle!", vbCritical, "Read error"
Exit Function
End If
'Read a LONG from the specified memory offset.
ReadProcessMem ProcessHandle, Offset, value, 4, 0&
'Return the found memory value.
ReadLong = value
'It is important to close the current process handle.
CloseHandle ProcessHandle
End Function
Public Function WriteLong(Offset As Long, WindowName As String, value As Long) As Boolean
Dim hwnd As Long
Dim ProcessID As Long
Dim ProcessHandle As Long
'Try to find the window that was passed in the variable WindowName to this function.
hwnd = FindWindow(vbNullString, WindowName)
If hwnd = 0 Then
'This is executed if the window cannot be found.
'You can add or write your own code here to customize your program.
MsgBox "Run The Game First!", vbOKOnly, "Write error"
Exit Function
End If
'Get the window's process ID.
GetWindowThreadProcessId hwnd, ProcessID
'Get a process handle
ProcessHandle = OpenProcess(PROCESS_ALL_ACCESS, False, ProcessID)
If ProcessHandle = 0 Then
'This is executed if a process handle cannot be found.
'You can add or write your own code here to customize your program.
MsgBox "Could not get a process handle!", vbCritical, "Write error"
Exit Function
End If
'Read a LONG from the specified memory offset.
WriteProcessMemory ProcessHandle, Offset, value, 4, 0&
'It is important to close the current process handle.
CloseHandle ProcessHandle
End Function
in a timer
Dim manavalue As Long
Dim hpvalue As Long
Dim thehpadress As Long
Dim thempadress As Long
'///////
Dim refillatmana As Long
Dim healathealth As Long
refillatmana = 1500
healathealth = 1300
'//////////
thehpadress = "&H635F0C"
thempadress = "&H635EF0"
manavalue = ReadLong(thempadress, "Tibia Testserver")
hpvalue = ReadLong(thehpadress, "Tibia Testserver")
lblmana.Caption = "Mana: " & manavalue
lblhealth.Caption = "Health: " & hpvalue
If manavalue < refillatmana Then
SendKeys ("{F10}")
End If
If hpvalue < healathealth Then
SendKeys ("{F11}")
End If
All this does is send my hotkeys to the game when my mana or health drops below a value. Its kind of a cheap mans auto heal / mana restore made for test server :P.
But it got me to thinking , if this was implemented into a bot like blackd (using postmessage api instead of send keys so it worked when tibia was out of focus) then surely no bot detector can see this.It is simulating a human 100% by pressing the hotkey and not changing any data at all within tibia.
Of course with massive progs like blackd theres other methods that can get you banned but i see no disadvantage to this code , on test server I have been to poi , pharoes , demons and all sorts with this little bot running , it works fine I feel just as safe as blackds auto heal (with the exception of it not working out of focus due to my own lazyness in using sendkeys and not postmessage)