introspection_read_process_memory()
Read the memory of a target process
Synopsis:
#include <sys/introspection.h>
int introspection_read_process_memory( pid64_t pid64,
uintptr_t offset,
void *buffer,
size_t bsize );
Arguments:
- pid64
- The PID (pid_t) or unique PID (pid64_t) of the target process.
- offset
- The memory address within the target process.
- buffer
- The location to store the data.
- bsize
- The size of the buffer.
Library:
libintrospection
Use the -l introspection option to qcc to link against this library.
Description:
The introspection_read_process_memory() function reads bsize bytes from the target process's memory, starting at offset. If offset is invalid (not mapped, too big), or the range (offset, offset + bsize) isn't completely mapped, the function returns -ESRVRFAULT.
Note:
Your process must have the
PROCMGR_AID_XPROCESS_MEM_READ ability enabled to read the memory
of another process.
Warning:
Reading memory from another process is unsafe.
In particular, reading from a physical mapping in the process's address space is
dangerous, as such mappings may include hardware registers. Reading these registers
can trigger side effects that can result in undefined and unsafe behavior, including
system crashes or hanging.
Returns:
The number of read bytes, on success. If an error occurs, the function returns the negative of a value from the Errors section.
Errors:
- EFAULT
- Error accessing the output buffer.
- EPERM
- The calling process doesn't have the required ability.
- ESRCH
- The PID is invalid.
- ESRVRFAULT
- The calling process tried to read a virtual memory range that wasn't mapped into the process.
Classification:
| Safety: | |
|---|---|
| Cancellation point | Yes |
| Signal handler | Yes |
| Thread | Yes |
Page updated:
