HelpSA-MP trainer, need help

Posts 1–9 of 9 · Page 1 of 1
SA-MP trainer, need help
Hi !
I have a question for those that play SA-MP and are creating cheats for it.Is there some way to create a trainer for this in VB.NET ?
And, are GTA SA/ SA-MP's adresses static or dynamic ? Last time i was testing with Cheat Engine, i could change money value from CE, however when i used ReadWriteMemory for vb.net then it couldnt find my gta_sa.exe process, could someone make a simple tutorial for trainer to this game, that will work all the time ?
Quote Originally Posted by silentus View Post
Hi !
I have a question for those that play SA-MP and are creating cheats for it.Is there some way to create a trainer for this in VB.NET ?
And, are GTA SA/ SA-MP's adresses static or dynamic ? Last time i was testing with Cheat Engine, i could change money value from CE, however when i used ReadWriteMemory for vb.net then it couldnt find my gta_sa.exe process, could someone make a simple tutorial for trainer to this game, that will work all the time ?
Just look here - Grand Theft Auto San Andreas Multi Player (SAMP) Hacks - MPGH - MultiPlayer Game Hacking & Cheats - Hacks, Cheats, Downloads, Trainers, Games

Also, instead of asking for help on the forums for a "simple" tutorial on how to hack SA-MP learn how to code.
if you have skype and teamview, I'll show you a couple things with cheatengine and vb.net if you want.

skype is same as my username here.
Hi guys!
Im not some complete noob, i know how to make basic programs, and i got a class to change address values.I have made money hack, unlimited ammo and +100 to money.However i want to change health value, that is a dynamic address.Its pretty simple to find out the address in CE, everything is given here:
Memory Addresses (SA) - GTAModding
Just need to add pointer (CPed) and 0x540 values and voila you got the address and you can change the health value.BUT, i want to do this in VB.NET
I got a class, that can read a dynamic address, write a dynamic addres etc, however its same class that i had problems with some time ago.When i try to use it, it shows a MessageBox with "Failed to open gta_sa" so it detects the process, but idk whats wrong (if i try to use it on a non existing process, it says "process_name isnt open"

Module:
Code:
Module dynamiczne

#Region "Declarations"

    Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Integer, ByVal bInheritHandle As Integer, ByVal dwProcessId As Integer) As Integer

    Private Declare Function WriteProcessMemory1 Lib "kernel32" Alias "WriteProcessMemory" (ByVal hProcess As Integer, ByVal lpBaseAddress As Integer, ByRef lpBuffer As Integer, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As Integer
    Private Declare Function WriteProcessMemory2 Lib "kernel32" Alias "WriteProcessMemory" (ByVal hProcess As Integer, ByVal lpBaseAddress As Integer, ByRef lpBuffer As Single, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As Single
    Private Declare Function WriteProcessMemory3 Lib "kernel32" Alias "WriteProcessMemory" (ByVal hProcess As Integer, ByVal lpBaseAddress As Integer, ByRef lpBuffer As Long, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As Long

    Private Declare Function ReadProcessMemory1 Lib "kernel32" Alias "ReadProcessMemory" (ByVal hProcess As Integer, ByVal lpBaseAddress As Integer, ByRef lpBuffer As Integer, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As Integer
    Private Declare Function ReadProcessMemory2 Lib "kernel32" Alias "ReadProcessMemory" (ByVal hProcess As Integer, ByVal lpBaseAddress As Integer, ByRef lpBuffer As Single, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As Single
    Private Declare Function ReadProcessMemory3 Lib "kernel32" Alias "ReadProcessMemory" (ByVal hProcess As Integer, ByVal lpBaseAddress As Integer, ByRef lpBuffer As Long, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As Long

    Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Integer) As Integer

    Const PROCESS_ALL_ACCESS = &H1F0FF

#End Region

#Region "Memory Functions"

    '//
    '//  Write Functions Below //
    '//

    Public Function writeDynamicInt(ByVal processName As String, ByVal baseAddress As Integer, ByVal Offsets As String, ByVal Value As Integer)
        Try
            Dim newAddress As Integer = getAddress(processName, baseAddress, Offsets)
            WriteInteger(processName, newAddress, Value)
            Return True
        Catch ex As Exception
            Return False
        End Try
    End Function

    Public Function writeDynamicFloat(ByVal processName As String, ByVal baseAddress As Integer, ByVal Offsets As String, ByVal Value As Single)
        Try
            Dim newAddress As Integer = getAddress(processName, baseAddress, Offsets)
            WriteFloat(processName, newAddress, Value)
            Return True
        Catch ex As Exception
            Return False
        End Try
    End Function

    Public Function writeDynamicLong(ByVal processName As String, ByVal baseAddress As Integer, ByVal Offsets As String, ByVal Value As Long)
        Try
            Dim newAddress As Integer = getAddress(processName, baseAddress, Offsets)
            WriteLong(processName, newAddress, Value)
            Return True
        Catch ex As Exception
            Return False
        End Try
    End Function

    Public Sub WriteFloat(ByVal ProcessName As String, ByVal Address As Integer, ByVal Value As Single, Optional ByVal nsize As Integer = 4)
        If ProcessName.EndsWith(".exe") Then
            ProcessName = ProcessName.Replace(".exe", "")
        End If
        Dim MyP As Process() = Process.GetProcessesByName(ProcessName)
        If MyP.Length = 0 Then
            MsgBox(ProcessName & " isn't open!", vbExclamation, "Error")
            Exit Sub
        End If
        Dim hProcess As IntPtr = OpenProcess(PROCESS_ALL_ACCESS, 0, MyP(0).Id)
        If hProcess = IntPtr.Zero Then
            MsgBox("Failed to open " & ProcessName & "!", vbExclamation, "Error")
            Exit Sub
        End If
        Dim hAddress As Integer
        Dim vBuffer As Single
        hAddress = Address
        vBuffer = Value
        WriteProcessMemory2(hProcess, hAddress, vBuffer, nsize, 0)
        CloseHandle(hProcess)
    End Sub

    Public Sub WriteLong(ByVal ProcessName As String, ByVal Address As Integer, ByVal Value As Long, Optional ByVal nsize As Integer = 4)
        If ProcessName.EndsWith(".exe") Then
            ProcessName = ProcessName.Replace(".exe", "")
        End If
        Dim MyP As Process() = Process.GetProcessesByName(ProcessName)
        If MyP.Length = 0 Then
            MsgBox(ProcessName & " isn't open!", vbExclamation, "Error")
            Exit Sub
        End If
        Dim hProcess As IntPtr = OpenProcess(PROCESS_ALL_ACCESS, 0, MyP(0).Id)
        If hProcess = IntPtr.Zero Then
            MsgBox("Failed to open " & ProcessName & "!", vbExclamation, "Error")
            Exit Sub
        End If

        Dim hAddress As Integer
        Dim vBuffer As Long

        hAddress = Address
        vBuffer = Value
        WriteProcessMemory3(hProcess, hAddress, vBuffer, nsize, 0)
        CloseHandle(hProcess)
    End Sub

    Public Sub WriteNOPs(ByVal ProcessName As String, ByVal Address As Long, ByVal NOPNum As Integer)
        Dim C As Integer
        Dim B As Integer
        If ProcessName.EndsWith(".exe") Then
            ProcessName = ProcessName.Replace(".exe", "")
        End If
        Dim MyP As Process() = Process.GetProcessesByName(ProcessName)
        If MyP.Length = 0 Then
            MsgBox(ProcessName & " isn't open!", vbExclamation, "Error")
            Exit Sub
        End If
        Dim hProcess As IntPtr = OpenProcess(PROCESS_ALL_ACCESS, 0, MyP(0).Id)
        If hProcess = IntPtr.Zero Then
            MsgBox("Failed to open " & ProcessName & "!", vbExclamation, "Error")
            Exit Sub
        End If

        B = 0
        For C = 1 To NOPNum
            Call WriteProcessMemory1(hProcess, Address + B, &H90, 1, 0&)
            B = B + 1
        Next C
        CloseHandle(hProcess)
    End Sub

    Public Sub WriteInteger(ByVal ProcessName As String, ByVal Address As Integer, ByVal Value As Integer, Optional ByVal nsize As Integer = 4)
        If ProcessName.EndsWith(".exe") Then
            ProcessName = ProcessName.Replace(".exe", "")
        End If
        Dim MyP As Process() = Process.GetProcessesByName(ProcessName)
        If MyP.Length = 0 Then
            MsgBox(ProcessName & " isn't open!", vbExclamation, "Error")
            Exit Sub
        End If
        Dim hProcess As IntPtr = OpenProcess(PROCESS_ALL_ACCESS, 0, MyP(0).Id)
        If hProcess = IntPtr.Zero Then
            MsgBox("Failed to open " & ProcessName & "!", vbExclamation, "Error")
            Exit Sub
        End If

        Dim hAddress, vBuffer As Integer
        hAddress = Address
        vBuffer = Value
        WriteProcessMemory1(hProcess, hAddress, CInt(vBuffer), nsize, 0)
        CloseHandle(hProcess)
    End Sub

    Public Function writeBytes(ByVal processName As String, ByVal baseAddress As Integer, ByVal Bytes As String, ByVal byteLength As Integer)
        Try
            Dim oldByte As Integer = ReadInteger(processName, baseAddress)
            Dim revByte As String = byteReverse(oldByte.ToString("X"))
            Dim byteTemp As String = Bytes & revByte.Remove(0, byteLength)
            Dim byteNew As String = Val("&H" & byteReverse(byteTemp))
            WriteInteger(processName, baseAddress, byteNew)
            Return True
        Catch ex As Exception
            Return False
        End Try
    End Function

    '//
    '//  Read Functions Below  //
    '//
    '//  Write Functions Above //
    '//

    Public Function ReadInteger(ByVal ProcessName As String, ByVal Address As Integer, Optional ByVal nsize As Integer = 4) As Integer
        If ProcessName.EndsWith(".exe") Then
            ProcessName = ProcessName.Replace(".exe", "")
        End If
        Dim MyP As Process() = Process.GetProcessesByName(ProcessName)
        If MyP.Length = 0 Then
            MsgBox(ProcessName & " isn't open!", vbExclamation, "Error")
            Return vbEmpty
            Exit Function
        End If
        Dim hProcess As IntPtr = OpenProcess(PROCESS_ALL_ACCESS, 0, MyP(0).Id)
        If hProcess = IntPtr.Zero Then
            MsgBox("Failed to open " & ProcessName & "!", vbExclamation, "Error")
            Return vbEmpty
            Exit Function
        End If

        Dim hAddress, vBuffer As Integer
        hAddress = Address
        ReadProcessMemory1(hProcess, hAddress, vBuffer, nsize, 0)
        CloseHandle(hProcess)
        Return vBuffer
    End Function

    Public Function ReadFloat(ByVal ProcessName As String, ByVal Address As Integer, Optional ByVal nsize As Integer = 4) As Single
        If ProcessName.EndsWith(".exe") Then
            ProcessName = ProcessName.Replace(".exe", "")
        End If
        Dim MyP As Process() = Process.GetProcessesByName(ProcessName)
        If MyP.Length = 0 Then
            MsgBox(ProcessName & " isn't open!", vbExclamation, "Error")
            Return vbEmpty
            Exit Function
        End If
        Dim hProcess As IntPtr = OpenProcess(PROCESS_ALL_ACCESS, 0, MyP(0).Id)
        If hProcess = IntPtr.Zero Then
            MsgBox("Failed to open " & ProcessName & "!", vbExclamation, "Error")
            Return vbEmpty
            Exit Function
        End If

        Dim hAddress As Integer
        Dim vBuffer As Single

        hAddress = Address
        ReadProcessMemory2(hProcess, hAddress, vBuffer, nsize, 0)
        CloseHandle(hProcess)
        Return vBuffer
    End Function

    Public Function ReadLong(ByVal ProcessName As String, ByVal Address As Integer, Optional ByVal nsize As Integer = 4) As Long
        If ProcessName.EndsWith(".exe") Then
            ProcessName = ProcessName.Replace(".exe", "")
        End If
        Dim MyP As Process() = Process.GetProcessesByName(ProcessName)
        If MyP.Length = 0 Then
            MsgBox(ProcessName & " isn't open!", vbExclamation, "Error")
            Return vbEmpty
            Exit Function
        End If
        Dim hProcess As IntPtr = OpenProcess(PROCESS_ALL_ACCESS, 0, MyP(0).Id)
        If hProcess = IntPtr.Zero Then
            MsgBox("Failed to open " & ProcessName & "!", vbExclamation, "Error")
            Return vbEmpty
            Exit Function
        End If

        Dim hAddress As Integer
        Dim vBuffer As Long

        hAddress = Address
        ReadProcessMemory3(hProcess, hAddress, vBuffer, nsize, 0)
        CloseHandle(hProcess)
        Return vBuffer
    End Function

    Public Function readDynamicInt(ByVal processName As String, ByVal baseAddress As Integer, ByVal Offsets As String)
        Try
            Dim newValue As Integer
            Dim newAddress As Integer = getAddress(processName, baseAddress, Offsets)
            newValue = ReadInteger(processName, newAddress)
            Return newValue
        Catch ex As Exception
            Return False
        End Try
    End Function

    Public Function readDynamicFloat(ByVal processName As String, ByVal baseAddress As Integer, ByVal Offsets As String)
        Try
            Dim newValue As Single
            Dim newAddress As Integer = getAddress(processName, baseAddress, Offsets)
            newValue = ReadFloat(processName, newAddress)
            Return newValue
        Catch ex As Exception
            Return False
        End Try
    End Function

    Public Function readDynamicLong(ByVal processName As String, ByVal baseAddress As Integer, ByVal Offsets As String)
        Try
            Dim newValue As Long
            Dim newAddress As Integer = getAddress(processName, baseAddress, Offsets)
            newValue = ReadLong(processName, newAddress)
            Return newValue
        Catch ex As Exception
            Return False
        End Try
    End Function

    Public Function readBytes(ByVal processName As String, ByVal baseAddress As String, ByVal byteLength As Integer)
        Try
            Dim oldByte As Integer = ReadInteger(processName, baseAddress)
            Dim revByte As String = byteReverse(oldByte.ToString("X"))
            Dim byteNew As String = revByte.Remove(byteLength)
            Return byteNew
        Catch ex As Exception
            Return False
        End Try
    End Function

    '//
    '//  Other Functions Below //
    '//

    Public Function getAddress(ByVal processName As String, ByVal baseAddress As Integer, ByVal Offsets As String)
        Dim genAddress As String = baseAddress
        Dim offSplit As String() = Offsets.Split(New Char() {":"c})
        Dim offTemp As String
        For Each offTemp In offSplit
            Dim grabAddress As Integer = ReadInteger(processName, genAddress)
            Dim offConvert As Integer = Convert.ToInt32(offTemp, 16)
            Dim addAddress = grabAddress + offConvert
            genAddress = "&H" & addAddress.ToString("X")
        Next
        Return genAddress
    End Function

    Public Function byteReverse(ByVal Input As String) As String
        Try
            Dim byteTemp As New List(Of String)
            Dim newByte As String = ""
            For i = 0 To Input.Length - 1 Step 2
                If i + 1 < Input.Length Then
                    byteTemp.Add(Input.Substring(i, 2))
                Else
                    byteTemp.Add(Input.Substring(i))
                End If
            Next
            For i = 0 To byteTemp.Count - 1
                newByte = byteTemp(i).ToString & newByte
            Next
            Return newByte
        Catch ex As Exception
            Return False
        End Try
    End Function

#End Region

End Module
Functions im trying to use are getAddress, readDynamicInt etc (however i will probably need to use readDynamicFloat as health is float type, but i cant it even get to work)
Someone knows what is wrong here ? Some guy told me it works for him, im using Windows XP SP3 and it doesnt for me
Quote Originally Posted by silentus View Post
Hi guys!
Im not some complete noob
Yes because using Cheat Engine is the really l33t way of making hacks. It's like copy & paste in a sense. You didn't really do any heavy lifting just minimal efforts.
Oh really shut up, im just trying to get some help with this class because it doesnt work for me, and its only class i have seen that has those functions
Quote Originally Posted by silentus View Post
Oh really shut up, im just trying to get some help with this class because it doesnt work for me, and its only class i have seen that has those functions
Stahp, you are really hurting my feelings! Seriously though, you look like a hardcore leecher with a skiddie attitude.
"Just need to add pointer (CPed) and 0x540 values and voila you got the address and you can change the health value.BUT, i want to do this in VB.NET"
Code:
Dim ptr1 as Intptr = MemMgr.ReadIntPtr(someAddr) 
Dim ptr2 as IntPtr = Memmgr.ReadIntPtr(ptr1 + &H540) '// Depending on Framework version, you can't ++ on IntPtr.  See IntPtr.Add()
?? Ofc you don't have a function called ReadIntPtr() but you should, and you should understand what it is. Ofc it's possible in vb.net :/ But you have to understand pointers and when/why they are used.

The way you overload RPM is a little weird. I think maybe you should re-structure your class/functions a little.

edit: I read that wrong, sounds like you only need.. (which ofc is still possible in vb.net)
Code:
Dim ptr1 as IntPtr = MemMgr.ReadIntPtr(someAddr)
Dim ptr2 as IntPtr = ptr1 + &H540 '' aka Addr of health value

Dim healthValue as Int32 = MemMgr.ReadInt32(ptr2) '// i assume health is stored as int32
??
Both of you.

CE is an awesome tool (scanner / debugger + more).

OP needs a proper memory library and to understand how it all works / why before attempting something this relatively complex. First learn to read the score value from pinball or something easy, then when you know your memory library works, move on to larger projects. Your code might compile and sort-of work, but it has several nuances that are going to cause you more work later..especially if you don't understand how it all works. Go to the 2nd page of the vb coding section, I wrote a tut w/ a lot of source and explain some of the concepts. You have to know how to program before trying to make a program...obviously.

--------------
"
Code:
 Public Function readBytes(ByVal processName As String, ByVal baseAddress As String, ByVal byteLength As Integer) ' As ?
        Try
            Dim oldByte As Integer = ReadInteger(processName, baseAddress) '//Integer?
            Dim revByte As String = byteReverse(oldByte.ToString("X")) 
            Dim byteNew As String = revByte.Remove(byteLength) 
            Return byteNew 'Return As String
        Catch ex As Exception
            Return False 'Return As Boolean
        End Try
    End Function
"
:|
Posts 1–9 of 9 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us