Deprecated: The behavior of unparenthesized expressions containing both '.' and '+'/'-' will change in PHP 8: '+'/'-' will take a higher precedence in /home/iano/public_html/tpforums-vb5/forum/includes/class_core.php on line 5842

PHP Warning: Use of undefined constant MYSQL_NUM - assumed 'MYSQL_NUM' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: Use of undefined constant MYSQL_ASSOC - assumed 'MYSQL_ASSOC' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: Use of undefined constant MYSQL_BOTH - assumed 'MYSQL_BOTH' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in ..../includes/functions_navigation.php on line 588

PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in ..../includes/functions_navigation.php on line 612

PHP Warning: Use of undefined constant archive_postsperpage - assumed 'archive_postsperpage' (this will throw an Error in a future version of PHP) in ..../archive/index.php on line 456
[VB6] Tibia Title Bar Changer [Archive] - Forums

PDA

View Full Version : [VB6] Tibia Title Bar Changer



jo3bingham
03-19-2007, 03:38 AM
In this tutorial I'll be showing you how to change the text of the Tibia Title Bar by using a module, text box, and a command button.

I'm going to assume that you know the basics of VB6, and if you don't I encourage you to learn.

First you need to start a new project (Standard EXE) and add a module to your project. In that module you'll need to add this code that is required for Tibia "Bot" programs.


Option Explicit

''// Win32 API
Public Declare Function GetActiveWindow Lib "user32" () As Long
Public Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd 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 WriteProcessMemory Lib "kernel32" (ByVal hProcess As Long, ByVal lpBaseAddress As Any, lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
Public Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Long, ByVal lpBaseAddress As Any, ByRef lpBuffer As Any, ByVal nSize As Long, 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 lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Public Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long
'
' Constants we need for the functions that read memory
'
Public Const PROCESS_VM_READ = (&H10)
Public Const PROCESS_VM_WRITE = (&H20)
Public Const PROCESS_VM_OPERATION = (&H8)
Public Const PROCESS_QUERY_INFORMATION = (&H400)
Public Const PROCESS_READ_WRITE_QUERY = PROCESS_VM_READ + PROCESS_VM_WRITE + PROCESS_VM_OPERATION + PROCESS_QUERY_INFORMATION
Public Const PROCESS_ALL_ACCESS = &H1F0FFF


Public Const SWP_NOACTIVATE = &H10
Public Const SWP_NOCOPYBITS = &H100
Public Const SWP_NOMOVE = &H2
Public Const SWP_NOOWNERZORDER = &H200 'Don't do owner Z ordering
Public Const SWP_NOREDRAW = &H8
Public Const SWP_NOSIZE = &H1
Public Const SWP_NOZORDER = &H4
Public Const SWP_FRAMECHANGED = &H20
Public Const HWND_NOTOPMOST = -2
Public Const HWND_TOPMOST = -1

Public Function Tibia_Hwnd() As Long

'Return the value of the Tibia Window
'Use to find the window alot

'Find Tibia's hwnd or Window
Dim tibiaclient As Long
tibiaclient = FindWindow("tibiaclient", vbNullString)

'Return hwnd to function
Tibia_Hwnd = tibiaclient

End Function


Public Function Memory_ReadByte(windowHwnd As Long, Address As Long) As Byte

' Declare some variables we need
Dim PID As Long ' Used to hold the Process Id
Dim phandle As Long ' Holds the Process Handle
Dim valbuffer As Byte ' Byte

' First get a handle to the "game" window
If (windowHwnd = 0) Then Exit Function

' We can now get the pid
GetWindowThreadProcessId windowHwnd, PID

' Use the pid to get a Process Handle
phandle = OpenProcess(PROCESS_VM_READ, False, PID)
If (phandle = 0) Then Exit Function

' Read Long
ReadProcessMemory phandle, Address, valbuffer, 1, 0&

' Return
Memory_ReadByte = valbuffer

' Close the Process Handle
CloseHandle phandle

End Function
Public Function Memory_ReadLong(windowHwnd As Long, Address As Long) As Long

' Declare some variables we need
Dim PID As Long ' Used to hold the Process Id
Dim phandle As Long ' Holds the Process Handle
Dim valbuffer As Long ' Long

' First get a handle to the "game" window
If (windowHwnd = 0) Then Exit Function

' We can now get the pid
GetWindowThreadProcessId windowHwnd, PID

' Use the pid to get a Process Handle
phandle = OpenProcess(PROCESS_VM_READ, False, PID)
If (phandle = 0) Then Exit Function

' Read Long
ReadProcessMemory phandle, Address, valbuffer, 4, 0&

' Return
Memory_ReadLong = valbuffer

' Close the Process Handle
CloseHandle phandle

End Function
Public Function Memory_ReadString(windowHwnd As Long, Address As Long) As String

' Declare some variables we need
Dim PID As Long ' Used to hold the Process Id
Dim phandle As Long ' Holds the Process Handle
Dim str(255) As Byte ' Read String Array

' First get a handle to the "game" window
If (windowHwnd = 0) Then Exit Function

' We can now get the pid
GetWindowThreadProcessId windowHwnd, PID

' Use the pid to get a Process Handle
phandle = OpenProcess(PROCESS_VM_READ, False, PID)
If (phandle = 0) Then Exit Function

' Read String
ReadProcessMemory phandle, Address, str(0), 255, 0&

' Return String
Memory_ReadString = StrConv(str, vbUnicode)

' Close the Process Handle
CloseHandle phandle

End Function
Public Function Memory_WriteString(TibiaHwnd As Long, Address As Long, tibiaString As String)

'// Write String

'Get length of current text in the status
Dim tempstr As String
tempstr = Memory_ReadString(Tibia_Hwnd, Address)

'Write to the status text now, with the LENGTH
Call Memory_WriteString_Len(Tibia_Hwnd, Address, tibiaString, Len(tempstr))

End Function
Public Function Memory_WriteString_Len(windowHwnd As Long, Address As Long, valbufferr As String, vallength As Long)

'Declare some variables we need
Dim PID As Long ' Used to hold the Process Id
Dim phandle As Long ' Holds the Process Handle

' First get a handle to the "game" window
If (windowHwnd = 0) Then Exit Function

' We can now get the pid
GetWindowThreadProcessId windowHwnd, PID

' Use the pid to get a Process Handle
phandle = OpenProcess(PROCESS_READ_WRITE_QUERY, False, PID)
If (phandle = 0) Then Exit Function

' Now we can write to memory space with length of that string
WriteProcessMemory phandle, Address, ByVal valbufferr, vallength, 0&

' Close the Process Handle
CloseHandle phandle

End Function
Public Sub Memory_WriteByte(windowHwnd As Long, Address As Long, valbuffer As Byte)

'Declare some variables we need
Dim PID As Long ' Used to hold the Process Id
Dim phandle As Long ' Holds the Process Handle

' First get a handle to the "game" window
If (windowHwnd = 0) Then Exit Sub

' We can now get the pid
GetWindowThreadProcessId windowHwnd, PID

' Use the pid to get a Process Handle
phandle = OpenProcess(PROCESS_READ_WRITE_QUERY, False, PID)
If (phandle = 0) Then Exit Sub

' Write Long
WriteProcessMemory phandle, Address, valbuffer, 1, 0&

' Close the Process Handle
CloseHandle phandle

End Sub

Public Sub Memory_WriteLong(windowHwnd As Long, Address As Long, valbuffer As Long)

'Declare some variables we need
Dim PID As Long ' Used to hold the Process Id
Dim phandle As Long ' Holds the Process Handle

' First get a handle to the "game" window
If (windowHwnd = 0) Then Exit Sub

' We can now get the pid
GetWindowThreadProcessId windowHwnd, PID

' Use the pid to get a Process Handle
phandle = OpenProcess(PROCESS_READ_WRITE_QUERY, False, PID)
If (phandle = 0) Then Exit Sub

' Write Long
WriteProcessMemory phandle, Address, valbuffer, 4, 0&

' Close the Process Handle
CloseHandle phandle

End Sub

Public Sub Window_Ontop(thewindow As Form)

SetWindowPos thewindow.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOACTIVATE Or SWP_NOMOVE

End Sub

Public Sub Window_NotOntop(thewindow As Form)

SetWindowPos thewindow.hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOACTIVATE Or SWP_NOMOVE

End Sub


Now on your Form add a command button and a text box. (You can name them whatever you like, but for this tutorial I'm going to leave them as default.)

Double-Click the command button to bring up the coding window and add this line of code in the Command1 Click Sub.


SetWindowText FindWindow("tibiaclient", vbNullString), Text1.Text

Change Text1 to whatever you named your text box.

And that's it! Now when you click your command button whatever you typed into the text box will be displayed on the Tibia Title Bar.

--Coming Tomorrow After I Get Some Sleep--
I'll show you how to display your characters Experience, Level, Health, Mana, etc. in the Title Bar.

p.s. If any Mod/Admin doesn't want me to display the module code then please remove it or leave a reply and I'll remove it. I couldn't decide on whether or not to remove it and make the reader find it themselves, but I decided to leave it just incase.

Enjoy,
Jo3

jo3bingham
03-27-2007, 02:42 AM
If you want to learn more about the functions that are declared in the module take a look at Shade's tutorial in this thread...here's the link if you're too lazy lol.

Link: http://www.tpforums.net/forum/showthread.php?t=105

Jo3

Wuefez
04-13-2007, 02:13 AM
What a tutorial you have wrote Joe, very very nice, its allways good to find well commented code explained, thank you very much and keep up with the good work!

Grob
04-13-2007, 09:38 AM
Looks like a hell lot of code for such a simple thing, but I didn't really read through it.


SetWindowText( FindWindow( "TibiaClient", NULL ), "Tibia - Sucks" );