I/O access to virtual memory contents of processes
Read and write data from/to the current process and other processes. This can be used for process monitoring, debugging, testing, communication, etc.
Examples
Reading the stack of the currently running process, through this library:
use ProcessVirtualMemoryIO;
use Read;
// Perform I/O on this current process.
let process_id = id;
let address_of_pid = &process_id as *const _ as u64;
let mut process_io = unsafe ?;
// Read the stack of this current thread.
let mut buffer = ;
process_io.read_exact?;
let also_pid = u32 from_ne_bytes;
assert_eq!;
Writing to the heap of the currently running process, through this library:
use ProcessVirtualMemoryIO;
use ;
// Perform I/O on this current process.
let process_id = id;
let mut process_io = unsafe ?;
// Some location on the heap that we will write to.
let mut pid_on_the_heap = Box new;
// Seek to that location and write the PID there.
process_io.seek?;
process_io.write?;
assert_eq!;
Safety
Memory safety
Writing to the virtual memory of a process is a potentially unsafe operation because it may introduce memory unsafety in that process, and may lead to unexpected states in that process. This is even more dangerous when the target process is the currently running process.
Running processes
Performing I/O on a running process is not recommended, because the
layout of its virtual memory can change at any time, or the process
could simply terminate and vanish.
Consider pausing all threads of the specified process before performing
I/O on it. This can usually be done via the SIGSTOP
and SIGCONT
POSIX signals.
Platform-specific notes
For the moment, only Linux is supported.
Versioning
This project adheres to Semantic Versioning.
The CHANGELOG.md
file details notable changes over time.
License
Copyright (c) 2020 MicroDoc Software GmbH.
See the LICENSE.txt
file at the top-level directory of this distribution.
Licensed under the MIT license. This file may not be copied, modified, or distributed except according to those terms.