Kernel32ReadProcessMemory(SafeProcessHandle, UIntPtr, StringBuilder, IntPtr, IntPtr) Method
Reads data from an area of memory in a specified process.
The entire area to be read must be accessible or the operation fails.
Namespace: DevCase.Win32.NativeMethodsAssembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
[DllImportAttribute("Kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static bool ReadProcessMemory(
SafeProcessHandle hProcess,
UIntPtr baseAddress,
StringBuilder buffer,
IntPtr size,
ref IntPtr refNumberOfBytesRead
)
<DllImportAttribute("Kernel32.dll", CharSet := CharSet.Unicode, SetLastError := true>]
Public Shared Function ReadProcessMemory (
hProcess As SafeProcessHandle,
baseAddress As UIntPtr,
<OutAttribute> buffer As StringBuilder,
size As IntPtr,
ByRef refNumberOfBytesRead As IntPtr
) As Boolean
Dim hProcess As SafeProcessHandle
Dim baseAddress As UIntPtr
Dim buffer As StringBuilder
Dim size As IntPtr
Dim refNumberOfBytesRead As IntPtr
Dim returnValue As Boolean
returnValue = Kernel32.ReadProcessMemory(hProcess,
baseAddress, buffer, size, refNumberOfBytesRead)
public:
[DllImportAttribute(L"Kernel32.dll", CharSet = CharSet::Unicode, SetLastError = true)]
static bool ReadProcessMemory(
[InAttribute] SafeProcessHandle^ hProcess,
[InAttribute] UIntPtr baseAddress,
[OutAttribute] StringBuilder^ buffer,
IntPtr size,
IntPtr% refNumberOfBytesRead
)
[<DllImportAttribute("Kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)>]
static member ReadProcessMemory :
hProcess : SafeProcessHandle *
baseAddress : UIntPtr *
buffer : StringBuilder byref *
size : IntPtr *
refNumberOfBytesRead : IntPtr byref -> bool
No code example is currently available or this language may not be supported.
- hProcess SafeProcessHandle
-
A handle to the process with memory that is being read.
The handle must have PROCESS_VM_READ access to the process.
- baseAddress UIntPtr
-
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.
- buffer StringBuilder
-
A pointer to a buffer that receives the contents from the address space of the specified process.
- size IntPtr
-
The number of bytes to be read from the specified process.
- refNumberOfBytesRead IntPtr
-
A pointer to a variable that receives the number of bytes transferred into the specified buffer.
If refNumberOfBytesRead is 0, the parameter is ignored.
Boolean If the function succeeds,
otherwise.