use winapi::um::processthreadsapi::{OpenProcess,CreateRemoteThreadEx};
use winapi::um::errhandlingapi::GetLastError;
use winapi::shared::ntdef::NULL;
use winapi::um::winnt::{HANDLE,
MEM_COMMIT, MEM_RELEASE, MEM_RESERVE, PAGE_EXECUTE_READWRITE, PROCESS_ALL_ACCESS
};
pub struct KernelObj {
handle: HANDLE,
}
unsafe fn get_proccess(process_id: u32) -> Result<KernelObj, DWORD> {
println!("inside get proccess => {}",process_id);
let process = OpenProcess(PROCESS_ALL_ACCESS, 0, process_id);
if process == NULL {
Err(GetLastError())
} else {
Ok(KernelObj{ handle: process })
}
}
I am using rust winapi on windows 11 I am trying to do a process injection
whenever I tried to open explorer.exe it always returned this error and it returning error 5
[target.'cfg(windows)'.dependencies]
winapi = { version = "0.3", features = ["winuser","errhandlingapi"] }
<read memory from 0x674 failed (0 of 1 bytes read)>
Edit => I Found that the code is still working but while debugging the debugger shows that error.