This crate is loosely based on read-process-memory
by luser, but has been extended to be able to write to process memory as well.
The current supported platforms are: - Windows - OSX - Linux
```rust use processmemory::{Memory, DataMember, Pid, TryIntoProcessHandle}; // 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).tryintoprocesshandle().unwrap();
// We make a DataMember
that has an offset referring to its location in memory
let member = DataMember::newoffset(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.getoffset().unwrap());
asserteq!(&x as *const _ as usize, member.getoffset().unwrap());
// The value of the member is the same as the variable
println!("Member value: {}", member.read().unwrap());
asserteq!(x, 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);
asserteq!(x, 6u32);
rust
use processmemory::{Memory, LocalMember};
// We have a variable with some value
let x = 4_u32;
println!("Original x-value: {}", x);
// We make a LocalMember
that has an offset referring to its location in memory
let member = LocalMember::newoffset(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.getoffset().unwrap());
asserteq!(&x as *const _ as usize, member.getoffset().unwrap());
// The value of the member is the same as the variable
println!("Member value: {}", member.read().unwrap());
asserteq!(x, 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);
asserteq!(x, 6u32);
```