pub unsafe trait ReadableProcessBuffer {
// Required methods
fn len(&self) -> usize;
fn ptr(&self) -> *const u8;
fn enter<F, R>(&self, fun: F) -> Result<R, Error>
where F: FnOnce(&ReadableProcessSlice) -> R;
}Expand description
A readable region of userspace process memory.
This trait can be used to gain read-only access to memory regions
wrapped in either a ReadOnlyProcessBuffer or a
ReadWriteProcessBuffer type.
§Safety
This is an unsafe trait as users of this trait need to trust that the
implementation of ReadableProcessBuffer::ptr is correct. Implementors of
this trait must ensure that the ReadableProcessBuffer::ptr method
follows the semantics and invariants described in its documentation.
Required Methods§
Sourcefn len(&self) -> usize
fn len(&self) -> usize
Length of the memory region.
If the process is no longer alive and the memory has been reclaimed, this method must return 0.
§Default Process Buffer
A default instance of a process buffer must return 0.
Sourcefn ptr(&self) -> *const u8
fn ptr(&self) -> *const u8
Pointer to the first byte of the userspace-allowed memory region.
If ReadableProcessBuffer::len returns a non-zero value,
then this method is guaranteed to return a pointer to the
start address of a memory region (of length returned by
len), allowable by a userspace process, and allowed to the
kernel for read operations. The memory region must not be
written to through this pointer.
If the length of the initially shared memory region
(irrespective of the return value of
len) is 0, this function
returns a pointer to address 0x0. This is because processes
may allow zero-length buffer to share no memory with the
kernel. Because these buffers have zero length, they may have
any arbitrary pointer value. However, these “dummy addresses”
should not be leaked, so this method returns 0 for zero-length
slices. Care must be taken to not create a Rust (slice)
reference over a null-pointer, as that is undefined behavior.
Users of this pointer must not produce any mutable aliasing, such as by
creating a reference from this pointer concurrently with calling
WriteableProcessBuffer::mut_enter.
§Default Process Buffer
A default instance of a process buffer must return a pointer
to address 0x0.
Sourcefn enter<F, R>(&self, fun: F) -> Result<R, Error>where
F: FnOnce(&ReadableProcessSlice) -> R,
fn enter<F, R>(&self, fun: F) -> Result<R, Error>where
F: FnOnce(&ReadableProcessSlice) -> R,
Applies a function to the (read only) process slice reference pointed to by the process buffer.
If the process is no longer alive and the memory has been
reclaimed, this method must return
Err(process::Error::NoSuchApp).
§Default Process Buffer
A default instance of a process buffer must return
Err(process::Error::NoSuchApp) without executing the passed
closure.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.