Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix winapi type definition change #636

Merged
merged 1 commit into from
Apr 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/timer/windows_timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,14 @@ pub struct CPUTimer {

impl CPUTimer {
pub unsafe fn start_suspended_process(child: &process::Child) -> Self {
let child_handle = child.as_raw_handle().cast();

// SAFETY: Creating a new job object is safe
let job_object = unsafe { CreateJobObjectW(ptr::null_mut(), ptr::null_mut()) };
assert!(!job_object.is_null(), "CreateJobObjectW failed");

// SAFETY: The job object handle is valid
let ret = unsafe { AssignProcessToJobObject(job_object, child.as_raw_handle()) };
let ret = unsafe { AssignProcessToJobObject(job_object, child_handle) };
assert!(ret != 0, "AssignProcessToJobObject failed");

#[cfg(windows_process_extensions_main_thread_handle)]
Expand All @@ -70,7 +72,7 @@ impl CPUTimer {
// resume a process by it's handle.

// SAFETY: The process handle is valid
let ret = unsafe { NtResumeProcess(child.as_raw_handle()) };
let ret = unsafe { NtResumeProcess(child_handle) };
assert!(ret == STATUS_SUCCESS, "NtResumeProcess failed");
}

Expand Down