diff --git a/crates/tests/handles/Cargo.toml b/crates/tests/handles/Cargo.toml index 45ec8c9aec..84c4e58d1c 100644 --- a/crates/tests/handles/Cargo.toml +++ b/crates/tests/handles/Cargo.toml @@ -16,6 +16,7 @@ features = [ "Win32_System_Registry", "Win32_Devices_Bluetooth", "Win32_System_ApplicationInstallationAndServicing", + "Win32_Security", ] [dependencies.windows-sys] diff --git a/crates/tests/handles/tests/legacy.rs b/crates/tests/handles/tests/legacy.rs index 4e2a49c349..88aa1b66f2 100644 --- a/crates/tests/handles/tests/legacy.rs +++ b/crates/tests/handles/tests/legacy.rs @@ -4,12 +4,12 @@ use windows::Win32::System::Registry::*; #[test] fn handle() { - let handle = HANDLE(0); + let handle = HANDLE(0 as _); let _clone = handle.clone(); let _copy: HANDLE = handle; - assert!(HANDLE::default() == HANDLE(0)); - assert!(HANDLE(0).is_invalid()); - assert!(HANDLE(-1).is_invalid()); + assert!(HANDLE::default() == HANDLE(0 as _)); + assert!(HANDLE(0 as _).is_invalid()); + assert!(HANDLE(-1 as _).is_invalid()); assert!(core::mem::size_of::() == core::mem::size_of::()); } diff --git a/crates/tests/handles/tests/sys.rs b/crates/tests/handles/tests/sys.rs index 026368d2a0..ec3ecff321 100644 --- a/crates/tests/handles/tests/sys.rs +++ b/crates/tests/handles/tests/sys.rs @@ -11,7 +11,7 @@ fn boolean() { fn hfont() { unsafe { let underlying: isize = 123; - let font: HFONT = underlying; + let font: HFONT = underlying as _; let object: HGDIOBJ = font; assert!(DeleteObject(font) == 0); diff --git a/crates/tests/handles/tests/win.rs b/crates/tests/handles/tests/win.rs index 07bf637247..abc1517c93 100644 --- a/crates/tests/handles/tests/win.rs +++ b/crates/tests/handles/tests/win.rs @@ -1,12 +1,13 @@ use windows::{ Win32::Devices::Bluetooth::*, Win32::Foundation::*, Win32::Graphics::Gdi::*, - Win32::System::ApplicationInstallationAndServicing::*, Win32::System::Registry::*, + Win32::Security::*, Win32::System::ApplicationInstallationAndServicing::*, + Win32::System::Registry::*, }; #[test] fn handle() { let underlying: isize = 123; - let handle: HANDLE = HANDLE(underlying); + let handle: HANDLE = HANDLE(underlying as _); assert!(!handle.is_invalid()); let copy = handle; @@ -18,7 +19,7 @@ fn handle() { let default = HANDLE::default(); assert!(default.is_invalid()); - assert_eq!(format!("{:?}", handle), "HANDLE(123)"); + assert_eq!(format!("{:?}", handle), "HANDLE(0x7b)"); } #[test] @@ -43,7 +44,7 @@ fn psid() { fn hfont() { unsafe { let underlying: isize = 123; - let font: HFONT = HFONT(underlying); + let font: HFONT = HFONT(underlying as _); let object: HGDIOBJ = HGDIOBJ(font.0); assert!(!DeleteObject(font).as_bool()); diff --git a/crates/tests/lib/tests/sys.rs b/crates/tests/lib/tests/sys.rs index 4a7c308b9e..9e79577ca1 100644 --- a/crates/tests/lib/tests/sys.rs +++ b/crates/tests/lib/tests/sys.rs @@ -6,7 +6,19 @@ use windows_sys::{ #[test] fn gdi() { unsafe { - AlphaBlend(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, std::mem::zeroed()); + AlphaBlend( + core::ptr::null_mut(), + 0, + 0, + 0, + 0, + core::ptr::null_mut(), + 0, + 0, + 0, + 0, + std::mem::zeroed(), + ); } } @@ -20,7 +32,15 @@ fn wait_on_address() { #[test] fn browser() { unsafe { - IECreateFile(std::ptr::null(), 0, 0, std::ptr::null(), 0, 0, 0); + IECreateFile( + std::ptr::null(), + 0, + 0, + std::ptr::null(), + 0, + 0, + core::ptr::null_mut(), + ); } } diff --git a/crates/tests/not_dll/tests/sys.rs b/crates/tests/not_dll/tests/sys.rs index 985a9ce8f2..41f2949400 100644 --- a/crates/tests/not_dll/tests/sys.rs +++ b/crates/tests/not_dll/tests/sys.rs @@ -5,6 +5,6 @@ use windows_sys::Win32::Graphics::Printing::*; #[test] fn test() { unsafe { - GetSpoolFileHandle(0); + GetSpoolFileHandle(core::ptr::null_mut()); } } diff --git a/crates/tests/reserved/tests/sys.rs b/crates/tests/reserved/tests/sys.rs index 0efc217d71..4fcd22c103 100644 --- a/crates/tests/reserved/tests/sys.rs +++ b/crates/tests/reserved/tests/sys.rs @@ -10,11 +10,19 @@ fn test() { assert_eq!(InSendMessageEx(std::ptr::null_mut()), ISMEX_NOSEND); assert!(CreateThreadpool(std::ptr::null_mut()) != 0); assert_eq!( - TrackPopupMenu(0, TPM_LEFTBUTTON, 1, 2, 0, 0, std::ptr::null()), + TrackPopupMenu( + core::ptr::null_mut(), + TPM_LEFTBUTTON, + 1, + 2, + 0, + core::ptr::null_mut(), + std::ptr::null() + ), 0 ); - let mut key = 0; + let mut key = core::ptr::null_mut(); RegOpenKeyExA(HKEY_CLASSES_ROOT, s!(r".txt"), 0, KEY_QUERY_VALUE, &mut key); let mut len = 0; RegQueryValueExA( diff --git a/crates/tests/reserved/tests/win.rs b/crates/tests/reserved/tests/win.rs index ed464ac27c..018bbaf894 100644 --- a/crates/tests/reserved/tests/win.rs +++ b/crates/tests/reserved/tests/win.rs @@ -8,18 +8,10 @@ use windows::{ fn test() -> Result<()> { unsafe { assert_eq!(InSendMessageEx(None), ISMEX_NOSEND); - assert!(CreateThreadpool(None).0 != 0); + assert!(CreateThreadpool(None).is_ok()); assert_eq!( - TrackPopupMenu( - HMENU(0), - TPM_LEFTBUTTON, - 1, - 2, - 0, - HWND(0), - Default::default(), - ), + TrackPopupMenu(None, TPM_LEFTBUTTON, 1, 2, 0, None, Default::default(),), FALSE ); diff --git a/crates/tests/resources/tests/sys.rs b/crates/tests/resources/tests/sys.rs index 2bcd36f135..17efe8f971 100644 --- a/crates/tests/resources/tests/sys.rs +++ b/crates/tests/resources/tests/sys.rs @@ -10,11 +10,17 @@ fn sys() { unsafe { SetLastError(0); assert_eq!(IDI_APPLICATION as u16, 32512); - assert_ne!(LoadIconW(0, IDI_APPLICATION), 0); + assert_ne!( + LoadIconW(core::ptr::null_mut(), IDI_APPLICATION), + core::ptr::null_mut() + ); assert_eq!(GetLastError(), 0); assert_eq!(TD_ERROR_ICON as i16, -2); - assert_eq!(LoadIconW(0, TD_ERROR_ICON), 0); + assert_eq!( + LoadIconW(core::ptr::null_mut(), TD_ERROR_ICON), + core::ptr::null_mut() + ); assert_eq!(GetLastError(), ERROR_RESOURCE_TYPE_NOT_FOUND); assert_eq!(COLE_DEFAULT_PRINCIPAL as usize, usize::MAX); diff --git a/crates/tests/sys/tests/simple.rs b/crates/tests/sys/tests/simple.rs index 8f6fee8323..f7fd38c8d7 100644 --- a/crates/tests/sys/tests/simple.rs +++ b/crates/tests/sys/tests/simple.rs @@ -26,20 +26,20 @@ fn types() { let _: i32 = DBG_APP_NOT_IDLE; // Handles - let _: HANDLE = 0; + let _: HANDLE = core::ptr::null_mut(); let _: PSTR = b"hello\0".as_ptr() as _; } #[test] fn callback() { unsafe { - extern "system" fn enum_window(_: isize, _: isize) -> i32 { + extern "system" fn enum_window(_: *mut core::ffi::c_void, _: isize) -> i32 { 0 } EnumWindows(Some(enum_window), 0); - extern "system" fn wndproc(_: isize, _: u32, _: usize, _: isize) -> isize { + extern "system" fn wndproc(_: *mut core::ffi::c_void, _: u32, _: usize, _: isize) -> isize { 0 } diff --git a/crates/tests/unions/tests/sys.rs b/crates/tests/unions/tests/sys.rs index a9b436d34d..9505618240 100644 --- a/crates/tests/unions/tests/sys.rs +++ b/crates/tests/unions/tests/sys.rs @@ -6,7 +6,7 @@ fn test() { Internal: 1, InternalHigh: 2, Anonymous: unsafe { std::mem::zeroed() }, - hEvent: Default::default(), + hEvent: core::ptr::null_mut(), }; assert_eq!(o.Internal, 1); @@ -17,9 +17,9 @@ fn test() { o.InternalHigh = 20; assert_eq!(o.InternalHigh, 20); - assert_eq!(o.hEvent, 0); - o.hEvent = 1; - assert_eq!(o.hEvent, 1); + assert_eq!(o.hEvent, core::ptr::null_mut()); + o.hEvent = 1 as _; + assert_eq!(o.hEvent, 1 as _); unsafe { assert_eq!(o.Anonymous.Pointer, core::ptr::null_mut()); diff --git a/crates/tests/unions/tests/win.rs b/crates/tests/unions/tests/win.rs index 7428c2c8b4..ef8f9bc8c1 100644 --- a/crates/tests/unions/tests/win.rs +++ b/crates/tests/unions/tests/win.rs @@ -21,9 +21,9 @@ fn test() { o.InternalHigh = 20; assert_eq!(o.InternalHigh, 20); - assert_eq!(o.hEvent, HANDLE(0)); - o.hEvent = HANDLE(1); - assert_eq!(o.hEvent, HANDLE(1)); + assert_eq!(o.hEvent, HANDLE(0 as _)); + o.hEvent = HANDLE(1 as _); + assert_eq!(o.hEvent, HANDLE(1 as _)); unsafe { assert_eq!(o.Anonymous.Pointer, core::ptr::null_mut()); @@ -80,7 +80,7 @@ fn d3d() { let mut desc = D3D12_INDIRECT_ARGUMENT_DESC { Type: D3D12_INDIRECT_ARGUMENT_TYPE_VERTEX_BUFFER_VIEW, Anonymous: D3D12_INDIRECT_ARGUMENT_DESC_0 { - VertexBuffer: D3D12_INDIRECT_ARGUMENT_DESC_0_4 { Slot: 123 }, + VertexBuffer: D3D12_INDIRECT_ARGUMENT_DESC_0_5 { Slot: 123 }, }, }; diff --git a/crates/tests/wdk/tests/sys.rs b/crates/tests/wdk/tests/sys.rs index ae0b83ee91..094406380d 100644 --- a/crates/tests/wdk/tests/sys.rs +++ b/crates/tests/wdk/tests/sys.rs @@ -3,7 +3,7 @@ use windows_sys::Wdk::System::OfflineRegistry::*; #[test] fn offline_registry() { unsafe { - let mut hive = 0; + let mut hive = core::ptr::null_mut(); ORCreateHive(&mut hive); ORCloseHive(hive); } diff --git a/crates/tests/win32/tests/win32.rs b/crates/tests/win32/tests/win32.rs index c471c1ab4b..7f3fde6de7 100644 --- a/crates/tests/win32/tests/win32.rs +++ b/crates/tests/win32/tests/win32.rs @@ -130,7 +130,7 @@ fn function() -> windows::core::Result<()> { fn bool_as_error() { unsafe { helpers::set_thread_ui_language(); - let error = SetEvent(HANDLE(0)).unwrap_err(); + let error = SetEvent(HANDLE(0 as _)).unwrap_err(); assert_eq!(error.code(), windows::core::HRESULT(-2147024890)); let message: String = error.message().try_into().unwrap(); @@ -176,7 +176,9 @@ fn com_inheritance() { let factory: IDXGIFactory7 = CreateDXGIFactory1().unwrap(); // IDXGIFactory - assert!(factory.MakeWindowAssociation(HWND(0), 0).is_ok()); + assert!(factory + .MakeWindowAssociation(None, DXGI_MWA_FLAGS::default()) + .is_ok()); // IDXGIFactory1 assert!(factory.IsCurrent().as_bool()); @@ -185,12 +187,12 @@ fn com_inheritance() { _ = factory.IsWindowedStereoEnabled(); // IDXGIFactory3 - assert!(factory.GetCreationFlags() == 0); + assert!(factory.GetCreationFlags() == DXGI_CREATE_FACTORY_FLAGS(0)); // IDXGIFactory7 (default) assert!( factory - .RegisterAdaptersChangedEvent(HANDLE(0)) + .RegisterAdaptersChangedEvent(None) .unwrap_err() .code() == DXGI_ERROR_INVALID_CALL @@ -232,16 +234,16 @@ fn interface() -> windows::core::Result<()> { fn callback() { unsafe { let a: PROPENUMPROCA = Some(callback_a); - assert!(BOOL(789) == a.unwrap()(HWND(123), s!("hello a"), HANDLE(456))); + assert!(BOOL(789) == a.unwrap()(HWND(123 as _), s!("hello a"), HANDLE(456 as _))); let a: PROPENUMPROCW = Some(callback_w); - assert!(BOOL(789) == a.unwrap()(HWND(123), w!("hello w").into(), HANDLE(456))); + assert!(BOOL(789) == a.unwrap()(HWND(123 as _), w!("hello w").into(), HANDLE(456 as _))); } } extern "system" fn callback_a(param0: HWND, param1: PCSTR, param2: HANDLE) -> BOOL { - assert!(param0.0 == 123); - assert!(param2.0 == 456); + assert!(param0.0 == 123 as _); + assert!(param2.0 == 456 as _); let s = unsafe { param1.to_string().unwrap() }; assert!(s == "hello a"); @@ -249,8 +251,8 @@ extern "system" fn callback_a(param0: HWND, param1: PCSTR, param2: HANDLE) -> BO } extern "system" fn callback_w(param0: HWND, param1: PCWSTR, param2: HANDLE) -> BOOL { - assert!(param0.0 == 123); - assert!(param2.0 == 456); + assert!(param0.0 == 123 as _); + assert!(param2.0 == 456 as _); let s = unsafe { param1.to_string().unwrap() }; assert!(s == "hello w"); BOOL(789) diff --git a/crates/tests/window_long/tests/sys.rs b/crates/tests/window_long/tests/sys.rs index 1245624bb7..c1a5e61d0b 100644 --- a/crates/tests/window_long/tests/sys.rs +++ b/crates/tests/window_long/tests/sys.rs @@ -4,9 +4,9 @@ use windows_sys::Win32::UI::WindowsAndMessaging::*; #[test] fn test() { unsafe { - SetWindowLongPtrA(0, GWLP_USERDATA, 0); - GetWindowLongPtrA(0, GWLP_USERDATA); - SetWindowLongPtrW(0, GWLP_USERDATA, 0); - GetWindowLongPtrW(0, GWLP_USERDATA); + SetWindowLongPtrA(core::ptr::null_mut(), GWLP_USERDATA, 0); + GetWindowLongPtrA(core::ptr::null_mut(), GWLP_USERDATA); + SetWindowLongPtrW(core::ptr::null_mut(), GWLP_USERDATA, 0); + GetWindowLongPtrW(core::ptr::null_mut(), GWLP_USERDATA); } }