QuestionVB.net Cheat Engine tutorial step 8. Whats wrong in my code?

Posts 1–15 of 16 · Page 1 of 2
VB.net Cheat Engine tutorial step 8. Whats wrong in my code?
Guys, i need your help. I have no idea whats wrong, but its not working! HELP)
Cheat engine tutorial step 8. A base adress is 002903B0, offsets C, 14, 0, 18.

Code:
Imports System.Runtime.InteropServices

Public Class form1

    'API ReadProcessMemory
    <DllImport("kernel32.dll", SetLastError:=True)> _
    Private Shared Function ReadProcessMemory( _
       ByVal hProcess As IntPtr, _
       ByVal lpBaseAddress As IntPtr, _
       <Out()> ByVal lpBuffer() As Byte, _
       ByVal dwSize As Integer, _
       ByRef lpNumberOfBytesRead As Integer) As Boolean
    End Function

    Private Function FindAddress(ByVal pHandle As IntPtr, ByVal BaseAddress As IntPtr, ByVal StaticPointer As IntPtr, ByVal Offsets() As IntPtr) As IntPtr
        ' Create a buffer that is 4 bytes on a 32-bit system or 8 bytes on a 64-bit system. 
        Dim tmp(IntPtr.Size - 1) As Byte
        Dim Address As IntPtr = BaseAddress
        ' We must check for 32-bit vs 64-bit. 
        If IntPtr.Size = 4 Then
            Address = New IntPtr(Address.ToInt32 + StaticPointer.ToInt32)
        Else
            Address = New IntPtr(Address.ToInt64 + StaticPointer.ToInt64)
        End If
        ' Loop through each offset to find the address 
        For i As Integer = 0 To Offsets.Length - 1
            ReadProcessMemory(pHandle, Address, tmp, IntPtr.Size, 0)
            If IntPtr.Size = 4 Then
                Address = BitConverter.ToInt32(tmp, 0) + Offsets(i).ToInt32()
            Else
                Address = BitConverter.ToInt64(tmp, 0) + Offsets(i).ToInt64()
            End If
        Next
        Return Address
    End Function


    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim p As Process() = Process.GetProcessesByName("Tutorial-i386")
        ' I'm assuming p is a Process object that represents the game process. 
        Dim pID As IntPtr = p(0).Handle
        Dim base As IntPtr = p(0).MainModule.BaseAddress
        ' Our static pointer... 
        Dim sptr As IntPtr = &H2903B0
        ' And our offsets... 
        Dim offsets() As IntPtr = {&HC, &H14, &H0, &H18}
        Dim addr As IntPtr = FindAddress(pID, base, sptr, offsets)
        Dim f As String
        f = addr.ToString
        MessageBox.Show(f)
    End Sub
End Class
Learn to code and stop copying and pasting please.
Quote Originally Posted by Hassan View Post
Learn to code and stop copying and pasting please.
This post here gave me cancer never post this again

OH SHIT
Quote Originally Posted by wut12345 View Post
This post here gave me cancer never post this again

OH SHIT
How can cancer like you get cancer?
Quote Originally Posted by Paul View Post


How can cancer like you get cancer?
Cause its cancer
Waiting for a meaningful help.
Code:
        For i As Integer = 0 To Offsets.Length - 1
            ReadProcessMemory(pHandle, Address, tmp, IntPtr.Size, 0)
            If IntPtr.Size = 4 Then 
                Address = BitConverter.ToInt32(tmp, 0) + Offsets(i).ToInt32() '' BREAK-POINT ON THIS LINE
            Else
                Address = BitConverter.ToInt64(tmp, 0) + Offsets(i).ToInt64() '' BREAK-POINT ON THIS LINE
            End If
        Next
Set the break-points, and tell us the outputs. If you want the addresses displayed in hex (which you probably do) , calling .ToString("X") on a number, will turn it into a string, in hex format.

---
Or, is it just
Code:
        Dim f As String
        f = addr.ToString("X") '' display the number as hex
        MessageBox.Show(f)

'replace with MessageBox.Show(addr.ToString("X")) and get rid of 'f' : un-needed.
?
Thank you so much dude!

Is this it?

np. This might help (just added some msg boxes) - 1 msgbox*

Code:
 Private Function FindAddress(ByVal pHandle As IntPtr, ByVal BaseAddress As IntPtr, ByVal StaticPointer As IntPtr, ByVal Offsets() As IntPtr) As IntPtr
        ' Create a buffer that is 4 bytes on a 32-bit system or 8 bytes on a 64-bit system. 
        Dim tmp(IntPtr.Size - 1) As Byte
        Dim _ListOfAllAddressAsHexString As New System.Text.StringBuilder '' AB -used for debugging output
        _ListOfAllAddressAsHexString.AppendLine("procHandle: " & pHandle.ToString)
        _ListOfAllAddressAsHexString.AppendLine("MainModuleBase: &H" & BaseAddress.ToString("X"))
        _ListOfAllAddressAsHexString.AppendLine("StaticOffset: &H" & StaticPointer.ToString("X"))
        Dim Address As IntPtr = BaseAddress 
        If IntPtr.Size = 4 Then         ' We must check for 32-bit vs 64-bit.
            Address = New IntPtr(Address.ToInt32 + StaticPointer.ToInt32) 
        Else
            Address = New IntPtr(Address.ToInt64 + StaticPointer.ToInt64)
        End If
        _ListOfAllAddressAsHexString.AppendLine("MainModuleBase + staticOffset: &H" & Address.ToString("X"))
        _ListOfAllAddressAsHexString.AppendLine("---------------------------")
        ' Loop through each offset to find the address 
        For i As Integer = 0 To Offsets.Length - 1
            ReadProcessMemory(pHandle, Address, tmp, IntPtr.Size, 0)
            If IntPtr.Size = 4 Then
                Address = BitConverter.ToInt32(tmp, 0) + Offsets(i).ToInt32()
            Else
                Address = BitConverter.ToInt64(tmp, 0) + Offsets(i).ToInt64()
            End If
            _ListOfAllAddressAsHexString.AppendLine("ptr#" & i & ": &H" & Address.ToString("X")) 
        Next
        ''display the msg box containing all the addr
        MessageBox.Show(_ListOfAllAddressAsHexString.ToArray,"debugging list -ab")
        Return Address 
    End Function
-upload a screenshot to some public site, and show the results here by doing.. (not mpgh 'Attachment') : )
[ img ] www.somesitedotcom/ your_image [ /img ] - (without spaces)
MessageBox.Show(_ListOfAllAddressAsHexString.ToArr ay, "debugging list -ab"), when "ToArray" must be "ToString".
Thank you, worked! )
haha yeah I was thinking List(Of string) I guess : ) cooleo.
So there is no bug: You only needed to display the number in hex, issue resolved?
idk what the final addr should be

"So there is no bug: You only needed to display the number in hex, issue resolved?"
Hope I will find a solution.

Shall immediately begin to learn English xD
..Can cancer get cancer?
Posts 1–15 of 16 · Page 1 of 2

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us