Results 1 to 12 of 12

Thread: Problems with this module

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2004
    Posts
    13

    Problems with this module

    This is a module to help read values in memory from a chosen process.


    VB Code:
    1. Module Module1
    2.     Public Const PROCESS_ALL_ACCESS = &H1F0FFF
    3.     'This above code makes it work on Windows XP
    4.     Public Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hWnd As Long, ByVal lpdwProcessId As Long) As Long
    5.     Public Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
    6.     Public Declare Function WriteProcessMemory Lib "kernel32" (ByVal hProcess As Long, ByVal lpBaseAddress As Integer, ByVal lpBuffer As Integer, ByVal nSize As Long, ByVal lpNumberOfBytesWritten As Long) As Long
    7.     Public Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
    8.     Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal Classname As String, ByVal WindowName As String) As Long
    9.     Public Declare Function ReadProcessMem Lib "kernel32" Alias "ReadProcessMemory" (ByVal hProcess As Long, ByVal lpBaseAddress As Integer, ByRef lpBuffer As Integer, ByVal nSize As Long, ByVal lpNumberOfBytesWritten As Long) As Long
    10.  
    11.  
    12.     Public Function ReadFour(ByVal GameClass As String, ByVal Address As Long, ByVal valbuffer As Long)
    13.         Dim hWnd As Long
    14.         Dim pId As Long
    15.         Dim phandle As Long
    16.         hWnd = FindWindow(GameClass, vbNullString)
    17.         If (hWnd = 0) Then
    18.             [COLOR=red]frmmain[/COLOR].lbl_debug.Caption = "Debug: Please Run x and restart the application."
    19.             Exit Function
    20.         End If
    21.         GetWindowThreadProcessId(hWnd, pId)
    22.         phandle = OpenProcess(PROCESS_ALL_ACCESS, False, pId)
    23.         If (phandle = 0) Then
    24.             MsgBox("Can't get ProcessId", vbCritical, "Error")
    25.             Exit Function
    26.         End If
    27.         ReadProcessMem(phandle, Address, valbuffer, 4, 0&)
    28.         CloseHandle([COLOR=red]hProcess[/COLOR])
    29.     End Function
    30. End Module

    I put in red the places that Visual studio is reporting errors. Anyone have any ideas? (I'm using VS.NET 2003)



    The author then suggest a possible use for this module:


    Get the CLASS NAME of your game.. and now ..
    go to your form.

    Add a timer and a textbox or label. I suggest label.. its cleaner..
    we are going to call our timer Timer1

    Timer1_Timer()

    Call Module1.ReadMorph("Game Class Name", &HAddress, variable)

    'Im using a label for this example

    Label1.caption = variable

    End Sub




    There you go!

    Simple code so that you can read an address and put its value in a label or textbox ect ect.

    Hope that was educational/helpful.
    Last edited by Tortle; Jan 11th, 2004 at 03:33 PM.

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