Struct titanium::desktop::memory::LocalMember
pub struct LocalMember<T> { /* private fields */ }
Expand description
This struct provides functions for modifying the memory of a program from within the address space of that program. This may be helpful for debug functions, or for an injected DLL.
Examples:
// We have a variable with some value
let x = 4u32;
// We make a `LocalMember` that has an offset referring to its location in memory
let member = LocalMember::new_offset(vec![&x as *const _ as usize]);
// The memory refered to is now the same
assert_eq!(&x as *const _ as usize, member.get_offset().unwrap());
// The value of the member is the same as the variable
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();
assert_eq!(x, 6u32);
Safety
These functions are technically not safe. Do not attempt to read or write to any local
memory that you do not know is correct. If you’re trying to explore your entire address space
or are testing to see if a pointer is allocated to you, use DataMember
with your own PID.
Unfortunately it’s not possible to implement some traits safely (e.g. Memory
on
DataMember
but implement it on other structures unsafely in Rust.
The implemented functions try to stop you from shooting yourself in the foot by checking none of the pointers end up at the null pointer, but this does not guarantee that you won’t be able to mess something up really badly in your program.
Implementations§
§impl<T> LocalMember<T>where
T: Copy,
impl<T> LocalMember<T>where T: Copy,
pub fn new() -> LocalMember<T>
pub fn new() -> LocalMember<T>
Creates a new LocalMember
with no offsets. Any calls to
Memory::read
will attempt to read from a null pointer reference.
To set offsets, use Memory::set_offset
offset), or create the LocalMember
using
new_offset
.
pub fn new_offset(offsets: Vec<usize, Global>) -> LocalMember<T>
pub fn new_offset(offsets: Vec<usize, Global>) -> LocalMember<T>
Create a new LocalMember
with a given set of offsets.
Trait Implementations§
§impl<T> Clone for LocalMember<T>where
T: Clone,
impl<T> Clone for LocalMember<T>where T: Clone,
§fn clone(&self) -> LocalMember<T>
fn clone(&self) -> LocalMember<T>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more§impl<T> Debug for LocalMember<T>where
T: Debug,
impl<T> Debug for LocalMember<T>where T: Debug,
§impl<T> Default for LocalMember<T>where
T: Default,
impl<T> Default for LocalMember<T>where T: Default,
§fn default() -> LocalMember<T>
fn default() -> LocalMember<T>
§impl<T> Memory<T> for LocalMember<T>where
T: Copy,
impl<T> Memory<T> for LocalMember<T>where T: Copy,
§unsafe fn read(&self) -> Result<T, Error>
unsafe fn read(&self) -> Result<T, Error>
This will only return a error if one of the offsets gives a null pointer. or give a non-aligned read
§fn write(&self, value: &T) -> Result<(), Error>
fn write(&self, value: &T) -> Result<(), Error>
This will only return a error if one of the offsets gives a null pointer.
§fn set_offset(&mut self, new_offsets: Vec<usize, Global>)
fn set_offset(&mut self, new_offsets: Vec<usize, Global>)
Vec<Vec<T>>
or a Vec<String>
. Read more§fn get_offset(&self) -> Result<usize, Error>
fn get_offset(&self) -> Result<usize, Error>
Memory::set_offset
. Read more