ok, in this forum you find a nice list of several address for Tibia 9.1+
The problem (since Tibia 9.1):
- they won't work directly in Vista/7
- the address only work if tibia base is &H400000
- tibia base is &H400000 always in Windows Xp
- tibia base is random in Vista/7
The solution
- you use a function to find current base in your tibia client instance
- offset = currentbase - &H400000
- the address that will work in your tibia client instance = offset + theXPaddress
- in windows xp you will always get offset = 0
- in windows 7/vista will get a random offset. But it will be the same until you close the tibia client.
How I find the current base? Maybe it is not the best way, but I know the size of the Tibia.exe submodule so I can find where is the right region with that.
In Tibia 9.1 : expectedRegionSize = &H2C3000
Below is the code of my function. Anyways you can see the full code in my multiclient or in my light cheat
Note: This code only will work for Tibia 9.1. For the updated code that works with any tibia version just scroll down to the end of this post
Code:
Public Function getProcessBase(ByVal hProcess As Long, expectedRegionSize As Long, Optional PIDinsteadHp As Boolean = False) As Long
On Error GoTo goterr
Dim lpMem As Long, ret As Long, lLenMBI As Long
Dim lWritten As Long, CalcAddress As Long, lPos As Long
Dim sBuffer As String
Dim sSearchString As String, sReplaceString As String
Dim si As SYSTEM_INFO
Dim mbi As MEMORY_BASIC_INFORMATION
Dim realH As Long
Dim pid As Long
Dim res As Long
If PIDinsteadHp = True Then
res = GetWindowThreadProcessId(hProcess, pid)
realH = OpenProcess(PROCESS_READ_WRITE_QUERY, False, pid)
hProcess = realH
End If
Call GetSystemInfo(si)
lpMem = si.lpMinimumApplicationAddress
lLenMBI = Len(mbi)
' Scan memory
Do While lpMem < si.lpMaximumApplicationAddress
mbi.RegionSize = 0
ret = VirtualQueryEx(hProcess, ByVal lpMem, mbi, lLenMBI)
If ret = lLenMBI Then
If (mbi.State = MEM_COMMIT) Then
' Debug.Print "BaseAddress=" & Hex(mbi.BaseAddress)
' Debug.Print "AllocationBase=" & Hex(mbi.AllocationBase)
' Debug.Print "RegionSize=" & Hex(mbi.RegionSize)
If (mbi.RegionSize = expectedRegionSize) Then ' this is the interesting region
If PIDinsteadHp = True Then
CloseHandle hProcess
End If
getProcessBase = mbi.AllocationBase
Exit Function
End If
End If
lpMem = mbi.BaseAddress + mbi.RegionSize
Else
Exit Do
End If
Loop
If PIDinsteadHp = True Then
CloseHandle hProcess
End If
goterr:
getProcessBase = 0
End Function
[size=large]UPDATE:[/size]
For newer versions of Tibia, you can leave the initial expectedRegionSize of 9.1 as a constant with value &H2C3000 AND just do a little change in my function:
From:
Code:
If (mbi.RegionSize = expectedRegionSize) Then ' this is the interesting region
To:
Code:
If (mbi.RegionSize >= expectedRegionSize) Then ' this is the interesting region
Why? because region size only have been growing since Tibia 9.1, and the good region it is always the first region with some big size. Exact region size does not really matter
(tested up to Tibia 9.44, but it probably will work in all future versions)
Below you have the final code already fixed to work in any tibia version:
Code:
Public Function getProcessBase(ByVal hProcess As Long, Optional PIDinsteadHp As Boolean = False) As Long
On Error GoTo goterr
Const expectedRegionSize As Long = &H2C3000
Dim lpMem As Long, ret As Long, lLenMBI As Long
Dim lWritten As Long, CalcAddress As Long, lPos As Long
Dim sBuffer As String
Dim sSearchString As String, sReplaceString As String
Dim si As SYSTEM_INFO
Dim mbi As MEMORY_BASIC_INFORMATION
Dim realH As Long
Dim pid As Long
Dim res As Long
If PIDinsteadHp = True Then
res = GetWindowThreadProcessId(hProcess, pid)
realH = OpenProcess(PROCESS_READ_WRITE_QUERY, False, pid)
hProcess = realH
End If
Call GetSystemInfo(si)
lpMem = si.lpMinimumApplicationAddress
lLenMBI = Len(mbi)
' Scan memory
Do While lpMem < si.lpMaximumApplicationAddress
mbi.RegionSize = 0
ret = VirtualQueryEx(hProcess, ByVal lpMem, mbi, lLenMBI)
If ret = lLenMBI Then
If (mbi.State = MEM_COMMIT) Then
' Debug.Print "BaseAddress=" & Hex(mbi.BaseAddress)
' Debug.Print "AllocationBase=" & Hex(mbi.AllocationBase)
' Debug.Print "RegionSize=" & Hex(mbi.RegionSize)
If (mbi.RegionSize >= expectedRegionSize) Then ' this is the interesting region
If PIDinsteadHp = True Then
CloseHandle hProcess
End If
getProcessBase = mbi.AllocationBase
Exit Function
End If
End If
lpMem = mbi.BaseAddress + mbi.RegionSize
Else
Exit Do
End If
Loop
If PIDinsteadHp = True Then
CloseHandle hProcess
End If
goterr:
getProcessBase = 0
End Function