|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
ElBartoDeLaMurte How do I cheat? Reputation: 0
Joined: 13 Nov 2016 Posts: 2
|
Posted: Sun Nov 13, 2016 7:31 am Post subject: Getting Base Address Module - VB6/VBA |
|
|
Hi all,
Before everything else, I know VB6 is a dead language and it is now better to use .NET - C# - C++. No need to boo me. But i do it out of curiosity.
Here is a VB.Net code to get the base address of a module :
Code: | Function ReturnClient() As System.IntPtr
Try
Dim pc As Process = Process.GetProcessesByName("hl2")( 0 )
For Each pm As ProcessModule In pc.Modules
If pm.ModuleName = "client.dll" Then Return pm.BaseAddress
Next
Catch ex As Exception
Return IntPtr.Zero
End Try
End Function |
Do you guys know how i could do it with VB6? Because at the moment, the only thingi can do is dealing with processes, but not their modules....
See you soon guys
|
|
Back to top |
|
|
atom0s Moderator Reputation: 198
Joined: 25 Jan 2006 Posts: 8517 Location: 127.0.0.1
|
Posted: Sun Nov 13, 2016 1:32 pm Post subject: |
|
|
Here are two functions from my old trainer toolkit I wrote for VB6:
Code: |
'-------------------------------------------------------------------------------------------
' Module Returns
'
' The following section of code contains functions used to obtain
' module information such as the size and base address of the loaded
' module inside the given process or window.
'-------------------------------------------------------------------------------------------
'//
' @Function: GetModuleBaseFromProcessName
' @Purpose : Returns the process Id of the given process name.
'\\
Public Function GetModuleBaseFromProcessName(ByVal szProcessName As String, ByVal szModuleName As String) As Long
Dim dwProcId As Long
dwProcId = GetProcessIdByName(szProcessName)
If dwProcId = 0 Then
GetModuleBaseFromProcessName = 0
Exit Function
End If
Dim me32 As MODULEENTRY32
Dim hSnapshot As Long
Dim bFoundModule As Boolean
Dim dwModuleBase As Long
me32.dwSize = Len(me32)
hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, dwProcId)
bFoundModule = Module32First(hSnapshot, me32)
Do While bFoundModule
If LCase$(Left(me32.szModule, InStr(me32.szModule, Chr(0)) - 1)) = LCase$(szModuleName) Then
dwModuleBase = me32.modBaseAddr
Exit Do
End If
bFoundModule = Module32Next(hSnapshot, me32)
Loop
Call CloseHandle(hSnapshot)
GetModuleBaseFromProcessName = dwModuleBase
End Function
'//
' @Function: GetModuleSizeFromProcessName
' @Purpose : Returns the process Id of the given process name.
'\\
Public Function GetModuleSizeFromProcessName(ByVal szProcessName As String, ByVal szModuleName As String) As Long
Dim dwProcId As Long
dwProcId = GetProcessIdByName(szProcessName)
If dwProcId = 0 Then
GetModuleSizeFromProcessName = 0
Exit Function
End If
Dim me32 As MODULEENTRY32
Dim hSnapshot As Long
Dim bFoundModule As Boolean
Dim dwModuleSize As Long
me32.dwSize = Len(me32)
hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, dwProcId)
bFoundModule = Module32First(hSnapshot, me32)
Do While bFoundModule
If LCase$(Left(me32.szModule, InStr(me32.szModule, Chr(0)) - 1)) = LCase$(szModuleName) Then
dwModuleSize = me32.modBaseSize
Exit Do
End If
bFoundModule = Module32Next(hSnapshot, me32)
Loop
Call CloseHandle(hSnapshot)
GetModuleSizeFromProcessName = dwModuleSize
End Function
|
_________________
- Retired. |
|
Back to top |
|
|
ElBartoDeLaMurte How do I cheat? Reputation: 0
Joined: 13 Nov 2016 Posts: 2
|
Posted: Tue Nov 15, 2016 3:25 pm Post subject: |
|
|
Sorry for the delay, i had some troubles with my laptop.
And thank you, your code works totally fine!
|
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|