CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2021

    How do I code pointers in Visual Basic? (Relating to Cheat Engine) I'm so confused!

    I use Cheat Engine and in Cheat Engine you have Memory Addresses and Pointers. In Cheat Engine I got my Memory and Pointers to work just fine.
    Now trying to do this Visual Basic is a pain. I must be misunderstanding something. This is what Cheat Engine has and this is what I am trying to code in Visual Basic:

    Name:  cheatengine.png
Views: 1405
Size:  13.7 KB

    Here is the code I am trying:

    baseaddress = 00007FF73EE70000
    GV.addresses = 01DB81B0
    pointer = A4
    When I add 'baseaddress' and 'GV.addresses' I get: '7FF740C281B0 ' Which is Mathematically correct.

    Now I know a Pointer points to a Memory Address that has a Memory Address in it which is a 4Byte. Then you read that address and add the pointer.

    My Code will show the correct value of '00007FF73EE70000' + '01DB81B0' (which is '7FF740C281B0')

    Dim testt As Long
    testt = (Convert.ToInt64(baseaddress, 16) + (GV.addresses))
    But no matter how much I play with '7FF740C281B0' I can't get Cheat Engines Value of '1C6B64B70F4'.

    I thought it worked like you read the Address in Hex stored at '00007FF73EE70000' + '01DB81B0' (baseaddress + GV.addresses). Then you take that addressed that is stored there and add the pointer 'A4'.

    But the value in Cheat Engine stored at ('00007FF73EE70000' + '01DB81B0') is '3058397264'

    Name:  cheatengine2.png
Views: 1116
Size:  10.3 KB

    And none of those will point to '1C6B64B70F4'.

    I need to get the Address '1C6B64B70F4' to add the pointer of 'A4'

    What am I doing wrong here????

    I am so confused on this... Can anyone help sort this mess out for me?


    I hope that because I am referencing Cheat Engine here that it does not break any rules. But I am relating this to a Visual Basic issue, so I thought it would be ok. If not, I apologize.

    I should note that this has NOTHING TO WITH CHEATING in a game. I am trying to read memory addresses in a game and display them to help keep track of a Characters Progress.

    I am reading variables such as HP, MP, and Coordinates. I then want to store the variables and keep track of there changes.

    I am not trying to modify any memory addresses.
    I am just reading memory addresses.

  2. #2
    DataMiser is offline Super Moderator Power Poster
    Join Date
    Jul 2008

    Re: How do I code pointers in Visual Basic? (Relating to Cheat Engine) I'm so confuse

    what is pointer defined as and is A4 a literal value or a variable?
    Always use [code][/code] tags when posting code.

  3. #3
    Join Date
    Jun 2021

    Thumbs up Re: How do I code pointers in Visual Basic? (Relating to Cheat Engine) I'm so confuse

    Here is the complete listing of the source code: (just copy it into a project and run it).
    HTML Code:
    Option Explicit
    Private Declare Sub CopyMemory Lib "kernel32" _
        Alias "RtlMoveMemory" (Destination As Any, _
        Source As Any, ByVal Length As Long)
    Private Declare Function GetProcessHeap Lib "kernel32" () As Long
    Private Declare Function HeapAlloc Lib "kernel32" _
        (ByVal hHeap As Long, ByVal dwFlags As Long,_
         ByVal dwBytes As Long) As Long
    Private Declare Function HeapFree Lib "kernel32" _
        (ByVal hHeap As Long, ByVal dwFlags As Long, lpMem As Any) As Long
    Private Declare Sub CopyMemoryWrite Lib "kernel32" Alias _
        "RtlMoveMemory" (ByVal Destination As Long, _
        Source As Any, ByVal Length As Long)
    Private Declare Sub CopyMemoryRead Lib "kernel32" Alias _
        "RtlMoveMemory" (Destination As Any, _
        ByVal Source As Long, ByVal Length As Long)
    Private Sub Form_Load()
        Dim ptr As Long   'int * ptr;
        Dim hHeap As Long
        hHeap = GetProcessHeap()
        ptr = HeapAlloc(hHeap, 0, 2) 'an integer in Visual Basic is 2 bytes
        If ptr <> 0 Then
        'memory was allocated
        'do stuff
            Dim i As Integer
            i = 10
            CopyMemoryWrite ptr, i, 2 ' an intger is two bytes
            Dim j As Integer
            CopyMemoryRead j, ptr, 2
            MsgBox "The adress of ptr is " & CStr(ptr) & _
                vbCrLf & "and the value is " & CStr(j)
            HeapFree GetProcessHeap(), 0, ptr
        End If
    End Sub
    Last edited by VictorN; July 1st, 2021 at 06:18 AM. Reason: Web link was removed.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Click Here to Expand Forum to Full Width