Function read_addr

Source
pub fn read_addr(pid: Pid, addr: usize, length: usize) -> Result<Vec<u8>, Error>
Expand description

read_addr is used to read n bytes from a process pid and starting from addr

§Note

the function will return Result<T,E>

Error examples:

  • EPERM: make sure running as sudo
  • ESRCH: make sure the process exist
  • ESFAULT: make sure the address exist in the scope of the process

§Backend

this function invokes the process_vm_readv syscall, enabling direct memory reading from a specified address in the target process.

Examples found in repository?
examples/read_example.rs (line 10)
3fn main(){
4    let pid:i32 = 1234; // id of app
5    let addr:usize = 0x70eb856006c0; // address of value to read 
6
7    //let pid = get_proc_by_name("SomeRandomGame");
8    let pid = process_read_write::get_proc_by_id(pid);
9
10    let health = process_read_write::read_addr(pid,addr,4);
11    println!("READING MEMORY: {:?}",health);
12}