Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    lock5126's Avatar
    Join Date
    May 2011
    Gender
    male
    Location
    Moscow, Russia
    Posts
    15
    Reputation
    10
    Thanks
    0

    Question 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
    Last edited by lock5126; 02-24-2013 at 08:06 AM.

  2. #2
    Hassan's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    System.Threading.Tasks
    Posts
    4,764
    Reputation
    495
    Thanks
    2,133
    My Mood
    Dead
    Learn to code and stop copying and pasting please.

  3. #3
    lock5126's Avatar
    Join Date
    May 2011
    Gender
    male
    Location
    Moscow, Russia
    Posts
    15
    Reputation
    10
    Thanks
    0
    Waiting for a meaningful help.
    Last edited by lock5126; 02-24-2013 at 09:06 AM.

  4. #4
    abuckau907's Avatar
    Join Date
    Dec 2012
    Gender
    male
    Location
    other side of the wire
    Posts
    1,342
    Reputation
    162
    Thanks
    239
    My Mood
    Cold
    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.
    ?
    Last edited by abuckau907; 02-24-2013 at 10:23 AM.
    'Some things that can be counted, don't matter. And some things that matter, can't be counted' - A.E.
    --
     

    My posts have some inaccuracies/are wrong/wrong keyword(s) used.
    They're (maybe) pretty close, and I hope they helped you, not created confusion. Take with grain of salt.

    -if you give rep, please leave a comment, else it means less.

  5. The Following User Says Thank You to abuckau907 For This Useful Post:

    lock5126 (02-24-2013)

  6. #5
    lock5126's Avatar
    Join Date
    May 2011
    Gender
    male
    Location
    Moscow, Russia
    Posts
    15
    Reputation
    10
    Thanks
    0
    Thank you so much dude!

    Is this it?

    Attached Thumbnails Attached Thumbnails
    EdkFaWW.png  

    Last edited by lock5126; 02-24-2013 at 10:50 AM.

  7. #6
    abuckau907's Avatar
    Join Date
    Dec 2012
    Gender
    male
    Location
    other side of the wire
    Posts
    1,342
    Reputation
    162
    Thanks
    239
    My Mood
    Cold
    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)
    Last edited by abuckau907; 02-24-2013 at 11:01 AM. Reason: [b]
    'Some things that can be counted, don't matter. And some things that matter, can't be counted' - A.E.
    --
     

    My posts have some inaccuracies/are wrong/wrong keyword(s) used.
    They're (maybe) pretty close, and I hope they helped you, not created confusion. Take with grain of salt.

    -if you give rep, please leave a comment, else it means less.

  8. The Following User Says Thank You to abuckau907 For This Useful Post:

    lock5126 (02-24-2013)

  9. #7
    lock5126's Avatar
    Join Date
    May 2011
    Gender
    male
    Location
    Moscow, Russia
    Posts
    15
    Reputation
    10
    Thanks
    0
    MessageBox.Show(_ListOfAllAddressAsHexString.ToArr ay, "debugging list -ab"), when "ToArray" must be "ToString".
    Thank you, worked! )

  10. #8
    abuckau907's Avatar
    Join Date
    Dec 2012
    Gender
    male
    Location
    other side of the wire
    Posts
    1,342
    Reputation
    162
    Thanks
    239
    My Mood
    Cold
    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?
    Last edited by abuckau907; 02-24-2013 at 11:13 AM.
    'Some things that can be counted, don't matter. And some things that matter, can't be counted' - A.E.
    --
     

    My posts have some inaccuracies/are wrong/wrong keyword(s) used.
    They're (maybe) pretty close, and I hope they helped you, not created confusion. Take with grain of salt.

    -if you give rep, please leave a comment, else it means less.

  11. #9
    lock5126's Avatar
    Join Date
    May 2011
    Gender
    male
    Location
    Moscow, Russia
    Posts
    15
    Reputation
    10
    Thanks
    0

  12. #10
    abuckau907's Avatar
    Join Date
    Dec 2012
    Gender
    male
    Location
    other side of the wire
    Posts
    1,342
    Reputation
    162
    Thanks
    239
    My Mood
    Cold
    idk what the final addr should be

    "So there is no bug: You only needed to display the number in hex, issue resolved?"
    'Some things that can be counted, don't matter. And some things that matter, can't be counted' - A.E.
    --
     

    My posts have some inaccuracies/are wrong/wrong keyword(s) used.
    They're (maybe) pretty close, and I hope they helped you, not created confusion. Take with grain of salt.

    -if you give rep, please leave a comment, else it means less.

  13. #11
    lock5126's Avatar
    Join Date
    May 2011
    Gender
    male
    Location
    Moscow, Russia
    Posts
    15
    Reputation
    10
    Thanks
    0
    Hope I will find a solution.

    Shall immediately begin to learn English xD

  14. #12
    wut12345's Avatar
    Join Date
    Oct 2012
    Gender
    male
    Posts
    294
    Reputation
    16
    Thanks
    1,453
    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

  15. #13
    Paul's Avatar
    Join Date
    Mar 2011
    Gender
    male
    Posts
    6,296
    Reputation
    473
    Thanks
    1,061
    My Mood
    Sleepy
    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?


  16. #14
    wut12345's Avatar
    Join Date
    Oct 2012
    Gender
    male
    Posts
    294
    Reputation
    16
    Thanks
    1,453
    Quote Originally Posted by Paul View Post


    How can cancer like you get cancer?
    Cause its cancer

  17. #15
    abuckau907's Avatar
    Join Date
    Dec 2012
    Gender
    male
    Location
    other side of the wire
    Posts
    1,342
    Reputation
    162
    Thanks
    239
    My Mood
    Cold
    ..Can cancer get cancer?
    'Some things that can be counted, don't matter. And some things that matter, can't be counted' - A.E.
    --
     

    My posts have some inaccuracies/are wrong/wrong keyword(s) used.
    They're (maybe) pretty close, and I hope they helped you, not created confusion. Take with grain of salt.

    -if you give rep, please leave a comment, else it means less.

Page 1 of 2 12 LastLast

Similar Threads

  1. Step 6 of the Cheat Engine Tutorial
    By JAA149 in forum General Game Hacking
    Replies: 0
    Last Post: 04-13-2012, 04:15 AM
  2. [Tutorial] Cheat Engine Tutorial v3.1(NEW) STEP 9
    By Magnificos in forum Game Hacking Tutorials
    Replies: 0
    Last Post: 02-28-2012, 07:24 PM
  3. [TUT] Basic Cheat Engine tutorial for begginers
    By rawr161 in forum Programming Tutorials
    Replies: 2
    Last Post: 08-14-2009, 06:41 AM
  4. Whats wrong with my code? =(
    By SadisticGrin in forum C++/C Programming
    Replies: 13
    Last Post: 08-03-2007, 11:39 AM