From adda95bf347f34d828fc8d0e23cf9b8473e773d0 Mon Sep 17 00:00:00 2001 From: Seth Westphal Date: Sun, 5 May 2024 13:59:41 -0500 Subject: [PATCH] Update windows-sys to 0.52. --- Cargo.toml | 5 ++++- src/sys/windows/afd.rs | 34 ++++++++++-------------------- src/sys/windows/io_status_block.rs | 4 ++-- 3 files changed, 17 insertions(+), 26 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 14e2ba143..be1fead56 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -49,8 +49,11 @@ log = { version = "0.4.8", optional = true } libc = "0.2.149" [target.'cfg(windows)'.dependencies.windows-sys] -version = "0.48" +version = "0.52" features = [ + "Wdk_Foundation", # Required for AFD. + "Wdk_Storage_FileSystem", # Required for AFD. + "Wdk_System_IO", # Required for AFD. "Win32_Foundation", # Basic types eg HANDLE "Win32_Networking_WinSock", # winsock2 types/functions "Win32_Storage_FileSystem", # Enables NtCreateFile diff --git a/src/sys/windows/afd.rs b/src/sys/windows/afd.rs index 3bda4536c..9f0cf5296 100644 --- a/src/sys/windows/afd.rs +++ b/src/sys/windows/afd.rs @@ -5,28 +5,15 @@ use std::io; use std::mem::size_of; use std::os::windows::io::AsRawHandle; +use windows_sys::Wdk::Storage::FileSystem::NtCancelIoFileEx; +use windows_sys::Wdk::System::IO::NtDeviceIoControlFile; 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::Win32::System::WindowsProgramming::{IO_STATUS_BLOCK, IO_STATUS_BLOCK_0}; const IOCTL_AFD_POLL: u32 = 0x00012024; -#[link(name = "ntdll")] -extern "system" { - /// See - /// - /// This is an undocumented API and as such not part of - /// from which `windows-sys` is generated, and also unlikely to be added, so - /// we manually declare it here - fn NtCancelIoFileEx( - FileHandle: HANDLE, - IoRequestToCancel: *mut IO_STATUS_BLOCK, - IoStatusBlock: *mut IO_STATUS_BLOCK, - ) -> NTSTATUS; -} /// Winsock2 AFD driver instance. /// /// All operations are unsafe due to IO_STATUS_BLOCK parameter are being used by Afd driver during STATUS_PENDING before I/O Completion Port returns its result. @@ -132,14 +119,15 @@ cfg_io_source! { use std::ptr::null_mut; 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, - }, - Storage::FileSystem::{FILE_OPEN, NtCreateFile, SetFileCompletionNotificationModes, SYNCHRONIZE, FILE_SHARE_READ, FILE_SHARE_WRITE}, + use windows_sys::Wdk::Foundation::OBJECT_ATTRIBUTES; + use windows_sys::Wdk::Storage::FileSystem::{NtCreateFile, FILE_OPEN}; + use windows_sys::Win32::Foundation::{INVALID_HANDLE_VALUE, UNICODE_STRING}; + use windows_sys::Win32::Storage::FileSystem::{ + SetFileCompletionNotificationModes, FILE_SHARE_READ, FILE_SHARE_WRITE, SYNCHRONIZE, }; + use windows_sys::Win32::System::WindowsProgramming::FILE_SKIP_SET_EVENT_ON_HANDLE; + + use super::iocp::CompletionPort; const AFD_HELPER_ATTRIBUTES: OBJECT_ATTRIBUTES = OBJECT_ATTRIBUTES { Length: size_of::() as u32, diff --git a/src/sys/windows/io_status_block.rs b/src/sys/windows/io_status_block.rs index d7eda6a6d..79b1a44db 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 {