Update windows-sys

Co-authored-by: Erkki Silvola <eki833@gmail.com>
This commit is contained in:
Kevin Mehall 2025-02-15 14:47:30 -07:00
parent 587da14a25
commit 03ffa4b36c
5 changed files with 16 additions and 12 deletions

View file

@ -26,7 +26,7 @@ rustix = { version = "0.38.17", features = ["fs", "event", "net"] }
libc = "0.2.155"
[target.'cfg(target_os="windows")'.dependencies]
windows-sys = { version = "0.48.0", features = ["Win32_Devices_Usb", "Win32_Devices_DeviceAndDriverInstallation", "Win32_Foundation", "Win32_Devices_Properties", "Win32_Storage_FileSystem", "Win32_Security", "Win32_System_IO", "Win32_System_Registry", "Win32_System_Com"] }
windows-sys = { version = "0.59.0", features = ["Win32_Devices_Usb", "Win32_Devices_DeviceAndDriverInstallation", "Win32_Foundation", "Win32_Devices_Properties", "Win32_Storage_FileSystem", "Win32_Security", "Win32_System_IO", "Win32_System_Registry", "Win32_System_Com"] }
[target.'cfg(target_os="macos")'.dependencies]
core-foundation = "0.9.3"

View file

@ -7,7 +7,7 @@ use std::{
io::{AsRawHandle, RawHandle},
prelude::OwnedHandle,
},
ptr::null_mut,
ptr,
sync::{Arc, Mutex},
time::Duration,
};
@ -244,13 +244,17 @@ pub(crate) struct WinusbFileHandle {
claimed_interfaces: BitSet256,
}
// SAFETY: WinUSB methods on the interface handle are thread-safe
unsafe impl Send for WinusbFileHandle {}
unsafe impl Sync for WinusbFileHandle {}
impl WinusbFileHandle {
fn new(path: &WCStr, first_interface: u8) -> Result<Self, Error> {
let handle = create_file(&path)?;
super::events::register(&handle)?;
let winusb_handle = unsafe {
let mut h = 0;
let mut h = ptr::null_mut();
if WinUsb_Initialize(raw_handle(&handle), &mut h) == FALSE {
error!("WinUsb_Initialize failed: {:?}", io::Error::last_os_error());
return Err(io::Error::last_os_error());
@ -286,7 +290,7 @@ impl WinusbFileHandle {
self.winusb_handle
} else {
unsafe {
let mut out_handle = 0;
let mut out_handle = ptr::null_mut();
let idx = interface_number - self.first_interface - 1;
if WinUsb_GetAssociatedInterface(self.winusb_handle, idx, &mut out_handle) == FALSE
{
@ -435,7 +439,7 @@ impl WindowsInterface {
data,
len.try_into().expect("request size too large"),
&mut actual_len,
null_mut(),
ptr::null_mut(),
);
if r == TRUE {

View file

@ -5,7 +5,7 @@ use std::{
io::HandleOrNull,
prelude::{OwnedHandle, RawHandle},
},
thread,
ptr, thread,
};
use windows_sys::Win32::{
Foundation::{GetLastError, FALSE, INVALID_HANDLE_VALUE},
@ -21,7 +21,7 @@ struct IoCompletionPort(OwnedHandle);
impl IoCompletionPort {
fn new() -> Result<IoCompletionPort, Error> {
unsafe {
let port = CreateIoCompletionPort(INVALID_HANDLE_VALUE, 0, 0, 0);
let port = CreateIoCompletionPort(INVALID_HANDLE_VALUE, ptr::null_mut(), 0, 0);
match HandleOrNull::from_raw_handle(port as RawHandle).try_into() {
Ok(handle) => Ok(IoCompletionPort(handle)),
Err(_) => {
@ -36,7 +36,7 @@ impl IoCompletionPort {
fn register(&self, handle: &OwnedHandle) -> Result<(), Error> {
unsafe {
let r = CreateIoCompletionPort(raw_handle(handle), raw_handle(&self.0), 0, 0);
if r == 0 {
if r == ptr::null_mut() {
let err = std::io::Error::last_os_error();
error!("CreateIoCompletionPort (register) failed: {err:?}");
Err(err)

View file

@ -3,7 +3,7 @@ use std::{
ffi::c_void,
io::ErrorKind,
mem::size_of,
ptr::addr_of,
ptr::{self, addr_of},
sync::Mutex,
task::{Context, Poll},
};
@ -57,7 +57,7 @@ impl WindowsHotplugWatch {
waker: AtomicWaker::new(),
}));
let mut registration = 0;
let mut registration = ptr::null_mut();
let filter = CM_NOTIFY_FILTER {
cbSize: size_of::<CM_NOTIFY_FILTER>() as u32,
Flags: 0,

View file

@ -7,7 +7,7 @@ use std::{
os::windows::prelude::{
AsHandle, AsRawHandle, HandleOrInvalid, OsStrExt, OsStringExt, OwnedHandle, RawHandle,
},
ptr::null,
ptr::{self, null},
slice,
};
@ -28,7 +28,7 @@ pub fn create_file(path: &WCStr) -> Result<OwnedHandle, io::Error> {
null(),
OPEN_EXISTING,
FILE_FLAG_OVERLAPPED,
0,
ptr::null_mut(),
);
HandleOrInvalid::from_raw_handle(r as RawHandle)
.try_into()