pub fn read_address(self, addres: &str) -> u64 {
let num = unsafe{mem::uninitialized()};
let addr = u64::from_str_radix(&addres[2..], 16).unwrap();
let test = unsafe{kernel32::ReadProcessMemory(self.handler, addr as *mut os::raw::c_void, num, u64::max_value(), 0 as *mut u64)};
return num as u64;
}
Your call to ReadProcessMemory tries to read 2^64 - 1 (u64::max_value()) bytes into a memory location pointed to by an uninitialized pointer.
Try something like this (untested):
use std::ptr;
pub fn read_address(self, address: &str) -> u64 {
let mut num = unsafe { mem::uninitialized() };
let addr = u64::from_str_radix(&address[2..], 16).unwrap();
let test = unsafe {
kernel32::ReadProcessMemory(self.handler,
addr as *const _,
&mut num as *mut _ as *mut _,
mem::size_of::<u64>() as winapi::SIZE_T,
ptr::null_mut())
};
// You should check the value of `test`
num
}
You can also have a look at how minject-rs does it. (See RemoteMemory at the top.)