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:
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"
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