mirror of
https://github.com/harivansh-afk/sandbox-agent.git
synced 2026-04-17 08:01:03 +00:00
fix: update Windows API calls for windows crate v0.52
This commit is contained in:
parent
60e1ce7e2d
commit
96ae6bed96
1 changed files with 6 additions and 6 deletions
|
|
@ -122,18 +122,18 @@ pub fn is_process_running(pid: u32) -> bool {
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
pub fn is_process_running(pid: u32) -> bool {
|
pub fn is_process_running(pid: u32) -> bool {
|
||||||
use windows::Win32::Foundation::{CloseHandle, HANDLE};
|
use windows::Win32::Foundation::CloseHandle;
|
||||||
use windows::Win32::System::Threading::{
|
use windows::Win32::System::Threading::{
|
||||||
GetExitCodeProcess, OpenProcess, PROCESS_QUERY_LIMITED_INFORMATION,
|
GetExitCodeProcess, OpenProcess, PROCESS_QUERY_LIMITED_INFORMATION,
|
||||||
};
|
};
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let handle = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, false, pid);
|
let handle = match OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, false, pid) {
|
||||||
if handle.is_invalid() {
|
Ok(h) => h,
|
||||||
return false;
|
Err(_) => return false,
|
||||||
}
|
};
|
||||||
let mut exit_code = 0u32;
|
let mut exit_code = 0u32;
|
||||||
let ok = GetExitCodeProcess(handle, &mut exit_code).as_bool();
|
let ok = GetExitCodeProcess(handle, &mut exit_code).is_ok();
|
||||||
let _ = CloseHandle(handle);
|
let _ = CloseHandle(handle);
|
||||||
ok && exit_code == 259
|
ok && exit_code == 259
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue