Reduce required permissions on OpenProcess

This commit is contained in:
Your Name
2024-08-26 23:41:46 -04:00
parent 82153d31c9
commit 5f69fc664a

View File

@@ -3,7 +3,7 @@ use std::error::Error;
use windows::Win32::{
Foundation::{CloseHandle, MAX_PATH},
System::Threading::{
OpenProcess, QueryFullProcessImageNameW, PROCESS_QUERY_INFORMATION, PROCESS_VM_READ,
OpenProcess, QueryFullProcessImageNameW, PROCESS_QUERY_LIMITED_INFORMATION
},
};
@@ -11,7 +11,7 @@ pub fn pid_to_exe_path(pid: u32) -> Result<String, Box<dyn Error>> {
let mut exe_name: Vec<u16> = Vec::with_capacity(MAX_PATH as usize);
let mut size: u32 = exe_name.capacity().try_into().unwrap();
unsafe {
let process = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, false, pid)?;
let process = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, false, pid)?;
QueryFullProcessImageNameW(
process,
Default::default(),