Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27351

VS 2008 Adding hex together and pointers

$
0
0
Hi !
I dont want to make any cheat/other malicious software.From some time im making a GTA:SA program that will save my money,health and few other things to a file, and then i will like to make it so someone else will be able to check out my "stats"
I got already money (im using this class to get memory access:
Code:

Module accessMemory

    Const PROCESS_VM_OPERATION As Integer = &H8
    Const PROCESS_VM_READ As Integer = &H10
    Const PROCESS_VM_WRITE As Integer = &H20
    Public Declare Function OpenProcess Lib "Kernel32" Alias "OpenProcess" (ByVal dwDesiredAccess As Integer, ByVal bInheritHandle As Boolean, ByVal dwProcessId As Integer) As IntPtr
    Public Declare Function ReadProcessMemory Lib "kernel32.dll" (ByVal processHandle As IntPtr, ByVal BaseAddress As Integer, ByVal Buffer As IntPtr, ByVal Size As Integer, ByRef OutputSize As Integer) As Boolean
    Public Declare Function WriteProcessMemory Lib "kernel32.dll" (ByVal processHandle As IntPtr, ByVal BaseAddress As Integer, ByVal Buffer As IntPtr, ByVal Size As Integer, ByRef OutputSize As Integer) As Boolean
    Public Declare Function CloseHandle Lib "Kernel32" Alias "CloseHandle" (ByVal hObject As IntPtr) As Boolean
    Public Function ReadVariable(ByVal pID As Integer, ByVal variableAddress As Integer, ByVal variableSize As Integer, ByRef localBuffer() As Byte) As Integer
        Dim hProcess As IntPtr = OpenProcess(PROCESS_VM_READ, False, pID)

        If hProcess = IntPtr.Zero Then Return 0

        Dim outputSize As Integer
        Dim tempGC As Runtime.InteropServices.GCHandle = Runtime.InteropServices.GCHandle.Alloc(localBuffer, Runtime.InteropServices.GCHandleType.Pinned)

        If Not ReadProcessMemory(hProcess, variableAddress, tempGC.AddrOfPinnedObject, variableSize, outputSize) Then outputSize = 0

        tempGC.Free()
        CloseHandle(hProcess)
        Return outputSize
    End Function
    Public Function WriteVariable(ByVal pID As Integer, ByVal variableAddress As Integer, ByVal variableSize As Integer, ByVal localBuffer() As Byte) As Integer
        Dim hProcess As IntPtr = OpenProcess(PROCESS_VM_WRITE Or PROCESS_VM_OPERATION, False, pID)

        If hProcess = IntPtr.Zero Then Return 0

        Dim outputSize As Integer
        Dim tempHandle As IntPtr = Runtime.InteropServices.Marshal.AllocHGlobal(variableSize)
        Runtime.InteropServices.Marshal.Copy(localBuffer, 0, tempHandle, variableSize)

        If Not WriteProcessMemory(hProcess, variableAddress, tempHandle, variableSize, outputSize) Then outputSize = 0

        Runtime.InteropServices.Marshal.FreeHGlobal(tempHandle)
        CloseHandle(hProcess)
        Return outputSize
    End Function

End Module

but Health address is dynamic, to get proper address i need to use pointer, i can do this in Cheat Engine, but i dont want to change the value but to read it and then put into some variable/label.
I have done this in Cheat Engine, i will post a screenshot from CE

Is it possible to do in VB.NET ?

Viewing all articles
Browse latest Browse all 27351

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>