Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Visual Basic ( VB ) (http://www.go4expert.com/forums/visual-basic/)
-   -   ReadProcessMemory API (http://www.go4expert.com/forums/readprocessmemory-api-t4314/)

Matelin 15May2007 16:55

ReadProcessMemory API
 
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


All times are GMT +5.5. The time now is 16:35.