From fd188f6404031415aa3b6236b1b74214676cf045 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Tue, 6 Aug 2024 02:21:29 +0900 Subject: [PATCH] Update windows-sys 0.59 --- Cargo.toml | 2 +- src/iocp/afd.rs | 19 ++++++++++++++----- src/iocp/port.rs | 9 +++++---- tests/windows_waitable.rs | 2 +- 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b418d47..c291ff2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,7 +34,7 @@ concurrent-queue = "2.2.0" pin-project-lite = "0.2.9" [target.'cfg(windows)'.dependencies.windows-sys] -version = "0.52" +version = "0.59" features = [ "Wdk_Foundation", "Wdk_Storage_FileSystem", diff --git a/src/iocp/afd.rs b/src/iocp/afd.rs index a4b58ba..f62fd5f 100644 --- a/src/iocp/afd.rs +++ b/src/iocp/afd.rs @@ -43,7 +43,6 @@ pub(super) struct AfdPollInfo { handles: [AfdPollHandleInfo; 1], } -#[derive(Default)] #[repr(C)] struct AfdPollHandleInfo { /// The handle to poll. @@ -56,6 +55,16 @@ struct AfdPollHandleInfo { status: NTSTATUS, } +impl Default for AfdPollHandleInfo { + fn default() -> Self { + Self { + handle: ptr::null_mut(), + events: Default::default(), + status: Default::default(), + } + } +} + impl AfdPollInfo { pub(super) fn handle_count(&self) -> u32 { self.handle_count @@ -288,7 +297,7 @@ impl NtdllImports { .get_or_init(|| unsafe { let ntdll = GetModuleHandleW(NTDLL_NAME.as_ptr() as *const _); - if ntdll == 0 { + if ntdll.is_null() { tracing::error!("Failed to load ntdll.dll"); return Err(io::Error::last_os_error()); } @@ -320,7 +329,7 @@ impl fmt::Debug for Afd { impl fmt::Debug for WriteAsHex { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "{:010x}", self.0) + write!(f, "{:010x}", self.0 as usize) } } @@ -385,7 +394,7 @@ where }; let mut device_attributes = OBJECT_ATTRIBUTES { Length: size_of::() as u32, - RootDirectory: 0, + RootDirectory: ptr::null_mut(), ObjectName: &mut device_name, Attributes: 0, SecurityDescriptor: ptr::null_mut(), @@ -468,7 +477,7 @@ where let result = unsafe { ntdll.NtDeviceIoControlFile( self.handle, - 0, + ptr::null_mut(), ptr::null_mut(), iosb.cast(), iosb.cast(), diff --git a/src/iocp/port.rs b/src/iocp/port.rs index 5bf3c35..f710c3a 100644 --- a/src/iocp/port.rs +++ b/src/iocp/port.rs @@ -9,6 +9,7 @@ use std::mem::MaybeUninit; use std::ops::Deref; use std::os::windows::io::{AsRawHandle, RawHandle}; use std::pin::Pin; +use std::ptr; use std::sync::Arc; use std::time::Duration; @@ -133,7 +134,7 @@ impl fmt::Debug for IoCompletionPort { impl fmt::Debug for WriteAsHex { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "{:010x}", self.0) + write!(f, "{:010x}", self.0 as usize) } } @@ -149,13 +150,13 @@ impl IoCompletionPort { let handle = unsafe { CreateIoCompletionPort( INVALID_HANDLE_VALUE, - 0, + ptr::null_mut(), 0, threads.try_into().expect("too many threads"), ) }; - if handle == 0 { + if handle.is_null() { Err(io::Error::last_os_error()) } else { Ok(Self { @@ -176,7 +177,7 @@ impl IoCompletionPort { let result = unsafe { CreateIoCompletionPort(handle as _, self.handle, handle as usize, 0) }; - if result == 0 { + if result.is_null() { return Err(io::Error::last_os_error()); } diff --git a/tests/windows_waitable.rs b/tests/windows_waitable.rs index dcd0edc..c9e0e8f 100644 --- a/tests/windows_waitable.rs +++ b/tests/windows_waitable.rs @@ -35,7 +35,7 @@ impl EventHandle { ) }; - if handle == 0 { + if handle.is_null() { Err(io::Error::last_os_error()) } else { Ok(Self(handle as _))