Thanks for posting. I'll start messing around with VB.Net right now.
Hello MPGH. I was writing module for VB.Net cause kyos tut interested me. However in kyo tut it was pretty strange lol. And there were a lot of problems with it. So i wrote a module, becouse copying and pasting code between subs and buttons sux, doesnt it? Now u will be able to change memory in 1 line of text (for pointers u'll need more :P). Pointers same as for VB6, read then add the offset and voila.
However reading isnt the same, here i got public variables storing read values. It is better becouse u dont need to declare variable every time u wanna read from some address. So reading will look like this (for byte, 2bytes, 4bytes, 8bytes):
and for float:Code:ReadMemory(“someapp”, &Haddress) Textbox1.Text = vBuffer
but before u can put ur greedy fingers on my module u need to figure out some parts of it. They were replaced with xxxxxx. Without figuring it out module won't work. Don't worry, errors displayed by VB will help youCode:ReadFloat(“someapp”, &Haddress) Textbox1.Text = vBufferS
And here comes the module:
There are no comments since a few days ago my comp crashed and i lost whole module. When rewritting i didnt want to bother rewriting them.Code:Option Explicit On Imports System Imports System.diagnostics Module ReadWriteMem Public vBuffer As Long 'public variable storing read values for Byte, 2 Bytes 4 Bytes and 8 Bytes Public vBufferS As Single 'public variable to store read floating point values 'stuff Public Declare Function KeyPressed Lib "user32" Alias "GetAsyncKeyState" (ByVal Key As Integer) As Integer Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long 'reading Private Declare Function ReadMem Lib "kernel32" Alias "xxxxxx" (ByVal hProcess As IntPtr, ByVal lpBaseAddress As IntPtr, ByRef buffer As Long, ByVal size As Int32, ByRef lpNumberOfBytesRead As Int32) As Boolean Private Declare Function ReadFloat Lib "kernel32" Alias "xxxxxx” (ByVal hProcess As IntPtr, ByVal lpBaseAddress As IntPtr, ByRef buffer As Single, ByVal size As Int32, ByRef lpNumberOfBytesRead As Int32) As Boolean 'writing Private Declare Function WriteMem Lib "kernel32" Alias "xxxxxx" (ByVal hProcess As IntPtr, ByVal lpBaseAddress As IntPtr, ByVal buffer() As Long, ByVal size As Int32, ByRef lpNumberOfBytesRead As Int32) As Boolean Private Declare Function WriteFloat Lib "kernel32" Alias "xxxxxx " (ByVal hProcess As IntPtr, ByVal lpBaseAddress As IntPtr, ByVal buffer() As Single, ByVal size As Int32, ByRef lpNumberOfBytesRead As Int32) As Boolean Private appProcess As Process Private Function SetProcess(ByVal ProcessName As String) As Boolean Dim processes As Process() = Process.GetProcessesByName(ProcessName) If (processes.Length > 0) Then appProcess = processes(0) Return True Else Return False End If End Function Public Function WriteMemory(ByVal appName As String, ByVal address As Integer, ByVal value As Object, ByVal bytes As Integer) If SetProcess((xxxxxx)) = False Then MsgBox(xxxxxx & " not found.", MsgBoxStyle.Critical, "Error") End Exit Function End If Dim buffer() As Long = New Long(0) {value} Return WriteMem(xxxxxxx.Handle, address, buffer, bytes, Nothing) CloseHandle(xxxxxxx.Handle) End Function Public Function ReadMemory(ByVal appName As String, ByVal address As Integer, ByVal bytes As Integer) If SetProcess((xxxxxxx)) = False Then MsgBox(xxxxxxx & " not found.", MsgBoxStyle.Critical, "Error") End Exit Function End If ReadMem(xxxxxxx.Handle, address, vBuffor, bytes, Nothing) Return vBuffer CloseHandle(xxxxxxx.Handle) End Function Public Function WriteFloat(ByVal appName As String, ByVal address As Integer, ByVal value As Single) If SetProcess((xxxxxx)) = False Then MsgBox(xxxxxx & " not found.", MsgBoxStyle.Critical, "Error") End Exit Function End If Dim buffer() As Single = New Single() {value} Return WriteFloat(xxxxxxx.Handle, address, buffer, 142, Nothing) CloseHandle(xxxxxxx.Handle) End Function Public Function ReadFloat(ByVal appName As String, ByVal address As Integer) If SetProcess((xxxxxx)) = False Then MsgBox(xxxxxx & " not found.", MsgBoxStyle.Critical, "Error") End Exit Function End If ReadMem(xxxxxxx.Handle, address, vBufferS, 834, Nothing) Return vBufferS CloseHandle(xxxxxxx.Handle) End Function End Module
btw except for xxxxxx-ed parts there are 2 code traps. :P But while reading u should notice them since they are kinda obvious (if u understand the code)
Thanks for posting. I'll start messing around with VB.Net right now.
Cheers for posting the TUT ill have to try it out sometime maybe tommorrow
Omg, n00bz..
Yesterday: VB6
Today: VB.NET
Tomorrow: C++
Day after: C#
Day after: Java
Day after: Delphi
Day after: Pascal
Day after ....
Nice tut, but do we realy need a tut for every language ? |-)
Some people own, some doesn't. No mather what hack theire using.
As i cant edit my post after such long time so i post the whole module here (no xxxx parts, i dont care anymore)
just give me credits in your trainers...Code:'------------------------------------------------ 'Module written by dezer '------------------------------------------------ Option Explicit On Imports System Imports System.diagnostics Module ReadWriteMem Public vBuffer As Long 'public variable storing read values Public vBufferS As Single 'public variable to store read floating point values 'stuff Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Integer, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Integer) As Integer Public Declare Function KeyPressed Lib "user32" Alias "GetAsyncKeyState" (ByVal Key As Integer) As Integer Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long 'reading Private Declare Function ReadMem Lib "kernel32" Alias "ReadProcessMemory" (ByVal hProcess As IntPtr, ByVal lpBaseAddress As IntPtr, ByRef buffer As Long, ByVal size As Int32, ByRef lpNumberOfBytesRead As Int32) As Boolean Private Declare Function ReadFloat Lib "kernel32" Alias "ReadProcessMemory" (ByVal hProcess As IntPtr, ByVal lpBaseAddress As IntPtr, ByRef buffer As Single, ByVal size As Int32, ByRef lpNumberOfBytesRead As Int32) As Boolean 'writing Private Declare Function WriteMem Lib "kernel32" Alias "WriteProcessMemory" (ByVal hProcess As IntPtr, ByVal lpBaseAddress As IntPtr, ByVal buffer() As Long, ByVal size As Int32, ByRef lpNumberOfBytesRead As Int32) As Boolean Private Declare Function WriteFloat Lib "kernel32" Alias "WriteProcessMemory" (ByVal hProcess As IntPtr, ByVal lpBaseAddress As IntPtr, ByVal buffer() As Single, ByVal size As Int32, ByRef lpNumberOfBytesRead As Int32) As Boolean Private appProcess As Process Private Function SetProcess(ByVal ProcessName As String) As Boolean Dim processes As Process() = Process.GetProcessesByName(ProcessName) If (processes.Length > 0) Then appProcess = processes(0) Return True Else Return False End If End Function Public Function WriteMemory(ByVal appName As String, ByVal address As Integer, ByVal value As Object, ByVal bytes As Integer) If SetProcess((appName)) = False Then MsgBox(appName & " not found.", MsgBoxStyle.Critical, "Error") End Exit Function End If Dim buffer() As Long = New Long(0) {value} Return WriteMem(appProcess.Handle, address, buffer, bytes, Nothing) CloseHandle(appProcess.Handle) End Function Public Function ReadMemory(ByVal appName As String, ByVal address As Integer, ByVal bytes As Integer) If SetProcess((appName)) = False Then MsgBox(appName & " not found.", MsgBoxStyle.Critical, "Error") End Exit Function End If ReadMem(appProcess.Handle, address, vBuffer, bytes, Nothing) Return vBuffer CloseHandle(appProcess.Handle) End Function Public Function WriteFloat(ByVal appName As String, ByVal address As Integer, ByVal value As Single) If SetProcess((appName)) = False Then MsgBox(appName & " not found.", MsgBoxStyle.Critical, "Error") End Exit Function End If Dim buffer() As Single = New Single() {value} Return WriteFloat(appProcess.Handle, address, buffer, 4, Nothing) CloseHandle(appProcess.Handle) End Function Public Function ReadFloat(ByVal appname As String, ByVal address As Integer) If SetProcess((appname)) = False Then MsgBox(appname & " not found.", MsgBoxStyle.Critical, "Error") End Exit Function End If ReadMem(appProcess.Handle, address, vBufferS, 4, Nothing) Return vBufferS CloseHandle(appProcess.Handle) End Function End Module