process_read_write

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

use process_read_write;

fn main(){
    let pid:i32 = 1234; // id of process 
    let addr:usize = 0x70eb856006c0; // address of value to read 

    //let pid = get_proc_by_name("SomeRandomGame");
    let pid = process_read_write::get_proc_by_id(pid);

    let health = process_read_write::read_addr(pid,addr,4);
    println!("READING MEMORY: {:?}",health);
}