#process #memory #extended #write #processes #read-write

process-memory

A rust library that can read/write the memory of other processes

6 releases (3 breaking)

0.4.0 Jul 18, 2020
0.3.0 Jan 17, 2020
0.2.3 Jan 18, 2018
0.1.1 Jan 11, 2018
Download history 20/week @ 2021-06-25 17/week @ 2021-07-02 16/week @ 2021-07-09 17/week @ 2021-07-16 19/week @ 2021-07-23 33/week @ 2021-07-30 30/week @ 2021-08-06 18/week @ 2021-08-13 19/week @ 2021-08-20 7/week @ 2021-08-27 45/week @ 2021-09-03 63/week @ 2021-09-10 39/week @ 2021-09-17 36/week @ 2021-09-24 24/week @ 2021-10-01 22/week @ 2021-10-08

105 downloads per month
Used in ddcore-rs

MIT license

39KB
586 lines

process-memory

Continuous Integration

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

Examples

use process_memory::{Memory, DataMember, Pid, TryIntoProcessHandle};
// We have a variable with some value
let x = 4_u32;
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: {}", member.read().unwrap());
assert_eq!(x, member.read().unwrap());
// We can write to and modify the value of the variable using the member
member.write(&6_u32).unwrap();
println!("New x-value: {}", x);
assert_eq!(x, 6_u32);
use process_memory::{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::new_offset(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: {}", member.read().unwrap());
assert_eq!(x, member.read().unwrap());
// We can write to and modify the value of the variable using the member
member.write(&6_u32).unwrap();
println!("New x-value: {}", x);
assert_eq!(x, 6_u32);

Dependencies

~76KB