Skip to content

Commit

Permalink
Update windows-sys 0.59
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Aug 5, 2024
1 parent 18030b8 commit 12403b6
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
19 changes: 14 additions & 5 deletions src/iocp/afd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ pub(super) struct AfdPollInfo {
handles: [AfdPollHandleInfo; 1],
}

#[derive(Default)]
#[repr(C)]
struct AfdPollHandleInfo {
/// The handle to poll.
Expand All @@ -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
Expand Down Expand Up @@ -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());
}
Expand Down Expand Up @@ -320,7 +329,7 @@ impl<T> fmt::Debug for Afd<T> {

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 isize)
}
}

Expand Down Expand Up @@ -385,7 +394,7 @@ where
};
let mut device_attributes = OBJECT_ATTRIBUTES {
Length: size_of::<OBJECT_ATTRIBUTES>() as u32,
RootDirectory: 0,
RootDirectory: ptr::null_mut(),
ObjectName: &mut device_name,
Attributes: 0,
SecurityDescriptor: ptr::null_mut(),
Expand Down Expand Up @@ -468,7 +477,7 @@ where
let result = unsafe {
ntdll.NtDeviceIoControlFile(
self.handle,
0,
ptr::null_mut(),
ptr::null_mut(),
iosb.cast(),
iosb.cast(),
Expand Down
9 changes: 5 additions & 4 deletions src/iocp/port.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -133,7 +134,7 @@ impl<T> fmt::Debug for IoCompletionPort<T> {

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 isize)
}
}

Expand All @@ -149,13 +150,13 @@ impl<T: CompletionHandle> IoCompletionPort<T> {
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 {
Expand All @@ -176,7 +177,7 @@ impl<T: CompletionHandle> IoCompletionPort<T> {
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());
}

Expand Down
2 changes: 1 addition & 1 deletion tests/windows_waitable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl EventHandle {
)
};

if handle == 0 {
if handle.is_null() {
Err(io::Error::last_os_error())
} else {
Ok(Self(handle as _))
Expand Down

0 comments on commit 12403b6

Please sign in to comment.