Struct process_vm_io::ProcessVirtualMemoryIO
source · #[non_exhaustive]pub struct ProcessVirtualMemoryIO { /* private fields */ }
Expand description
Implementations§
source§impl ProcessVirtualMemoryIO
impl ProcessVirtualMemoryIO
sourcepub unsafe fn new(process_id: u32, initial_address: u64) -> Result<Self, Error>
pub unsafe fn new(process_id: u32, initial_address: u64) -> Result<Self, Error>
Create a new object to perform input/output of data from/to the virtual
memory contents of the process identified by process_id
.
The initial virtual memory address where data transfers initially
happen is specified by initial_address
. Inquiring the system for the
layout of the process address space can help specify this value.
On Linux, the file /proc/[process_id]/maps
can help with this.
Common errors
If the specified process does not exist, or this process does not have the right to send signals to the specified process, then an error is returned.
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
Apart from the process identifier, there is no strong link between the
specified process and this ProcessVirtualMemoryIO
instance.
If the specified process runs and terminates, then further I/O
operations involving this instance may fail.
If the process identifier of the dead process is reused by another
process, then I/O may successfully continue with the new process,
which might not be the desired behavior.
sourcepub fn process_id(&self) -> u32
pub fn process_id(&self) -> u32
Return the process identifier of the target process.
Trait Implementations§
source§impl Debug for ProcessVirtualMemoryIO
impl Debug for ProcessVirtualMemoryIO
source§impl Read for ProcessVirtualMemoryIO
impl Read for ProcessVirtualMemoryIO
source§fn read(&mut self, buf: &mut [u8]) -> Result<usize>
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
source§fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize>
fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize>
read
, except that it reads into a slice of buffers. Read moresource§fn is_read_vectored(&self) -> bool
fn is_read_vectored(&self) -> bool
can_vector
)1.0.0 · source§fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
buf
. Read more1.0.0 · source§fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
buf
. Read more1.6.0 · source§fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
buf
. Read moresource§fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
read_buf
)source§fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
read_buf
)cursor
. Read more1.0.0 · source§fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
Read
. Read moresource§impl Seek for ProcessVirtualMemoryIO
impl Seek for ProcessVirtualMemoryIO
source§fn seek(&mut self, pos: SeekFrom) -> Result<u64>
fn seek(&mut self, pos: SeekFrom) -> Result<u64>
Seek to an address in the virtual memory address space of the associated process.
If the seek operation completed successfully, this method returns the new position from the start of the stream.
The target address need not be readable/writable or even mapped. Seeking beyond the address space size puts the cursor after the end of the address space.
1.55.0 · source§fn rewind(&mut self) -> Result<(), Error>
fn rewind(&mut self) -> Result<(), Error>
source§fn stream_len(&mut self) -> Result<u64, Error>
fn stream_len(&mut self) -> Result<u64, Error>
seek_stream_len
)source§impl Write for ProcessVirtualMemoryIO
impl Write for ProcessVirtualMemoryIO
source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector
)1.0.0 · source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
write_all_vectored
)