Getting info from GTA SA:MP

A

Anon 21556

Guest
I don't know if someone before me wanted to do thing such I want to do but...

Is there any way to get info from SA:MP server into my Visual Basic 6 application like Name and/or ID of the nearest player, his health, armor, his X,Y,Z position, rotation, ID of his car, but priority to me is to find nearest player's ID.
I was thinking about s0beit because I seen that it has all those in-built, just I want to know how to get all those informations to my VB6 app.

etc. I need to pull out a player that has a wanted level (difference between normal player and player with wanted level is color, normal player color is white and player with wanted level is red) from a vehicle with some command etc /getout [ID], and can do it only if player is etc 5 feet in range of my position.
Another situation is when in vehicle there are 2 or more players, then I need to get out driver first.

So, I want it to return the ID to my app, so my app generates string '/getout ID' to clipboard.
The reason why I use VB6 is that VB6 is the simpliest for me, but if I could I would intergrate that 'option' into s0beit's menu with some hotkey or something like that.
 

T3KTONIT

Well-known member
Joined
Sep 2, 2013
Messages
308
Reaction score
5
yeah you can, just use r/w process memory functions..

here is a wrapper for vb6 :
Code:
' This module could be used for a number of things,
' mostly it is used for memory based hacks and add-
' ons for games and applications. Somewhat messy,
' it has been hacked together throughout the years
'
' - rancid ( www.r-cid.com )

Option Explicit

Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long

Private Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Long, lpBaseAddress As Any, lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
Private Declare Function WriteProcessMemory Lib "kernel32" (ByVal hProcess As Long, lpBaseAddress As Any, 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 hPid As Long
Private hProcess As Long

Public Property Let pid(dwPid As Long)
    hPid = dwPid
    hProcess = OpenProcess(&H1F0FFF, False, hPid)
End Property

Public Property Get pid() As Long
    pid = hPid
End Property

Public Sub writeByte(lngAddress As Long, bVal As Byte)
    WritePtr lngAddress, VarPtr(bVal), 1
End Sub

Public Sub writeInteger(lngAddress As Long, intValue As Integer)
    WritePtr lngAddress, VarPtr(intValue), 2
End Sub

Public Sub writeSingle(lngAddress As Long, sngValue As Single)
    WritePtr lngAddress, VarPtr(sngValue), 4
End Sub

Public Sub writeLong(lngAddress As Long, lngValue As Long)
    WritePtr lngAddress, VarPtr(lngValue), 4
End Sub

Public Sub WriteString(lngAddress As Long, strValue As String)
    Dim lngBytesWritten As Long
    WriteProcessMemory hProcess, ByVal lngAddress, ByVal strValue, Len(strValue), lngBytesWritten
End Sub

Public Function WritePtr(lngAddress As Long, destPtr As Long, length As Long) As Long
    Dim lngBytesWritten As Long
    WriteProcessMemory hProcess, ByVal lngAddress, ByVal destPtr, length, lngBytesWritten
    WritePtr = lngBytesWritten
End Function

Public Function copyToType(destPtr As Long, length As Long, lngAddr As Long) As Boolean
    copyToType = (ReadProcessMemory(hProcess, ByVal lngAddr, ByVal destPtr, length, &H0) <> 0)
End Function

Public Function readLong(lngAddr As Long) As Long
    copyToType VarPtr(readLong), 4, lngAddr
End Function

Public Function readInteger(lngAddr As Long) As Integer
    copyToType VarPtr(readInteger), 2, lngAddr
End Function

Public Function readSingle(lngAddr As Long) As Single
    copyToType VarPtr(readSingle), 4, lngAddr
End Function

Public Function readByte(lngAddr As Long) As Byte
    copyToType VarPtr(readByte), 1, lngAddr
End Function

'//strings ends at null characters
Public Function readString(length As Long, lngAddr As Long) As String
    Dim strTmp As String, i As Long
    
    strTmp = String(length, 0)

    If (ReadProcessMemory(hProcess, ByVal lngAddr, ByVal strTmp, length, &H0) <> 0) Then
        i = InStr(strTmp, Chr(0))
        
        If i > 0 Then strTmp = Left(strTmp, i - 1)
        
        readString = strTmp
        
        lngBaseAddr = lngBaseAddr + length
    End If
End Function

'//string contains null characters
Public Function readStringN(length As Long, lngAddr As Long) As String
    Dim strTmp As String, i As Long
    
    strTmp = String(length, 0)

    If (ReadProcessMemory(hProcess, ByVal lngAddr, ByVal strTmp, length, &H0) <> 0) Then
        readStringN = strTmp
    End If
End Function
 
A

Anon 21556

Guest
Is there any tutorial or explanation on how to use those functions and read or write to addresses into memory?
 
Top