Struct titanium::desktop::memory::DataMember
pub struct DataMember<T> { /* private fields */ }
Expand description
Tools for working with memory of other programs
This module provides functions for modifying the memory of a program from outside of the address space of that program.
Examples:
// We have a variable with some value
let x = 4u32;
println!("Original x-value: {}", x);
// We need to make sure that we get a handle to a process, in this case, ourselves
let handle = (std::process::id() as Pid).try_into_process_handle().unwrap();
// We make a `DataMember` that has an offset referring to its location in memory
let member = DataMember::new_offset(handle, vec![&x as *const _ as usize]);
// The memory refered to is now the same
println!("Memory location: &x: {}, member: {}", &x as *const _ as usize,
member.get_offset().unwrap());
assert_eq!(&x as *const _ as usize, member.get_offset().unwrap());
// The value of the member is the same as the variable
println!("Member value: {}", unsafe { member.read().unwrap() });
assert_eq!(x, unsafe { member.read().unwrap() });
// We can write to and modify the value of the variable using the member
member.write(&6u32).unwrap();
println!("New x-value: {}", x);
assert_eq!(x, 6u32);
Implementations§
§impl<T> DataMember<T>where
T: Copy,
impl<T> DataMember<T>where T: Copy,
pub fn new(handle: (i32, Architecture)) -> DataMember<T>
pub fn new(handle: (i32, Architecture)) -> DataMember<T>
Create a new DataMember
from a ProcessHandle
. You must remember to call
try_into_process_handle
on a Pid
, because the types may have the same backing type,
resulting in errors when called with the wrong value.
By default, there will be no offsets, leading to an error when attempting to call
Memory::read
, so you will likely need to call Memory::set_offset
before attempting
any reads.
pub fn new_offset(
handle: (i32, Architecture),
offsets: Vec<usize, Global>
) -> DataMember<T>
pub fn new_offset( handle: (i32, Architecture), offsets: Vec<usize, Global> ) -> DataMember<T>
Create a new DataMember
from a ProcessHandle
and some number of offsets. You must
remember to call try_into_process_handle
on a Pid
as sometimes the Pid
can have
the same backing type as a ProcessHandle
, resulting in an error.
Trait Implementations§
§impl<T> Clone for DataMember<T>where
T: Clone,
impl<T> Clone for DataMember<T>where T: Clone,
§fn clone(&self) -> DataMember<T>
fn clone(&self) -> DataMember<T>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read more§impl<T> Debug for DataMember<T>where
T: Debug,
impl<T> Debug for DataMember<T>where T: Debug,
§impl<T> Memory<T> for DataMember<T>where
T: Copy,
impl<T> Memory<T> for DataMember<T>where T: Copy,
§fn set_offset(&mut self, new_offsets: Vec<usize, Global>)
fn set_offset(&mut self, new_offsets: Vec<usize, Global>)
Set the offsets to the location in memory. This is used for things such as multi-level
pointers, such as a
Vec<Vec<T>>
or a Vec<String>
. Read more§fn get_offset(&self) -> Result<usize, Error>
fn get_offset(&self) -> Result<usize, Error>
Gets the actual total offset from the offsets given by
Memory::set_offset
. Read moreAuto Trait Implementations§
impl<T> RefUnwindSafe for DataMember<T>where T: RefUnwindSafe,
impl<T> !Send for DataMember<T>
impl<T> !Sync for DataMember<T>
impl<T> Unpin for DataMember<T>
impl<T> UnwindSafe for DataMember<T>where T: RefUnwindSafe,
Blanket Implementations§
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> RoundFrom<T> for T
impl<T> RoundFrom<T> for T
§fn round_from(x: T) -> T
fn round_from(x: T) -> T
Performs the conversion.
§impl<T, U> RoundInto<U> for Twhere
U: RoundFrom<T>,
impl<T, U> RoundInto<U> for Twhere U: RoundFrom<T>,
§fn round_into(self) -> U
fn round_into(self) -> U
Performs the conversion.