diff --git a/Cargo.toml b/Cargo.toml index 447d9d8dd..8fd8983e6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -49,11 +49,17 @@ log = { version = "0.4.8", optional = true } libc = "0.2.149" [target.'cfg(windows)'.dependencies.windows-sys] -version = "0.48" +version = "0.52" features = [ "Win32_Foundation", # Basic types eg HANDLE "Win32_Networking_WinSock", # winsock2 types/functions - "Win32_Storage_FileSystem", # Enables NtCreateFile + + # NtCreateFile and associated + "Win32_Storage_FileSystem", + "Wdk_Foundation", + "Wdk_System_IO", + "Wdk_Storage_FileSystem", + "Win32_System_IO", # IO types like OVERLAPPED etc "Win32_System_WindowsProgramming", # General future used for various types/funcs ] diff --git a/src/sys/windows/afd.rs b/src/sys/windows/afd.rs index 3bda4536c..b32dfbf7c 100644 --- a/src/sys/windows/afd.rs +++ b/src/sys/windows/afd.rs @@ -8,8 +8,9 @@ use std::os::windows::io::AsRawHandle; use windows_sys::Win32::Foundation::{ RtlNtStatusToDosError, HANDLE, NTSTATUS, STATUS_NOT_FOUND, STATUS_PENDING, STATUS_SUCCESS, }; -use windows_sys::Win32::System::WindowsProgramming::{ - NtDeviceIoControlFile, IO_STATUS_BLOCK, IO_STATUS_BLOCK_0, +use windows_sys::{ + Wdk::System::IO::NtDeviceIoControlFile, + Win32::System::IO::{IO_STATUS_BLOCK, IO_STATUS_BLOCK_0}, }; const IOCTL_AFD_POLL: u32 = 0x00012024; @@ -133,12 +134,16 @@ cfg_io_source! { use std::sync::atomic::{AtomicUsize, Ordering}; use super::iocp::CompletionPort; - use windows_sys::Win32::{ - Foundation::{UNICODE_STRING, INVALID_HANDLE_VALUE}, - System::WindowsProgramming::{ - OBJECT_ATTRIBUTES, FILE_SKIP_SET_EVENT_ON_HANDLE, + use windows_sys::{ + Win32::{ + Foundation::{UNICODE_STRING, INVALID_HANDLE_VALUE}, + System::WindowsProgramming::FILE_SKIP_SET_EVENT_ON_HANDLE, + Storage::FileSystem::{SetFileCompletionNotificationModes, SYNCHRONIZE, FILE_SHARE_READ, FILE_SHARE_WRITE}, + }, + Wdk::{ + Foundation::OBJECT_ATTRIBUTES, + Storage::FileSystem::{FILE_OPEN, NtCreateFile}, }, - Storage::FileSystem::{FILE_OPEN, NtCreateFile, SetFileCompletionNotificationModes, SYNCHRONIZE, FILE_SHARE_READ, FILE_SHARE_WRITE}, }; const AFD_HELPER_ATTRIBUTES: OBJECT_ATTRIBUTES = OBJECT_ATTRIBUTES { diff --git a/src/sys/windows/io_status_block.rs b/src/sys/windows/io_status_block.rs index d7eda6a6d..bd2a6dcfe 100644 --- a/src/sys/windows/io_status_block.rs +++ b/src/sys/windows/io_status_block.rs @@ -1,12 +1,12 @@ use std::fmt; use std::ops::{Deref, DerefMut}; -use windows_sys::Win32::System::WindowsProgramming::IO_STATUS_BLOCK; +use windows_sys::Win32::System::IO::IO_STATUS_BLOCK; pub struct IoStatusBlock(IO_STATUS_BLOCK); cfg_io_source! { - use windows_sys::Win32::System::WindowsProgramming::{IO_STATUS_BLOCK_0}; + use windows_sys::Win32::System::IO::IO_STATUS_BLOCK_0; impl IoStatusBlock { pub fn zeroed() -> Self { diff --git a/src/sys/windows/iocp.rs b/src/sys/windows/iocp.rs index c71b695d4..3b619564b 100644 --- a/src/sys/windows/iocp.rs +++ b/src/sys/windows/iocp.rs @@ -206,7 +206,7 @@ impl CompletionStatus { /// A completion key is a per-handle key that is specified when it is added /// to an I/O completion port via `add_handle` or `add_socket`. pub fn token(&self) -> usize { - self.0.lpCompletionKey as usize + self.0.lpCompletionKey } /// Returns a pointer to the `Overlapped` structure that was specified when diff --git a/src/sys/windows/net.rs b/src/sys/windows/net.rs index 5cc235335..c2b540560 100644 --- a/src/sys/windows/net.rs +++ b/src/sys/windows/net.rs @@ -75,7 +75,7 @@ pub(crate) fn socket_addr(addr: &SocketAddr) -> (SocketAddrCRepr, i32) { }; let sockaddr_in = SOCKADDR_IN { - sin_family: AF_INET as u16, // 1 + sin_family: AF_INET, // 1 sin_port: addr.port().to_be(), sin_addr, sin_zero: [0; 8], @@ -97,7 +97,7 @@ pub(crate) fn socket_addr(addr: &SocketAddr) -> (SocketAddrCRepr, i32) { }; let sockaddr_in6 = SOCKADDR_IN6 { - sin6_family: AF_INET6 as u16, // 23 + sin6_family: AF_INET6, // 23 sin6_port: addr.port().to_be(), sin6_addr, sin6_flowinfo: addr.flowinfo(), diff --git a/src/sys/windows/udp.rs b/src/sys/windows/udp.rs index 87e269fa3..3e975973f 100644 --- a/src/sys/windows/udp.rs +++ b/src/sys/windows/udp.rs @@ -30,8 +30,8 @@ pub(crate) fn only_v6(socket: &net::UdpSocket) -> io::Result { syscall!( getsockopt( socket.as_raw_socket() as usize, - IPPROTO_IPV6 as i32, - IPV6_V6ONLY as i32, + IPPROTO_IPV6, + IPV6_V6ONLY, optval.as_mut_ptr().cast(), &mut optlen, ), diff --git a/tests/util/mod.rs b/tests/util/mod.rs index 7a192d9b0..7fcb9fe5e 100644 --- a/tests/util/mod.rs +++ b/tests/util/mod.rs @@ -285,8 +285,8 @@ pub fn set_linger_zero(socket: &TcpStream) { let res = unsafe { setsockopt( socket.as_raw_socket() as _, - SOL_SOCKET as i32, - SO_LINGER as i32, + SOL_SOCKET, + SO_LINGER, &mut val as *mut _ as *mut _, size_of::() as _, )