 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
froggercs How do I cheat?
Reputation: 0
Joined: 29 Oct 2013 Posts: 2
|
Posted: Tue Oct 29, 2013 11:32 am Post subject: How do I write process memory to a listbox? |
|
|
Hi I am trying to make my VB.net program find a process, then get the value of an offset and add it to a list box.
I found this code for reading/writing memory...
| Code: |
Module ReadWritingMemory
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
Const PROCESS_ALL_ACCESS = &H1F0FF
Public Function WriteDMAInteger(ByVal Process As String, ByVal Address As Integer, ByVal Offsets As Integer(), ByVal Value As Integer, ByVal Level As Integer, Optional ByVal nsize As Integer = 4) As Boolean
Try
Dim lvl As Integer = Address
For i As Integer = 1 To Level
lvl = ReadInteger(Process, lvl, nsize) + Offsets(i - 1)
Next
WriteInteger(Process, lvl, Value, nsize)
Return True
Catch ex As Exception
Return False
End Try
End Function
Public Function ReadDMAInteger(ByVal Process As String, ByVal Address As Integer, ByVal Offsets As Integer(), ByVal Level As Integer, Optional ByVal nsize As Integer = 4) As Integer
Try
Dim lvl As Integer = Address
For i As Integer = 1 To Level
lvl = ReadInteger(Process, lvl, nsize) + Offsets(i - 1)
Next
Dim vBuffer As Integer
vBuffer = ReadInteger(Process, lvl, nsize)
Return vBuffer
Catch ex As Exception
End Try
End Function
Public Function WriteDMAFloat(ByVal Process As String, ByVal Address As Integer, ByVal Offsets As Integer(), ByVal Value As Single, ByVal Level As Integer, Optional ByVal nsize As Integer = 4) As Boolean
Try
Dim lvl As Integer = Address
For i As Integer = 1 To Level
lvl = ReadFloat(Process, lvl, nsize) + Offsets(i - 1)
Next
WriteFloat(Process, lvl, Value, nsize)
Return True
Catch ex As Exception
Return False
End Try
End Function
Public Function ReadDMAFloat(ByVal Process As String, ByVal Address As Integer, ByVal Offsets As Integer(), ByVal Level As Integer, Optional ByVal nsize As Integer = 4) As Single
Try
Dim lvl As Integer = Address
For i As Integer = 1 To Level
lvl = ReadFloat(Process, lvl, nsize) + Offsets(i - 1)
Next
Dim vBuffer As Single
vBuffer = ReadFloat(Process, lvl, nsize)
Return vBuffer
Catch ex As Exception
End Try
End Function
Public Function WriteDMALong(ByVal Process As String, ByVal Address As Integer, ByVal Offsets As Integer(), ByVal Value As Long, ByVal Level As Integer, Optional ByVal nsize As Integer = 4) As Boolean
Try
Dim lvl As Integer = Address
For i As Integer = 1 To Level
lvl = ReadLong(Process, lvl, nsize) + Offsets(i - 1)
Next
WriteLong(Process, lvl, Value, nsize)
Return True
Catch ex As Exception
Return False
End Try
End Function
Public Function ReadDMALong(ByVal Process As String, ByVal Address As Integer, ByVal Offsets As Integer(), ByVal Level As Integer, Optional ByVal nsize As Integer = 4) As Long
Try
Dim lvl As Integer = Address
For i As Integer = 1 To Level
lvl = ReadLong(Process, lvl, nsize) + Offsets(i - 1)
Next
Dim vBuffer As Long
vBuffer = ReadLong(Process, lvl, nsize)
Return vBuffer
Catch ex As Exception
End Try
End Function
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", "")
Form1.Label12.Text = ProcessName
End If
Dim MyP As Process() = Process.GetProcessesByName(ProcessName)
If MyP.Length = 0 Then
Form1.Label12.Text = "No Process Selected"
'MessageBox.Show(ProcessName & " isn't open!")
Exit Sub
End If
Dim hProcess As IntPtr = OpenProcess(PROCESS_ALL_ACCESS, 0, MyP(0).Id)
If hProcess = IntPtr.Zero Then
MessageBox.Show("Failed to open " & ProcessName & "!")
Exit Sub
End If
B = 0
For C = 1 To NOPNum
Call WriteProcessMemory1(hProcess, Address + B, &H90, 1, 0&)
B = B + 1
Next C
End Sub
Public Sub WriteXBytes(ByVal ProcessName As String, ByVal Address As Long, ByVal Value As String)
If ProcessName.EndsWith(".exe") Then
ProcessName = ProcessName.Replace(".exe", "")
Form1.Label12.Text = ProcessName
End If
Dim MyP As Process() = Process.GetProcessesByName(ProcessName)
If MyP.Length = 0 Then
Form1.Label12.Text = "No Process Selected"
'MessageBox.Show(ProcessName & " isn't open!")
Exit Sub
End If
Dim hProcess As IntPtr = OpenProcess(PROCESS_ALL_ACCESS, 0, MyP(0).Id)
If hProcess = IntPtr.Zero Then
MessageBox.Show("Failed to open " & ProcessName & "!")
Exit Sub
End If
Dim C As Integer
Dim B As Integer
Dim D As Integer
Dim V As Byte
B = 0
D = 1
For C = 1 To Math.Round((Len(Value) / 2))
V = Val("&H" & Mid$(Value, D, 2))
Call WriteProcessMemory1(hProcess, Address + B, V, 1, 0&)
B = B + 1
D = D + 2
Next C
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", "")
Form1.Label12.Text.Equals(ProcessName)
End If
Dim MyP As Process() = Process.GetProcessesByName(ProcessName)
If MyP.Length = 0 Then
Form1.Label12.Text = "No Process Selected"
'MessageBox.Show(ProcessName & " isn't open!")
Exit Sub
End If
Dim hProcess As IntPtr = OpenProcess(PROCESS_ALL_ACCESS, 0, MyP(0).Id)
If hProcess = IntPtr.Zero Then
MessageBox.Show("Failed to open " & ProcessName & "!")
Exit Sub
End If
Dim hAddress, vBuffer As Integer
hAddress = Address
vBuffer = Value
WriteProcessMemory1(hProcess, hAddress, CInt(vBuffer), nsize, 0)
End Sub
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", "")
Form1.Label12.Text = ProcessName
End If
Dim MyP As Process() = Process.GetProcessesByName(ProcessName)
If MyP.Length = 0 Then
Form1.Label12.Text = "No Process Selected"
'MessageBox.Show(ProcessName & " isn't open!")
Exit Sub
End If
Dim hProcess As IntPtr = OpenProcess(PROCESS_ALL_ACCESS, 0, MyP(0).Id)
If hProcess = IntPtr.Zero Then
MessageBox.Show("Failed to open " & ProcessName & "!")
Exit Sub
End If
Dim hAddress As Integer
Dim vBuffer As Single
hAddress = Address
vBuffer = Value
WriteProcessMemory2(hProcess, hAddress, vBuffer, nsize, 0)
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", "")
Form1.Label12.Text = ProcessName
End If
Dim MyP As Process() = Process.GetProcessesByName(ProcessName)
If MyP.Length = 0 Then
Form1.Label12.Text = "No Process Selected"
'MessageBox.Show(ProcessName & " isn't open!")
Exit Sub
End If
Dim hProcess As IntPtr = OpenProcess(PROCESS_ALL_ACCESS, 0, MyP(0).Id)
If hProcess = IntPtr.Zero Then
MessageBox.Show("Failed to open " & ProcessName & "!")
Exit Sub
End If
Dim hAddress As Integer
Dim vBuffer As Long
hAddress = Address
vBuffer = Value
WriteProcessMemory3(hProcess, hAddress, vBuffer, nsize, 0)
End Sub
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", "")
Form1.Label12.Text = ProcessName
End If
Dim MyP As Process() = Process.GetProcessesByName(ProcessName)
If MyP.Length = 0 Then
Form1.Label12.Text = "No Process Selected"
'MessageBox.Show(ProcessName & " isn't open!")
Exit Function
End If
Dim hProcess As IntPtr = OpenProcess(PROCESS_ALL_ACCESS, 0, MyP(0).Id)
If hProcess = IntPtr.Zero Then
MessageBox.Show("Failed to open " & ProcessName & "!")
Exit Function
End If
Dim hAddress, vBuffer As Integer
hAddress = Address
ReadProcessMemory1(hProcess, hAddress, vBuffer, nsize, 0)
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", "")
Form1.Label12.Text = ProcessName
End If
Dim MyP As Process() = Process.GetProcessesByName(ProcessName)
If MyP.Length = 0 Then
Form1.Label12.Text = "No Process Selected"
'MessageBox.Show(ProcessName & " isn't open!")
Exit Function
End If
Dim hProcess As IntPtr = OpenProcess(PROCESS_ALL_ACCESS, 0, MyP(0).Id)
If hProcess = IntPtr.Zero Then
MessageBox.Show("Failed to open " & ProcessName & "!")
Exit Function
End If
Dim hAddress As Integer
Dim vBuffer As Single
hAddress = Address
ReadProcessMemory2(hProcess, hAddress, vBuffer, nsize, 0)
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", "")
Form1.Label12.Text = ProcessName
End If
Dim MyP As Process() = Process.GetProcessesByName(ProcessName)
If MyP.Length = 0 Then
Form1.Label12.Text = "No Process Selected"
'MessageBox.Show(ProcessName & " isn't open!")
Exit Function
End If
Dim hProcess As IntPtr = OpenProcess(PROCESS_ALL_ACCESS, 0, MyP(0).Id)
If hProcess = IntPtr.Zero Then
MessageBox.Show("Failed to open " & ProcessName & "!")
Exit Function
End If
Dim hAddress As Integer
Dim vBuffer As Long
hAddress = Address
ReadProcessMemory3(hProcess, hAddress, vBuffer, nsize, 0)
Return vBuffer
End Function
End Module
|
I don't know if this is relevant to what I am trying to do, but if anyone can help me get a value from an offset... it would be much appreciated...
when I try I keep getting a 0 added to my list box because I am using
| Code: |
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
ListBox1.Items.Add(ReadInteger("iw5sp", &H12A9910))
End Sub
|
|
|
| Back to top |
|
 |
froggercs How do I cheat?
Reputation: 0
Joined: 29 Oct 2013 Posts: 2
|
Posted: Sun Nov 03, 2013 2:48 am Post subject: |
|
|
| Well, 118 views... and no help, thankfully i figured it out on my own, thanks guys...
|
|
| Back to top |
|
 |
DELETED_USER Newbie cheater
Reputation: 1
Joined: 02 Oct 2013 Posts: 24 Location: Venezuela
|
Posted: Sun Nov 03, 2013 3:17 am Post subject: |
|
|
Nobody here will copy and paste the plagiarized code that you've pasted, just to help some neophytes who doesn't know how to work with OOP.
So... you should be grateful, because nobody here has insulted you, by copy and paste code without knowing what you're really doing.
|
|
| Back to top |
|
 |
voidaccess How do I cheat?
Reputation: 0
Joined: 01 Nov 2013 Posts: 9
|
Posted: Sun Nov 03, 2013 1:34 pm Post subject: |
|
|
| zShacktar wrote: | Nobody here will copy and paste the plagiarized code that you've pasted, just to help some neophytes who doesn't know how to work with OOP.
So... you should be grateful, because nobody here has insulted you, by copy and paste code without knowing what you're really doing. |
He never claimed it to be his code, in fact 2nd line he said "I found this code for reading/writing memory... ".
|
|
| Back to top |
|
 |
DELETED_USER Newbie cheater
Reputation: 1
Joined: 02 Oct 2013 Posts: 24 Location: Venezuela
|
Posted: Sun Nov 03, 2013 2:16 pm Post subject: |
|
|
| voidaccess wrote: | | zShacktar wrote: | Nobody here will copy and paste the plagiarized code that you've pasted, just to help some neophytes who doesn't know how to work with OOP.
So... you should be grateful, because nobody here has insulted you, by copy and paste code without knowing what you're really doing. |
He never claimed it to be his code, in fact 2nd line he said "I found this code for reading/writing memory... ". |
And I never said that he said so... read carefully.
|
|
| Back to top |
|
 |
SteveAndrew Master Cheater
Reputation: 30
Joined: 02 Sep 2012 Posts: 323
|
Posted: Wed Nov 06, 2013 4:20 pm Post subject: !AHH |
|
|
Whatever! Neither of those things even matters anyways! The real issue here is that is VB guys!!! (Visual Basic / Virtually Bootless / Basically Useless!)
AHHHHH!!! MY EYES!!! IT BURNS!!!
lol, no but seriously it did hurt my eyes to look at that stuff! Now I have to write some C++ code for at least an hour just to clear that stuff out of my mind!
haha
_________________
|
|
| Back to top |
|
 |
DELETED_USER Newbie cheater
Reputation: 1
Joined: 02 Oct 2013 Posts: 24 Location: Venezuela
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Sun Nov 10, 2013 2:18 am Post subject: |
|
|
Stay on topic people. And if you aren't going to help, don't bother posting.
_________________
- Retired. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|