Shreyas
23-04-08, 12:56 PM
Objectives:
In this tutorial you will learn how to make a VB.NET application to hack a game's memory. In this case 3D Pinball's memory. This hack will modify 3D Pinball's score.
Requirements:
* 3D Pinball Game (Pre-installed with Windows XP)
* Any VB.NET version. You can download it from microsoft.com
* Basic VB.NET knowledge. You can get some video tutorials on microsoft.com.
Procedure:
* Start a new Console Application in VB.NET (I do not recommend a Windows Forms Application as it tends to use more memory).
* Add a new class named Trainer.vb.
* Put the following code in the class:
Public Declare Function GetWindowThreadProcessId Lib "User32" (ByVal hwnd As Integer, ByRef lpdwProcessId As Integer) As Integer
Public Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Integer, ByVal bInheritHandle As Integer, ByVal dwProcessId As Integer) As Integer
Public Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Integer) As Integer
Public Declare Function FindWindow Lib "User32" Alias "FindWindowA" (ByVal Classname As String, ByVal WindowName As String) As Integer
'For Reading and Writing Process Memory
Public Declare Function WriteProcessMemory Lib "kernel32" (ByVal hProcess As Integer, ByVal lpBaseAddress As Integer, ByRef lpBuffer As Integer, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As Integer
Public Declare Function ReadProcessMemory 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
'Disable Memory Protection
'Public Declare Function VirtualProtectEx Lib "kernel32" (ByVal hProcess As Integer, ByRef lpAddress As Object, ByVal dwSize As Integer, ByVal flNewProtect As Integer, ByRef lpflOldProtect As Integer) As Integer
Const PROCESS_ALL_ACCESS = &H1F0FFF
Dim value As Single
Dim _ProcessName As String, _processHandle As IntPtr
Property RrocessName() As String
Get
Return _ProcessName
End Get
Set(ByVal value As String)
_ProcessName = value
End Set
End Property
Sub New(ByVal processName As String)
_ProcessName = processName
End Sub
Function OpenProcess() As Boolean
Dim myProcesses As Process() = Process.GetProcessesByName(_ProcessName)
If myProcesses.Length = 0 Then
'Optional Stuff Goes Here...like Label displaying some kind of text
Return False
Exit Function
End If
_processHandle = OpenProcess(PROCESS_ALL_ACCESS, 0, myProcesses(0).Id)
If _processHandle = IntPtr.Zero Then
'Optional Stuff Goes Here...like Label displaying some kind of text
Return False
Exit Function
End If
Return True
End Function
Function GetValue(ByVal offset As Integer) As Single
ReadProcessMemory(_processHandle, offset, value, 1, 0)
Return value
End Function
Sub SetValue(ByVal offset As Integer, ByVal value As Single)
WriteProcessMemory(_processHandle, offset, value, 4, 4)
End Sub
Sub closeProcess()
If _processHandle <> 0 Then CloseHandle(_processHandle)
End Sub
Function GetSValue(ByVal offset As Integer) As Integer
If OpenProcess = False Then Exit Function
Dim value As Integer
ReadProcessMemory(_processHandle, offset, value, 1, 0)
Return value
closeProcess()
End Function
Sub SetSValue(ByVal offset As Integer, ByVal value As Integer)
If OpenProcess = False Then Exit Sub
WriteProcessMemory(_processHandle, offset, value, 1, 1)
closeProcess()
End Sub
* In the Console Application's Main Sub, add the code:
Dim trnr as new Trainer("PINBALL")
trnr.SetSValue(&HA40C62,123456)
* The value after &H is the value you found in Part 1. 123456 is the score you want to set, you can change it to the score you want. Change the value after &H to the value you get in Part 1.
Conclusion:
You have succeeded in making a game trainer! To use this, start playing pinball, and then run your application.
Exercise:
Try to make a trainer (to edit runs) for Cricket 07.
In this tutorial you will learn how to make a VB.NET application to hack a game's memory. In this case 3D Pinball's memory. This hack will modify 3D Pinball's score.
Requirements:
* 3D Pinball Game (Pre-installed with Windows XP)
* Any VB.NET version. You can download it from microsoft.com
* Basic VB.NET knowledge. You can get some video tutorials on microsoft.com.
Procedure:
* Start a new Console Application in VB.NET (I do not recommend a Windows Forms Application as it tends to use more memory).
* Add a new class named Trainer.vb.
* Put the following code in the class:
Public Declare Function GetWindowThreadProcessId Lib "User32" (ByVal hwnd As Integer, ByRef lpdwProcessId As Integer) As Integer
Public Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Integer, ByVal bInheritHandle As Integer, ByVal dwProcessId As Integer) As Integer
Public Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Integer) As Integer
Public Declare Function FindWindow Lib "User32" Alias "FindWindowA" (ByVal Classname As String, ByVal WindowName As String) As Integer
'For Reading and Writing Process Memory
Public Declare Function WriteProcessMemory Lib "kernel32" (ByVal hProcess As Integer, ByVal lpBaseAddress As Integer, ByRef lpBuffer As Integer, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As Integer
Public Declare Function ReadProcessMemory 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
'Disable Memory Protection
'Public Declare Function VirtualProtectEx Lib "kernel32" (ByVal hProcess As Integer, ByRef lpAddress As Object, ByVal dwSize As Integer, ByVal flNewProtect As Integer, ByRef lpflOldProtect As Integer) As Integer
Const PROCESS_ALL_ACCESS = &H1F0FFF
Dim value As Single
Dim _ProcessName As String, _processHandle As IntPtr
Property RrocessName() As String
Get
Return _ProcessName
End Get
Set(ByVal value As String)
_ProcessName = value
End Set
End Property
Sub New(ByVal processName As String)
_ProcessName = processName
End Sub
Function OpenProcess() As Boolean
Dim myProcesses As Process() = Process.GetProcessesByName(_ProcessName)
If myProcesses.Length = 0 Then
'Optional Stuff Goes Here...like Label displaying some kind of text
Return False
Exit Function
End If
_processHandle = OpenProcess(PROCESS_ALL_ACCESS, 0, myProcesses(0).Id)
If _processHandle = IntPtr.Zero Then
'Optional Stuff Goes Here...like Label displaying some kind of text
Return False
Exit Function
End If
Return True
End Function
Function GetValue(ByVal offset As Integer) As Single
ReadProcessMemory(_processHandle, offset, value, 1, 0)
Return value
End Function
Sub SetValue(ByVal offset As Integer, ByVal value As Single)
WriteProcessMemory(_processHandle, offset, value, 4, 4)
End Sub
Sub closeProcess()
If _processHandle <> 0 Then CloseHandle(_processHandle)
End Sub
Function GetSValue(ByVal offset As Integer) As Integer
If OpenProcess = False Then Exit Function
Dim value As Integer
ReadProcessMemory(_processHandle, offset, value, 1, 0)
Return value
closeProcess()
End Function
Sub SetSValue(ByVal offset As Integer, ByVal value As Integer)
If OpenProcess = False Then Exit Sub
WriteProcessMemory(_processHandle, offset, value, 1, 1)
closeProcess()
End Sub
* In the Console Application's Main Sub, add the code:
Dim trnr as new Trainer("PINBALL")
trnr.SetSValue(&HA40C62,123456)
* The value after &H is the value you found in Part 1. 123456 is the score you want to set, you can change it to the score you want. Change the value after &H to the value you get in Part 1.
Conclusion:
You have succeeded in making a game trainer! To use this, start playing pinball, and then run your application.
Exercise:
Try to make a trainer (to edit runs) for Cricket 07.