 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
yoodidoo How do I cheat?
Reputation: 0
Joined: 20 Jul 2008 Posts: 6
|
Posted: Tue Jul 29, 2008 5:23 pm Post subject: [VB.NET] Problem with multi lvl pointers |
|
|
Hello,
i've been hacking games for a little while now and decided to learn
how to find my own addresses. Up until now I used addresses posted
on other forums. I'm now working on a trainer I intend to release here
but I have this problem.
I have no trouble finding addresses or pointers, however when I try to
code a hack that has multi lvl pointers, I don't know what to do. I tried
using base pointer but when I test my hack the game crashes. The first
lvl pointer works but since it's not static my hack won't work after the
game closes.
Could someone help me out?
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Tue Jul 29, 2008 11:18 pm Post subject: |
|
|
| You want to start at the static address you hopefully followed the pointer down to. Then, just ReadProcessMemory on it, do whatever you need to with the offset, and repeat until you're done.
|
|
| Back to top |
|
 |
yoodidoo How do I cheat?
Reputation: 0
Joined: 20 Jul 2008 Posts: 6
|
Posted: Wed Jul 30, 2008 12:34 pm Post subject: |
|
|
Sorry if I ask a lot of questions sometimes, I don't like to
but i'm trying my best to understand so I can make projects
on my own.
I've never used the ReadProcessMemory function before, or any
Read function for that matter, so if you or someone could elaborate
for me or point me to a tut I would GREATLY appreciate it.
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Wed Jul 30, 2008 5:42 pm Post subject: |
|
|
It would help a lot if you had some ground to stand on when it came to the Win32 API, which we're going to have to make use of.
MSDN and pinvoke.net are going to be your best friends here.
Here's some of what MSDN has to say about ReadProcessMemory.
| Code: | BOOL WINAPI ReadProcessMemory(
__in HANDLE hProcess,
__in LPCVOID lpBaseAddress,
__out LPVOID lpBuffer,
__in SIZE_T nSize,
__out SIZE_T *lpNumberOfBytesRead
); |
... and the pinvoke signature since we're using .NET:
| Code: | <DllImport("kernel32.dll")> _
Public Shared Function ReadProcessMemory( _
ByVal hProcess As IntPtr, _
ByVal lpBaseAddress As IntPtr, _
ByVal lpBuffer As Byte(), _
ByVal iSize As UInt32, _
ByRef lpNumberOfBytesRead As UInt32 _
) As Boolean
End Function |
As you can see, it needs a handle to the process you plan on using. Thankfully .NET has a pretty simple way of doing this.
Take a look at the: System.Diagnostics.Process class
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.aspx
Look through the methods, and sure enough we will come across something that looks like just what we need.
http://msdn.microsoft.com/en-us/library/z3w4xdc9.aspx
It returns a Process array, so you can just do something like: | Code: | | Dim p As Process() = Process.GetProcessesByName("winmine") |
Now we can just call ReadProcessMemory.
The end result (which will read the timer on minesweeper):
| Code: | Imports System.Runtime.InteropServices
Public Class Form1
<DllImport("kernel32.dll")> _
Public Shared Function ReadProcessMemory( _
ByVal hProcess As IntPtr, _
ByVal lpBaseAddress As IntPtr, _
ByVal lpBuffer As Byte(), _
ByVal iSize As UInt32, _
ByRef lpNumberOfBytesRead As UInt32 _
) As Boolean
End Function
Dim p As Process() = Process.GetProcessesByName("winmine")
Dim buffer As Byte() = New Byte(0) {}
Dim bytesRead As UInt32 = 0
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click
ReadProcessMemory(p(0).Handle, &H100579C, buffer, 1, bytesRead)
textBox1.Text = BitConverter.ToString(buffer)
End Sub
End Class |
... and there you have it. An example as to get setup, and read a value.
|
|
| Back to top |
|
 |
samuri25404 Grandmaster Cheater
Reputation: 7
Joined: 04 May 2007 Posts: 955 Location: Why do you care?
|
Posted: Wed Jul 30, 2008 5:46 pm Post subject: |
|
|
Uhh, not quite, Slovach.
You're creating a byte[] with size 0, and asking to read 0 bytes. You're just gonna get null from the bit converter.
_________________
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Wed Jul 30, 2008 5:50 pm Post subject: |
|
|
| samuri25404 wrote: | Uhh, not quite, Slovach.
You're creating a byte[] with size 0, and asking to read 0 bytes. You're just gonna get null from the bit converter. |
edit: that should work fine in VB
in VB.net: 5 = 0 - 5, so 6 bytes.
in C#: 5 = 0 - 4, or 5 bytes.
so yes, that 0 would in fact create a byte array with 1 byte.
|
|
| Back to top |
|
 |
yoodidoo How do I cheat?
Reputation: 0
Joined: 20 Jul 2008 Posts: 6
|
Posted: Wed Jul 30, 2008 7:25 pm Post subject: |
|
|
Alright, thank you very much for your replies, I start working
on this as soon as I can. My knowledge on this stuff isn't as
high as I would like it to be, but I have to start somewhere and
i'm taking classes on programming soon.
|
|
| Back to top |
|
 |
samuri25404 Grandmaster Cheater
Reputation: 7
Joined: 04 May 2007 Posts: 955 Location: Why do you care?
|
Posted: Wed Jul 30, 2008 8:32 pm Post subject: |
|
|
| slovach wrote: | | samuri25404 wrote: | Uhh, not quite, Slovach.
You're creating a byte[] with size 0, and asking to read 0 bytes. You're just gonna get null from the bit converter. |
edit: that should work fine in VB
in VB.net: 5 = 0 - 5, so 6 bytes.
in C#: 5 = 0 - 4, or 5 bytes.
so yes, that 0 would in fact create a byte array with 1 byte. |
Ah, my bad.
But the maximum time value goes up to 999 (because of a cmp in the memory); that requires at least 3 bytes (4 when rounded up). The max that a user would get from doing RPM is 255, which won't always be true.
_________________
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Wed Jul 30, 2008 9:56 pm Post subject: |
|
|
Ok fine, I made an oops.
SUPERIOR VERSION
| Code: | Dim p As Process() = Process.GetProcessesByName("winmine")
Dim buffer As Byte() = New Byte(3) {}
Dim bytesRead As UInt32 = 0
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click
ReadProcessMemory(p(0).Handle, &H100579C, buffer, 4, bytesRead)
textBox1.Text = Convert.ToString(BitConverter.ToUInt32(buffer, 0))
End Sub
|
|
|
| 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
|
|