Results 1 to 5 of 5

Thread: Read/Write ProcessMemory

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Apr 2004
    Location
    sweden
    Posts
    176

    Resolved Read/Write ProcessMemory

    Hello,
    How can i read or write a address with a value that has length more then 4?
    Seams like ReadProcessMem only gets the first 4 of the value.

    Im trying to get the whole value from a word that has length 17 in memory.
    Code:
    dim value as byte
    GetWindowThreadProcessId hwnd, pid
    phandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid)
    ReadProcessMem phandle, address, value, 1, 0&
    CloseHandle hProcess
    Thanks,
    Naitsabes
    Last edited by naitsabes85; Jun 21st, 2005 at 03:11 AM.

  2. #2
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359

    Re: Read/Write ProcessMemory

    I assume you are referring to ReadProcessMemory()?
    It's declaration is as follows;

    VB Code:
    1. Public Declare Function ReadProcessMemory Lib "kernel32" Alias "ReadProcessMemory" (ByVal hProcess As Long, lpBaseAddress As Any, lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long

    So the 2nd last parameter is the amount of data to read. By the way, the last parameter is passed ByRef, so you should be passing in a variable of type Long to test if the correct amount of data was read.
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Apr 2004
    Location
    sweden
    Posts
    176

    Re: Read/Write ProcessMemory

    Something like this?
    Code:
    Dim valbuffer As Long
    ReadProcessMemory phandle, &H5EB988, valbuffer, 17, 0&
    Text1 = valbuffer
    Thanks,
    naitsabes
    Last edited by naitsabes85; Jun 21st, 2005 at 03:26 AM.

  4. #4
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Read/Write ProcessMemory

    More like this

    VB Code:
    1. Public Declare Function ReadProcessMemory Lib "kernel32" Alias "ReadProcessMemory" _
    2.     (ByVal hProcess As Long, _
    3.      ByRef lpBaseAddress As Any, _
    4.      ByRef lpBuffer As Any, _
    5.      ByVal nSize As Long, _
    6.      ByRef lpNumberOfBytesRead As Long) _
    7.     As Long
    8.  
    9. Dim lngBytesRead        As Long
    10. Dim bufReadBuffer(16)   As Byte
    11.  
    12. ReadProcessMemory phandle, _
    13.                   ByVal &H5EB988&, _
    14.                   ByVal VarPtr(bufReadBuffer(0)), _
    15.                   ByVal 17&, _
    16.                   lngBytesRead
    Last edited by penagate; Jun 21st, 2005 at 06:47 AM.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Apr 2004
    Location
    sweden
    Posts
    176

    Re: Read/Write ProcessMemory

    Quote Originally Posted by penagate
    More like this

    VB Code:
    1. Public Declare Function ReadProcessMemory Lib "kernel32" Alias "ReadProcessMemory" _
    2.     (ByVal hProcess As Long, _
    3.      ByRef lpBaseAddress As Any, _
    4.      ByRef lpBuffer As Any, _
    5.      ByVal nSize As Long, _
    6.      ByRef lpNumberOfBytesRead As Long) _
    7.     As Long
    8.  
    9. Dim lngBytesRead        As Long
    10. Dim bufReadBuffer(16)   As Byte
    11.  
    12. ReadProcessMemory phandle, _
    13.                   ByVal &H5EB988&, _
    14.                   ByVal VarPtr(bufReadBuffer(0)), _
    15.                   ByVal 17&, _
    16.                   lngBytesRead
    Thanks ill try that!
    naitsabes

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