Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

ReadProcessMemory (user32)
 
.
Summary
Reads data from an area of memory in a specified process. The entire area to be read must be accessible or the operation fails.

C# Signature:

[DllImport("kernel32.dll", SetLastError = true)]
   public static extern bool ReadProcessMemory(
   IntPtr hProcess,
   IntPtr lpBaseAddress,
   byte[] lpBuffer,
   Int32 nSize,
   out IntPtr lpNumberOfBytesRead);

VB Signature:

   Private Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Integer, ByVal lpBaseAddress As Integer, ByVal lpBuffer As Integer, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As Integer

Parameters

Parameters

hProcess in

A handle to the process with memory that is being read. The handle must have PROCESS_VM_READ access to the process.

lpBaseAddress in
lpBaseAddress in

A pointer to the base address in the specified process from which to read. Before any data transfer occurs, the system verifies that all data in the base address and memory of the specified size is accessible for read access, and if it is not accessible the function fails.

lpBuffer out
lpBuffer out

A pointer to a buffer that receives the contents from the address space of the specified process.

nSize in
nSize in

The number of bytes to be read from the specified process.

lpNumberOfBytesRead out
lpNumberOfBytesRead out

A pointer to a variable that receives the number of bytes transferred into the specified buffer. If lpNumberOfBytesRead is NULL, the parameter is ignored.

User-Defined Types:

None.

Alternative Managed API:

Do you know one? Please contribute it!

Notes:

None.

Tips & Tricks:

Please add some!

Sample Code:

Please add some!

Documentation

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

 
Access PInvoke.net directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version
Revisions