Skip to content

Commit 08ec15b

Browse files
committed
Upgrade to windows-sys 0.62
1 parent 2564bff commit 08ec15b

File tree

3 files changed

+117
-71
lines changed

3 files changed

+117
-71
lines changed

Cargo.lock

Lines changed: 105 additions & 60 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ include = ["/src", "LICENSE"]
2020
default-target = "x86_64-pc-windows-msvc"
2121

2222
[dependencies]
23-
windows = { version = "0.44.0", features = [
23+
windows = { version = "0.61.2", features = [
2424
"Win32_System_Diagnostics_Etw",
2525
"Win32_Foundation",
2626
"Win32_System_Time",

src/lib.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use windows::Win32::Foundation::{
1313
CloseHandle, GetLastError, ERROR_SUCCESS, ERROR_WMI_INSTANCE_NOT_FOUND, HANDLE,
1414
INVALID_HANDLE_VALUE, WIN32_ERROR,
1515
};
16+
use windows::Win32::Security::SE_SYSTEM_PROFILE_NAME;
1617
use windows::Win32::Security::{
1718
AdjustTokenPrivileges, LookupPrivilegeValueW, SE_PRIVILEGE_ENABLED, TOKEN_ADJUST_PRIVILEGES,
1819
TOKEN_PRIVILEGES,
@@ -30,7 +31,6 @@ use windows::Win32::System::Diagnostics::Etw::{
3031
WNODE_FLAG_TRACED_GUID,
3132
};
3233
use windows::Win32::System::SystemInformation::{GetVersionExA, OSVERSIONINFOA};
33-
use windows::Win32::System::SystemServices::SE_SYSTEM_PROFILE_NAME;
3434
use windows::Win32::System::Threading::{
3535
GetCurrentProcess, GetCurrentThread, OpenProcess, OpenProcessToken, SetThreadPriority,
3636
WaitForSingleObject, CREATE_SUSPENDED, PROCESS_ALL_ACCESS, THREAD_PRIORITY_TIME_CRITICAL,
@@ -89,7 +89,7 @@ impl Drop for TraceContext {
8989
// SAFETY: TraceContext invariants ensure these are valid
9090
unsafe {
9191
let ret = CloseHandle(self.target_process_handle);
92-
if ret.0 == 0 {
92+
if ret == 0 {
9393
panic!("TraceContext::CloseHandle error:{:?}", get_last_error(""));
9494
}
9595
}
@@ -172,24 +172,24 @@ fn acquire_privileges() -> Result<()> {
172172
privs.PrivilegeCount = 1;
173173
privs.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
174174
if unsafe {
175-
LookupPrivilegeValueW(None, SE_SYSTEM_PROFILE_NAME, &mut privs.Privileges[0].Luid).0 == 0
175+
LookupPrivilegeValueW(None, SE_SYSTEM_PROFILE_NAME, &mut privs.Privileges[0].Luid) == 0
176176
} {
177177
return Err(get_last_error("acquire_privileges LookupPrivilegeValueA"));
178178
}
179179
let mut pt = HANDLE::default();
180-
if unsafe { OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &mut pt).0 == 0 } {
180+
if unsafe { OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &mut pt) == 0 } {
181181
return Err(get_last_error("OpenProcessToken"));
182182
}
183183
let adjust = unsafe { AdjustTokenPrivileges(pt, false, Some(addr_of!(privs)), 0, None, None) };
184-
if adjust.0 == 0 {
184+
if adjust == 0 {
185185
let err = Err(get_last_error("AdjustTokenPrivileges"));
186186
unsafe {
187187
CloseHandle(pt);
188188
}
189189
return err;
190190
}
191191
let ret = unsafe { CloseHandle(pt) };
192-
if ret.0 == 0 {
192+
if ret == 0 {
193193
return Err(get_last_error("acquire_privileges CloseHandle"));
194194
}
195195
let status = unsafe { GetLastError() };
@@ -198,6 +198,7 @@ fn acquire_privileges() -> Result<()> {
198198
}
199199
Ok(())
200200
}
201+
201202
/// SAFETY: is_suspended must only be true if `target_process` is suspended
202203
unsafe fn trace_from_process_id(
203204
target_process_id: u32,
@@ -207,7 +208,7 @@ unsafe fn trace_from_process_id(
207208
let mut winver_info = OSVERSIONINFOA::default();
208209
winver_info.dwOSVersionInfoSize = size_of::<OSVERSIONINFOA>() as u32;
209210
let ret = GetVersionExA(&mut winver_info);
210-
if ret.0 == 0 {
211+
if ret == 0 {
211212
return Err(get_last_error("TraceSetInformation interval"));
212213
}
213214
// If we're not win7 or more, return unsupported
@@ -228,7 +229,7 @@ unsafe fn trace_from_process_id(
228229
// TODO: Parameter?
229230
interval.Interval = (1000000000 / 8000) / 100;
230231
let ret = TraceSetInformation(
231-
None,
232+
CONTROLTRACE_HANDLE::default(),
232233
// The value is supported on Windows 8, Windows Server 2012, and later.
233234
TraceSampledProfileIntervalInfo,
234235
addr_of!(interval).cast(),
@@ -298,7 +299,7 @@ unsafe fn trace_from_process_id(
298299
{
299300
let mut event_trace_props_copy = event_trace_props.clone();
300301
let control_stop_retcode = ControlTraceA(
301-
None,
302+
CONTROLTRACE_HANDLE::default(),
302303
kernel_logger_name_with_nul_pcstr,
303304
addr_of_mut!(event_trace_props_copy) as *mut _,
304305
EVENT_TRACE_CONTROL_STOP,
@@ -484,7 +485,7 @@ unsafe fn trace_from_process_id(
484485
log.Anonymous2.EventRecordCallback = Some(event_record_callback);
485486

486487
let trace_processing_handle = OpenTraceA(&mut log);
487-
if trace_processing_handle.0 == INVALID_HANDLE_VALUE.0 as u64 {
488+
if trace_processing_handle == INVALID_HANDLE_VALUE.0 as u64 {
488489
return Err(get_last_error("OpenTraceA processing"));
489490
}
490491

0 commit comments

Comments
 (0)