1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

ReadProcessMemory API

Discussion in 'Visual Basic ( VB )' started by Matelin, May 15, 2007.

  1. Matelin

    Matelin New Member

    Joined:
    May 15, 2007
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hi
    I need read values from memeory using ReadProcessMemory win API
    what get for now is

    Code:
    Dim ptrWindowLoc As IntPtr
            ptrWindowLoc = FindWindow(Nothing, TextBox1.Text)
            Label3.Text = ptrWindowLoc.ToString
    
            Dim WindowThreadIdentifier As IntPtr
            Dim WindowProcessIdentifier As IntPtr
    
            WindowThreadIdentifier = GetWindowThreadProcessId(ptrWindowLoc, WindowProcessIdentifier)
            Label5.Text = WindowThreadIdentifier.ToString
            Label7.Text = WindowProcessIdentifier
    
            Dim process As IntPtr
            process = OpenProcess(PROCESS_VM_OPERATION Or PROCESS_VM_READ Or PROCESS_VM_WRITE Or _
                       PROCESS_QUERY_INFORMATION, False, WindowProcessIdentifier.ToInt32)
    
            Label9.Text = process.ToString
    
            Dim lvi As LVITEM = New LVITEM
            Dim ptrVirtualAddress As IntPtr
            Dim _ptrVirtualAddress As IntPtr = IntPtr.Zero
            
            'ptrVirtualAddress = VirtualAllocEx(process, IntPtr.Zero, Marshal.SizeOf(GetType(LVITEM)), MEM_COMMIT and , PAGE_READWRITE)
            ptrVirtualAddress = VirtualAllocEx(process, IntPtr.Zero, 512, &H2000, PAGE_READWRITE)
            If ptrVirtualAddress = IntPtr.Zero Then
                Throw New SystemException("Failed to allocate memory in remote process")
            End If
    
    'problem section
    
    Dim a As IntPtr = IntPtr.Zero
            Dim buffer(512) As Byte
    
                   Dim x As Int32 = ReadProcessMemory(process, &H234343, buffer, 512, a)
    
            Dim strf As String = ""
            Dim i As Integer
            For i = 0 To 500
                strf = strf + buffer(i).ToString
            Next
    
            MessageBox.Show(strf) 
    
    the problem is i dont understand the read process parameter
    how can i get the pointer to value i want if i only have a running process

    Any 1 can help
    ThaNKS
     
    Last edited by a moderator: May 15, 2007

Share This Page