Read and write data from/to the current process and other processes. This can be used for process monitoring, debugging, testing, communication, etc.
Reading the stack of the currently running process, through this library:
```rust use processvmio::ProcessVirtualMemoryIO; use std::io::Read;
// Perform I/O on this current process. let processid = std::process::id(); let addressofpid = &processid as *const _ as u64; let mut processio = unsafe { ProcessVirtualMemoryIO::new(processid, addressofpid) }?;
// Read the stack of this current thread.
let mut buffer = [0u8; std::mem::sizeof::
Writing to the heap of the currently running process, through this library:
```rust use processvmio::ProcessVirtualMemoryIO; use std::io::{Seek, Write};
// Perform I/O on this current process. let processid = std::process::id(); let mut processio = unsafe { ProcessVirtualMemoryIO::new(process_id, 0) }?;
// Some location on the heap that we will write to. let mut pidontheheap = Box::new(0u32);
// Seek to that location and write the PID there. processio.seek(std::io::SeekFrom::Start(pidontheheap.asmut() as *mut _ as u64))?; processio.write(&processid.tone_bytes())?;
asserteq!(processid, *pidonthe_heap); ```
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.
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.
For the moment, only Linux is supported.
This project adheres to Semantic Versioning.
The CHANGELOG.md
file details notable changes over time.
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.