Skip to main content

ProcessMemorySlice

Struct ProcessMemorySlice 

Source
pub struct ProcessMemorySlice<'a> { /* private fields */ }
Available on crate feature process-memory only.
Expand description

A unowned slice of a buffer in the memory space of a (remote) process.

Implementations§

Source§

impl<'a> ProcessMemorySlice<'a>

Source

pub const unsafe fn from_raw_parts( ptr: *mut u8, len: usize, process: BorrowedProcess<'a>, ) -> Self

Constructs a new slice from the given raw parts.

§Safety

The caller must ensure that the designated region of memory

Source

pub fn is_local(&self) -> bool

Returns whether the memory is allocated in the current process.

Source

pub fn is_remote(&self) -> bool

Returns whether the memory is allocated in another process.

Source

pub const fn process(&self) -> BorrowedProcess<'a>

Returns the process the buffer is allocated in.

Source

pub const fn len(&self) -> usize

Returns the length of the buffer.

Source

pub const fn is_empty(&self) -> bool

Returns whether the buffer is empty.

Source

pub fn read(&self, offset: usize, buf: &mut [u8]) -> Result<(), Error>

Copies the contents of this buffer starting from the given offset to the given local buffer.

§Panics

This function will panic if the given offset plus the given buffer length exceeds this buffer’s length.

Source

pub unsafe fn read_struct<T>(&self, offset: usize) -> Result<T, Error>

Reads a value of type T from this buffer starting from the given offset.

§Panics

This function will panic if the given offset plus the size of the value exceeds this buffer’s length.

§Safety

The caller must ensure that the designated region of memory contains a valid instance of type T at the given offset.

Source

pub fn write(&self, offset: usize, buf: &[u8]) -> Result<(), Error>

Copies the contents of the given local buffer to this buffer at the given offset.

§Panics

This function will panic if the given offset plus the size of the local buffer exceeds this buffer’s length.

Source

pub fn write_struct<T: ?Sized>(&self, offset: usize, s: &T) -> Result<(), Error>

Writes a value of type T to this buffer at the given offset.

§Panics

This function will panic if the given offset plus the given buffer length exceeds this buffer’s length.

Source

pub const fn as_ptr(&self) -> *mut u8

Returns a pointer to the start of the buffer.

§Note

The returned pointer is only valid in the target process.

Source

pub fn slice(&self, bounds: impl RangeBounds<usize>) -> Self

Returns a slice of this buffer.

Source

pub fn as_local_slice(&self) -> Option<&[u8]>

Constructs a new slice spanning the whole buffer.

Source

pub fn as_local_slice_mut(&mut self) -> Option<&mut [u8]>

Constructs a new mutable slice spanning the whole buffer.

Source

pub fn flush_instruction_cache(&self) -> Result<(), Error>

Flushes the CPU instruction cache for the whole buffer. This may be necesary if the buffer is used to store dynamically generated code. For details see FlushInstructionCache.

Trait Implementations§

Source§

impl<'a> AsMut<ProcessMemorySlice<'a>> for ProcessMemoryBuffer<'a>

Source§

fn as_mut(&mut self) -> &mut ProcessMemorySlice<'a>

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<'a> AsRef<ProcessMemorySlice<'a>> for ProcessMemoryBuffer<'a>

Source§

fn as_ref(&self) -> &ProcessMemorySlice<'a>

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<'a> Clone for ProcessMemorySlice<'a>

Source§

fn clone(&self) -> ProcessMemorySlice<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for ProcessMemorySlice<'a>

Source§

impl<'a> Debug for ProcessMemorySlice<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> !Send for ProcessMemorySlice<'a>

Available on Windows only.
§

impl<'a> !Sync for ProcessMemorySlice<'a>

Available on Windows only.
§

impl<'a> Freeze for ProcessMemorySlice<'a>

Available on Windows only.
§

impl<'a> RefUnwindSafe for ProcessMemorySlice<'a>

Available on Windows only.
§

impl<'a> Unpin for ProcessMemorySlice<'a>

Available on Windows only.
§

impl<'a> UnsafeUnpin for ProcessMemorySlice<'a>

Available on Windows only.
§

impl<'a> UnwindSafe for ProcessMemorySlice<'a>

Available on Windows only.

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Available on Windows only.
Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Available on Windows only.
Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Available on Windows only.
Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Available on Windows only.
Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DropFlavorWrapper<T> for T

Available on Windows only.
Source§

type Flavor = MayDrop

The DropFlavor that wraps T into Self
Source§

impl<T> From<T> for T

Available on Windows only.
Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, W> HasTypeWitness<W> for T
where W: MakeTypeWitness<Arg = T>, T: ?Sized,

Available on Windows only.
Source§

const WITNESS: W = W::MAKE

A constant of the type witness
Source§

impl<T> Identity for T
where T: ?Sized,

Available on Windows only.
Source§

const TYPE_EQ: TypeEq<T, <T as Identity>::Type> = TypeEq::NEW

Proof that Self is the same type as Self::Type, provides methods for casting between Self and Self::Type.
Source§

type Type = T

The same type as Self, used to emulate type equality bounds (T == U) with associated type equality constraints (T: Identity<Type = U>).
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Available on Windows only.
Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Available on Windows only.
Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Available on Windows only.
Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Available on Windows only.
Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.