[−][src]Crate process_memory
This crate provides tools for working with the raw memory of programs, whether that be the implemented by the user.
Examples
// 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);
// 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);
Structs
DataMember | Tools for working with memory of other programs |
LocalMember | Tools for working with local memory |
Traits
CopyAddress | A trait that defines that it is possible to copy some memory from something represented by a type into a buffer. |
HandleChecker | A trait to check that a |
Memory | A trait that refers to and allows writing to a region of memory in a running program. |
PutAddress | A trait that defines that it is possible to put a buffer into the memory of something represented by a type. |
TryIntoProcessHandle | A trait that attempts to turn some type into a |
Functions
copy_address | Copy |
Type Definitions
Pid | On Linux a |
ProcessHandle | On Linux a |