Skip to content
Myr

Cleanup Windows CPUTimer

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Clemens Wasser · committed by David Peter · parent a596c70 · Browse files · 2 files+7 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+7 added−2 removed

  • other:+7 added−2 removed

2 files+7 added−2 removed

modified:src/timer/windows_timer.rs+5 added-2 removed
1 unmodified line
2#![warn(unsafe_op_in_unsafe_fn)]34use std::{mem, os::windows::io::AsRawHandle, process, ptr};56use clap::__macro_refs::once_cell::sync::Lazy;6use winapi::{7 shared::{ntdef::NTSTATUS, ntstatus::STATUS_SUCCESS},8 um::{9 handleapi::CloseHandle,
7 unmodified lines
1718#[cfg(windows_process_extensions_main_thread_handle)]19use winapi::shared::minwindef::DWORD;2021#[cfg(not(windows_process_extensions_main_thread_handle))]22use once_cell::sync::Lazy;2324use crate::util::units::Second;2526const HUNDRED_NS_PER_MS: i64 = 10;2728#[cfg(not(windows_process_extensions_main_thread_handle))]29#[allow(non_upper_case_globals)]30static NtResumeProcess: Lazy<unsafe extern "system" fn(ProcessHandle: HANDLE) -> NTSTATUS> =31 Lazy::new(|| {32 // SAFETY: Getting the module handle for ntdll.dll is safe
26 unmodified lines
59 #[cfg(windows_process_extensions_main_thread_handle)]60 {61 // SAFETY: The main thread handle is valid62 let ret = unsafe { ResumeThread(child.main_thread_handle().as_raw_handle()) };60 assert!(ret != -1 as DWORD, "NtResumeProcess failed");63 assert!(ret != -1 as DWORD, "ResumeThread failed");64 }6566 #[cfg(not(windows_process_extensions_main_thread_handle))]67 {
55 unmodified lines
modified:Cargo.toml+2 added