diff --git a/.github/readme.md b/.github/readme.md index cc3d85bf62..0b26e1e09b 100644 --- a/.github/readme.md +++ b/.github/readme.md @@ -81,7 +81,7 @@ use windows_sys::{ fn main() { unsafe { - let event = CreateEventW(std::ptr::null(), 1, 0, std::ptr::null()); + let event = CreateEventW(std::ptr::null(), 1, 0, std::ptr::null())?; SetEvent(event); WaitForSingleObject(event, 0); CloseHandle(event); diff --git a/crates/libs/bindgen/src/async.rs b/crates/libs/bindgen/src/async.rs index 7977018e66..1e01330255 100644 --- a/crates/libs/bindgen/src/async.rs +++ b/crates/libs/bindgen/src/async.rs @@ -46,7 +46,7 @@ fn gen_async_kind(kind: AsyncKind, name: &TypeDef, self_name: &TypeDef, cfg: &Cf impl<#(#constraints)*> #name { pub fn get(&self) -> ::windows::core::Result<#return_type> { if self.Status()? == #namespace AsyncStatus::Started { - let (_waiter, signaler) = ::windows::core::Waiter::new(); + let (_waiter, signaler) = ::windows::core::Waiter::new()?; self.SetCompleted(#namespace #handler::new(move |_sender, _args| { // Safe because the waiter will only be dropped after being signaled. unsafe { signaler.signal(); } diff --git a/crates/libs/bindgen/src/functions.rs b/crates/libs/bindgen/src/functions.rs index eb578a2108..c40367598c 100644 --- a/crates/libs/bindgen/src/functions.rs +++ b/crates/libs/bindgen/src/functions.rs @@ -203,24 +203,49 @@ fn gen_win_function(def: &MethodDef, gen: &Gen) -> TokenStream { } } SignatureKind::ReturnStruct | SignatureKind::PreserveSig => { - let args = gen_win32_args(&signature.params); - let params = gen_win32_params(&signature.params, gen); + if handle_last_error(def, &signature) { + let args = gen_win32_args(&signature.params); + let params = gen_win32_params(&signature.params, gen); + let return_type = gen_element_name(&signature.return_type.unwrap(), gen); - quote! { - #doc - #features - #[inline] - pub unsafe fn #name<#constraints>(#params) #abi_return_type { - #[cfg(windows)] - { - #link_attr - extern "system" { - fn #name(#(#abi_params),*) #abi_return_type; + quote! { + #doc + #features + #[inline] + pub unsafe fn #name<#constraints>(#params) -> ::windows::core::Result<#return_type> { + #[cfg(windows)] + { + #link_attr + extern "system" { + fn #name(#(#abi_params),*) -> #return_type; + } + let result__ = #name(#args); + (!result__.is_invalid()).then(||result__).ok_or_else(::windows::core::Error::from_win32) } - ::core::mem::transmute(#name(#args)) + #[cfg(not(windows))] + unimplemented!("Unsupported target OS"); + } + } + } else { + let args = gen_win32_args(&signature.params); + let params = gen_win32_params(&signature.params, gen); + + quote! { + #doc + #features + #[inline] + pub unsafe fn #name<#constraints>(#params) #abi_return_type { + #[cfg(windows)] + { + #link_attr + extern "system" { + fn #name(#(#abi_params),*) #abi_return_type; + } + ::core::mem::transmute(#name(#args)) + } + #[cfg(not(windows))] + unimplemented!("Unsupported target OS"); } - #[cfg(not(windows))] - unimplemented!("Unsupported target OS"); } } } @@ -257,3 +282,21 @@ fn does_not_return(def: &MethodDef) -> TokenStream { quote! {} } } + +fn handle_last_error(def: &MethodDef, signature: &Signature) -> bool { + if let Some(map) = def.impl_map() { + if map.flags().last_error() { + if let Some(Type::TypeDef(return_type)) = &signature.return_type { + if return_type.is_handle() { + if return_type.underlying_type().is_pointer() { + return true; + } + if !return_type.invalid_values().is_empty() { + return true; + } + } + } + } + } + false +} diff --git a/crates/libs/bindgen/src/handles.rs b/crates/libs/bindgen/src/handles.rs index 8cb113ed5c..e2eee52dc6 100644 --- a/crates/libs/bindgen/src/handles.rs +++ b/crates/libs/bindgen/src/handles.rs @@ -10,7 +10,7 @@ pub fn gen(def: &TypeDef, gen: &Gen) -> TokenStream { pub fn gen_sys_handle(def: &TypeDef, gen: &Gen) -> TokenStream { let ident = gen_ident(def.name()); - let signature = gen_signature(def, gen); + let signature = gen_default_type(&def.underlying_type(), gen); quote! { pub type #ident = #signature; @@ -20,26 +20,42 @@ pub fn gen_sys_handle(def: &TypeDef, gen: &Gen) -> TokenStream { pub fn gen_win_handle(def: &TypeDef, gen: &Gen) -> TokenStream { let name = def.name(); let ident = gen_ident(def.name()); - let signature = gen_signature(def, gen); + let underlying_type = def.underlying_type(); + let signature = gen_default_type(&underlying_type, gen); + let check = if underlying_type.is_pointer() { + quote! { + impl #ident { + pub fn is_invalid(&self) -> bool { + self.0.is_null() + } + } + } + } else { + let invalid = def.invalid_values(); + + if !invalid.is_empty() { + let invalid = invalid.iter().map(|value| { + let value = Literal::i64_unsuffixed(*value); + quote! { self.0 == #value } + }); + quote! { + impl #ident { + pub fn is_invalid(&self) -> bool { + #(#invalid)||* + } + } + } + } else { + quote! {} + } + }; let mut tokens = quote! { #[repr(transparent)] // Unfortunately, Rust requires these to be derived to allow constant patterns. #[derive(::core::cmp::PartialEq, ::core::cmp::Eq)] pub struct #ident(pub #signature); - impl #ident { - pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } - } - } + #check impl ::core::default::Default for #ident { fn default() -> Self { unsafe { ::core::mem::zeroed() } @@ -77,8 +93,3 @@ pub fn gen_win_handle(def: &TypeDef, gen: &Gen) -> TokenStream { tokens } - -fn gen_signature(def: &TypeDef, gen: &Gen) -> TokenStream { - let def = def.fields().next().map(|field| field.get_type(Some(def))).unwrap(); - gen_default_type(&def, gen) -} diff --git a/crates/libs/bindgen/src/replacements/handle.rs b/crates/libs/bindgen/src/replacements/handle.rs deleted file mode 100644 index 62427f4554..0000000000 --- a/crates/libs/bindgen/src/replacements/handle.rs +++ /dev/null @@ -1,46 +0,0 @@ -use super::*; - -pub fn gen() -> TokenStream { - quote! { - #[repr(transparent)] - pub struct HANDLE(pub isize); - impl HANDLE { - pub fn is_invalid(&self) -> bool { - self.0 == 0 || self.0 == -1 - } - - pub fn ok(self) -> ::windows::core::Result { - if self.is_invalid() { - Err(::windows::core::Error::from_win32()) - } else { - Ok(self) - } - } - } - impl ::core::default::Default for HANDLE { - fn default() -> Self { - Self(0) - } - } - impl ::core::clone::Clone for HANDLE { - fn clone(&self) -> Self { - *self - } - } - impl ::core::marker::Copy for HANDLE {} - impl ::core::cmp::PartialEq for HANDLE { - fn eq(&self, other: &Self) -> bool { - self.0 == other.0 - } - } - impl ::core::cmp::Eq for HANDLE {} - impl ::core::fmt::Debug for HANDLE { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_tuple("HANDLE").field(&self.0).finish() - } - } - unsafe impl ::windows::core::Abi for HANDLE { - type Abi = Self; - } - } -} diff --git a/crates/libs/bindgen/src/replacements/mod.rs b/crates/libs/bindgen/src/replacements/mod.rs index 48a31598e9..19940b806c 100644 --- a/crates/libs/bindgen/src/replacements/mod.rs +++ b/crates/libs/bindgen/src/replacements/mod.rs @@ -1,7 +1,6 @@ use super::*; mod bool32; mod bstr; -mod handle; mod ntstatus; pub fn gen(def: &TypeDef) -> Option { @@ -9,7 +8,6 @@ pub fn gen(def: &TypeDef) -> Option { TypeName::BOOL => Some(bool32::gen()), TypeName::BSTR => Some(bstr::gen()), TypeName::NTSTATUS => Some(ntstatus::gen()), - TypeName::HANDLE => Some(handle::gen()), _ => None, } } diff --git a/crates/libs/metadata/src/reader/param_flags.rs b/crates/libs/metadata/src/reader/flags.rs similarity index 63% rename from crates/libs/metadata/src/reader/param_flags.rs rename to crates/libs/metadata/src/reader/flags.rs index 599d1a54be..efaac125e8 100644 --- a/crates/libs/metadata/src/reader/param_flags.rs +++ b/crates/libs/metadata/src/reader/flags.rs @@ -12,3 +12,12 @@ impl ParamFlags { self.0 & 0x0010 != 0 } } + +#[derive(Default)] +pub struct PInvokeAttributes(pub u32); + +impl PInvokeAttributes { + pub fn last_error(&self) -> bool { + self.0 & 0x0040 != 0 + } +} diff --git a/crates/libs/metadata/src/reader/mod.rs b/crates/libs/metadata/src/reader/mod.rs index dae5639bd2..fe00465d79 100644 --- a/crates/libs/metadata/src/reader/mod.rs +++ b/crates/libs/metadata/src/reader/mod.rs @@ -5,9 +5,9 @@ mod cfg; mod codes; mod constant_value; mod file; +mod flags; mod guid; mod interface_kind; -mod param_flags; mod row; mod signature; mod signature_kind; @@ -27,9 +27,9 @@ pub use cfg::*; pub use codes::*; pub use constant_value::*; pub use file::*; +pub use flags::*; pub use guid::*; pub use interface_kind::*; -pub use param_flags::*; pub use r#type::*; pub use row::*; pub use signature::*; diff --git a/crates/libs/metadata/src/reader/tables/impl_map.rs b/crates/libs/metadata/src/reader/tables/impl_map.rs index 399a248041..4bd12e199f 100644 --- a/crates/libs/metadata/src/reader/tables/impl_map.rs +++ b/crates/libs/metadata/src/reader/tables/impl_map.rs @@ -4,6 +4,10 @@ use super::*; pub struct ImplMap(pub Row); impl ImplMap { + pub fn flags(&self) -> PInvokeAttributes { + PInvokeAttributes(self.0.u32(0)) + } + pub fn scope(&self) -> ModuleRef { ModuleRef(Row::new(self.0.u32(3) - 1, TableIndex::ModuleRef, self.0.file)) } diff --git a/crates/libs/metadata/src/reader/tables/type_def.rs b/crates/libs/metadata/src/reader/tables/type_def.rs index d8ac7b2774..29c1d80920 100644 --- a/crates/libs/metadata/src/reader/tables/type_def.rs +++ b/crates/libs/metadata/src/reader/tables/type_def.rs @@ -450,6 +450,19 @@ impl TypeDef { }) } + pub fn invalid_values(&self) -> Vec { + self.attributes() + .filter_map(|attribute| { + if attribute.name() == "InvalidHandleValueAttribute" { + if let Some((_, ConstantValue::I64(value))) = attribute.args().get(0) { + return Some(*value); + } + } + None + }) + .collect() + } + pub fn is_convertible_to(&self) -> Option<&Type> { self.attributes().find_map(|attribute| { if attribute.name() == "AlsoUsableForAttribute" { diff --git a/crates/libs/metadata/src/reader/type_name.rs b/crates/libs/metadata/src/reader/type_name.rs index 2c80795887..0cf8668198 100644 --- a/crates/libs/metadata/src/reader/type_name.rs +++ b/crates/libs/metadata/src/reader/type_name.rs @@ -65,7 +65,6 @@ impl TypeName { pub const PWSTR: Self = Self::from_const("Windows.Win32.Foundation", "PWSTR"); pub const PSTR: Self = Self::from_const("Windows.Win32.Foundation", "PSTR"); pub const BSTR: Self = Self::from_const("Windows.Win32.Foundation", "BSTR"); - pub const HANDLE: Self = Self::from_const("Windows.Win32.Foundation", "HANDLE"); pub const HRESULT: Self = Self::from_const("Windows.Win32.Foundation", "HRESULT"); pub const D2D_MATRIX_3X2_F: Self = Self::from_const("Windows.Win32.Graphics.Direct2D.Common", "D2D_MATRIX_3X2_F"); pub const IUnknown: Self = Self::from_const("Windows.Win32.System.Com", "IUnknown"); diff --git a/crates/libs/tokens/src/token_stream.rs b/crates/libs/tokens/src/token_stream.rs index f2c631f0dd..d42dfcc54e 100644 --- a/crates/libs/tokens/src/token_stream.rs +++ b/crates/libs/tokens/src/token_stream.rs @@ -142,6 +142,7 @@ macro_rules! unsuffixed { } impl Literal { + unsuffixed!(i64 => i64_unsuffixed); unsuffixed!(usize => usize_unsuffixed); unsuffixed!(u32 => u32_unsuffixed); unsuffixed!(u16 => u16_unsuffixed); diff --git a/crates/libs/windows/src/Windows/Devices/Sms/mod.rs b/crates/libs/windows/src/Windows/Devices/Sms/mod.rs index 388dbcfff8..c79fa3dba3 100644 --- a/crates/libs/windows/src/Windows/Devices/Sms/mod.rs +++ b/crates/libs/windows/src/Windows/Devices/Sms/mod.rs @@ -142,7 +142,7 @@ impl ::windows::core::RuntimeName for DeleteSmsMessageOperation { impl DeleteSmsMessageOperation { pub fn get(&self) -> ::windows::core::Result<()> { if self.Status()? == super::super::Foundation::AsyncStatus::Started { - let (_waiter, signaler) = ::windows::core::Waiter::new(); + let (_waiter, signaler) = ::windows::core::Waiter::new()?; self.SetCompleted(super::super::Foundation::AsyncActionCompletedHandler::new(move |_sender, _args| { unsafe { signaler.signal(); @@ -377,7 +377,7 @@ impl ::windows::core::RuntimeName for DeleteSmsMessagesOperation { impl DeleteSmsMessagesOperation { pub fn get(&self) -> ::windows::core::Result<()> { if self.Status()? == super::super::Foundation::AsyncStatus::Started { - let (_waiter, signaler) = ::windows::core::Waiter::new(); + let (_waiter, signaler) = ::windows::core::Waiter::new()?; self.SetCompleted(super::super::Foundation::AsyncActionCompletedHandler::new(move |_sender, _args| { unsafe { signaler.signal(); @@ -615,7 +615,7 @@ impl ::windows::core::RuntimeName for GetSmsDeviceOperation { impl GetSmsDeviceOperation { pub fn get(&self) -> ::windows::core::Result { if self.Status()? == super::super::Foundation::AsyncStatus::Started { - let (_waiter, signaler) = ::windows::core::Waiter::new(); + let (_waiter, signaler) = ::windows::core::Waiter::new()?; self.SetCompleted(super::super::Foundation::AsyncOperationCompletedHandler::new(move |_sender, _args| { unsafe { signaler.signal(); @@ -853,7 +853,7 @@ impl ::windows::core::RuntimeName for GetSmsMessageOperation { impl GetSmsMessageOperation { pub fn get(&self) -> ::windows::core::Result { if self.Status()? == super::super::Foundation::AsyncStatus::Started { - let (_waiter, signaler) = ::windows::core::Waiter::new(); + let (_waiter, signaler) = ::windows::core::Waiter::new()?; self.SetCompleted(super::super::Foundation::AsyncOperationCompletedHandler::new(move |_sender, _args| { unsafe { signaler.signal(); @@ -1106,7 +1106,7 @@ impl ::windows::core::RuntimeName for GetSmsMessagesOperation { impl GetSmsMessagesOperation { pub fn get(&self) -> ::windows::core::Result> { if self.Status()? == super::super::Foundation::AsyncStatus::Started { - let (_waiter, signaler) = ::windows::core::Waiter::new(); + let (_waiter, signaler) = ::windows::core::Waiter::new()?; self.SetCompleted(super::super::Foundation::AsyncOperationWithProgressCompletedHandler::new(move |_sender, _args| { unsafe { signaler.signal(); @@ -2830,7 +2830,7 @@ impl ::windows::core::RuntimeName for SendSmsMessageOperation { impl SendSmsMessageOperation { pub fn get(&self) -> ::windows::core::Result<()> { if self.Status()? == super::super::Foundation::AsyncStatus::Started { - let (_waiter, signaler) = ::windows::core::Waiter::new(); + let (_waiter, signaler) = ::windows::core::Waiter::new()?; self.SetCompleted(super::super::Foundation::AsyncActionCompletedHandler::new(move |_sender, _args| { unsafe { signaler.signal(); diff --git a/crates/libs/windows/src/Windows/Foundation/mod.rs b/crates/libs/windows/src/Windows/Foundation/mod.rs index 2b528f15f9..18ed9d9bc9 100644 --- a/crates/libs/windows/src/Windows/Foundation/mod.rs +++ b/crates/libs/windows/src/Windows/Foundation/mod.rs @@ -1160,7 +1160,7 @@ unsafe impl ::windows::core::RuntimeType for IAsyncAction { impl IAsyncAction { pub fn get(&self) -> ::windows::core::Result<()> { if self.Status()? == AsyncStatus::Started { - let (_waiter, signaler) = ::windows::core::Waiter::new(); + let (_waiter, signaler) = ::windows::core::Waiter::new()?; self.SetCompleted(AsyncActionCompletedHandler::new(move |_sender, _args| { unsafe { signaler.signal(); @@ -1360,7 +1360,7 @@ unsafe impl ::windows::core:: impl IAsyncActionWithProgress { pub fn get(&self) -> ::windows::core::Result<()> { if self.Status()? == AsyncStatus::Started { - let (_waiter, signaler) = ::windows::core::Waiter::new(); + let (_waiter, signaler) = ::windows::core::Waiter::new()?; self.SetCompleted(AsyncActionWithProgressCompletedHandler::new(move |_sender, _args| { unsafe { signaler.signal(); @@ -1672,7 +1672,7 @@ unsafe impl ::windows::core::Ru impl IAsyncOperation { pub fn get(&self) -> ::windows::core::Result { if self.Status()? == AsyncStatus::Started { - let (_waiter, signaler) = ::windows::core::Waiter::new(); + let (_waiter, signaler) = ::windows::core::Waiter::new()?; self.SetCompleted(AsyncOperationCompletedHandler::new(move |_sender, _args| { unsafe { signaler.signal(); @@ -1880,7 +1880,7 @@ unsafe impl IAsyncOperationWithProgress { pub fn get(&self) -> ::windows::core::Result { if self.Status()? == AsyncStatus::Started { - let (_waiter, signaler) = ::windows::core::Waiter::new(); + let (_waiter, signaler) = ::windows::core::Waiter::new()?; self.SetCompleted(AsyncOperationWithProgressCompletedHandler::new(move |_sender, _args| { unsafe { signaler.signal(); diff --git a/crates/libs/windows/src/Windows/Security/Authentication/OnlineId/mod.rs b/crates/libs/windows/src/Windows/Security/Authentication/OnlineId/mod.rs index e4401d2e77..dbe5fce99c 100644 --- a/crates/libs/windows/src/Windows/Security/Authentication/OnlineId/mod.rs +++ b/crates/libs/windows/src/Windows/Security/Authentication/OnlineId/mod.rs @@ -1021,7 +1021,7 @@ impl ::windows::core::RuntimeName for SignOutUserOperation { impl SignOutUserOperation { pub fn get(&self) -> ::windows::core::Result<()> { if self.Status()? == super::super::super::Foundation::AsyncStatus::Started { - let (_waiter, signaler) = ::windows::core::Waiter::new(); + let (_waiter, signaler) = ::windows::core::Waiter::new()?; self.SetCompleted(super::super::super::Foundation::AsyncActionCompletedHandler::new(move |_sender, _args| { unsafe { signaler.signal(); @@ -1263,7 +1263,7 @@ impl ::windows::core::RuntimeName for UserAuthenticationOperation { impl UserAuthenticationOperation { pub fn get(&self) -> ::windows::core::Result { if self.Status()? == super::super::super::Foundation::AsyncStatus::Started { - let (_waiter, signaler) = ::windows::core::Waiter::new(); + let (_waiter, signaler) = ::windows::core::Waiter::new()?; self.SetCompleted(super::super::super::Foundation::AsyncOperationCompletedHandler::new(move |_sender, _args| { unsafe { signaler.signal(); diff --git a/crates/libs/windows/src/Windows/Storage/Streams/mod.rs b/crates/libs/windows/src/Windows/Storage/Streams/mod.rs index c97cdc6941..1468828249 100644 --- a/crates/libs/windows/src/Windows/Storage/Streams/mod.rs +++ b/crates/libs/windows/src/Windows/Storage/Streams/mod.rs @@ -651,7 +651,7 @@ impl ::windows::core::RuntimeName for DataReaderLoadOperation { impl DataReaderLoadOperation { pub fn get(&self) -> ::windows::core::Result { if self.Status()? == super::super::Foundation::AsyncStatus::Started { - let (_waiter, signaler) = ::windows::core::Waiter::new(); + let (_waiter, signaler) = ::windows::core::Waiter::new()?; self.SetCompleted(super::super::Foundation::AsyncOperationCompletedHandler::new(move |_sender, _args| { unsafe { signaler.signal(); @@ -1209,7 +1209,7 @@ impl ::windows::core::RuntimeName for DataWriterStoreOperation { impl DataWriterStoreOperation { pub fn get(&self) -> ::windows::core::Result { if self.Status()? == super::super::Foundation::AsyncStatus::Started { - let (_waiter, signaler) = ::windows::core::Waiter::new(); + let (_waiter, signaler) = ::windows::core::Waiter::new()?; self.SetCompleted(super::super::Foundation::AsyncOperationCompletedHandler::new(move |_sender, _args| { unsafe { signaler.signal(); diff --git a/crates/libs/windows/src/Windows/Win32/Devices/AllJoyn/mod.rs b/crates/libs/windows/src/Windows/Win32/Devices/AllJoyn/mod.rs index 45de3bf1d2..bfdc19a6fc 100644 --- a/crates/libs/windows/src/Windows/Win32/Devices/AllJoyn/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/Devices/AllJoyn/mod.rs @@ -104,14 +104,15 @@ pub unsafe fn AllJoynCloseBusHandle<'a, Param0: ::windows::core::IntoParam<'a, s #[doc = "*Required features: `\"Win32_Devices_AllJoyn\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn AllJoynConnectToBus<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(connectionspec: Param0) -> super::super::Foundation::HANDLE { +pub unsafe fn AllJoynConnectToBus<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(connectionspec: Param0) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn AllJoynConnectToBus(connectionspec: ::windows::core::PCWSTR) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(AllJoynConnectToBus(connectionspec.into_param().abi())) + let result__ = AllJoynConnectToBus(connectionspec.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -1060,18 +1061,6 @@ impl ::core::fmt::Debug for alljoyn_about_announceflag { #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq)] pub struct alljoyn_aboutdata(pub isize); -impl alljoyn_aboutdata { - pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } - } -} impl ::core::default::Default for alljoyn_aboutdata { fn default() -> Self { unsafe { ::core::mem::zeroed() } @@ -1710,18 +1699,6 @@ pub unsafe fn alljoyn_aboutdata_setsupporturl<'a, Param0: ::windows::core::IntoP #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq)] pub struct alljoyn_aboutdatalistener(pub isize); -impl alljoyn_aboutdatalistener { - pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } - } -} impl ::core::default::Default for alljoyn_aboutdatalistener { fn default() -> Self { unsafe { ::core::mem::zeroed() } @@ -2003,18 +1980,6 @@ pub unsafe fn alljoyn_abouticonproxy_getversion(proxy: *mut _alljoyn_abouticonpr #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq)] pub struct alljoyn_aboutlistener(pub isize); -impl alljoyn_aboutlistener { - pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } - } -} impl ::core::default::Default for alljoyn_aboutlistener { fn default() -> Self { unsafe { ::core::mem::zeroed() } @@ -2095,18 +2060,6 @@ pub unsafe fn alljoyn_aboutlistener_destroy<'a, Param0: ::windows::core::IntoPar #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq)] pub struct alljoyn_aboutobj(pub isize); -impl alljoyn_aboutobj { - pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } - } -} impl ::core::default::Default for alljoyn_aboutobj { fn default() -> Self { unsafe { ::core::mem::zeroed() } @@ -2199,18 +2152,6 @@ pub unsafe fn alljoyn_aboutobj_unannounce<'a, Param0: ::windows::core::IntoParam #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq)] pub struct alljoyn_aboutobjectdescription(pub isize); -impl alljoyn_aboutobjectdescription { - pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } - } -} impl ::core::default::Default for alljoyn_aboutobjectdescription { fn default() -> Self { unsafe { ::core::mem::zeroed() } @@ -2401,18 +2342,6 @@ pub unsafe fn alljoyn_aboutobjectdescription_haspath<'a, Param0: ::windows::core #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq)] pub struct alljoyn_aboutproxy(pub isize); -impl alljoyn_aboutproxy { - pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } - } -} impl ::core::default::Default for alljoyn_aboutproxy { fn default() -> Self { unsafe { ::core::mem::zeroed() } @@ -2536,18 +2465,6 @@ impl ::core::fmt::Debug for alljoyn_applicationstate { #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq)] pub struct alljoyn_applicationstatelistener(pub isize); -impl alljoyn_applicationstatelistener { - pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } - } -} impl ::core::default::Default for alljoyn_applicationstatelistener { fn default() -> Self { unsafe { ::core::mem::zeroed() } @@ -2630,18 +2547,6 @@ pub type alljoyn_applicationstatelistener_state_ptr = ::core::option::Option bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } - } -} impl ::core::default::Default for alljoyn_authlistener { fn default() -> Self { unsafe { ::core::mem::zeroed() } @@ -2840,18 +2745,6 @@ pub unsafe fn alljoyn_authlistenerasync_destroy<'a, Param0: ::windows::core::Int #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq)] pub struct alljoyn_autopinger(pub isize); -impl alljoyn_autopinger { - pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } - } -} impl ::core::default::Default for alljoyn_autopinger { fn default() -> Self { unsafe { ::core::mem::zeroed() } @@ -3004,18 +2897,6 @@ pub unsafe fn alljoyn_autopinger_setpinginterval<'a, Param0: ::windows::core::In #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq)] pub struct alljoyn_busattachment(pub isize); -impl alljoyn_busattachment { - pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } - } -} impl ::core::default::Default for alljoyn_busattachment { fn default() -> Self { unsafe { ::core::mem::zeroed() } @@ -4190,18 +4071,6 @@ pub unsafe fn alljoyn_busattachment_whoimplements_interfaces<'a, Param0: ::windo #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq)] pub struct alljoyn_buslistener(pub isize); -impl alljoyn_buslistener { - pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } - } -} impl ::core::default::Default for alljoyn_buslistener { fn default() -> Self { unsafe { ::core::mem::zeroed() } @@ -4314,18 +4183,6 @@ pub type alljoyn_buslistener_name_owner_changed_ptr = ::core::option::Option bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } - } -} impl ::core::default::Default for alljoyn_busobject { fn default() -> Self { unsafe { ::core::mem::zeroed() } @@ -4819,18 +4676,6 @@ impl ::core::fmt::Debug for alljoyn_claimcapabilityadditionalinfo_masks { #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq)] pub struct alljoyn_credentials(pub isize); -impl alljoyn_credentials { - pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } - } -} impl ::core::default::Default for alljoyn_credentials { fn default() -> Self { unsafe { ::core::mem::zeroed() } @@ -5133,18 +4978,6 @@ pub unsafe fn alljoyn_init() -> QStatus { #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq)] pub struct alljoyn_interfacedescription(pub isize); -impl alljoyn_interfacedescription { - pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } - } -} impl ::core::default::Default for alljoyn_interfacedescription { fn default() -> Self { unsafe { ::core::mem::zeroed() } @@ -6079,18 +5912,6 @@ pub type alljoyn_interfacedescription_translation_callback_ptr = ::core::option: #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq)] pub struct alljoyn_keystore(pub isize); -impl alljoyn_keystore { - pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } - } -} impl ::core::default::Default for alljoyn_keystore { fn default() -> Self { unsafe { ::core::mem::zeroed() } @@ -6113,18 +5934,6 @@ unsafe impl ::windows::core::Abi for alljoyn_keystore { #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq)] pub struct alljoyn_keystorelistener(pub isize); -impl alljoyn_keystorelistener { - pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } - } -} impl ::core::default::Default for alljoyn_keystorelistener { fn default() -> Self { unsafe { ::core::mem::zeroed() } @@ -6320,18 +6129,6 @@ impl ::core::default::Default for alljoyn_manifestarray { #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq)] pub struct alljoyn_message(pub isize); -impl alljoyn_message { - pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } - } -} impl ::core::default::Default for alljoyn_message { fn default() -> Self { unsafe { ::core::mem::zeroed() } @@ -6827,18 +6624,6 @@ impl ::core::fmt::Debug for alljoyn_messagetype { #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq)] pub struct alljoyn_msgarg(pub isize); -impl alljoyn_msgarg { - pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } - } -} impl ::core::default::Default for alljoyn_msgarg { fn default() -> Self { unsafe { ::core::mem::zeroed() } @@ -7967,18 +7752,6 @@ pub unsafe fn alljoyn_msgarg_tostring<'a, Param0: ::windows::core::IntoParam<'a, #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq)] pub struct alljoyn_observer(pub isize); -impl alljoyn_observer { - pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } - } -} impl ::core::default::Default for alljoyn_observer { fn default() -> Self { unsafe { ::core::mem::zeroed() } @@ -8117,18 +7890,6 @@ pub unsafe fn alljoyn_observer_unregisterlistener<'a, Param0: ::windows::core::I #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq)] pub struct alljoyn_observerlistener(pub isize); -impl alljoyn_observerlistener { - pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } - } -} impl ::core::default::Default for alljoyn_observerlistener { fn default() -> Self { unsafe { ::core::mem::zeroed() } @@ -8224,18 +7985,6 @@ pub unsafe fn alljoyn_passwordmanager_setcredentials<'a, Param0: ::windows::core #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq)] pub struct alljoyn_permissionconfigurationlistener(pub isize); -impl alljoyn_permissionconfigurationlistener { - pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } - } -} impl ::core::default::Default for alljoyn_permissionconfigurationlistener { fn default() -> Self { unsafe { ::core::mem::zeroed() } @@ -8327,18 +8076,6 @@ pub type alljoyn_permissionconfigurationlistener_startmanagement_ptr = ::core::o #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq)] pub struct alljoyn_permissionconfigurator(pub isize); -impl alljoyn_permissionconfigurator { - pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } - } -} impl ::core::default::Default for alljoyn_permissionconfigurator { fn default() -> Self { unsafe { ::core::mem::zeroed() } @@ -8823,18 +8560,6 @@ pub unsafe fn alljoyn_permissionconfigurator_updatepolicy<'a, Param0: ::windows: #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq)] pub struct alljoyn_pinglistener(pub isize); -impl alljoyn_pinglistener { - pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } - } -} impl ::core::default::Default for alljoyn_pinglistener { fn default() -> Self { unsafe { ::core::mem::zeroed() } @@ -8916,18 +8641,6 @@ pub unsafe fn alljoyn_pinglistener_destroy<'a, Param0: ::windows::core::IntoPara #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq)] pub struct alljoyn_proxybusobject(pub isize); -impl alljoyn_proxybusobject { - pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } - } -} impl ::core::default::Default for alljoyn_proxybusobject { fn default() -> Self { unsafe { ::core::mem::zeroed() } @@ -9408,18 +9121,6 @@ pub unsafe fn alljoyn_proxybusobject_parsexml<'a, Param0: ::windows::core::IntoP #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq)] pub struct alljoyn_proxybusobject_ref(pub isize); -impl alljoyn_proxybusobject_ref { - pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } - } -} impl ::core::default::Default for alljoyn_proxybusobject_ref { fn default() -> Self { unsafe { ::core::mem::zeroed() } @@ -9638,18 +9339,6 @@ pub unsafe fn alljoyn_routershutdown() -> QStatus { #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq)] pub struct alljoyn_securityapplicationproxy(pub isize); -impl alljoyn_securityapplicationproxy { - pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } - } -} impl ::core::default::Default for alljoyn_securityapplicationproxy { fn default() -> Self { unsafe { ::core::mem::zeroed() } @@ -10036,18 +9725,6 @@ pub unsafe fn alljoyn_securityapplicationproxy_updatepolicy<'a, Param0: ::window #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq)] pub struct alljoyn_sessionlistener(pub isize); -impl alljoyn_sessionlistener { - pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } - } -} impl ::core::default::Default for alljoyn_sessionlistener { fn default() -> Self { unsafe { ::core::mem::zeroed() } @@ -10171,18 +9848,6 @@ impl ::core::fmt::Debug for alljoyn_sessionlostreason { #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq)] pub struct alljoyn_sessionopts(pub isize); -impl alljoyn_sessionopts { - pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } - } -} impl ::core::default::Default for alljoyn_sessionopts { fn default() -> Self { unsafe { ::core::mem::zeroed() } @@ -10373,18 +10038,6 @@ pub unsafe fn alljoyn_sessionopts_set_transports<'a, Param0: ::windows::core::In #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq)] pub struct alljoyn_sessionportlistener(pub isize); -impl alljoyn_sessionportlistener { - pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } - } -} impl ::core::default::Default for alljoyn_sessionportlistener { fn default() -> Self { unsafe { ::core::mem::zeroed() } diff --git a/crates/libs/windows/src/Windows/Win32/Devices/Bluetooth/mod.rs b/crates/libs/windows/src/Windows/Win32/Devices/Bluetooth/mod.rs index 7dab585149..49a123de3f 100644 --- a/crates/libs/windows/src/Windows/Win32/Devices/Bluetooth/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/Devices/Bluetooth/mod.rs @@ -3321,14 +3321,7 @@ pub const GenericTelephonyServiceClassID_UUID16: u32 = 4612u32; pub struct HANDLE_SDP_TYPE(pub u64); impl HANDLE_SDP_TYPE { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HANDLE_SDP_TYPE { diff --git a/crates/libs/windows/src/Windows/Win32/Devices/DeviceAndDriverInstallation/mod.rs b/crates/libs/windows/src/Windows/Win32/Devices/DeviceAndDriverInstallation/mod.rs index cfe1316de2..ff51a201a9 100644 --- a/crates/libs/windows/src/Windows/Win32/Devices/DeviceAndDriverInstallation/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/Devices/DeviceAndDriverInstallation/mod.rs @@ -6562,14 +6562,7 @@ pub const GUID_WUDF_DEVICE_HOST_PROBLEM: ::windows::core::GUID = ::windows::core pub struct HCMNOTIFICATION(pub isize); impl HCMNOTIFICATION { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HCMNOTIFICATION { @@ -13450,14 +13443,15 @@ pub unsafe fn SetupDiClassNameFromGuidW(classguid: *const ::windows::core::GUID, #[doc = "*Required features: `\"Win32_Devices_DeviceAndDriverInstallation\"`, `\"Win32_System_Registry\"`*"] #[cfg(feature = "Win32_System_Registry")] #[inline] -pub unsafe fn SetupDiCreateDevRegKeyA<'a, Param6: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(deviceinfoset: *const ::core::ffi::c_void, deviceinfodata: *const SP_DEVINFO_DATA, scope: u32, hwprofile: u32, keytype: u32, infhandle: *const ::core::ffi::c_void, infsectionname: Param6) -> super::super::System::Registry::HKEY { +pub unsafe fn SetupDiCreateDevRegKeyA<'a, Param6: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(deviceinfoset: *const ::core::ffi::c_void, deviceinfodata: *const SP_DEVINFO_DATA, scope: u32, hwprofile: u32, keytype: u32, infhandle: *const ::core::ffi::c_void, infsectionname: Param6) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn SetupDiCreateDevRegKeyA(deviceinfoset: *const ::core::ffi::c_void, deviceinfodata: *const SP_DEVINFO_DATA, scope: u32, hwprofile: u32, keytype: u32, infhandle: *const ::core::ffi::c_void, infsectionname: ::windows::core::PCSTR) -> super::super::System::Registry::HKEY; } - ::core::mem::transmute(SetupDiCreateDevRegKeyA(::core::mem::transmute(deviceinfoset), ::core::mem::transmute(deviceinfodata), ::core::mem::transmute(scope), ::core::mem::transmute(hwprofile), ::core::mem::transmute(keytype), ::core::mem::transmute(infhandle), infsectionname.into_param().abi())) + let result__ = SetupDiCreateDevRegKeyA(::core::mem::transmute(deviceinfoset), ::core::mem::transmute(deviceinfodata), ::core::mem::transmute(scope), ::core::mem::transmute(hwprofile), ::core::mem::transmute(keytype), ::core::mem::transmute(infhandle), infsectionname.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -13465,14 +13459,15 @@ pub unsafe fn SetupDiCreateDevRegKeyA<'a, Param6: ::windows::core::IntoParam<'a, #[doc = "*Required features: `\"Win32_Devices_DeviceAndDriverInstallation\"`, `\"Win32_System_Registry\"`*"] #[cfg(feature = "Win32_System_Registry")] #[inline] -pub unsafe fn SetupDiCreateDevRegKeyW<'a, Param6: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(deviceinfoset: *const ::core::ffi::c_void, deviceinfodata: *const SP_DEVINFO_DATA, scope: u32, hwprofile: u32, keytype: u32, infhandle: *const ::core::ffi::c_void, infsectionname: Param6) -> super::super::System::Registry::HKEY { +pub unsafe fn SetupDiCreateDevRegKeyW<'a, Param6: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(deviceinfoset: *const ::core::ffi::c_void, deviceinfodata: *const SP_DEVINFO_DATA, scope: u32, hwprofile: u32, keytype: u32, infhandle: *const ::core::ffi::c_void, infsectionname: Param6) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn SetupDiCreateDevRegKeyW(deviceinfoset: *const ::core::ffi::c_void, deviceinfodata: *const SP_DEVINFO_DATA, scope: u32, hwprofile: u32, keytype: u32, infhandle: *const ::core::ffi::c_void, infsectionname: ::windows::core::PCWSTR) -> super::super::System::Registry::HKEY; } - ::core::mem::transmute(SetupDiCreateDevRegKeyW(::core::mem::transmute(deviceinfoset), ::core::mem::transmute(deviceinfodata), ::core::mem::transmute(scope), ::core::mem::transmute(hwprofile), ::core::mem::transmute(keytype), ::core::mem::transmute(infhandle), infsectionname.into_param().abi())) + let result__ = SetupDiCreateDevRegKeyW(::core::mem::transmute(deviceinfoset), ::core::mem::transmute(deviceinfodata), ::core::mem::transmute(scope), ::core::mem::transmute(hwprofile), ::core::mem::transmute(keytype), ::core::mem::transmute(infhandle), infsectionname.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -13570,14 +13565,15 @@ pub unsafe fn SetupDiCreateDeviceInterfaceA<'a, Param3: ::windows::core::IntoPar #[doc = "*Required features: `\"Win32_Devices_DeviceAndDriverInstallation\"`, `\"Win32_System_Registry\"`*"] #[cfg(feature = "Win32_System_Registry")] #[inline] -pub unsafe fn SetupDiCreateDeviceInterfaceRegKeyA<'a, Param5: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(deviceinfoset: *const ::core::ffi::c_void, deviceinterfacedata: *const SP_DEVICE_INTERFACE_DATA, reserved: u32, samdesired: u32, infhandle: *const ::core::ffi::c_void, infsectionname: Param5) -> super::super::System::Registry::HKEY { +pub unsafe fn SetupDiCreateDeviceInterfaceRegKeyA<'a, Param5: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(deviceinfoset: *const ::core::ffi::c_void, deviceinterfacedata: *const SP_DEVICE_INTERFACE_DATA, reserved: u32, samdesired: u32, infhandle: *const ::core::ffi::c_void, infsectionname: Param5) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn SetupDiCreateDeviceInterfaceRegKeyA(deviceinfoset: *const ::core::ffi::c_void, deviceinterfacedata: *const SP_DEVICE_INTERFACE_DATA, reserved: u32, samdesired: u32, infhandle: *const ::core::ffi::c_void, infsectionname: ::windows::core::PCSTR) -> super::super::System::Registry::HKEY; } - ::core::mem::transmute(SetupDiCreateDeviceInterfaceRegKeyA(::core::mem::transmute(deviceinfoset), ::core::mem::transmute(deviceinterfacedata), ::core::mem::transmute(reserved), ::core::mem::transmute(samdesired), ::core::mem::transmute(infhandle), infsectionname.into_param().abi())) + let result__ = SetupDiCreateDeviceInterfaceRegKeyA(::core::mem::transmute(deviceinfoset), ::core::mem::transmute(deviceinterfacedata), ::core::mem::transmute(reserved), ::core::mem::transmute(samdesired), ::core::mem::transmute(infhandle), infsectionname.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -13585,14 +13581,15 @@ pub unsafe fn SetupDiCreateDeviceInterfaceRegKeyA<'a, Param5: ::windows::core::I #[doc = "*Required features: `\"Win32_Devices_DeviceAndDriverInstallation\"`, `\"Win32_System_Registry\"`*"] #[cfg(feature = "Win32_System_Registry")] #[inline] -pub unsafe fn SetupDiCreateDeviceInterfaceRegKeyW<'a, Param5: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(deviceinfoset: *const ::core::ffi::c_void, deviceinterfacedata: *const SP_DEVICE_INTERFACE_DATA, reserved: u32, samdesired: u32, infhandle: *const ::core::ffi::c_void, infsectionname: Param5) -> super::super::System::Registry::HKEY { +pub unsafe fn SetupDiCreateDeviceInterfaceRegKeyW<'a, Param5: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(deviceinfoset: *const ::core::ffi::c_void, deviceinterfacedata: *const SP_DEVICE_INTERFACE_DATA, reserved: u32, samdesired: u32, infhandle: *const ::core::ffi::c_void, infsectionname: Param5) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn SetupDiCreateDeviceInterfaceRegKeyW(deviceinfoset: *const ::core::ffi::c_void, deviceinterfacedata: *const SP_DEVICE_INTERFACE_DATA, reserved: u32, samdesired: u32, infhandle: *const ::core::ffi::c_void, infsectionname: ::windows::core::PCWSTR) -> super::super::System::Registry::HKEY; } - ::core::mem::transmute(SetupDiCreateDeviceInterfaceRegKeyW(::core::mem::transmute(deviceinfoset), ::core::mem::transmute(deviceinterfacedata), ::core::mem::transmute(reserved), ::core::mem::transmute(samdesired), ::core::mem::transmute(infhandle), infsectionname.into_param().abi())) + let result__ = SetupDiCreateDeviceInterfaceRegKeyW(::core::mem::transmute(deviceinfoset), ::core::mem::transmute(deviceinterfacedata), ::core::mem::transmute(reserved), ::core::mem::transmute(samdesired), ::core::mem::transmute(infhandle), infsectionname.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -14890,14 +14887,15 @@ pub unsafe fn SetupDiLoadDeviceIcon(deviceinfoset: *const ::core::ffi::c_void, d #[doc = "*Required features: `\"Win32_Devices_DeviceAndDriverInstallation\"`, `\"Win32_System_Registry\"`*"] #[cfg(feature = "Win32_System_Registry")] #[inline] -pub unsafe fn SetupDiOpenClassRegKey(classguid: *const ::windows::core::GUID, samdesired: u32) -> super::super::System::Registry::HKEY { +pub unsafe fn SetupDiOpenClassRegKey(classguid: *const ::windows::core::GUID, samdesired: u32) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn SetupDiOpenClassRegKey(classguid: *const ::windows::core::GUID, samdesired: u32) -> super::super::System::Registry::HKEY; } - ::core::mem::transmute(SetupDiOpenClassRegKey(::core::mem::transmute(classguid), ::core::mem::transmute(samdesired))) + let result__ = SetupDiOpenClassRegKey(::core::mem::transmute(classguid), ::core::mem::transmute(samdesired)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -14905,14 +14903,15 @@ pub unsafe fn SetupDiOpenClassRegKey(classguid: *const ::windows::core::GUID, sa #[doc = "*Required features: `\"Win32_Devices_DeviceAndDriverInstallation\"`, `\"Win32_System_Registry\"`*"] #[cfg(feature = "Win32_System_Registry")] #[inline] -pub unsafe fn SetupDiOpenClassRegKeyExA<'a, Param3: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(classguid: *const ::windows::core::GUID, samdesired: u32, flags: u32, machinename: Param3, reserved: *mut ::core::ffi::c_void) -> super::super::System::Registry::HKEY { +pub unsafe fn SetupDiOpenClassRegKeyExA<'a, Param3: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(classguid: *const ::windows::core::GUID, samdesired: u32, flags: u32, machinename: Param3, reserved: *mut ::core::ffi::c_void) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn SetupDiOpenClassRegKeyExA(classguid: *const ::windows::core::GUID, samdesired: u32, flags: u32, machinename: ::windows::core::PCSTR, reserved: *mut ::core::ffi::c_void) -> super::super::System::Registry::HKEY; } - ::core::mem::transmute(SetupDiOpenClassRegKeyExA(::core::mem::transmute(classguid), ::core::mem::transmute(samdesired), ::core::mem::transmute(flags), machinename.into_param().abi(), ::core::mem::transmute(reserved))) + let result__ = SetupDiOpenClassRegKeyExA(::core::mem::transmute(classguid), ::core::mem::transmute(samdesired), ::core::mem::transmute(flags), machinename.into_param().abi(), ::core::mem::transmute(reserved)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -14920,14 +14919,15 @@ pub unsafe fn SetupDiOpenClassRegKeyExA<'a, Param3: ::windows::core::IntoParam<' #[doc = "*Required features: `\"Win32_Devices_DeviceAndDriverInstallation\"`, `\"Win32_System_Registry\"`*"] #[cfg(feature = "Win32_System_Registry")] #[inline] -pub unsafe fn SetupDiOpenClassRegKeyExW<'a, Param3: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(classguid: *const ::windows::core::GUID, samdesired: u32, flags: u32, machinename: Param3, reserved: *mut ::core::ffi::c_void) -> super::super::System::Registry::HKEY { +pub unsafe fn SetupDiOpenClassRegKeyExW<'a, Param3: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(classguid: *const ::windows::core::GUID, samdesired: u32, flags: u32, machinename: Param3, reserved: *mut ::core::ffi::c_void) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn SetupDiOpenClassRegKeyExW(classguid: *const ::windows::core::GUID, samdesired: u32, flags: u32, machinename: ::windows::core::PCWSTR, reserved: *mut ::core::ffi::c_void) -> super::super::System::Registry::HKEY; } - ::core::mem::transmute(SetupDiOpenClassRegKeyExW(::core::mem::transmute(classguid), ::core::mem::transmute(samdesired), ::core::mem::transmute(flags), machinename.into_param().abi(), ::core::mem::transmute(reserved))) + let result__ = SetupDiOpenClassRegKeyExW(::core::mem::transmute(classguid), ::core::mem::transmute(samdesired), ::core::mem::transmute(flags), machinename.into_param().abi(), ::core::mem::transmute(reserved)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -14935,14 +14935,15 @@ pub unsafe fn SetupDiOpenClassRegKeyExW<'a, Param3: ::windows::core::IntoParam<' #[doc = "*Required features: `\"Win32_Devices_DeviceAndDriverInstallation\"`, `\"Win32_System_Registry\"`*"] #[cfg(feature = "Win32_System_Registry")] #[inline] -pub unsafe fn SetupDiOpenDevRegKey(deviceinfoset: *const ::core::ffi::c_void, deviceinfodata: *const SP_DEVINFO_DATA, scope: u32, hwprofile: u32, keytype: u32, samdesired: u32) -> super::super::System::Registry::HKEY { +pub unsafe fn SetupDiOpenDevRegKey(deviceinfoset: *const ::core::ffi::c_void, deviceinfodata: *const SP_DEVINFO_DATA, scope: u32, hwprofile: u32, keytype: u32, samdesired: u32) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn SetupDiOpenDevRegKey(deviceinfoset: *const ::core::ffi::c_void, deviceinfodata: *const SP_DEVINFO_DATA, scope: u32, hwprofile: u32, keytype: u32, samdesired: u32) -> super::super::System::Registry::HKEY; } - ::core::mem::transmute(SetupDiOpenDevRegKey(::core::mem::transmute(deviceinfoset), ::core::mem::transmute(deviceinfodata), ::core::mem::transmute(scope), ::core::mem::transmute(hwprofile), ::core::mem::transmute(keytype), ::core::mem::transmute(samdesired))) + let result__ = SetupDiOpenDevRegKey(::core::mem::transmute(deviceinfoset), ::core::mem::transmute(deviceinfodata), ::core::mem::transmute(scope), ::core::mem::transmute(hwprofile), ::core::mem::transmute(keytype), ::core::mem::transmute(samdesired)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -14995,14 +14996,15 @@ pub unsafe fn SetupDiOpenDeviceInterfaceA<'a, Param1: ::windows::core::IntoParam #[doc = "*Required features: `\"Win32_Devices_DeviceAndDriverInstallation\"`, `\"Win32_System_Registry\"`*"] #[cfg(feature = "Win32_System_Registry")] #[inline] -pub unsafe fn SetupDiOpenDeviceInterfaceRegKey(deviceinfoset: *const ::core::ffi::c_void, deviceinterfacedata: *const SP_DEVICE_INTERFACE_DATA, reserved: u32, samdesired: u32) -> super::super::System::Registry::HKEY { +pub unsafe fn SetupDiOpenDeviceInterfaceRegKey(deviceinfoset: *const ::core::ffi::c_void, deviceinterfacedata: *const SP_DEVICE_INTERFACE_DATA, reserved: u32, samdesired: u32) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn SetupDiOpenDeviceInterfaceRegKey(deviceinfoset: *const ::core::ffi::c_void, deviceinterfacedata: *const SP_DEVICE_INTERFACE_DATA, reserved: u32, samdesired: u32) -> super::super::System::Registry::HKEY; } - ::core::mem::transmute(SetupDiOpenDeviceInterfaceRegKey(::core::mem::transmute(deviceinfoset), ::core::mem::transmute(deviceinterfacedata), ::core::mem::transmute(reserved), ::core::mem::transmute(samdesired))) + let result__ = SetupDiOpenDeviceInterfaceRegKey(::core::mem::transmute(deviceinfoset), ::core::mem::transmute(deviceinterfacedata), ::core::mem::transmute(reserved), ::core::mem::transmute(samdesired)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); diff --git a/crates/libs/windows/src/Windows/Win32/Devices/Display/mod.rs b/crates/libs/windows/src/Windows/Win32/Devices/Display/mod.rs index cf1c4d012a..ee26e866d9 100644 --- a/crates/libs/windows/src/Windows/Win32/Devices/Display/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/Devices/Display/mod.rs @@ -1593,14 +1593,7 @@ pub const DEVPKEY_IndirectDisplay: super::super::UI::Shell::PropertiesSystem::PR pub struct DHPDEV(pub isize); impl DHPDEV { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for DHPDEV { @@ -1627,14 +1620,7 @@ unsafe impl ::windows::core::Abi for DHPDEV { pub struct DHSURF(pub isize); impl DHSURF { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for DHSURF { @@ -6981,14 +6967,7 @@ pub unsafe fn GetVCPFeatureAndVCPFeatureReply<'a, Param0: ::windows::core::IntoP pub struct HBM(pub isize); impl HBM { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HBM { @@ -7015,14 +6994,7 @@ unsafe impl ::windows::core::Abi for HBM { pub struct HDEV(pub isize); impl HDEV { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HDEV { @@ -7049,14 +7021,7 @@ unsafe impl ::windows::core::Abi for HDEV { pub struct HDRVOBJ(pub isize); impl HDRVOBJ { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HDRVOBJ { @@ -7083,14 +7048,7 @@ unsafe impl ::windows::core::Abi for HDRVOBJ { pub struct HFASTMUTEX(pub isize); impl HFASTMUTEX { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HFASTMUTEX { @@ -7173,14 +7131,7 @@ pub const HOST_DSI_TRANSMISSION_TIMEOUT: u32 = 64u32; pub struct HSEMAPHORE(pub isize); impl HSEMAPHORE { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HSEMAPHORE { @@ -7207,14 +7158,7 @@ unsafe impl ::windows::core::Abi for HSEMAPHORE { pub struct HSURF(pub isize); impl HSURF { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HSURF { diff --git a/crates/libs/windows/src/Windows/Win32/Devices/Enumeration/Pnp/mod.rs b/crates/libs/windows/src/Windows/Win32/Devices/Enumeration/Pnp/mod.rs index 392481afc5..7d68faad07 100644 --- a/crates/libs/windows/src/Windows/Win32/Devices/Enumeration/Pnp/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/Devices/Enumeration/Pnp/mod.rs @@ -20,14 +20,7 @@ pub const FAULT_INVALID_VARIABLE: u32 = 404u32; pub struct HSWDEVICE(pub isize); impl HSWDEVICE { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HSWDEVICE { diff --git a/crates/libs/windows/src/Windows/Win32/Devices/SerialCommunication/mod.rs b/crates/libs/windows/src/Windows/Win32/Devices/SerialCommunication/mod.rs index d0a2a16749..69f9c2d966 100644 --- a/crates/libs/windows/src/Windows/Win32/Devices/SerialCommunication/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/Devices/SerialCommunication/mod.rs @@ -111,14 +111,7 @@ pub unsafe fn ComDBResizeDatabase<'a, Param0: ::windows::core::IntoParam<'a, HCO pub struct HCOMDB(pub isize); impl HCOMDB { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HCOMDB { diff --git a/crates/libs/windows/src/Windows/Win32/Foundation/mod.rs b/crates/libs/windows/src/Windows/Win32/Foundation/mod.rs index f00394ecbd..26074d3de1 100644 --- a/crates/libs/windows/src/Windows/Win32/Foundation/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/Foundation/mod.rs @@ -200,18 +200,6 @@ impl<'a> ::windows::core::IntoParam<'a, BOOL> for bool { #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq)] pub struct BOOLEAN(pub u8); -impl BOOLEAN { - pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } - } -} impl ::core::default::Default for BOOLEAN { fn default() -> Self { unsafe { ::core::mem::zeroed() } @@ -539,18 +527,6 @@ pub const CERT_E_WRONG_USAGE: ::windows::core::HRESULT = ::windows::core::HRESUL #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq)] pub struct CHAR(pub u8); -impl CHAR { - pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } - } -} impl ::core::default::Default for CHAR { fn default() -> Self { unsafe { ::core::mem::zeroed() } @@ -3906,22 +3882,16 @@ pub unsafe fn GetLastError() -> WIN32_ERROR { unimplemented!("Unsupported target OS"); } #[repr(transparent)] +#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq)] pub struct HANDLE(pub isize); impl HANDLE { pub fn is_invalid(&self) -> bool { - self.0 == 0 || self.0 == -1 - } - pub fn ok(self) -> ::windows::core::Result { - if self.is_invalid() { - Err(::windows::core::Error::from_win32()) - } else { - Ok(self) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HANDLE { fn default() -> Self { - Self(0) + unsafe { ::core::mem::zeroed() } } } impl ::core::clone::Clone for HANDLE { @@ -3930,12 +3900,6 @@ impl ::core::clone::Clone for HANDLE { } } impl ::core::marker::Copy for HANDLE {} -impl ::core::cmp::PartialEq for HANDLE { - fn eq(&self, other: &Self) -> bool { - self.0 == other.0 - } -} -impl ::core::cmp::Eq for HANDLE {} impl ::core::fmt::Debug for HANDLE { fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { f.debug_tuple("HANDLE").field(&self.0).finish() @@ -4002,18 +3966,6 @@ impl ::core::ops::Not for HANDLE_FLAGS { #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq)] pub struct HANDLE_PTR(pub usize); -impl HANDLE_PTR { - pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } - } -} impl ::core::default::Default for HANDLE_PTR { fn default() -> Self { unsafe { ::core::mem::zeroed() } @@ -4190,18 +4142,6 @@ pub const HCS_E_WINDOWS_INSIDER_REQUIRED: ::windows::core::HRESULT = ::windows:: #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq)] pub struct HINSTANCE(pub isize); -impl HINSTANCE { - pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } - } -} impl ::core::default::Default for HINSTANCE { fn default() -> Self { unsafe { ::core::mem::zeroed() } @@ -4256,14 +4196,7 @@ impl ::core::default::Default for HLSURF__ { pub struct HRSRC(pub isize); impl HRSRC { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HRSRC { @@ -4504,18 +4437,6 @@ impl ::core::default::Default for HUMPD__ { #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq)] pub struct HWND(pub isize); -impl HWND { - pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } - } -} impl ::core::default::Default for HWND { fn default() -> Self { unsafe { ::core::mem::zeroed() } @@ -4592,18 +4513,6 @@ pub const LANGUAGE_S_LARGE_WORD: ::windows::core::HRESULT = ::windows::core::HRE #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq)] pub struct LPARAM(pub isize); -impl LPARAM { - pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } - } -} impl ::core::default::Default for LPARAM { fn default() -> Self { unsafe { ::core::mem::zeroed() } @@ -4626,18 +4535,6 @@ unsafe impl ::windows::core::Abi for LPARAM { #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq)] pub struct LRESULT(pub isize); -impl LRESULT { - pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } - } -} impl ::core::default::Default for LRESULT { fn default() -> Self { unsafe { ::core::mem::zeroed() } @@ -5856,14 +5753,7 @@ pub type PROC = ::core::option::Option isize>; pub struct PSID(pub *mut ::core::ffi::c_void); impl PSID { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0.is_null() } } impl ::core::default::Default for PSID { @@ -6946,18 +6836,6 @@ pub const SEVERITY_SUCCESS: u32 = 0u32; #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq)] pub struct SHANDLE_PTR(pub isize); -impl SHANDLE_PTR { - pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } - } -} impl ::core::default::Default for SHANDLE_PTR { fn default() -> Self { unsafe { ::core::mem::zeroed() } @@ -21023,18 +20901,6 @@ pub const WINVER_MAXVER: u32 = 2560u32; #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq)] pub struct WPARAM(pub usize); -impl WPARAM { - pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } - } -} impl ::core::default::Default for WPARAM { fn default() -> Self { unsafe { ::core::mem::zeroed() } diff --git a/crates/libs/windows/src/Windows/Win32/Globalization/mod.rs b/crates/libs/windows/src/Windows/Win32/Globalization/mod.rs index 380738c7a1..3a27afef11 100644 --- a/crates/libs/windows/src/Windows/Win32/Globalization/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/Globalization/mod.rs @@ -2630,14 +2630,7 @@ pub const HIGH_SURROGATE_START: u32 = 55296u32; pub struct HIMC(pub isize); impl HIMC { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HIMC { @@ -2664,14 +2657,7 @@ unsafe impl ::windows::core::Abi for HIMC { pub struct HIMCC(pub isize); impl HIMCC { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HIMCC { @@ -2698,14 +2684,7 @@ unsafe impl ::windows::core::Abi for HIMCC { pub struct HSAVEDUILANGUAGES(pub isize); impl HSAVEDUILANGUAGES { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HSAVEDUILANGUAGES { diff --git a/crates/libs/windows/src/Windows/Win32/Graphics/Gdi/mod.rs b/crates/libs/windows/src/Windows/Win32/Graphics/Gdi/mod.rs index 8d122cee8c..6e1f4b2d29 100644 --- a/crates/libs/windows/src/Windows/Win32/Graphics/Gdi/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/Graphics/Gdi/mod.rs @@ -1717,14 +1717,15 @@ pub unsafe fn CreateDIBPatternBrushPt(lppackeddib: *const ::core::ffi::c_void, i #[doc = "*Required features: `\"Win32_Graphics_Gdi\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn CreateDIBSection<'a, Param0: ::windows::core::IntoParam<'a, HDC>, Param4: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>>(hdc: Param0, pbmi: *const BITMAPINFO, usage: DIB_USAGE, ppvbits: *mut *mut ::core::ffi::c_void, hsection: Param4, offset: u32) -> HBITMAP { +pub unsafe fn CreateDIBSection<'a, Param0: ::windows::core::IntoParam<'a, HDC>, Param4: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>>(hdc: Param0, pbmi: *const BITMAPINFO, usage: DIB_USAGE, ppvbits: *mut *mut ::core::ffi::c_void, hsection: Param4, offset: u32) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateDIBSection(hdc: HDC, pbmi: *const BITMAPINFO, usage: DIB_USAGE, ppvbits: *mut *mut ::core::ffi::c_void, hsection: super::super::Foundation::HANDLE, offset: u32) -> HBITMAP; } - ::core::mem::transmute(CreateDIBSection(hdc.into_param().abi(), ::core::mem::transmute(pbmi), ::core::mem::transmute(usage), ::core::mem::transmute(ppvbits), hsection.into_param().abi(), ::core::mem::transmute(offset))) + let result__ = CreateDIBSection(hdc.into_param().abi(), ::core::mem::transmute(pbmi), ::core::mem::transmute(usage), ::core::mem::transmute(ppvbits), hsection.into_param().abi(), ::core::mem::transmute(offset)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -2229,14 +2230,7 @@ pub unsafe fn CreateSolidBrush(color: u32) -> HBRUSH { pub struct CreatedHDC(pub isize); impl CreatedHDC { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for CreatedHDC { @@ -11765,14 +11759,7 @@ impl ::core::fmt::Debug for HATCH_BRUSH_STYLE { pub struct HBITMAP(pub isize); impl HBITMAP { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HBITMAP { @@ -11804,14 +11791,7 @@ impl<'a> ::windows::core::IntoParam<'a, HGDIOBJ> for HBITMAP { pub struct HBRUSH(pub isize); impl HBRUSH { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HBRUSH { @@ -11843,14 +11823,7 @@ impl<'a> ::windows::core::IntoParam<'a, HGDIOBJ> for HBRUSH { pub struct HDC(pub isize); impl HDC { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HDC { @@ -11918,14 +11891,7 @@ pub const HEBREW_CHARSET: u32 = 177u32; pub struct HENHMETAFILE(pub isize); impl HENHMETAFILE { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HENHMETAFILE { @@ -11952,14 +11918,7 @@ unsafe impl ::windows::core::Abi for HENHMETAFILE { pub struct HFONT(pub isize); impl HFONT { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HFONT { @@ -11991,14 +11950,7 @@ impl<'a> ::windows::core::IntoParam<'a, HGDIOBJ> for HFONT { pub struct HGDIOBJ(pub isize); impl HGDIOBJ { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HGDIOBJ { @@ -12025,14 +11977,7 @@ unsafe impl ::windows::core::Abi for HGDIOBJ { pub struct HMETAFILE(pub isize); impl HMETAFILE { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HMETAFILE { @@ -12059,14 +12004,7 @@ unsafe impl ::windows::core::Abi for HMETAFILE { pub struct HMONITOR(pub isize); impl HMONITOR { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HMONITOR { @@ -12093,14 +12031,7 @@ unsafe impl ::windows::core::Abi for HMONITOR { pub struct HPALETTE(pub isize); impl HPALETTE { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HPALETTE { @@ -12132,14 +12063,7 @@ impl<'a> ::windows::core::IntoParam<'a, HGDIOBJ> for HPALETTE { pub struct HPEN(pub isize); impl HPEN { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HPEN { @@ -12171,14 +12095,7 @@ impl<'a> ::windows::core::IntoParam<'a, HGDIOBJ> for HPEN { pub struct HRGN(pub isize); impl HRGN { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HRGN { @@ -12212,14 +12129,7 @@ pub const HS_API_MAX: u32 = 12u32; pub struct HdcMetdataEnhFileHandle(pub isize); impl HdcMetdataEnhFileHandle { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HdcMetdataEnhFileHandle { @@ -12246,14 +12156,7 @@ unsafe impl ::windows::core::Abi for HdcMetdataEnhFileHandle { pub struct HdcMetdataFileHandle(pub isize); impl HdcMetdataFileHandle { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HdcMetdataFileHandle { diff --git a/crates/libs/windows/src/Windows/Win32/Graphics/OpenGL/mod.rs b/crates/libs/windows/src/Windows/Win32/Graphics/OpenGL/mod.rs index 9df8e7dd8c..e382849b4a 100644 --- a/crates/libs/windows/src/Windows/Win32/Graphics/OpenGL/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/Graphics/OpenGL/mod.rs @@ -1577,14 +1577,7 @@ pub unsafe fn GetPixelFormat<'a, Param0: ::windows::core::IntoParam<'a, super::G pub struct HGLRC(pub isize); impl HGLRC { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HGLRC { @@ -7456,14 +7449,15 @@ pub unsafe fn wglCopyContext<'a, Param0: ::windows::core::IntoParam<'a, HGLRC>, #[doc = "*Required features: `\"Win32_Graphics_OpenGL\"`, `\"Win32_Graphics_Gdi\"`*"] #[cfg(feature = "Win32_Graphics_Gdi")] #[inline] -pub unsafe fn wglCreateContext<'a, Param0: ::windows::core::IntoParam<'a, super::Gdi::HDC>>(param0: Param0) -> HGLRC { +pub unsafe fn wglCreateContext<'a, Param0: ::windows::core::IntoParam<'a, super::Gdi::HDC>>(param0: Param0) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn wglCreateContext(param0: super::Gdi::HDC) -> HGLRC; } - ::core::mem::transmute(wglCreateContext(param0.into_param().abi())) + let result__ = wglCreateContext(param0.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -7471,14 +7465,15 @@ pub unsafe fn wglCreateContext<'a, Param0: ::windows::core::IntoParam<'a, super: #[doc = "*Required features: `\"Win32_Graphics_OpenGL\"`, `\"Win32_Graphics_Gdi\"`*"] #[cfg(feature = "Win32_Graphics_Gdi")] #[inline] -pub unsafe fn wglCreateLayerContext<'a, Param0: ::windows::core::IntoParam<'a, super::Gdi::HDC>>(param0: Param0, param1: i32) -> HGLRC { +pub unsafe fn wglCreateLayerContext<'a, Param0: ::windows::core::IntoParam<'a, super::Gdi::HDC>>(param0: Param0, param1: i32) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn wglCreateLayerContext(param0: super::Gdi::HDC, param1: i32) -> HGLRC; } - ::core::mem::transmute(wglCreateLayerContext(param0.into_param().abi(), ::core::mem::transmute(param1))) + let result__ = wglCreateLayerContext(param0.into_param().abi(), ::core::mem::transmute(param1)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); diff --git a/crates/libs/windows/src/Windows/Win32/Media/Audio/mod.rs b/crates/libs/windows/src/Windows/Win32/Media/Audio/mod.rs index f877e3d7a4..32c38bc609 100644 --- a/crates/libs/windows/src/Windows/Win32/Media/Audio/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/Media/Audio/mod.rs @@ -2581,14 +2581,7 @@ pub const FORMATCHOOSE_MESSAGE: u32 = 0u32; pub struct HACMDRIVER(pub isize); impl HACMDRIVER { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HACMDRIVER { @@ -2615,14 +2608,7 @@ unsafe impl ::windows::core::Abi for HACMDRIVER { pub struct HACMDRIVERID(pub isize); impl HACMDRIVERID { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HACMDRIVERID { @@ -2649,14 +2635,7 @@ unsafe impl ::windows::core::Abi for HACMDRIVERID { pub struct HACMOBJ(pub isize); impl HACMOBJ { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HACMOBJ { @@ -2683,14 +2662,7 @@ unsafe impl ::windows::core::Abi for HACMOBJ { pub struct HACMSTREAM(pub isize); impl HACMSTREAM { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HACMSTREAM { @@ -2717,14 +2689,7 @@ unsafe impl ::windows::core::Abi for HACMSTREAM { pub struct HMIDI(pub isize); impl HMIDI { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HMIDI { @@ -2751,14 +2716,7 @@ unsafe impl ::windows::core::Abi for HMIDI { pub struct HMIDIIN(pub isize); impl HMIDIIN { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HMIDIIN { @@ -2785,14 +2743,7 @@ unsafe impl ::windows::core::Abi for HMIDIIN { pub struct HMIDIOUT(pub isize); impl HMIDIOUT { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HMIDIOUT { @@ -2819,14 +2770,7 @@ unsafe impl ::windows::core::Abi for HMIDIOUT { pub struct HMIDISTRM(pub isize); impl HMIDISTRM { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HMIDISTRM { @@ -2853,14 +2797,7 @@ unsafe impl ::windows::core::Abi for HMIDISTRM { pub struct HMIXER(pub isize); impl HMIXER { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HMIXER { @@ -2887,14 +2824,7 @@ unsafe impl ::windows::core::Abi for HMIXER { pub struct HMIXEROBJ(pub isize); impl HMIXEROBJ { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HMIXEROBJ { @@ -2921,14 +2851,7 @@ unsafe impl ::windows::core::Abi for HMIXEROBJ { pub struct HWAVE(pub isize); impl HWAVE { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HWAVE { @@ -2955,14 +2878,7 @@ unsafe impl ::windows::core::Abi for HWAVE { pub struct HWAVEIN(pub isize); impl HWAVEIN { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HWAVEIN { @@ -2989,14 +2905,7 @@ unsafe impl ::windows::core::Abi for HWAVEIN { pub struct HWAVEOUT(pub isize); impl HWAVEOUT { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HWAVEOUT { diff --git a/crates/libs/windows/src/Windows/Win32/Media/Multimedia/mod.rs b/crates/libs/windows/src/Windows/Win32/Media/Multimedia/mod.rs index 8e0f4afa72..6bc5722b02 100644 --- a/crates/libs/windows/src/Windows/Win32/Media/Multimedia/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/Media/Multimedia/mod.rs @@ -3238,14 +3238,7 @@ pub unsafe fn GetSaveFileNamePreviewW(lpofn: *mut super::super::UI::Controls::Di pub struct HDRVR(pub isize); impl HDRVR { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HDRVR { @@ -3272,14 +3265,7 @@ unsafe impl ::windows::core::Abi for HDRVR { pub struct HIC(pub isize); impl HIC { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HIC { @@ -3306,14 +3292,7 @@ unsafe impl ::windows::core::Abi for HIC { pub struct HMMIO(pub isize); impl HMMIO { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HMMIO { @@ -3340,14 +3319,7 @@ unsafe impl ::windows::core::Abi for HMMIO { pub struct HVIDEO(pub isize); impl HVIDEO { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HVIDEO { diff --git a/crates/libs/windows/src/Windows/Win32/Media/mod.rs b/crates/libs/windows/src/Windows/Win32/Media/mod.rs index 242e517cc2..e13f784a42 100644 --- a/crates/libs/windows/src/Windows/Win32/Media/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/Media/mod.rs @@ -30,14 +30,7 @@ pub mod WindowsMediaFormat; pub struct HTASK(pub isize); impl HTASK { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HTASK { diff --git a/crates/libs/windows/src/Windows/Win32/NetworkManagement/Dns/mod.rs b/crates/libs/windows/src/Windows/Win32/NetworkManagement/Dns/mod.rs index 35b313e3c6..864fcefa06 100644 --- a/crates/libs/windows/src/Windows/Win32/NetworkManagement/Dns/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/NetworkManagement/Dns/mod.rs @@ -4318,14 +4318,7 @@ pub unsafe fn DnsConnectionUpdateIfIndexTable(pconnectionifindexentries: *const pub struct DnsContextHandle(pub isize); impl DnsContextHandle { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for DnsContextHandle { diff --git a/crates/libs/windows/src/Windows/Win32/NetworkManagement/IpHelper/mod.rs b/crates/libs/windows/src/Windows/Win32/NetworkManagement/IpHelper/mod.rs index abed6cc534..5db7f24607 100644 --- a/crates/libs/windows/src/Windows/Win32/NetworkManagement/IpHelper/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/NetworkManagement/IpHelper/mod.rs @@ -2400,14 +2400,7 @@ pub unsafe fn GetUnicastIpAddressTable(family: u16, table: *mut *mut MIB_UNICAST pub struct HIFTIMESTAMPCHANGE(pub isize); impl HIFTIMESTAMPCHANGE { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HIFTIMESTAMPCHANGE { @@ -5189,14 +5182,15 @@ pub const IP_UNLOAD: u32 = 11022u32; pub const IP_UNRECOGNIZED_NEXT_HEADER: u32 = 11043u32; #[doc = "*Required features: `\"Win32_NetworkManagement_IpHelper\"`*"] #[inline] -pub unsafe fn Icmp6CreateFile() -> IcmpHandle { +pub unsafe fn Icmp6CreateFile() -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn Icmp6CreateFile() -> IcmpHandle; } - ::core::mem::transmute(Icmp6CreateFile()) + let result__ = Icmp6CreateFile(); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -5247,14 +5241,15 @@ pub unsafe fn IcmpCloseHandle<'a, Param0: ::windows::core::IntoParam<'a, IcmpHan } #[doc = "*Required features: `\"Win32_NetworkManagement_IpHelper\"`*"] #[inline] -pub unsafe fn IcmpCreateFile() -> IcmpHandle { +pub unsafe fn IcmpCreateFile() -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn IcmpCreateFile() -> IcmpHandle; } - ::core::mem::transmute(IcmpCreateFile()) + let result__ = IcmpCreateFile(); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -5264,14 +5259,7 @@ pub unsafe fn IcmpCreateFile() -> IcmpHandle { pub struct IcmpHandle(pub isize); impl IcmpHandle { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for IcmpHandle { diff --git a/crates/libs/windows/src/Windows/Win32/NetworkManagement/QoS/mod.rs b/crates/libs/windows/src/Windows/Win32/NetworkManagement/QoS/mod.rs index 4f7126f0ed..1f6422efec 100644 --- a/crates/libs/windows/src/Windows/Win32/NetworkManagement/QoS/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/NetworkManagement/QoS/mod.rs @@ -1599,14 +1599,7 @@ pub const LPM_API_VERSION_1: u32 = 1u32; pub struct LPM_HANDLE(pub isize); impl LPM_HANDLE { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for LPM_HANDLE { @@ -2986,14 +2979,7 @@ impl ::core::default::Default for RESV_STYLE { pub struct RHANDLE(pub isize); impl RHANDLE { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for RHANDLE { diff --git a/crates/libs/windows/src/Windows/Win32/NetworkManagement/Rras/mod.rs b/crates/libs/windows/src/Windows/Win32/NetworkManagement/Rras/mod.rs index 2efd458408..fb39dc9787 100644 --- a/crates/libs/windows/src/Windows/Win32/NetworkManagement/Rras/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/NetworkManagement/Rras/mod.rs @@ -644,14 +644,7 @@ impl ::core::default::Default for GRE_CONFIG_PARAMS0 { pub struct HRASCONN(pub isize); impl HRASCONN { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HRASCONN { diff --git a/crates/libs/windows/src/Windows/Win32/NetworkManagement/WNet/mod.rs b/crates/libs/windows/src/Windows/Win32/NetworkManagement/WNet/mod.rs index 9971b1470d..ac568d194d 100644 --- a/crates/libs/windows/src/Windows/Win32/NetworkManagement/WNet/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/NetworkManagement/WNet/mod.rs @@ -1168,14 +1168,7 @@ impl ::core::fmt::Debug for NP_PROPERTY_DIALOG_SELECTION { pub struct NetEnumHandle(pub isize); impl NetEnumHandle { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for NetEnumHandle { diff --git a/crates/libs/windows/src/Windows/Win32/Networking/ActiveDirectory/mod.rs b/crates/libs/windows/src/Windows/Win32/Networking/ActiveDirectory/mod.rs index f439bcb0b0..46f44f7175 100644 --- a/crates/libs/windows/src/Windows/Win32/Networking/ActiveDirectory/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/Networking/ActiveDirectory/mod.rs @@ -9162,14 +9162,7 @@ pub const GUID_USERS_CONTAINER_W: &'static str = "a9d1ca15768811d1aded00c04fd8d5 pub struct GetDcContextHandle(pub isize); impl GetDcContextHandle { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for GetDcContextHandle { diff --git a/crates/libs/windows/src/Windows/Win32/Networking/Clustering/mod.rs b/crates/libs/windows/src/Windows/Win32/Networking/Clustering/mod.rs index 88a9da53df..d228fe66a8 100644 --- a/crates/libs/windows/src/Windows/Win32/Networking/Clustering/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/Networking/Clustering/mod.rs @@ -11138,14 +11138,15 @@ pub unsafe fn GetClusterFromResource(hresource: *const _HRESOURCE) -> *mut _HCLU #[doc = "*Required features: `\"Win32_Networking_Clustering\"`, `\"Win32_System_Registry\"`*"] #[cfg(feature = "Win32_System_Registry")] #[inline] -pub unsafe fn GetClusterGroupKey(hgroup: *const _HGROUP, samdesired: u32) -> super::super::System::Registry::HKEY { +pub unsafe fn GetClusterGroupKey(hgroup: *const _HGROUP, samdesired: u32) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn GetClusterGroupKey(hgroup: *const _HGROUP, samdesired: u32) -> super::super::System::Registry::HKEY; } - ::core::mem::transmute(GetClusterGroupKey(::core::mem::transmute(hgroup), ::core::mem::transmute(samdesired))) + let result__ = GetClusterGroupKey(::core::mem::transmute(hgroup), ::core::mem::transmute(samdesired)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -11181,14 +11182,15 @@ pub unsafe fn GetClusterInformation(hcluster: *const _HCLUSTER, lpszclustername: #[doc = "*Required features: `\"Win32_Networking_Clustering\"`, `\"Win32_System_Registry\"`*"] #[cfg(feature = "Win32_System_Registry")] #[inline] -pub unsafe fn GetClusterKey(hcluster: *const _HCLUSTER, samdesired: u32) -> super::super::System::Registry::HKEY { +pub unsafe fn GetClusterKey(hcluster: *const _HCLUSTER, samdesired: u32) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn GetClusterKey(hcluster: *const _HCLUSTER, samdesired: u32) -> super::super::System::Registry::HKEY; } - ::core::mem::transmute(GetClusterKey(::core::mem::transmute(hcluster), ::core::mem::transmute(samdesired))) + let result__ = GetClusterKey(::core::mem::transmute(hcluster), ::core::mem::transmute(samdesired)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -11210,14 +11212,15 @@ pub unsafe fn GetClusterNetInterface<'a, Param1: ::windows::core::IntoParam<'a, #[doc = "*Required features: `\"Win32_Networking_Clustering\"`, `\"Win32_System_Registry\"`*"] #[cfg(feature = "Win32_System_Registry")] #[inline] -pub unsafe fn GetClusterNetInterfaceKey(hnetinterface: *const _HNETINTERFACE, samdesired: u32) -> super::super::System::Registry::HKEY { +pub unsafe fn GetClusterNetInterfaceKey(hnetinterface: *const _HNETINTERFACE, samdesired: u32) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn GetClusterNetInterfaceKey(hnetinterface: *const _HNETINTERFACE, samdesired: u32) -> super::super::System::Registry::HKEY; } - ::core::mem::transmute(GetClusterNetInterfaceKey(::core::mem::transmute(hnetinterface), ::core::mem::transmute(samdesired))) + let result__ = GetClusterNetInterfaceKey(::core::mem::transmute(hnetinterface), ::core::mem::transmute(samdesired)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -11253,14 +11256,15 @@ pub unsafe fn GetClusterNetworkId(hnetwork: *const _HNETWORK, lpsznetworkid: ::w #[doc = "*Required features: `\"Win32_Networking_Clustering\"`, `\"Win32_System_Registry\"`*"] #[cfg(feature = "Win32_System_Registry")] #[inline] -pub unsafe fn GetClusterNetworkKey(hnetwork: *const _HNETWORK, samdesired: u32) -> super::super::System::Registry::HKEY { +pub unsafe fn GetClusterNetworkKey(hnetwork: *const _HNETWORK, samdesired: u32) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn GetClusterNetworkKey(hnetwork: *const _HNETWORK, samdesired: u32) -> super::super::System::Registry::HKEY; } - ::core::mem::transmute(GetClusterNetworkKey(::core::mem::transmute(hnetwork), ::core::mem::transmute(samdesired))) + let result__ = GetClusterNetworkKey(::core::mem::transmute(hnetwork), ::core::mem::transmute(samdesired)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -11296,14 +11300,15 @@ pub unsafe fn GetClusterNodeId(hnode: *const _HNODE, lpsznodeid: ::windows::core #[doc = "*Required features: `\"Win32_Networking_Clustering\"`, `\"Win32_System_Registry\"`*"] #[cfg(feature = "Win32_System_Registry")] #[inline] -pub unsafe fn GetClusterNodeKey(hnode: *const _HNODE, samdesired: u32) -> super::super::System::Registry::HKEY { +pub unsafe fn GetClusterNodeKey(hnode: *const _HNODE, samdesired: u32) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn GetClusterNodeKey(hnode: *const _HNODE, samdesired: u32) -> super::super::System::Registry::HKEY; } - ::core::mem::transmute(GetClusterNodeKey(::core::mem::transmute(hnode), ::core::mem::transmute(samdesired))) + let result__ = GetClusterNodeKey(::core::mem::transmute(hnode), ::core::mem::transmute(samdesired)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -11396,14 +11401,15 @@ pub unsafe fn GetClusterResourceDependencyExpression(hresource: *const _HRESOURC #[doc = "*Required features: `\"Win32_Networking_Clustering\"`, `\"Win32_System_Registry\"`*"] #[cfg(feature = "Win32_System_Registry")] #[inline] -pub unsafe fn GetClusterResourceKey(hresource: *const _HRESOURCE, samdesired: u32) -> super::super::System::Registry::HKEY { +pub unsafe fn GetClusterResourceKey(hresource: *const _HRESOURCE, samdesired: u32) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn GetClusterResourceKey(hresource: *const _HRESOURCE, samdesired: u32) -> super::super::System::Registry::HKEY; } - ::core::mem::transmute(GetClusterResourceKey(::core::mem::transmute(hresource), ::core::mem::transmute(samdesired))) + let result__ = GetClusterResourceKey(::core::mem::transmute(hresource), ::core::mem::transmute(samdesired)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -11440,14 +11446,15 @@ pub unsafe fn GetClusterResourceState(hresource: *const _HRESOURCE, lpsznodename #[doc = "*Required features: `\"Win32_Networking_Clustering\"`, `\"Win32_System_Registry\"`*"] #[cfg(feature = "Win32_System_Registry")] #[inline] -pub unsafe fn GetClusterResourceTypeKey<'a, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(hcluster: *const _HCLUSTER, lpsztypename: Param1, samdesired: u32) -> super::super::System::Registry::HKEY { +pub unsafe fn GetClusterResourceTypeKey<'a, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(hcluster: *const _HCLUSTER, lpsztypename: Param1, samdesired: u32) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn GetClusterResourceTypeKey(hcluster: *const _HCLUSTER, lpsztypename: ::windows::core::PCWSTR, samdesired: u32) -> super::super::System::Registry::HKEY; } - ::core::mem::transmute(GetClusterResourceTypeKey(::core::mem::transmute(hcluster), lpsztypename.into_param().abi(), ::core::mem::transmute(samdesired))) + let result__ = GetClusterResourceTypeKey(::core::mem::transmute(hcluster), lpsztypename.into_param().abi(), ::core::mem::transmute(samdesired)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); diff --git a/crates/libs/windows/src/Windows/Win32/Networking/WebSocket/mod.rs b/crates/libs/windows/src/Windows/Win32/Networking/WebSocket/mod.rs index 2615063274..27d6b4bf7f 100644 --- a/crates/libs/windows/src/Windows/Win32/Networking/WebSocket/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/Networking/WebSocket/mod.rs @@ -239,14 +239,7 @@ impl ::core::fmt::Debug for WEB_SOCKET_CLOSE_STATUS { pub struct WEB_SOCKET_HANDLE(pub isize); impl WEB_SOCKET_HANDLE { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for WEB_SOCKET_HANDLE { diff --git a/crates/libs/windows/src/Windows/Win32/Networking/WinInet/mod.rs b/crates/libs/windows/src/Windows/Win32/Networking/WinInet/mod.rs index a845039da6..f90cdf5ea1 100644 --- a/crates/libs/windows/src/Windows/Win32/Networking/WinInet/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/Networking/WinInet/mod.rs @@ -1669,14 +1669,15 @@ pub unsafe fn FindFirstUrlCacheContainerW(pdwmodified: *mut u32, lpcontainerinfo #[doc = "*Required features: `\"Win32_Networking_WinInet\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn FindFirstUrlCacheEntryA<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(lpszurlsearchpattern: Param0, lpfirstcacheentryinfo: *mut INTERNET_CACHE_ENTRY_INFOA, lpcbcacheentryinfo: *mut u32) -> super::super::Foundation::HANDLE { +pub unsafe fn FindFirstUrlCacheEntryA<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(lpszurlsearchpattern: Param0, lpfirstcacheentryinfo: *mut INTERNET_CACHE_ENTRY_INFOA, lpcbcacheentryinfo: *mut u32) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn FindFirstUrlCacheEntryA(lpszurlsearchpattern: ::windows::core::PCSTR, lpfirstcacheentryinfo: *mut INTERNET_CACHE_ENTRY_INFOA, lpcbcacheentryinfo: *mut u32) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(FindFirstUrlCacheEntryA(lpszurlsearchpattern.into_param().abi(), ::core::mem::transmute(lpfirstcacheentryinfo), ::core::mem::transmute(lpcbcacheentryinfo))) + let result__ = FindFirstUrlCacheEntryA(lpszurlsearchpattern.into_param().abi(), ::core::mem::transmute(lpfirstcacheentryinfo), ::core::mem::transmute(lpcbcacheentryinfo)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -1684,14 +1685,15 @@ pub unsafe fn FindFirstUrlCacheEntryA<'a, Param0: ::windows::core::IntoParam<'a, #[doc = "*Required features: `\"Win32_Networking_WinInet\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn FindFirstUrlCacheEntryExA<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(lpszurlsearchpattern: Param0, dwflags: u32, dwfilter: u32, groupid: i64, lpfirstcacheentryinfo: *mut INTERNET_CACHE_ENTRY_INFOA, lpcbcacheentryinfo: *mut u32, lpgroupattributes: *mut ::core::ffi::c_void, lpcbgroupattributes: *mut u32, lpreserved: *mut ::core::ffi::c_void) -> super::super::Foundation::HANDLE { +pub unsafe fn FindFirstUrlCacheEntryExA<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(lpszurlsearchpattern: Param0, dwflags: u32, dwfilter: u32, groupid: i64, lpfirstcacheentryinfo: *mut INTERNET_CACHE_ENTRY_INFOA, lpcbcacheentryinfo: *mut u32, lpgroupattributes: *mut ::core::ffi::c_void, lpcbgroupattributes: *mut u32, lpreserved: *mut ::core::ffi::c_void) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn FindFirstUrlCacheEntryExA(lpszurlsearchpattern: ::windows::core::PCSTR, dwflags: u32, dwfilter: u32, groupid: i64, lpfirstcacheentryinfo: *mut INTERNET_CACHE_ENTRY_INFOA, lpcbcacheentryinfo: *mut u32, lpgroupattributes: *mut ::core::ffi::c_void, lpcbgroupattributes: *mut u32, lpreserved: *mut ::core::ffi::c_void) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(FindFirstUrlCacheEntryExA(lpszurlsearchpattern.into_param().abi(), ::core::mem::transmute(dwflags), ::core::mem::transmute(dwfilter), ::core::mem::transmute(groupid), ::core::mem::transmute(lpfirstcacheentryinfo), ::core::mem::transmute(lpcbcacheentryinfo), ::core::mem::transmute(lpgroupattributes), ::core::mem::transmute(lpcbgroupattributes), ::core::mem::transmute(lpreserved))) + let result__ = FindFirstUrlCacheEntryExA(lpszurlsearchpattern.into_param().abi(), ::core::mem::transmute(dwflags), ::core::mem::transmute(dwfilter), ::core::mem::transmute(groupid), ::core::mem::transmute(lpfirstcacheentryinfo), ::core::mem::transmute(lpcbcacheentryinfo), ::core::mem::transmute(lpgroupattributes), ::core::mem::transmute(lpcbgroupattributes), ::core::mem::transmute(lpreserved)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -1699,14 +1701,15 @@ pub unsafe fn FindFirstUrlCacheEntryExA<'a, Param0: ::windows::core::IntoParam<' #[doc = "*Required features: `\"Win32_Networking_WinInet\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn FindFirstUrlCacheEntryExW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(lpszurlsearchpattern: Param0, dwflags: u32, dwfilter: u32, groupid: i64, lpfirstcacheentryinfo: *mut INTERNET_CACHE_ENTRY_INFOW, lpcbcacheentryinfo: *mut u32, lpgroupattributes: *mut ::core::ffi::c_void, lpcbgroupattributes: *mut u32, lpreserved: *mut ::core::ffi::c_void) -> super::super::Foundation::HANDLE { +pub unsafe fn FindFirstUrlCacheEntryExW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(lpszurlsearchpattern: Param0, dwflags: u32, dwfilter: u32, groupid: i64, lpfirstcacheentryinfo: *mut INTERNET_CACHE_ENTRY_INFOW, lpcbcacheentryinfo: *mut u32, lpgroupattributes: *mut ::core::ffi::c_void, lpcbgroupattributes: *mut u32, lpreserved: *mut ::core::ffi::c_void) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn FindFirstUrlCacheEntryExW(lpszurlsearchpattern: ::windows::core::PCWSTR, dwflags: u32, dwfilter: u32, groupid: i64, lpfirstcacheentryinfo: *mut INTERNET_CACHE_ENTRY_INFOW, lpcbcacheentryinfo: *mut u32, lpgroupattributes: *mut ::core::ffi::c_void, lpcbgroupattributes: *mut u32, lpreserved: *mut ::core::ffi::c_void) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(FindFirstUrlCacheEntryExW(lpszurlsearchpattern.into_param().abi(), ::core::mem::transmute(dwflags), ::core::mem::transmute(dwfilter), ::core::mem::transmute(groupid), ::core::mem::transmute(lpfirstcacheentryinfo), ::core::mem::transmute(lpcbcacheentryinfo), ::core::mem::transmute(lpgroupattributes), ::core::mem::transmute(lpcbgroupattributes), ::core::mem::transmute(lpreserved))) + let result__ = FindFirstUrlCacheEntryExW(lpszurlsearchpattern.into_param().abi(), ::core::mem::transmute(dwflags), ::core::mem::transmute(dwfilter), ::core::mem::transmute(groupid), ::core::mem::transmute(lpfirstcacheentryinfo), ::core::mem::transmute(lpcbcacheentryinfo), ::core::mem::transmute(lpgroupattributes), ::core::mem::transmute(lpcbgroupattributes), ::core::mem::transmute(lpreserved)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -1714,14 +1717,15 @@ pub unsafe fn FindFirstUrlCacheEntryExW<'a, Param0: ::windows::core::IntoParam<' #[doc = "*Required features: `\"Win32_Networking_WinInet\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn FindFirstUrlCacheEntryW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(lpszurlsearchpattern: Param0, lpfirstcacheentryinfo: *mut INTERNET_CACHE_ENTRY_INFOW, lpcbcacheentryinfo: *mut u32) -> super::super::Foundation::HANDLE { +pub unsafe fn FindFirstUrlCacheEntryW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(lpszurlsearchpattern: Param0, lpfirstcacheentryinfo: *mut INTERNET_CACHE_ENTRY_INFOW, lpcbcacheentryinfo: *mut u32) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn FindFirstUrlCacheEntryW(lpszurlsearchpattern: ::windows::core::PCWSTR, lpfirstcacheentryinfo: *mut INTERNET_CACHE_ENTRY_INFOW, lpcbcacheentryinfo: *mut u32) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(FindFirstUrlCacheEntryW(lpszurlsearchpattern.into_param().abi(), ::core::mem::transmute(lpfirstcacheentryinfo), ::core::mem::transmute(lpcbcacheentryinfo))) + let result__ = FindFirstUrlCacheEntryW(lpszurlsearchpattern.into_param().abi(), ::core::mem::transmute(lpfirstcacheentryinfo), ::core::mem::transmute(lpcbcacheentryinfo)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -1729,14 +1733,15 @@ pub unsafe fn FindFirstUrlCacheEntryW<'a, Param0: ::windows::core::IntoParam<'a, #[doc = "*Required features: `\"Win32_Networking_WinInet\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn FindFirstUrlCacheGroup(dwflags: u32, dwfilter: u32, lpsearchcondition: *mut ::core::ffi::c_void, dwsearchcondition: u32, lpgroupid: *mut i64, lpreserved: *mut ::core::ffi::c_void) -> super::super::Foundation::HANDLE { +pub unsafe fn FindFirstUrlCacheGroup(dwflags: u32, dwfilter: u32, lpsearchcondition: *mut ::core::ffi::c_void, dwsearchcondition: u32, lpgroupid: *mut i64, lpreserved: *mut ::core::ffi::c_void) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn FindFirstUrlCacheGroup(dwflags: u32, dwfilter: u32, lpsearchcondition: *mut ::core::ffi::c_void, dwsearchcondition: u32, lpgroupid: *mut i64, lpreserved: *mut ::core::ffi::c_void) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(FindFirstUrlCacheGroup(::core::mem::transmute(dwflags), ::core::mem::transmute(dwfilter), ::core::mem::transmute(lpsearchcondition), ::core::mem::transmute(dwsearchcondition), ::core::mem::transmute(lpgroupid), ::core::mem::transmute(lpreserved))) + let result__ = FindFirstUrlCacheGroup(::core::mem::transmute(dwflags), ::core::mem::transmute(dwfilter), ::core::mem::transmute(lpsearchcondition), ::core::mem::transmute(dwsearchcondition), ::core::mem::transmute(lpgroupid), ::core::mem::transmute(lpreserved)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -3686,14 +3691,7 @@ impl ::core::default::Default for HTTP_PUSH_TRANSPORT_SETTING { pub struct HTTP_PUSH_WAIT_HANDLE(pub isize); impl HTTP_PUSH_WAIT_HANDLE { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HTTP_PUSH_WAIT_HANDLE { @@ -9839,14 +9837,15 @@ pub unsafe fn RetrieveUrlCacheEntryFileW<'a, Param0: ::windows::core::IntoParam< #[doc = "*Required features: `\"Win32_Networking_WinInet\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn RetrieveUrlCacheEntryStreamA<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>, Param3: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>>(lpszurlname: Param0, lpcacheentryinfo: *mut INTERNET_CACHE_ENTRY_INFOA, lpcbcacheentryinfo: *mut u32, frandomread: Param3, dwreserved: u32) -> super::super::Foundation::HANDLE { +pub unsafe fn RetrieveUrlCacheEntryStreamA<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>, Param3: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>>(lpszurlname: Param0, lpcacheentryinfo: *mut INTERNET_CACHE_ENTRY_INFOA, lpcbcacheentryinfo: *mut u32, frandomread: Param3, dwreserved: u32) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn RetrieveUrlCacheEntryStreamA(lpszurlname: ::windows::core::PCSTR, lpcacheentryinfo: *mut INTERNET_CACHE_ENTRY_INFOA, lpcbcacheentryinfo: *mut u32, frandomread: super::super::Foundation::BOOL, dwreserved: u32) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(RetrieveUrlCacheEntryStreamA(lpszurlname.into_param().abi(), ::core::mem::transmute(lpcacheentryinfo), ::core::mem::transmute(lpcbcacheentryinfo), frandomread.into_param().abi(), ::core::mem::transmute(dwreserved))) + let result__ = RetrieveUrlCacheEntryStreamA(lpszurlname.into_param().abi(), ::core::mem::transmute(lpcacheentryinfo), ::core::mem::transmute(lpcbcacheentryinfo), frandomread.into_param().abi(), ::core::mem::transmute(dwreserved)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -9854,14 +9853,15 @@ pub unsafe fn RetrieveUrlCacheEntryStreamA<'a, Param0: ::windows::core::IntoPara #[doc = "*Required features: `\"Win32_Networking_WinInet\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn RetrieveUrlCacheEntryStreamW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>, Param3: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>>(lpszurlname: Param0, lpcacheentryinfo: *mut INTERNET_CACHE_ENTRY_INFOW, lpcbcacheentryinfo: *mut u32, frandomread: Param3, dwreserved: u32) -> super::super::Foundation::HANDLE { +pub unsafe fn RetrieveUrlCacheEntryStreamW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>, Param3: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>>(lpszurlname: Param0, lpcacheentryinfo: *mut INTERNET_CACHE_ENTRY_INFOW, lpcbcacheentryinfo: *mut u32, frandomread: Param3, dwreserved: u32) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn RetrieveUrlCacheEntryStreamW(lpszurlname: ::windows::core::PCWSTR, lpcacheentryinfo: *mut INTERNET_CACHE_ENTRY_INFOW, lpcbcacheentryinfo: *mut u32, frandomread: super::super::Foundation::BOOL, dwreserved: u32) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(RetrieveUrlCacheEntryStreamW(lpszurlname.into_param().abi(), ::core::mem::transmute(lpcacheentryinfo), ::core::mem::transmute(lpcbcacheentryinfo), frandomread.into_param().abi(), ::core::mem::transmute(dwreserved))) + let result__ = RetrieveUrlCacheEntryStreamW(lpszurlname.into_param().abi(), ::core::mem::transmute(lpcacheentryinfo), ::core::mem::transmute(lpcbcacheentryinfo), frandomread.into_param().abi(), ::core::mem::transmute(dwreserved)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); diff --git a/crates/libs/windows/src/Windows/Win32/Networking/WinSock/mod.rs b/crates/libs/windows/src/Windows/Win32/Networking/WinSock/mod.rs index f3b45a8b6a..13d1be045b 100644 --- a/crates/libs/windows/src/Windows/Win32/Networking/WinSock/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/Networking/WinSock/mod.rs @@ -1698,14 +1698,7 @@ pub unsafe fn GetTypeByNameW<'a, Param0: ::windows::core::IntoParam<'a, ::window pub struct HWSAEVENT(pub isize); impl HWSAEVENT { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HWSAEVENT { @@ -8024,18 +8017,6 @@ impl ::core::default::Default for SOCKADDR_STORAGE_XP { #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq)] pub struct SOCKET(pub usize); -impl SOCKET { - pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } - } -} impl ::core::default::Default for SOCKET { fn default() -> Self { unsafe { ::core::mem::zeroed() } diff --git a/crates/libs/windows/src/Windows/Win32/Security/Authentication/Identity/mod.rs b/crates/libs/windows/src/Windows/Win32/Security/Authentication/Identity/mod.rs index 0addfed3d7..de81ae8755 100644 --- a/crates/libs/windows/src/Windows/Win32/Security/Authentication/Identity/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/Security/Authentication/Identity/mod.rs @@ -6813,14 +6813,7 @@ pub unsafe fn LsaGetLogonSessionData(logonid: *const super::super::super::Founda pub struct LsaHandle(pub isize); impl LsaHandle { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for LsaHandle { diff --git a/crates/libs/windows/src/Windows/Win32/Security/Authorization/UI/mod.rs b/crates/libs/windows/src/Windows/Win32/Security/Authorization/UI/mod.rs index d6032e4ce9..57c281078a 100644 --- a/crates/libs/windows/src/Windows/Win32/Security/Authorization/UI/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/Security/Authorization/UI/mod.rs @@ -4,14 +4,15 @@ pub const CFSTR_ACLUI_SID_INFO_LIST: &'static str = "CFSTR_ACLUI_SID_INFO_LIST"; #[doc = "*Required features: `\"Win32_Security_Authorization_UI\"`, `\"Win32_UI_Controls\"`*"] #[cfg(feature = "Win32_UI_Controls")] #[inline] -pub unsafe fn CreateSecurityPage<'a, Param0: ::windows::core::IntoParam<'a, ISecurityInformation>>(psi: Param0) -> super::super::super::UI::Controls::HPROPSHEETPAGE { +pub unsafe fn CreateSecurityPage<'a, Param0: ::windows::core::IntoParam<'a, ISecurityInformation>>(psi: Param0) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateSecurityPage(psi: ::windows::core::RawPtr) -> super::super::super::UI::Controls::HPROPSHEETPAGE; } - ::core::mem::transmute(CreateSecurityPage(psi.into_param().abi())) + let result__ = CreateSecurityPage(psi.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); diff --git a/crates/libs/windows/src/Windows/Win32/Security/Authorization/mod.rs b/crates/libs/windows/src/Windows/Win32/Security/Authorization/mod.rs index 494a5e5be4..c5185baddc 100644 --- a/crates/libs/windows/src/Windows/Win32/Security/Authorization/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/Security/Authorization/mod.rs @@ -1014,14 +1014,7 @@ impl ::core::fmt::Debug for AUTHZ_ACCESS_CHECK_FLAGS { pub struct AUTHZ_ACCESS_CHECK_RESULTS_HANDLE(pub isize); impl AUTHZ_ACCESS_CHECK_RESULTS_HANDLE { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for AUTHZ_ACCESS_CHECK_RESULTS_HANDLE { @@ -1125,14 +1118,7 @@ pub const AUTHZ_ALLOW_MULTIPLE_SOURCE_INSTANCES: u32 = 1u32; pub struct AUTHZ_AUDIT_EVENT_HANDLE(pub isize); impl AUTHZ_AUDIT_EVENT_HANDLE { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for AUTHZ_AUDIT_EVENT_HANDLE { @@ -1192,14 +1178,7 @@ impl ::core::fmt::Debug for AUTHZ_AUDIT_EVENT_INFORMATION_CLASS { pub struct AUTHZ_AUDIT_EVENT_TYPE_HANDLE(pub isize); impl AUTHZ_AUDIT_EVENT_TYPE_HANDLE { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for AUTHZ_AUDIT_EVENT_TYPE_HANDLE { @@ -1352,14 +1331,7 @@ impl ::core::default::Default for AUTHZ_CAP_CHANGE_SUBSCRIPTION_HANDLE__ { pub struct AUTHZ_CLIENT_CONTEXT_HANDLE(pub isize); impl AUTHZ_CLIENT_CONTEXT_HANDLE { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for AUTHZ_CLIENT_CONTEXT_HANDLE { @@ -1647,14 +1619,7 @@ impl ::core::ops::Not for AUTHZ_RESOURCE_MANAGER_FLAGS { pub struct AUTHZ_RESOURCE_MANAGER_HANDLE(pub isize); impl AUTHZ_RESOURCE_MANAGER_HANDLE { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for AUTHZ_RESOURCE_MANAGER_HANDLE { @@ -2001,14 +1966,7 @@ impl ::core::default::Default for AUTHZ_SECURITY_ATTRIBUTE_V1_0 { pub struct AUTHZ_SECURITY_EVENT_PROVIDER_HANDLE(pub isize); impl AUTHZ_SECURITY_EVENT_PROVIDER_HANDLE { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for AUTHZ_SECURITY_EVENT_PROVIDER_HANDLE { diff --git a/crates/libs/windows/src/Windows/Win32/Security/Credentials/mod.rs b/crates/libs/windows/src/Windows/Win32/Security/Credentials/mod.rs index 87a003fafc..a3a407b832 100644 --- a/crates/libs/windows/src/Windows/Win32/Security/Credentials/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/Security/Credentials/mod.rs @@ -3171,14 +3171,15 @@ pub const SC_DLG_NO_UI: u32 = 2u32; #[doc = "*Required features: `\"Win32_Security_Credentials\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn SCardAccessStartedEvent() -> super::super::Foundation::HANDLE { +pub unsafe fn SCardAccessStartedEvent() -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn SCardAccessStartedEvent() -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(SCardAccessStartedEvent()) + let result__ = SCardAccessStartedEvent(); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); diff --git a/crates/libs/windows/src/Windows/Win32/Security/Cryptography/mod.rs b/crates/libs/windows/src/Windows/Win32/Security/Cryptography/mod.rs index 4eb9fe4e8c..a068ecc9e6 100644 --- a/crates/libs/windows/src/Windows/Win32/Security/Cryptography/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/Security/Cryptography/mod.rs @@ -367,14 +367,7 @@ pub const BCRYPT_ALGORITHM_NAME: &'static str = "AlgorithmName"; pub struct BCRYPT_ALG_HANDLE(pub isize); impl BCRYPT_ALG_HANDLE { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == 0 } } impl ::core::default::Default for BCRYPT_ALG_HANDLE { @@ -1306,14 +1299,7 @@ pub const BCRYPT_KEY_DERIVATION_OPERATION: u32 = 64u32; pub struct BCRYPT_KEY_HANDLE(pub isize); impl BCRYPT_KEY_HANDLE { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == 0 } } impl ::core::default::Default for BCRYPT_KEY_HANDLE { @@ -20062,42 +20048,45 @@ pub unsafe fn CertOpenServerOcspResponse(pchaincontext: *const CERT_CHAIN_CONTEX } #[doc = "*Required features: `\"Win32_Security_Cryptography\"`*"] #[inline] -pub unsafe fn CertOpenStore<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>, Param2: ::windows::core::IntoParam<'a, HCRYPTPROV_LEGACY>>(lpszstoreprovider: Param0, dwencodingtype: CERT_QUERY_ENCODING_TYPE, hcryptprov: Param2, dwflags: CERT_OPEN_STORE_FLAGS, pvpara: *const ::core::ffi::c_void) -> HCERTSTORE { +pub unsafe fn CertOpenStore<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>, Param2: ::windows::core::IntoParam<'a, HCRYPTPROV_LEGACY>>(lpszstoreprovider: Param0, dwencodingtype: CERT_QUERY_ENCODING_TYPE, hcryptprov: Param2, dwflags: CERT_OPEN_STORE_FLAGS, pvpara: *const ::core::ffi::c_void) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CertOpenStore(lpszstoreprovider: ::windows::core::PCSTR, dwencodingtype: CERT_QUERY_ENCODING_TYPE, hcryptprov: HCRYPTPROV_LEGACY, dwflags: CERT_OPEN_STORE_FLAGS, pvpara: *const ::core::ffi::c_void) -> HCERTSTORE; } - ::core::mem::transmute(CertOpenStore(lpszstoreprovider.into_param().abi(), ::core::mem::transmute(dwencodingtype), hcryptprov.into_param().abi(), ::core::mem::transmute(dwflags), ::core::mem::transmute(pvpara))) + let result__ = CertOpenStore(lpszstoreprovider.into_param().abi(), ::core::mem::transmute(dwencodingtype), hcryptprov.into_param().abi(), ::core::mem::transmute(dwflags), ::core::mem::transmute(pvpara)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); } #[doc = "*Required features: `\"Win32_Security_Cryptography\"`*"] #[inline] -pub unsafe fn CertOpenSystemStoreA<'a, Param0: ::windows::core::IntoParam<'a, HCRYPTPROV_LEGACY>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(hprov: Param0, szsubsystemprotocol: Param1) -> HCERTSTORE { +pub unsafe fn CertOpenSystemStoreA<'a, Param0: ::windows::core::IntoParam<'a, HCRYPTPROV_LEGACY>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(hprov: Param0, szsubsystemprotocol: Param1) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CertOpenSystemStoreA(hprov: HCRYPTPROV_LEGACY, szsubsystemprotocol: ::windows::core::PCSTR) -> HCERTSTORE; } - ::core::mem::transmute(CertOpenSystemStoreA(hprov.into_param().abi(), szsubsystemprotocol.into_param().abi())) + let result__ = CertOpenSystemStoreA(hprov.into_param().abi(), szsubsystemprotocol.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); } #[doc = "*Required features: `\"Win32_Security_Cryptography\"`*"] #[inline] -pub unsafe fn CertOpenSystemStoreW<'a, Param0: ::windows::core::IntoParam<'a, HCRYPTPROV_LEGACY>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(hprov: Param0, szsubsystemprotocol: Param1) -> HCERTSTORE { +pub unsafe fn CertOpenSystemStoreW<'a, Param0: ::windows::core::IntoParam<'a, HCRYPTPROV_LEGACY>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(hprov: Param0, szsubsystemprotocol: Param1) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CertOpenSystemStoreW(hprov: HCRYPTPROV_LEGACY, szsubsystemprotocol: ::windows::core::PCWSTR) -> HCERTSTORE; } - ::core::mem::transmute(CertOpenSystemStoreW(hprov.into_param().abi(), szsubsystemprotocol.into_param().abi())) + let result__ = CertOpenSystemStoreW(hprov.into_param().abi(), szsubsystemprotocol.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -21372,14 +21361,15 @@ pub unsafe fn CryptGetKeyParam(hkey: usize, dwparam: CRYPT_KEY_PARAM_ID, pbdata: } #[doc = "*Required features: `\"Win32_Security_Cryptography\"`*"] #[inline] -pub unsafe fn CryptGetMessageCertificates<'a, Param1: ::windows::core::IntoParam<'a, HCRYPTPROV_LEGACY>>(dwmsgandcertencodingtype: u32, hcryptprov: Param1, dwflags: u32, pbsignedblob: *const u8, cbsignedblob: u32) -> HCERTSTORE { +pub unsafe fn CryptGetMessageCertificates<'a, Param1: ::windows::core::IntoParam<'a, HCRYPTPROV_LEGACY>>(dwmsgandcertencodingtype: u32, hcryptprov: Param1, dwflags: u32, pbsignedblob: *const u8, cbsignedblob: u32) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CryptGetMessageCertificates(dwmsgandcertencodingtype: u32, hcryptprov: HCRYPTPROV_LEGACY, dwflags: u32, pbsignedblob: *const u8, cbsignedblob: u32) -> HCERTSTORE; } - ::core::mem::transmute(CryptGetMessageCertificates(::core::mem::transmute(dwmsgandcertencodingtype), hcryptprov.into_param().abi(), ::core::mem::transmute(dwflags), ::core::mem::transmute(pbsignedblob), ::core::mem::transmute(cbsignedblob))) + let result__ = CryptGetMessageCertificates(::core::mem::transmute(dwmsgandcertencodingtype), hcryptprov.into_param().abi(), ::core::mem::transmute(dwflags), ::core::mem::transmute(pbsignedblob), ::core::mem::transmute(cbsignedblob)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -23512,14 +23502,7 @@ impl ::core::fmt::Debug for HASHALGORITHM_ENUM { pub struct HCERTCHAINENGINE(pub isize); impl HCERTCHAINENGINE { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HCERTCHAINENGINE { @@ -23546,14 +23529,7 @@ unsafe impl ::windows::core::Abi for HCERTCHAINENGINE { pub struct HCERTSTORE(pub *mut ::core::ffi::c_void); impl HCERTSTORE { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0.is_null() } } impl ::core::default::Default for HCERTSTORE { @@ -23580,14 +23556,7 @@ unsafe impl ::windows::core::Abi for HCERTSTORE { pub struct HCERTSTOREPROV(pub *mut ::core::ffi::c_void); impl HCERTSTOREPROV { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0.is_null() } } impl ::core::default::Default for HCERTSTOREPROV { @@ -23614,14 +23583,7 @@ unsafe impl ::windows::core::Abi for HCERTSTOREPROV { pub struct HCRYPTASYNC(pub isize); impl HCRYPTASYNC { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HCRYPTASYNC { @@ -23648,14 +23610,7 @@ unsafe impl ::windows::core::Abi for HCRYPTASYNC { pub struct HCRYPTPROV_LEGACY(pub usize); impl HCRYPTPROV_LEGACY { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == 0 } } impl ::core::default::Default for HCRYPTPROV_LEGACY { @@ -23682,14 +23637,7 @@ unsafe impl ::windows::core::Abi for HCRYPTPROV_LEGACY { pub struct HCRYPTPROV_OR_NCRYPT_KEY_HANDLE(pub usize); impl HCRYPTPROV_OR_NCRYPT_KEY_HANDLE { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == 0 } } impl ::core::default::Default for HCRYPTPROV_OR_NCRYPT_KEY_HANDLE { @@ -25884,14 +25832,7 @@ impl ::core::ops::Not for NCRYPT_FLAGS { pub struct NCRYPT_HANDLE(pub usize); impl NCRYPT_HANDLE { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == 0 } } impl ::core::default::Default for NCRYPT_HANDLE { @@ -25918,14 +25859,7 @@ unsafe impl ::windows::core::Abi for NCRYPT_HANDLE { pub struct NCRYPT_HASH_HANDLE(pub usize); impl NCRYPT_HASH_HANDLE { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == 0 } } impl ::core::default::Default for NCRYPT_HASH_HANDLE { @@ -26130,14 +26064,7 @@ pub const NCRYPT_KEY_DERIVATION_OPERATION: u32 = 64u32; pub struct NCRYPT_KEY_HANDLE(pub usize); impl NCRYPT_KEY_HANDLE { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == 0 } } impl ::core::default::Default for NCRYPT_KEY_HANDLE { @@ -26693,14 +26620,7 @@ pub const NCRYPT_PROVIDER_HANDLE_PROPERTY: &'static str = "Provider Handle"; pub struct NCRYPT_PROV_HANDLE(pub usize); impl NCRYPT_PROV_HANDLE { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == 0 } } impl ::core::default::Default for NCRYPT_PROV_HANDLE { @@ -26753,14 +26673,7 @@ pub const NCRYPT_SEALING_FLAG: u32 = 256u32; pub struct NCRYPT_SECRET_HANDLE(pub usize); impl NCRYPT_SECRET_HANDLE { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == 0 } } impl ::core::default::Default for NCRYPT_SECRET_HANDLE { @@ -28469,14 +28382,15 @@ pub unsafe fn PFXExportCertStoreEx<'a, Param0: ::windows::core::IntoParam<'a, HC } #[doc = "*Required features: `\"Win32_Security_Cryptography\"`*"] #[inline] -pub unsafe fn PFXImportCertStore<'a, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(ppfx: *const CRYPTOAPI_BLOB, szpassword: Param1, dwflags: CRYPT_KEY_FLAGS) -> HCERTSTORE { +pub unsafe fn PFXImportCertStore<'a, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(ppfx: *const CRYPTOAPI_BLOB, szpassword: Param1, dwflags: CRYPT_KEY_FLAGS) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn PFXImportCertStore(ppfx: *const CRYPTOAPI_BLOB, szpassword: ::windows::core::PCWSTR, dwflags: CRYPT_KEY_FLAGS) -> HCERTSTORE; } - ::core::mem::transmute(PFXImportCertStore(::core::mem::transmute(ppfx), szpassword.into_param().abi(), ::core::mem::transmute(dwflags))) + let result__ = PFXImportCertStore(::core::mem::transmute(ppfx), szpassword.into_param().abi(), ::core::mem::transmute(dwflags)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); diff --git a/crates/libs/windows/src/Windows/Win32/Security/mod.rs b/crates/libs/windows/src/Windows/Win32/Security/mod.rs index 5c3d4a176f..70b5ab3211 100644 --- a/crates/libs/windows/src/Windows/Win32/Security/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/Security/mod.rs @@ -2401,14 +2401,7 @@ pub unsafe fn GetWindowsAccountDomainSid<'a, Param0: ::windows::core::IntoParam< pub struct HDIAGNOSTIC_DATA_QUERY_SESSION(pub isize); impl HDIAGNOSTIC_DATA_QUERY_SESSION { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HDIAGNOSTIC_DATA_QUERY_SESSION { @@ -2435,14 +2428,7 @@ unsafe impl ::windows::core::Abi for HDIAGNOSTIC_DATA_QUERY_SESSION { pub struct HDIAGNOSTIC_EVENT_CATEGORY_DESCRIPTION(pub isize); impl HDIAGNOSTIC_EVENT_CATEGORY_DESCRIPTION { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HDIAGNOSTIC_EVENT_CATEGORY_DESCRIPTION { @@ -2469,14 +2455,7 @@ unsafe impl ::windows::core::Abi for HDIAGNOSTIC_EVENT_CATEGORY_DESCRIPTION { pub struct HDIAGNOSTIC_EVENT_PRODUCER_DESCRIPTION(pub isize); impl HDIAGNOSTIC_EVENT_PRODUCER_DESCRIPTION { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HDIAGNOSTIC_EVENT_PRODUCER_DESCRIPTION { @@ -2503,14 +2482,7 @@ unsafe impl ::windows::core::Abi for HDIAGNOSTIC_EVENT_PRODUCER_DESCRIPTION { pub struct HDIAGNOSTIC_EVENT_TAG_DESCRIPTION(pub isize); impl HDIAGNOSTIC_EVENT_TAG_DESCRIPTION { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HDIAGNOSTIC_EVENT_TAG_DESCRIPTION { @@ -2537,14 +2509,7 @@ unsafe impl ::windows::core::Abi for HDIAGNOSTIC_EVENT_TAG_DESCRIPTION { pub struct HDIAGNOSTIC_RECORD(pub isize); impl HDIAGNOSTIC_RECORD { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HDIAGNOSTIC_RECORD { @@ -2571,14 +2536,7 @@ unsafe impl ::windows::core::Abi for HDIAGNOSTIC_RECORD { pub struct HDIAGNOSTIC_REPORT(pub isize); impl HDIAGNOSTIC_REPORT { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HDIAGNOSTIC_REPORT { @@ -3231,14 +3189,7 @@ pub unsafe fn MapGenericMask(accessmask: *mut u32, genericmapping: *const GENERI pub struct NCRYPT_DESCRIPTOR_HANDLE(pub isize); impl NCRYPT_DESCRIPTOR_HANDLE { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for NCRYPT_DESCRIPTOR_HANDLE { @@ -3265,14 +3216,7 @@ unsafe impl ::windows::core::Abi for NCRYPT_DESCRIPTOR_HANDLE { pub struct NCRYPT_STREAM_HANDLE(pub isize); impl NCRYPT_STREAM_HANDLE { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for NCRYPT_STREAM_HANDLE { @@ -3595,14 +3539,7 @@ impl ::core::default::Default for PRIVILEGE_SET { pub struct PSECURITY_DESCRIPTOR(pub *mut ::core::ffi::c_void); impl PSECURITY_DESCRIPTOR { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0.is_null() } } impl ::core::default::Default for PSECURITY_DESCRIPTOR { @@ -3768,14 +3705,7 @@ pub unsafe fn RtlNormalizeSecurityDescriptor<'a, Param4: ::windows::core::IntoPa pub struct SAFER_LEVEL_HANDLE(pub isize); impl SAFER_LEVEL_HANDLE { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for SAFER_LEVEL_HANDLE { @@ -3802,14 +3732,7 @@ unsafe impl ::windows::core::Abi for SAFER_LEVEL_HANDLE { pub struct SC_HANDLE(pub isize); impl SC_HANDLE { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for SC_HANDLE { diff --git a/crates/libs/windows/src/Windows/Win32/Storage/CloudFilters/mod.rs b/crates/libs/windows/src/Windows/Win32/Storage/CloudFilters/mod.rs index 959b5ef10b..445b652b95 100644 --- a/crates/libs/windows/src/Windows/Win32/Storage/CloudFilters/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/Storage/CloudFilters/mod.rs @@ -1361,14 +1361,7 @@ impl ::core::ops::Not for CF_CALLBACK_VALIDATE_DATA_FLAGS { pub struct CF_CONNECTION_KEY(pub isize); impl CF_CONNECTION_KEY { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for CF_CONNECTION_KEY { diff --git a/crates/libs/windows/src/Windows/Win32/Storage/Compression/mod.rs b/crates/libs/windows/src/Windows/Win32/Storage/Compression/mod.rs index 3746d4fa3f..671690bc59 100644 --- a/crates/libs/windows/src/Windows/Win32/Storage/Compression/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/Storage/Compression/mod.rs @@ -4,14 +4,7 @@ pub struct COMPRESSOR_HANDLE(pub isize); impl COMPRESSOR_HANDLE { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for COMPRESSOR_HANDLE { diff --git a/crates/libs/windows/src/Windows/Win32/Storage/FileSystem/mod.rs b/crates/libs/windows/src/Windows/Win32/Storage/FileSystem/mod.rs index a4f2f06fca..627d7271cd 100644 --- a/crates/libs/windows/src/Windows/Win32/Storage/FileSystem/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/Storage/FileSystem/mod.rs @@ -2632,14 +2632,15 @@ pub unsafe fn CreateDirectoryW<'a, Param0: ::windows::core::IntoParam<'a, ::wind #[doc = "*Required features: `\"Win32_Storage_FileSystem\"`, `\"Win32_Foundation\"`, `\"Win32_Security\"`*"] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Security"))] #[inline] -pub unsafe fn CreateEnlistment<'a, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>, Param2: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>>(lpenlistmentattributes: *mut super::super::Security::SECURITY_ATTRIBUTES, resourcemanagerhandle: Param1, transactionhandle: Param2, notificationmask: u32, createoptions: u32, enlistmentkey: *mut ::core::ffi::c_void) -> super::super::Foundation::HANDLE { +pub unsafe fn CreateEnlistment<'a, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>, Param2: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>>(lpenlistmentattributes: *mut super::super::Security::SECURITY_ATTRIBUTES, resourcemanagerhandle: Param1, transactionhandle: Param2, notificationmask: u32, createoptions: u32, enlistmentkey: *mut ::core::ffi::c_void) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateEnlistment(lpenlistmentattributes: *mut super::super::Security::SECURITY_ATTRIBUTES, resourcemanagerhandle: super::super::Foundation::HANDLE, transactionhandle: super::super::Foundation::HANDLE, notificationmask: u32, createoptions: u32, enlistmentkey: *mut ::core::ffi::c_void) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(CreateEnlistment(::core::mem::transmute(lpenlistmentattributes), resourcemanagerhandle.into_param().abi(), transactionhandle.into_param().abi(), ::core::mem::transmute(notificationmask), ::core::mem::transmute(createoptions), ::core::mem::transmute(enlistmentkey))) + let result__ = CreateEnlistment(::core::mem::transmute(lpenlistmentattributes), resourcemanagerhandle.into_param().abi(), transactionhandle.into_param().abi(), ::core::mem::transmute(notificationmask), ::core::mem::transmute(createoptions), ::core::mem::transmute(enlistmentkey)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -2647,14 +2648,15 @@ pub unsafe fn CreateEnlistment<'a, Param1: ::windows::core::IntoParam<'a, super: #[doc = "*Required features: `\"Win32_Storage_FileSystem\"`, `\"Win32_Foundation\"`, `\"Win32_Security\"`*"] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Security"))] #[inline] -pub unsafe fn CreateFile2<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(lpfilename: Param0, dwdesiredaccess: FILE_ACCESS_FLAGS, dwsharemode: FILE_SHARE_MODE, dwcreationdisposition: FILE_CREATION_DISPOSITION, pcreateexparams: *const CREATEFILE2_EXTENDED_PARAMETERS) -> super::super::Foundation::HANDLE { +pub unsafe fn CreateFile2<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(lpfilename: Param0, dwdesiredaccess: FILE_ACCESS_FLAGS, dwsharemode: FILE_SHARE_MODE, dwcreationdisposition: FILE_CREATION_DISPOSITION, pcreateexparams: *const CREATEFILE2_EXTENDED_PARAMETERS) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateFile2(lpfilename: ::windows::core::PCWSTR, dwdesiredaccess: FILE_ACCESS_FLAGS, dwsharemode: FILE_SHARE_MODE, dwcreationdisposition: FILE_CREATION_DISPOSITION, pcreateexparams: *const CREATEFILE2_EXTENDED_PARAMETERS) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(CreateFile2(lpfilename.into_param().abi(), ::core::mem::transmute(dwdesiredaccess), ::core::mem::transmute(dwsharemode), ::core::mem::transmute(dwcreationdisposition), ::core::mem::transmute(pcreateexparams))) + let result__ = CreateFile2(lpfilename.into_param().abi(), ::core::mem::transmute(dwdesiredaccess), ::core::mem::transmute(dwsharemode), ::core::mem::transmute(dwcreationdisposition), ::core::mem::transmute(pcreateexparams)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -2677,14 +2679,15 @@ pub unsafe fn CreateFile2FromAppW<'a, Param0: ::windows::core::IntoParam<'a, ::w #[doc = "*Required features: `\"Win32_Storage_FileSystem\"`, `\"Win32_Foundation\"`, `\"Win32_Security\"`*"] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Security"))] #[inline] -pub unsafe fn CreateFileA<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>, Param6: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>>(lpfilename: Param0, dwdesiredaccess: FILE_ACCESS_FLAGS, dwsharemode: FILE_SHARE_MODE, lpsecurityattributes: *const super::super::Security::SECURITY_ATTRIBUTES, dwcreationdisposition: FILE_CREATION_DISPOSITION, dwflagsandattributes: FILE_FLAGS_AND_ATTRIBUTES, htemplatefile: Param6) -> super::super::Foundation::HANDLE { +pub unsafe fn CreateFileA<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>, Param6: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>>(lpfilename: Param0, dwdesiredaccess: FILE_ACCESS_FLAGS, dwsharemode: FILE_SHARE_MODE, lpsecurityattributes: *const super::super::Security::SECURITY_ATTRIBUTES, dwcreationdisposition: FILE_CREATION_DISPOSITION, dwflagsandattributes: FILE_FLAGS_AND_ATTRIBUTES, htemplatefile: Param6) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateFileA(lpfilename: ::windows::core::PCSTR, dwdesiredaccess: FILE_ACCESS_FLAGS, dwsharemode: FILE_SHARE_MODE, lpsecurityattributes: *const super::super::Security::SECURITY_ATTRIBUTES, dwcreationdisposition: FILE_CREATION_DISPOSITION, dwflagsandattributes: FILE_FLAGS_AND_ATTRIBUTES, htemplatefile: super::super::Foundation::HANDLE) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(CreateFileA(lpfilename.into_param().abi(), ::core::mem::transmute(dwdesiredaccess), ::core::mem::transmute(dwsharemode), ::core::mem::transmute(lpsecurityattributes), ::core::mem::transmute(dwcreationdisposition), ::core::mem::transmute(dwflagsandattributes), htemplatefile.into_param().abi())) + let result__ = CreateFileA(lpfilename.into_param().abi(), ::core::mem::transmute(dwdesiredaccess), ::core::mem::transmute(dwsharemode), ::core::mem::transmute(lpsecurityattributes), ::core::mem::transmute(dwcreationdisposition), ::core::mem::transmute(dwflagsandattributes), htemplatefile.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -2707,14 +2710,15 @@ pub unsafe fn CreateFileFromAppW<'a, Param0: ::windows::core::IntoParam<'a, ::wi #[doc = "*Required features: `\"Win32_Storage_FileSystem\"`, `\"Win32_Foundation\"`, `\"Win32_Security\"`*"] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Security"))] #[inline] -pub unsafe fn CreateFileTransactedA<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>, Param6: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>, Param7: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>>(lpfilename: Param0, dwdesiredaccess: u32, dwsharemode: FILE_SHARE_MODE, lpsecurityattributes: *const super::super::Security::SECURITY_ATTRIBUTES, dwcreationdisposition: FILE_CREATION_DISPOSITION, dwflagsandattributes: FILE_FLAGS_AND_ATTRIBUTES, htemplatefile: Param6, htransaction: Param7, pusminiversion: *const TXFS_MINIVERSION, lpextendedparameter: *mut ::core::ffi::c_void) -> super::super::Foundation::HANDLE { +pub unsafe fn CreateFileTransactedA<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>, Param6: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>, Param7: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>>(lpfilename: Param0, dwdesiredaccess: u32, dwsharemode: FILE_SHARE_MODE, lpsecurityattributes: *const super::super::Security::SECURITY_ATTRIBUTES, dwcreationdisposition: FILE_CREATION_DISPOSITION, dwflagsandattributes: FILE_FLAGS_AND_ATTRIBUTES, htemplatefile: Param6, htransaction: Param7, pusminiversion: *const TXFS_MINIVERSION, lpextendedparameter: *mut ::core::ffi::c_void) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateFileTransactedA(lpfilename: ::windows::core::PCSTR, dwdesiredaccess: u32, dwsharemode: FILE_SHARE_MODE, lpsecurityattributes: *const super::super::Security::SECURITY_ATTRIBUTES, dwcreationdisposition: FILE_CREATION_DISPOSITION, dwflagsandattributes: FILE_FLAGS_AND_ATTRIBUTES, htemplatefile: super::super::Foundation::HANDLE, htransaction: super::super::Foundation::HANDLE, pusminiversion: *const TXFS_MINIVERSION, lpextendedparameter: *mut ::core::ffi::c_void) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(CreateFileTransactedA(lpfilename.into_param().abi(), ::core::mem::transmute(dwdesiredaccess), ::core::mem::transmute(dwsharemode), ::core::mem::transmute(lpsecurityattributes), ::core::mem::transmute(dwcreationdisposition), ::core::mem::transmute(dwflagsandattributes), htemplatefile.into_param().abi(), htransaction.into_param().abi(), ::core::mem::transmute(pusminiversion), ::core::mem::transmute(lpextendedparameter))) + let result__ = CreateFileTransactedA(lpfilename.into_param().abi(), ::core::mem::transmute(dwdesiredaccess), ::core::mem::transmute(dwsharemode), ::core::mem::transmute(lpsecurityattributes), ::core::mem::transmute(dwcreationdisposition), ::core::mem::transmute(dwflagsandattributes), htemplatefile.into_param().abi(), htransaction.into_param().abi(), ::core::mem::transmute(pusminiversion), ::core::mem::transmute(lpextendedparameter)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -2722,14 +2726,15 @@ pub unsafe fn CreateFileTransactedA<'a, Param0: ::windows::core::IntoParam<'a, : #[doc = "*Required features: `\"Win32_Storage_FileSystem\"`, `\"Win32_Foundation\"`, `\"Win32_Security\"`*"] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Security"))] #[inline] -pub unsafe fn CreateFileTransactedW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>, Param6: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>, Param7: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>>(lpfilename: Param0, dwdesiredaccess: u32, dwsharemode: FILE_SHARE_MODE, lpsecurityattributes: *const super::super::Security::SECURITY_ATTRIBUTES, dwcreationdisposition: FILE_CREATION_DISPOSITION, dwflagsandattributes: FILE_FLAGS_AND_ATTRIBUTES, htemplatefile: Param6, htransaction: Param7, pusminiversion: *const TXFS_MINIVERSION, lpextendedparameter: *mut ::core::ffi::c_void) -> super::super::Foundation::HANDLE { +pub unsafe fn CreateFileTransactedW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>, Param6: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>, Param7: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>>(lpfilename: Param0, dwdesiredaccess: u32, dwsharemode: FILE_SHARE_MODE, lpsecurityattributes: *const super::super::Security::SECURITY_ATTRIBUTES, dwcreationdisposition: FILE_CREATION_DISPOSITION, dwflagsandattributes: FILE_FLAGS_AND_ATTRIBUTES, htemplatefile: Param6, htransaction: Param7, pusminiversion: *const TXFS_MINIVERSION, lpextendedparameter: *mut ::core::ffi::c_void) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateFileTransactedW(lpfilename: ::windows::core::PCWSTR, dwdesiredaccess: u32, dwsharemode: FILE_SHARE_MODE, lpsecurityattributes: *const super::super::Security::SECURITY_ATTRIBUTES, dwcreationdisposition: FILE_CREATION_DISPOSITION, dwflagsandattributes: FILE_FLAGS_AND_ATTRIBUTES, htemplatefile: super::super::Foundation::HANDLE, htransaction: super::super::Foundation::HANDLE, pusminiversion: *const TXFS_MINIVERSION, lpextendedparameter: *mut ::core::ffi::c_void) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(CreateFileTransactedW(lpfilename.into_param().abi(), ::core::mem::transmute(dwdesiredaccess), ::core::mem::transmute(dwsharemode), ::core::mem::transmute(lpsecurityattributes), ::core::mem::transmute(dwcreationdisposition), ::core::mem::transmute(dwflagsandattributes), htemplatefile.into_param().abi(), htransaction.into_param().abi(), ::core::mem::transmute(pusminiversion), ::core::mem::transmute(lpextendedparameter))) + let result__ = CreateFileTransactedW(lpfilename.into_param().abi(), ::core::mem::transmute(dwdesiredaccess), ::core::mem::transmute(dwsharemode), ::core::mem::transmute(lpsecurityattributes), ::core::mem::transmute(dwcreationdisposition), ::core::mem::transmute(dwflagsandattributes), htemplatefile.into_param().abi(), htransaction.into_param().abi(), ::core::mem::transmute(pusminiversion), ::core::mem::transmute(lpextendedparameter)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -2737,14 +2742,15 @@ pub unsafe fn CreateFileTransactedW<'a, Param0: ::windows::core::IntoParam<'a, : #[doc = "*Required features: `\"Win32_Storage_FileSystem\"`, `\"Win32_Foundation\"`, `\"Win32_Security\"`*"] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Security"))] #[inline] -pub unsafe fn CreateFileW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>, Param6: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>>(lpfilename: Param0, dwdesiredaccess: FILE_ACCESS_FLAGS, dwsharemode: FILE_SHARE_MODE, lpsecurityattributes: *const super::super::Security::SECURITY_ATTRIBUTES, dwcreationdisposition: FILE_CREATION_DISPOSITION, dwflagsandattributes: FILE_FLAGS_AND_ATTRIBUTES, htemplatefile: Param6) -> super::super::Foundation::HANDLE { +pub unsafe fn CreateFileW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>, Param6: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>>(lpfilename: Param0, dwdesiredaccess: FILE_ACCESS_FLAGS, dwsharemode: FILE_SHARE_MODE, lpsecurityattributes: *const super::super::Security::SECURITY_ATTRIBUTES, dwcreationdisposition: FILE_CREATION_DISPOSITION, dwflagsandattributes: FILE_FLAGS_AND_ATTRIBUTES, htemplatefile: Param6) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateFileW(lpfilename: ::windows::core::PCWSTR, dwdesiredaccess: FILE_ACCESS_FLAGS, dwsharemode: FILE_SHARE_MODE, lpsecurityattributes: *const super::super::Security::SECURITY_ATTRIBUTES, dwcreationdisposition: FILE_CREATION_DISPOSITION, dwflagsandattributes: FILE_FLAGS_AND_ATTRIBUTES, htemplatefile: super::super::Foundation::HANDLE) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(CreateFileW(lpfilename.into_param().abi(), ::core::mem::transmute(dwdesiredaccess), ::core::mem::transmute(dwsharemode), ::core::mem::transmute(lpsecurityattributes), ::core::mem::transmute(dwcreationdisposition), ::core::mem::transmute(dwflagsandattributes), htemplatefile.into_param().abi())) + let result__ = CreateFileW(lpfilename.into_param().abi(), ::core::mem::transmute(dwdesiredaccess), ::core::mem::transmute(dwsharemode), ::core::mem::transmute(lpsecurityattributes), ::core::mem::transmute(dwcreationdisposition), ::core::mem::transmute(dwflagsandattributes), htemplatefile.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -2842,14 +2848,15 @@ pub unsafe fn CreateLogContainerScanContext<'a, Param0: ::windows::core::IntoPar #[doc = "*Required features: `\"Win32_Storage_FileSystem\"`, `\"Win32_Foundation\"`, `\"Win32_Security\"`*"] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Security"))] #[inline] -pub unsafe fn CreateLogFile<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(pszlogfilename: Param0, fdesiredaccess: FILE_ACCESS_FLAGS, dwsharemode: FILE_SHARE_MODE, psalogfile: *mut super::super::Security::SECURITY_ATTRIBUTES, fcreatedisposition: FILE_CREATION_DISPOSITION, fflagsandattributes: FILE_FLAGS_AND_ATTRIBUTES) -> super::super::Foundation::HANDLE { +pub unsafe fn CreateLogFile<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(pszlogfilename: Param0, fdesiredaccess: FILE_ACCESS_FLAGS, dwsharemode: FILE_SHARE_MODE, psalogfile: *mut super::super::Security::SECURITY_ATTRIBUTES, fcreatedisposition: FILE_CREATION_DISPOSITION, fflagsandattributes: FILE_FLAGS_AND_ATTRIBUTES) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateLogFile(pszlogfilename: ::windows::core::PCWSTR, fdesiredaccess: FILE_ACCESS_FLAGS, dwsharemode: FILE_SHARE_MODE, psalogfile: *mut super::super::Security::SECURITY_ATTRIBUTES, fcreatedisposition: FILE_CREATION_DISPOSITION, fflagsandattributes: FILE_FLAGS_AND_ATTRIBUTES) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(CreateLogFile(pszlogfilename.into_param().abi(), ::core::mem::transmute(fdesiredaccess), ::core::mem::transmute(dwsharemode), ::core::mem::transmute(psalogfile), ::core::mem::transmute(fcreatedisposition), ::core::mem::transmute(fflagsandattributes))) + let result__ = CreateLogFile(pszlogfilename.into_param().abi(), ::core::mem::transmute(fdesiredaccess), ::core::mem::transmute(dwsharemode), ::core::mem::transmute(psalogfile), ::core::mem::transmute(fcreatedisposition), ::core::mem::transmute(fflagsandattributes)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -2872,14 +2879,15 @@ pub unsafe fn CreateLogMarshallingArea<'a, Param0: ::windows::core::IntoParam<'a #[doc = "*Required features: `\"Win32_Storage_FileSystem\"`, `\"Win32_Foundation\"`, `\"Win32_Security\"`*"] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Security"))] #[inline] -pub unsafe fn CreateResourceManager<'a, Param3: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>, Param4: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(lpresourcemanagerattributes: *mut super::super::Security::SECURITY_ATTRIBUTES, resourcemanagerid: *mut ::windows::core::GUID, createoptions: u32, tmhandle: Param3, description: Param4) -> super::super::Foundation::HANDLE { +pub unsafe fn CreateResourceManager<'a, Param3: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>, Param4: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(lpresourcemanagerattributes: *mut super::super::Security::SECURITY_ATTRIBUTES, resourcemanagerid: *mut ::windows::core::GUID, createoptions: u32, tmhandle: Param3, description: Param4) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateResourceManager(lpresourcemanagerattributes: *mut super::super::Security::SECURITY_ATTRIBUTES, resourcemanagerid: *mut ::windows::core::GUID, createoptions: u32, tmhandle: super::super::Foundation::HANDLE, description: ::windows::core::PCWSTR) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(CreateResourceManager(::core::mem::transmute(lpresourcemanagerattributes), ::core::mem::transmute(resourcemanagerid), ::core::mem::transmute(createoptions), tmhandle.into_param().abi(), description.into_param().abi())) + let result__ = CreateResourceManager(::core::mem::transmute(lpresourcemanagerattributes), ::core::mem::transmute(resourcemanagerid), ::core::mem::transmute(createoptions), tmhandle.into_param().abi(), description.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -2962,14 +2970,15 @@ pub unsafe fn CreateTapePartition<'a, Param0: ::windows::core::IntoParam<'a, sup #[doc = "*Required features: `\"Win32_Storage_FileSystem\"`, `\"Win32_Foundation\"`, `\"Win32_Security\"`*"] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Security"))] #[inline] -pub unsafe fn CreateTransaction<'a, Param6: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(lptransactionattributes: *mut super::super::Security::SECURITY_ATTRIBUTES, uow: *mut ::windows::core::GUID, createoptions: u32, isolationlevel: u32, isolationflags: u32, timeout: u32, description: Param6) -> super::super::Foundation::HANDLE { +pub unsafe fn CreateTransaction<'a, Param6: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(lptransactionattributes: *mut super::super::Security::SECURITY_ATTRIBUTES, uow: *mut ::windows::core::GUID, createoptions: u32, isolationlevel: u32, isolationflags: u32, timeout: u32, description: Param6) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateTransaction(lptransactionattributes: *mut super::super::Security::SECURITY_ATTRIBUTES, uow: *mut ::windows::core::GUID, createoptions: u32, isolationlevel: u32, isolationflags: u32, timeout: u32, description: ::windows::core::PCWSTR) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(CreateTransaction(::core::mem::transmute(lptransactionattributes), ::core::mem::transmute(uow), ::core::mem::transmute(createoptions), ::core::mem::transmute(isolationlevel), ::core::mem::transmute(isolationflags), ::core::mem::transmute(timeout), description.into_param().abi())) + let result__ = CreateTransaction(::core::mem::transmute(lptransactionattributes), ::core::mem::transmute(uow), ::core::mem::transmute(createoptions), ::core::mem::transmute(isolationlevel), ::core::mem::transmute(isolationflags), ::core::mem::transmute(timeout), description.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -2977,14 +2986,15 @@ pub unsafe fn CreateTransaction<'a, Param6: ::windows::core::IntoParam<'a, ::win #[doc = "*Required features: `\"Win32_Storage_FileSystem\"`, `\"Win32_Foundation\"`, `\"Win32_Security\"`*"] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Security"))] #[inline] -pub unsafe fn CreateTransactionManager<'a, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(lptransactionattributes: *mut super::super::Security::SECURITY_ATTRIBUTES, logfilename: Param1, createoptions: u32, commitstrength: u32) -> super::super::Foundation::HANDLE { +pub unsafe fn CreateTransactionManager<'a, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(lptransactionattributes: *mut super::super::Security::SECURITY_ATTRIBUTES, logfilename: Param1, createoptions: u32, commitstrength: u32) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateTransactionManager(lptransactionattributes: *mut super::super::Security::SECURITY_ATTRIBUTES, logfilename: ::windows::core::PCWSTR, createoptions: u32, commitstrength: u32) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(CreateTransactionManager(::core::mem::transmute(lptransactionattributes), logfilename.into_param().abi(), ::core::mem::transmute(createoptions), ::core::mem::transmute(commitstrength))) + let result__ = CreateTransactionManager(::core::mem::transmute(lptransactionattributes), logfilename.into_param().abi(), ::core::mem::transmute(createoptions), ::core::mem::transmute(commitstrength)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -6209,14 +6219,7 @@ pub unsafe fn FileTimeToLocalFileTime(lpfiletime: *const super::super::Foundatio pub struct FindChangeNotificationHandle(pub isize); impl FindChangeNotificationHandle { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for FindChangeNotificationHandle { @@ -6273,14 +6276,7 @@ pub unsafe fn FindCloseChangeNotification<'a, Param0: ::windows::core::IntoParam pub struct FindFileHandle(pub isize); impl FindFileHandle { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for FindFileHandle { @@ -6307,14 +6303,7 @@ unsafe impl ::windows::core::Abi for FindFileHandle { pub struct FindFileNameHandle(pub isize); impl FindFileNameHandle { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for FindFileNameHandle { @@ -6339,14 +6328,15 @@ unsafe impl ::windows::core::Abi for FindFileNameHandle { #[doc = "*Required features: `\"Win32_Storage_FileSystem\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn FindFirstChangeNotificationA<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>>(lppathname: Param0, bwatchsubtree: Param1, dwnotifyfilter: FILE_NOTIFY_CHANGE) -> FindChangeNotificationHandle { +pub unsafe fn FindFirstChangeNotificationA<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>>(lppathname: Param0, bwatchsubtree: Param1, dwnotifyfilter: FILE_NOTIFY_CHANGE) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn FindFirstChangeNotificationA(lppathname: ::windows::core::PCSTR, bwatchsubtree: super::super::Foundation::BOOL, dwnotifyfilter: FILE_NOTIFY_CHANGE) -> FindChangeNotificationHandle; } - ::core::mem::transmute(FindFirstChangeNotificationA(lppathname.into_param().abi(), bwatchsubtree.into_param().abi(), ::core::mem::transmute(dwnotifyfilter))) + let result__ = FindFirstChangeNotificationA(lppathname.into_param().abi(), bwatchsubtree.into_param().abi(), ::core::mem::transmute(dwnotifyfilter)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -6354,14 +6344,15 @@ pub unsafe fn FindFirstChangeNotificationA<'a, Param0: ::windows::core::IntoPara #[doc = "*Required features: `\"Win32_Storage_FileSystem\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn FindFirstChangeNotificationW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>>(lppathname: Param0, bwatchsubtree: Param1, dwnotifyfilter: FILE_NOTIFY_CHANGE) -> FindChangeNotificationHandle { +pub unsafe fn FindFirstChangeNotificationW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>>(lppathname: Param0, bwatchsubtree: Param1, dwnotifyfilter: FILE_NOTIFY_CHANGE) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn FindFirstChangeNotificationW(lppathname: ::windows::core::PCWSTR, bwatchsubtree: super::super::Foundation::BOOL, dwnotifyfilter: FILE_NOTIFY_CHANGE) -> FindChangeNotificationHandle; } - ::core::mem::transmute(FindFirstChangeNotificationW(lppathname.into_param().abi(), bwatchsubtree.into_param().abi(), ::core::mem::transmute(dwnotifyfilter))) + let result__ = FindFirstChangeNotificationW(lppathname.into_param().abi(), bwatchsubtree.into_param().abi(), ::core::mem::transmute(dwnotifyfilter)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -6369,28 +6360,30 @@ pub unsafe fn FindFirstChangeNotificationW<'a, Param0: ::windows::core::IntoPara #[doc = "*Required features: `\"Win32_Storage_FileSystem\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn FindFirstFileA<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(lpfilename: Param0, lpfindfiledata: *mut WIN32_FIND_DATAA) -> FindFileHandle { +pub unsafe fn FindFirstFileA<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(lpfilename: Param0, lpfindfiledata: *mut WIN32_FIND_DATAA) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn FindFirstFileA(lpfilename: ::windows::core::PCSTR, lpfindfiledata: *mut WIN32_FIND_DATAA) -> FindFileHandle; } - ::core::mem::transmute(FindFirstFileA(lpfilename.into_param().abi(), ::core::mem::transmute(lpfindfiledata))) + let result__ = FindFirstFileA(lpfilename.into_param().abi(), ::core::mem::transmute(lpfindfiledata)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); } #[doc = "*Required features: `\"Win32_Storage_FileSystem\"`*"] #[inline] -pub unsafe fn FindFirstFileExA<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(lpfilename: Param0, finfolevelid: FINDEX_INFO_LEVELS, lpfindfiledata: *mut ::core::ffi::c_void, fsearchop: FINDEX_SEARCH_OPS, lpsearchfilter: *mut ::core::ffi::c_void, dwadditionalflags: FIND_FIRST_EX_FLAGS) -> FindFileHandle { +pub unsafe fn FindFirstFileExA<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(lpfilename: Param0, finfolevelid: FINDEX_INFO_LEVELS, lpfindfiledata: *mut ::core::ffi::c_void, fsearchop: FINDEX_SEARCH_OPS, lpsearchfilter: *mut ::core::ffi::c_void, dwadditionalflags: FIND_FIRST_EX_FLAGS) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn FindFirstFileExA(lpfilename: ::windows::core::PCSTR, finfolevelid: FINDEX_INFO_LEVELS, lpfindfiledata: *mut ::core::ffi::c_void, fsearchop: FINDEX_SEARCH_OPS, lpsearchfilter: *mut ::core::ffi::c_void, dwadditionalflags: FIND_FIRST_EX_FLAGS) -> FindFileHandle; } - ::core::mem::transmute(FindFirstFileExA(lpfilename.into_param().abi(), ::core::mem::transmute(finfolevelid), ::core::mem::transmute(lpfindfiledata), ::core::mem::transmute(fsearchop), ::core::mem::transmute(lpsearchfilter), ::core::mem::transmute(dwadditionalflags))) + let result__ = FindFirstFileExA(lpfilename.into_param().abi(), ::core::mem::transmute(finfolevelid), ::core::mem::transmute(lpfindfiledata), ::core::mem::transmute(fsearchop), ::core::mem::transmute(lpsearchfilter), ::core::mem::transmute(dwadditionalflags)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -6412,14 +6405,15 @@ pub unsafe fn FindFirstFileExFromAppW<'a, Param0: ::windows::core::IntoParam<'a, } #[doc = "*Required features: `\"Win32_Storage_FileSystem\"`*"] #[inline] -pub unsafe fn FindFirstFileExW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(lpfilename: Param0, finfolevelid: FINDEX_INFO_LEVELS, lpfindfiledata: *mut ::core::ffi::c_void, fsearchop: FINDEX_SEARCH_OPS, lpsearchfilter: *mut ::core::ffi::c_void, dwadditionalflags: FIND_FIRST_EX_FLAGS) -> FindFileHandle { +pub unsafe fn FindFirstFileExW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(lpfilename: Param0, finfolevelid: FINDEX_INFO_LEVELS, lpfindfiledata: *mut ::core::ffi::c_void, fsearchop: FINDEX_SEARCH_OPS, lpsearchfilter: *mut ::core::ffi::c_void, dwadditionalflags: FIND_FIRST_EX_FLAGS) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn FindFirstFileExW(lpfilename: ::windows::core::PCWSTR, finfolevelid: FINDEX_INFO_LEVELS, lpfindfiledata: *mut ::core::ffi::c_void, fsearchop: FINDEX_SEARCH_OPS, lpsearchfilter: *mut ::core::ffi::c_void, dwadditionalflags: FIND_FIRST_EX_FLAGS) -> FindFileHandle; } - ::core::mem::transmute(FindFirstFileExW(lpfilename.into_param().abi(), ::core::mem::transmute(finfolevelid), ::core::mem::transmute(lpfindfiledata), ::core::mem::transmute(fsearchop), ::core::mem::transmute(lpsearchfilter), ::core::mem::transmute(dwadditionalflags))) + let result__ = FindFirstFileExW(lpfilename.into_param().abi(), ::core::mem::transmute(finfolevelid), ::core::mem::transmute(lpfindfiledata), ::core::mem::transmute(fsearchop), ::core::mem::transmute(lpsearchfilter), ::core::mem::transmute(dwadditionalflags)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -6427,28 +6421,30 @@ pub unsafe fn FindFirstFileExW<'a, Param0: ::windows::core::IntoParam<'a, ::wind #[doc = "*Required features: `\"Win32_Storage_FileSystem\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn FindFirstFileNameTransactedW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>, Param4: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>>(lpfilename: Param0, dwflags: u32, stringlength: *mut u32, linkname: ::windows::core::PWSTR, htransaction: Param4) -> FindFileNameHandle { +pub unsafe fn FindFirstFileNameTransactedW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>, Param4: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>>(lpfilename: Param0, dwflags: u32, stringlength: *mut u32, linkname: ::windows::core::PWSTR, htransaction: Param4) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn FindFirstFileNameTransactedW(lpfilename: ::windows::core::PCWSTR, dwflags: u32, stringlength: *mut u32, linkname: ::windows::core::PWSTR, htransaction: super::super::Foundation::HANDLE) -> FindFileNameHandle; } - ::core::mem::transmute(FindFirstFileNameTransactedW(lpfilename.into_param().abi(), ::core::mem::transmute(dwflags), ::core::mem::transmute(stringlength), ::core::mem::transmute(linkname), htransaction.into_param().abi())) + let result__ = FindFirstFileNameTransactedW(lpfilename.into_param().abi(), ::core::mem::transmute(dwflags), ::core::mem::transmute(stringlength), ::core::mem::transmute(linkname), htransaction.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); } #[doc = "*Required features: `\"Win32_Storage_FileSystem\"`*"] #[inline] -pub unsafe fn FindFirstFileNameW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(lpfilename: Param0, dwflags: u32, stringlength: *mut u32, linkname: ::windows::core::PWSTR) -> FindFileNameHandle { +pub unsafe fn FindFirstFileNameW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(lpfilename: Param0, dwflags: u32, stringlength: *mut u32, linkname: ::windows::core::PWSTR) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn FindFirstFileNameW(lpfilename: ::windows::core::PCWSTR, dwflags: u32, stringlength: *mut u32, linkname: ::windows::core::PWSTR) -> FindFileNameHandle; } - ::core::mem::transmute(FindFirstFileNameW(lpfilename.into_param().abi(), ::core::mem::transmute(dwflags), ::core::mem::transmute(stringlength), ::core::mem::transmute(linkname))) + let result__ = FindFirstFileNameW(lpfilename.into_param().abi(), ::core::mem::transmute(dwflags), ::core::mem::transmute(stringlength), ::core::mem::transmute(linkname)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -6456,14 +6452,15 @@ pub unsafe fn FindFirstFileNameW<'a, Param0: ::windows::core::IntoParam<'a, ::wi #[doc = "*Required features: `\"Win32_Storage_FileSystem\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn FindFirstFileTransactedA<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>, Param6: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>>(lpfilename: Param0, finfolevelid: FINDEX_INFO_LEVELS, lpfindfiledata: *mut ::core::ffi::c_void, fsearchop: FINDEX_SEARCH_OPS, lpsearchfilter: *mut ::core::ffi::c_void, dwadditionalflags: u32, htransaction: Param6) -> FindFileHandle { +pub unsafe fn FindFirstFileTransactedA<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>, Param6: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>>(lpfilename: Param0, finfolevelid: FINDEX_INFO_LEVELS, lpfindfiledata: *mut ::core::ffi::c_void, fsearchop: FINDEX_SEARCH_OPS, lpsearchfilter: *mut ::core::ffi::c_void, dwadditionalflags: u32, htransaction: Param6) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn FindFirstFileTransactedA(lpfilename: ::windows::core::PCSTR, finfolevelid: FINDEX_INFO_LEVELS, lpfindfiledata: *mut ::core::ffi::c_void, fsearchop: FINDEX_SEARCH_OPS, lpsearchfilter: *mut ::core::ffi::c_void, dwadditionalflags: u32, htransaction: super::super::Foundation::HANDLE) -> FindFileHandle; } - ::core::mem::transmute(FindFirstFileTransactedA(lpfilename.into_param().abi(), ::core::mem::transmute(finfolevelid), ::core::mem::transmute(lpfindfiledata), ::core::mem::transmute(fsearchop), ::core::mem::transmute(lpsearchfilter), ::core::mem::transmute(dwadditionalflags), htransaction.into_param().abi())) + let result__ = FindFirstFileTransactedA(lpfilename.into_param().abi(), ::core::mem::transmute(finfolevelid), ::core::mem::transmute(lpfindfiledata), ::core::mem::transmute(fsearchop), ::core::mem::transmute(lpsearchfilter), ::core::mem::transmute(dwadditionalflags), htransaction.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -6471,14 +6468,15 @@ pub unsafe fn FindFirstFileTransactedA<'a, Param0: ::windows::core::IntoParam<'a #[doc = "*Required features: `\"Win32_Storage_FileSystem\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn FindFirstFileTransactedW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>, Param6: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>>(lpfilename: Param0, finfolevelid: FINDEX_INFO_LEVELS, lpfindfiledata: *mut ::core::ffi::c_void, fsearchop: FINDEX_SEARCH_OPS, lpsearchfilter: *mut ::core::ffi::c_void, dwadditionalflags: u32, htransaction: Param6) -> FindFileHandle { +pub unsafe fn FindFirstFileTransactedW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>, Param6: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>>(lpfilename: Param0, finfolevelid: FINDEX_INFO_LEVELS, lpfindfiledata: *mut ::core::ffi::c_void, fsearchop: FINDEX_SEARCH_OPS, lpsearchfilter: *mut ::core::ffi::c_void, dwadditionalflags: u32, htransaction: Param6) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn FindFirstFileTransactedW(lpfilename: ::windows::core::PCWSTR, finfolevelid: FINDEX_INFO_LEVELS, lpfindfiledata: *mut ::core::ffi::c_void, fsearchop: FINDEX_SEARCH_OPS, lpsearchfilter: *mut ::core::ffi::c_void, dwadditionalflags: u32, htransaction: super::super::Foundation::HANDLE) -> FindFileHandle; } - ::core::mem::transmute(FindFirstFileTransactedW(lpfilename.into_param().abi(), ::core::mem::transmute(finfolevelid), ::core::mem::transmute(lpfindfiledata), ::core::mem::transmute(fsearchop), ::core::mem::transmute(lpsearchfilter), ::core::mem::transmute(dwadditionalflags), htransaction.into_param().abi())) + let result__ = FindFirstFileTransactedW(lpfilename.into_param().abi(), ::core::mem::transmute(finfolevelid), ::core::mem::transmute(lpfindfiledata), ::core::mem::transmute(fsearchop), ::core::mem::transmute(lpsearchfilter), ::core::mem::transmute(dwadditionalflags), htransaction.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -6486,14 +6484,15 @@ pub unsafe fn FindFirstFileTransactedW<'a, Param0: ::windows::core::IntoParam<'a #[doc = "*Required features: `\"Win32_Storage_FileSystem\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn FindFirstFileW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(lpfilename: Param0, lpfindfiledata: *mut WIN32_FIND_DATAW) -> FindFileHandle { +pub unsafe fn FindFirstFileW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(lpfilename: Param0, lpfindfiledata: *mut WIN32_FIND_DATAW) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn FindFirstFileW(lpfilename: ::windows::core::PCWSTR, lpfindfiledata: *mut WIN32_FIND_DATAW) -> FindFileHandle; } - ::core::mem::transmute(FindFirstFileW(lpfilename.into_param().abi(), ::core::mem::transmute(lpfindfiledata))) + let result__ = FindFirstFileW(lpfilename.into_param().abi(), ::core::mem::transmute(lpfindfiledata)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -6501,84 +6500,90 @@ pub unsafe fn FindFirstFileW<'a, Param0: ::windows::core::IntoParam<'a, ::window #[doc = "*Required features: `\"Win32_Storage_FileSystem\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn FindFirstStreamTransactedW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>, Param4: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>>(lpfilename: Param0, infolevel: STREAM_INFO_LEVELS, lpfindstreamdata: *mut ::core::ffi::c_void, dwflags: u32, htransaction: Param4) -> FindStreamHandle { +pub unsafe fn FindFirstStreamTransactedW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>, Param4: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>>(lpfilename: Param0, infolevel: STREAM_INFO_LEVELS, lpfindstreamdata: *mut ::core::ffi::c_void, dwflags: u32, htransaction: Param4) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn FindFirstStreamTransactedW(lpfilename: ::windows::core::PCWSTR, infolevel: STREAM_INFO_LEVELS, lpfindstreamdata: *mut ::core::ffi::c_void, dwflags: u32, htransaction: super::super::Foundation::HANDLE) -> FindStreamHandle; } - ::core::mem::transmute(FindFirstStreamTransactedW(lpfilename.into_param().abi(), ::core::mem::transmute(infolevel), ::core::mem::transmute(lpfindstreamdata), ::core::mem::transmute(dwflags), htransaction.into_param().abi())) + let result__ = FindFirstStreamTransactedW(lpfilename.into_param().abi(), ::core::mem::transmute(infolevel), ::core::mem::transmute(lpfindstreamdata), ::core::mem::transmute(dwflags), htransaction.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); } #[doc = "*Required features: `\"Win32_Storage_FileSystem\"`*"] #[inline] -pub unsafe fn FindFirstStreamW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(lpfilename: Param0, infolevel: STREAM_INFO_LEVELS, lpfindstreamdata: *mut ::core::ffi::c_void, dwflags: u32) -> FindStreamHandle { +pub unsafe fn FindFirstStreamW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(lpfilename: Param0, infolevel: STREAM_INFO_LEVELS, lpfindstreamdata: *mut ::core::ffi::c_void, dwflags: u32) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn FindFirstStreamW(lpfilename: ::windows::core::PCWSTR, infolevel: STREAM_INFO_LEVELS, lpfindstreamdata: *mut ::core::ffi::c_void, dwflags: u32) -> FindStreamHandle; } - ::core::mem::transmute(FindFirstStreamW(lpfilename.into_param().abi(), ::core::mem::transmute(infolevel), ::core::mem::transmute(lpfindstreamdata), ::core::mem::transmute(dwflags))) + let result__ = FindFirstStreamW(lpfilename.into_param().abi(), ::core::mem::transmute(infolevel), ::core::mem::transmute(lpfindstreamdata), ::core::mem::transmute(dwflags)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); } #[doc = "*Required features: `\"Win32_Storage_FileSystem\"`*"] #[inline] -pub unsafe fn FindFirstVolumeA(lpszvolumename: &mut [u8]) -> FindVolumeHandle { +pub unsafe fn FindFirstVolumeA(lpszvolumename: &mut [u8]) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn FindFirstVolumeA(lpszvolumename: ::windows::core::PSTR, cchbufferlength: u32) -> FindVolumeHandle; } - ::core::mem::transmute(FindFirstVolumeA(::core::mem::transmute(::windows::core::as_mut_ptr_or_null(lpszvolumename)), lpszvolumename.len() as _)) + let result__ = FindFirstVolumeA(::core::mem::transmute(::windows::core::as_mut_ptr_or_null(lpszvolumename)), lpszvolumename.len() as _); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); } #[doc = "*Required features: `\"Win32_Storage_FileSystem\"`*"] #[inline] -pub unsafe fn FindFirstVolumeMountPointA<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(lpszrootpathname: Param0, lpszvolumemountpoint: &mut [u8]) -> FindVolumeMointPointHandle { +pub unsafe fn FindFirstVolumeMountPointA<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(lpszrootpathname: Param0, lpszvolumemountpoint: &mut [u8]) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn FindFirstVolumeMountPointA(lpszrootpathname: ::windows::core::PCSTR, lpszvolumemountpoint: ::windows::core::PSTR, cchbufferlength: u32) -> FindVolumeMointPointHandle; } - ::core::mem::transmute(FindFirstVolumeMountPointA(lpszrootpathname.into_param().abi(), ::core::mem::transmute(::windows::core::as_mut_ptr_or_null(lpszvolumemountpoint)), lpszvolumemountpoint.len() as _)) + let result__ = FindFirstVolumeMountPointA(lpszrootpathname.into_param().abi(), ::core::mem::transmute(::windows::core::as_mut_ptr_or_null(lpszvolumemountpoint)), lpszvolumemountpoint.len() as _); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); } #[doc = "*Required features: `\"Win32_Storage_FileSystem\"`*"] #[inline] -pub unsafe fn FindFirstVolumeMountPointW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(lpszrootpathname: Param0, lpszvolumemountpoint: &mut [u16]) -> FindVolumeMointPointHandle { +pub unsafe fn FindFirstVolumeMountPointW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(lpszrootpathname: Param0, lpszvolumemountpoint: &mut [u16]) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn FindFirstVolumeMountPointW(lpszrootpathname: ::windows::core::PCWSTR, lpszvolumemountpoint: ::windows::core::PWSTR, cchbufferlength: u32) -> FindVolumeMointPointHandle; } - ::core::mem::transmute(FindFirstVolumeMountPointW(lpszrootpathname.into_param().abi(), ::core::mem::transmute(::windows::core::as_mut_ptr_or_null(lpszvolumemountpoint)), lpszvolumemountpoint.len() as _)) + let result__ = FindFirstVolumeMountPointW(lpszrootpathname.into_param().abi(), ::core::mem::transmute(::windows::core::as_mut_ptr_or_null(lpszvolumemountpoint)), lpszvolumemountpoint.len() as _); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); } #[doc = "*Required features: `\"Win32_Storage_FileSystem\"`*"] #[inline] -pub unsafe fn FindFirstVolumeW(lpszvolumename: &mut [u16]) -> FindVolumeHandle { +pub unsafe fn FindFirstVolumeW(lpszvolumename: &mut [u16]) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn FindFirstVolumeW(lpszvolumename: ::windows::core::PWSTR, cchbufferlength: u32) -> FindVolumeHandle; } - ::core::mem::transmute(FindFirstVolumeW(::core::mem::transmute(::windows::core::as_mut_ptr_or_null(lpszvolumename)), lpszvolumename.len() as _)) + let result__ = FindFirstVolumeW(::core::mem::transmute(::windows::core::as_mut_ptr_or_null(lpszvolumename)), lpszvolumename.len() as _); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -6723,14 +6728,7 @@ pub unsafe fn FindNextVolumeW<'a, Param0: ::windows::core::IntoParam<'a, FindVol pub struct FindStreamHandle(pub isize); impl FindStreamHandle { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for FindStreamHandle { @@ -6772,14 +6770,7 @@ pub unsafe fn FindVolumeClose<'a, Param0: ::windows::core::IntoParam<'a, FindVol pub struct FindVolumeHandle(pub isize); impl FindVolumeHandle { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for FindVolumeHandle { @@ -6806,14 +6797,7 @@ unsafe impl ::windows::core::Abi for FindVolumeHandle { pub struct FindVolumeMointPointHandle(pub isize); impl FindVolumeMointPointHandle { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for FindVolumeMointPointHandle { @@ -14464,14 +14448,15 @@ pub unsafe fn OpenEncryptedFileRawW<'a, Param0: ::windows::core::IntoParam<'a, : #[doc = "*Required features: `\"Win32_Storage_FileSystem\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn OpenEnlistment<'a, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>>(dwdesiredaccess: u32, resourcemanagerhandle: Param1, enlistmentid: *mut ::windows::core::GUID) -> super::super::Foundation::HANDLE { +pub unsafe fn OpenEnlistment<'a, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>>(dwdesiredaccess: u32, resourcemanagerhandle: Param1, enlistmentid: *mut ::windows::core::GUID) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn OpenEnlistment(dwdesiredaccess: u32, resourcemanagerhandle: super::super::Foundation::HANDLE, enlistmentid: *mut ::windows::core::GUID) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(OpenEnlistment(::core::mem::transmute(dwdesiredaccess), resourcemanagerhandle.into_param().abi(), ::core::mem::transmute(enlistmentid))) + let result__ = OpenEnlistment(::core::mem::transmute(dwdesiredaccess), resourcemanagerhandle.into_param().abi(), ::core::mem::transmute(enlistmentid)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -14494,14 +14479,15 @@ pub unsafe fn OpenFile<'a, Param0: ::windows::core::IntoParam<'a, ::windows::cor #[doc = "*Required features: `\"Win32_Storage_FileSystem\"`, `\"Win32_Foundation\"`, `\"Win32_Security\"`*"] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Security"))] #[inline] -pub unsafe fn OpenFileById<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>>(hvolumehint: Param0, lpfileid: *const FILE_ID_DESCRIPTOR, dwdesiredaccess: FILE_ACCESS_FLAGS, dwsharemode: FILE_SHARE_MODE, lpsecurityattributes: *const super::super::Security::SECURITY_ATTRIBUTES, dwflagsandattributes: FILE_FLAGS_AND_ATTRIBUTES) -> super::super::Foundation::HANDLE { +pub unsafe fn OpenFileById<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>>(hvolumehint: Param0, lpfileid: *const FILE_ID_DESCRIPTOR, dwdesiredaccess: FILE_ACCESS_FLAGS, dwsharemode: FILE_SHARE_MODE, lpsecurityattributes: *const super::super::Security::SECURITY_ATTRIBUTES, dwflagsandattributes: FILE_FLAGS_AND_ATTRIBUTES) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn OpenFileById(hvolumehint: super::super::Foundation::HANDLE, lpfileid: *const FILE_ID_DESCRIPTOR, dwdesiredaccess: FILE_ACCESS_FLAGS, dwsharemode: FILE_SHARE_MODE, lpsecurityattributes: *const super::super::Security::SECURITY_ATTRIBUTES, dwflagsandattributes: FILE_FLAGS_AND_ATTRIBUTES) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(OpenFileById(hvolumehint.into_param().abi(), ::core::mem::transmute(lpfileid), ::core::mem::transmute(dwdesiredaccess), ::core::mem::transmute(dwsharemode), ::core::mem::transmute(lpsecurityattributes), ::core::mem::transmute(dwflagsandattributes))) + let result__ = OpenFileById(hvolumehint.into_param().abi(), ::core::mem::transmute(lpfileid), ::core::mem::transmute(dwdesiredaccess), ::core::mem::transmute(dwsharemode), ::core::mem::transmute(lpsecurityattributes), ::core::mem::transmute(dwflagsandattributes)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -14509,14 +14495,15 @@ pub unsafe fn OpenFileById<'a, Param0: ::windows::core::IntoParam<'a, super::sup #[doc = "*Required features: `\"Win32_Storage_FileSystem\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn OpenResourceManager<'a, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>>(dwdesiredaccess: u32, tmhandle: Param1, resourcemanagerid: *mut ::windows::core::GUID) -> super::super::Foundation::HANDLE { +pub unsafe fn OpenResourceManager<'a, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>>(dwdesiredaccess: u32, tmhandle: Param1, resourcemanagerid: *mut ::windows::core::GUID) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn OpenResourceManager(dwdesiredaccess: u32, tmhandle: super::super::Foundation::HANDLE, resourcemanagerid: *mut ::windows::core::GUID) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(OpenResourceManager(::core::mem::transmute(dwdesiredaccess), tmhandle.into_param().abi(), ::core::mem::transmute(resourcemanagerid))) + let result__ = OpenResourceManager(::core::mem::transmute(dwdesiredaccess), tmhandle.into_param().abi(), ::core::mem::transmute(resourcemanagerid)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -14524,14 +14511,15 @@ pub unsafe fn OpenResourceManager<'a, Param1: ::windows::core::IntoParam<'a, sup #[doc = "*Required features: `\"Win32_Storage_FileSystem\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn OpenTransaction(dwdesiredaccess: u32, transactionid: *mut ::windows::core::GUID) -> super::super::Foundation::HANDLE { +pub unsafe fn OpenTransaction(dwdesiredaccess: u32, transactionid: *mut ::windows::core::GUID) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn OpenTransaction(dwdesiredaccess: u32, transactionid: *mut ::windows::core::GUID) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(OpenTransaction(::core::mem::transmute(dwdesiredaccess), ::core::mem::transmute(transactionid))) + let result__ = OpenTransaction(::core::mem::transmute(dwdesiredaccess), ::core::mem::transmute(transactionid)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -14539,14 +14527,15 @@ pub unsafe fn OpenTransaction(dwdesiredaccess: u32, transactionid: *mut ::window #[doc = "*Required features: `\"Win32_Storage_FileSystem\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn OpenTransactionManager<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(logfilename: Param0, desiredaccess: u32, openoptions: u32) -> super::super::Foundation::HANDLE { +pub unsafe fn OpenTransactionManager<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(logfilename: Param0, desiredaccess: u32, openoptions: u32) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn OpenTransactionManager(logfilename: ::windows::core::PCWSTR, desiredaccess: u32, openoptions: u32) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(OpenTransactionManager(logfilename.into_param().abi(), ::core::mem::transmute(desiredaccess), ::core::mem::transmute(openoptions))) + let result__ = OpenTransactionManager(logfilename.into_param().abi(), ::core::mem::transmute(desiredaccess), ::core::mem::transmute(openoptions)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -14554,14 +14543,15 @@ pub unsafe fn OpenTransactionManager<'a, Param0: ::windows::core::IntoParam<'a, #[doc = "*Required features: `\"Win32_Storage_FileSystem\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn OpenTransactionManagerById(transactionmanagerid: *const ::windows::core::GUID, desiredaccess: u32, openoptions: u32) -> super::super::Foundation::HANDLE { +pub unsafe fn OpenTransactionManagerById(transactionmanagerid: *const ::windows::core::GUID, desiredaccess: u32, openoptions: u32) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn OpenTransactionManagerById(transactionmanagerid: *const ::windows::core::GUID, desiredaccess: u32, openoptions: u32) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(OpenTransactionManagerById(::core::mem::transmute(transactionmanagerid), ::core::mem::transmute(desiredaccess), ::core::mem::transmute(openoptions))) + let result__ = OpenTransactionManagerById(::core::mem::transmute(transactionmanagerid), ::core::mem::transmute(desiredaccess), ::core::mem::transmute(openoptions)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -15042,14 +15032,15 @@ pub const RESOURCE_MANAGER_VOLATILE: u32 = 1u32; #[doc = "*Required features: `\"Win32_Storage_FileSystem\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn ReOpenFile<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>>(horiginalfile: Param0, dwdesiredaccess: FILE_ACCESS_FLAGS, dwsharemode: FILE_SHARE_MODE, dwflagsandattributes: FILE_FLAGS_AND_ATTRIBUTES) -> super::super::Foundation::HANDLE { +pub unsafe fn ReOpenFile<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>>(horiginalfile: Param0, dwdesiredaccess: FILE_ACCESS_FLAGS, dwsharemode: FILE_SHARE_MODE, dwflagsandattributes: FILE_FLAGS_AND_ATTRIBUTES) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn ReOpenFile(horiginalfile: super::super::Foundation::HANDLE, dwdesiredaccess: FILE_ACCESS_FLAGS, dwsharemode: FILE_SHARE_MODE, dwflagsandattributes: FILE_FLAGS_AND_ATTRIBUTES) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(ReOpenFile(horiginalfile.into_param().abi(), ::core::mem::transmute(dwdesiredaccess), ::core::mem::transmute(dwsharemode), ::core::mem::transmute(dwflagsandattributes))) + let result__ = ReOpenFile(horiginalfile.into_param().abi(), ::core::mem::transmute(dwdesiredaccess), ::core::mem::transmute(dwsharemode), ::core::mem::transmute(dwflagsandattributes)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); diff --git a/crates/libs/windows/src/Windows/Win32/Storage/InstallableFileSystems/mod.rs b/crates/libs/windows/src/Windows/Win32/Storage/InstallableFileSystems/mod.rs index b1f5fc8347..96eb9f10da 100644 --- a/crates/libs/windows/src/Windows/Win32/Storage/InstallableFileSystems/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/Storage/InstallableFileSystems/mod.rs @@ -695,14 +695,7 @@ pub unsafe fn FilterFindFirst(dwinformationclass: FILTER_INFORMATION_CLASS, lpbu pub struct FilterFindHandle(pub isize); impl FilterFindHandle { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for FilterFindHandle { @@ -845,14 +838,7 @@ pub unsafe fn FilterInstanceFindFirst<'a, Param0: ::windows::core::IntoParam<'a, pub struct FilterInstanceFindHandle(pub isize); impl FilterInstanceFindHandle { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for FilterInstanceFindHandle { @@ -995,14 +981,7 @@ pub unsafe fn FilterVolumeFindFirst(dwinformationclass: FILTER_VOLUME_INFORMATIO pub struct FilterVolumeFindHandle(pub isize); impl FilterVolumeFindHandle { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for FilterVolumeFindHandle { @@ -1073,14 +1052,7 @@ pub unsafe fn FilterVolumeInstanceFindFirst<'a, Param0: ::windows::core::IntoPar pub struct FilterVolumeInstanceFindHandle(pub isize); impl FilterVolumeInstanceFindHandle { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for FilterVolumeInstanceFindHandle { @@ -1122,14 +1094,7 @@ pub unsafe fn FilterVolumeInstanceFindNext<'a, Param0: ::windows::core::IntoPara pub struct HFILTER(pub isize); impl HFILTER { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HFILTER { @@ -1156,14 +1121,7 @@ unsafe impl ::windows::core::Abi for HFILTER { pub struct HFILTER_INSTANCE(pub isize); impl HFILTER_INSTANCE { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HFILTER_INSTANCE { diff --git a/crates/libs/windows/src/Windows/Win32/Storage/Jet/mod.rs b/crates/libs/windows/src/Windows/Win32/Storage/Jet/mod.rs index 36ec002d0c..6c0eb24cf3 100644 --- a/crates/libs/windows/src/Windows/Win32/Storage/Jet/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/Storage/Jet/mod.rs @@ -2670,14 +2670,7 @@ impl ::core::default::Default for JET_LOGTIME_1_0 { pub struct JET_LS(pub usize); impl JET_LS { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == 0 } } impl ::core::default::Default for JET_LS { @@ -2978,14 +2971,7 @@ impl ::core::default::Default for JET_OPERATIONCONTEXT { pub struct JET_OSSNAPID(pub usize); impl JET_OSSNAPID { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == 0 } } impl ::core::default::Default for JET_OSSNAPID { diff --git a/crates/libs/windows/src/Windows/Win32/Storage/ProjectedFileSystem/mod.rs b/crates/libs/windows/src/Windows/Win32/Storage/ProjectedFileSystem/mod.rs index ca2b254a16..fedc5d3e1a 100644 --- a/crates/libs/windows/src/Windows/Win32/Storage/ProjectedFileSystem/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/Storage/ProjectedFileSystem/mod.rs @@ -278,14 +278,7 @@ impl ::core::fmt::Debug for PRJ_COMPLETE_COMMAND_TYPE { pub struct PRJ_DIR_ENTRY_BUFFER_HANDLE(pub isize); impl PRJ_DIR_ENTRY_BUFFER_HANDLE { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for PRJ_DIR_ENTRY_BUFFER_HANDLE { @@ -532,14 +525,7 @@ pub type PRJ_GET_PLACEHOLDER_INFO_CB = ::core::option::Option bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for PRJ_NAMESPACE_VIRTUALIZATION_CONTEXT { diff --git a/crates/libs/windows/src/Windows/Win32/Storage/StructuredStorage/mod.rs b/crates/libs/windows/src/Windows/Win32/Storage/StructuredStorage/mod.rs index 7df5274caa..94e2bfe07c 100644 --- a/crates/libs/windows/src/Windows/Win32/Storage/StructuredStorage/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/Storage/StructuredStorage/mod.rs @@ -4,14 +4,7 @@ pub struct JET_API_PTR(pub usize); impl JET_API_PTR { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == 0 } } impl ::core::default::Default for JET_API_PTR { @@ -38,14 +31,7 @@ unsafe impl ::windows::core::Abi for JET_API_PTR { pub struct JET_HANDLE(pub usize); impl JET_HANDLE { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == 0 } } impl ::core::default::Default for JET_HANDLE { @@ -72,14 +58,7 @@ unsafe impl ::windows::core::Abi for JET_HANDLE { pub struct JET_INSTANCE(pub usize); impl JET_INSTANCE { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == 0 } } impl ::core::default::Default for JET_INSTANCE { @@ -106,14 +85,7 @@ unsafe impl ::windows::core::Abi for JET_INSTANCE { pub struct JET_SESID(pub usize); impl JET_SESID { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == 0 } } impl ::core::default::Default for JET_SESID { @@ -140,14 +112,7 @@ unsafe impl ::windows::core::Abi for JET_SESID { pub struct JET_TABLEID(pub usize); impl JET_TABLEID { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == 0 } } impl ::core::default::Default for JET_TABLEID { diff --git a/crates/libs/windows/src/Windows/Win32/Storage/Xps/mod.rs b/crates/libs/windows/src/Windows/Win32/Storage/Xps/mod.rs index 66cb4868c1..4801cbf741 100644 --- a/crates/libs/windows/src/Windows/Win32/Storage/Xps/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/Storage/Xps/mod.rs @@ -306,14 +306,7 @@ pub unsafe fn ExtEscape<'a, Param0: ::windows::core::IntoParam<'a, super::super: pub struct HPTPROVIDER(pub isize); impl HPTPROVIDER { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HPTPROVIDER { diff --git a/crates/libs/windows/src/Windows/Win32/System/Antimalware/mod.rs b/crates/libs/windows/src/Windows/Win32/System/Antimalware/mod.rs index 976907a459..fb6c468b0c 100644 --- a/crates/libs/windows/src/Windows/Win32/System/Antimalware/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/System/Antimalware/mod.rs @@ -540,14 +540,7 @@ pub const CAntimalware: ::windows::core::GUID = ::windows::core::GUID::from_u128 pub struct HAMSICONTEXT(pub isize); impl HAMSICONTEXT { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HAMSICONTEXT { @@ -574,14 +567,7 @@ unsafe impl ::windows::core::Abi for HAMSICONTEXT { pub struct HAMSISESSION(pub isize); impl HAMSISESSION { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HAMSISESSION { diff --git a/crates/libs/windows/src/Windows/Win32/System/ApplicationInstallationAndServicing/mod.rs b/crates/libs/windows/src/Windows/Win32/System/ApplicationInstallationAndServicing/mod.rs index dcaea2f856..c8c7e36121 100644 --- a/crates/libs/windows/src/Windows/Win32/System/ApplicationInstallationAndServicing/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/System/ApplicationInstallationAndServicing/mod.rs @@ -1022,14 +1022,15 @@ impl ::core::fmt::Debug for CREATE_ASM_NAME_OBJ_FLAGS { #[doc = "*Required features: `\"Win32_System_ApplicationInstallationAndServicing\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn CreateActCtxA(pactctx: *const ACTCTXA) -> super::super::Foundation::HANDLE { +pub unsafe fn CreateActCtxA(pactctx: *const ACTCTXA) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateActCtxA(pactctx: *const ACTCTXA) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(CreateActCtxA(::core::mem::transmute(pactctx))) + let result__ = CreateActCtxA(::core::mem::transmute(pactctx)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -1037,14 +1038,15 @@ pub unsafe fn CreateActCtxA(pactctx: *const ACTCTXA) -> super::super::Foundation #[doc = "*Required features: `\"Win32_System_ApplicationInstallationAndServicing\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn CreateActCtxW(pactctx: *const ACTCTXW) -> super::super::Foundation::HANDLE { +pub unsafe fn CreateActCtxW(pactctx: *const ACTCTXW) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateActCtxW(pactctx: *const ACTCTXW) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(CreateActCtxW(::core::mem::transmute(pactctx))) + let result__ = CreateActCtxW(::core::mem::transmute(pactctx)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -7945,14 +7947,7 @@ impl ::core::default::Default for MSIFILEHASHINFO { pub struct MSIHANDLE(pub u32); impl MSIHANDLE { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for MSIHANDLE { diff --git a/crates/libs/windows/src/Windows/Win32/System/Com/mod.rs b/crates/libs/windows/src/Windows/Win32/System/Com/mod.rs index 938f415b03..15f457924a 100644 --- a/crates/libs/windows/src/Windows/Win32/System/Com/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/System/Com/mod.rs @@ -1714,14 +1714,7 @@ impl ::core::fmt::Debug for COWAIT_FLAGS { pub struct CO_DEVICE_CATALOG_COOKIE(pub isize); impl CO_DEVICE_CATALOG_COOKIE { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for CO_DEVICE_CATALOG_COOKIE { @@ -1809,14 +1802,7 @@ impl ::core::fmt::Debug for CO_MARSHALING_CONTEXT_ATTRIBUTES { pub struct CO_MTA_USAGE_COOKIE(pub isize); impl CO_MTA_USAGE_COOKIE { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for CO_MTA_USAGE_COOKIE { diff --git a/crates/libs/windows/src/Windows/Win32/System/Console/mod.rs b/crates/libs/windows/src/Windows/Win32/System/Console/mod.rs index db279b7bf7..9e68d4d4da 100644 --- a/crates/libs/windows/src/Windows/Win32/System/Console/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/System/Console/mod.rs @@ -597,14 +597,15 @@ pub unsafe fn ClosePseudoConsole<'a, Param0: ::windows::core::IntoParam<'a, HPCO #[doc = "*Required features: `\"Win32_System_Console\"`, `\"Win32_Foundation\"`, `\"Win32_Security\"`*"] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Security"))] #[inline] -pub unsafe fn CreateConsoleScreenBuffer(dwdesiredaccess: u32, dwsharemode: u32, lpsecurityattributes: *const super::super::Security::SECURITY_ATTRIBUTES, dwflags: u32, lpscreenbufferdata: *mut ::core::ffi::c_void) -> super::super::Foundation::HANDLE { +pub unsafe fn CreateConsoleScreenBuffer(dwdesiredaccess: u32, dwsharemode: u32, lpsecurityattributes: *const super::super::Security::SECURITY_ATTRIBUTES, dwflags: u32, lpscreenbufferdata: *mut ::core::ffi::c_void) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateConsoleScreenBuffer(dwdesiredaccess: u32, dwsharemode: u32, lpsecurityattributes: *const super::super::Security::SECURITY_ATTRIBUTES, dwflags: u32, lpscreenbufferdata: *mut ::core::ffi::c_void) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(CreateConsoleScreenBuffer(::core::mem::transmute(dwdesiredaccess), ::core::mem::transmute(dwsharemode), ::core::mem::transmute(lpsecurityattributes), ::core::mem::transmute(dwflags), ::core::mem::transmute(lpscreenbufferdata))) + let result__ = CreateConsoleScreenBuffer(::core::mem::transmute(dwdesiredaccess), ::core::mem::transmute(dwsharemode), ::core::mem::transmute(lpsecurityattributes), ::core::mem::transmute(dwflags), ::core::mem::transmute(lpscreenbufferdata)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -1310,14 +1311,15 @@ pub unsafe fn GetNumberOfConsoleMouseButtons(lpnumberofmousebuttons: *mut u32) - #[doc = "*Required features: `\"Win32_System_Console\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn GetStdHandle(nstdhandle: STD_HANDLE) -> super::super::Foundation::HANDLE { +pub unsafe fn GetStdHandle(nstdhandle: STD_HANDLE) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn GetStdHandle(nstdhandle: STD_HANDLE) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(GetStdHandle(::core::mem::transmute(nstdhandle))) + let result__ = GetStdHandle(::core::mem::transmute(nstdhandle)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -1329,14 +1331,7 @@ pub const HISTORY_NO_DUP_FLAG: u32 = 1u32; pub struct HPCON(pub isize); impl HPCON { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HPCON { diff --git a/crates/libs/windows/src/Windows/Win32/System/DataExchange/mod.rs b/crates/libs/windows/src/Windows/Win32/System/DataExchange/mod.rs index b4982cde0c..7fc25da6d5 100644 --- a/crates/libs/windows/src/Windows/Win32/System/DataExchange/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/System/DataExchange/mod.rs @@ -1442,14 +1442,15 @@ pub unsafe fn GetAtomNameW(natom: u16, lpbuffer: &mut [u16]) -> u32 { #[doc = "*Required features: `\"Win32_System_DataExchange\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn GetClipboardData(uformat: u32) -> super::super::Foundation::HANDLE { +pub unsafe fn GetClipboardData(uformat: u32) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn GetClipboardData(uformat: u32) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(GetClipboardData(::core::mem::transmute(uformat))) + let result__ = GetClipboardData(::core::mem::transmute(uformat)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -1701,14 +1702,7 @@ pub unsafe fn GlobalGetAtomNameW(natom: u16, lpbuffer: &mut [u16]) -> u32 { pub struct HCONV(pub isize); impl HCONV { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HCONV { @@ -1735,14 +1729,7 @@ unsafe impl ::windows::core::Abi for HCONV { pub struct HCONVLIST(pub isize); impl HCONVLIST { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HCONVLIST { @@ -1771,14 +1758,7 @@ pub const HDATA_APPOWNED: u32 = 1u32; pub struct HDDEDATA(pub isize); impl HDDEDATA { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == 0 } } impl ::core::default::Default for HDDEDATA { @@ -1805,14 +1785,7 @@ unsafe impl ::windows::core::Abi for HDDEDATA { pub struct HSZ(pub isize); impl HSZ { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HSZ { @@ -2394,14 +2367,15 @@ pub const SZDDE_ITEM_ITEMLIST: &'static str = "TopicItemList"; #[doc = "*Required features: `\"Win32_System_DataExchange\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn SetClipboardData<'a, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>>(uformat: u32, hmem: Param1) -> super::super::Foundation::HANDLE { +pub unsafe fn SetClipboardData<'a, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>>(uformat: u32, hmem: Param1) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn SetClipboardData(uformat: u32, hmem: super::super::Foundation::HANDLE) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(SetClipboardData(::core::mem::transmute(uformat), hmem.into_param().abi())) + let result__ = SetClipboardData(::core::mem::transmute(uformat), hmem.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); diff --git a/crates/libs/windows/src/Windows/Win32/System/Diagnostics/Debug/mod.rs b/crates/libs/windows/src/Windows/Win32/System/Diagnostics/Debug/mod.rs index b23b754af7..30ecd37ef5 100644 --- a/crates/libs/windows/src/Windows/Win32/System/Diagnostics/Debug/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/System/Diagnostics/Debug/mod.rs @@ -9136,14 +9136,15 @@ pub unsafe fn FatalExit(exitcode: i32) -> ! { #[doc = "*Required features: `\"Win32_System_Diagnostics_Debug\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn FindDebugInfoFile<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(filename: Param0, symbolpath: Param1, debugfilepath: ::windows::core::PSTR) -> super::super::super::Foundation::HANDLE { +pub unsafe fn FindDebugInfoFile<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(filename: Param0, symbolpath: Param1, debugfilepath: ::windows::core::PSTR) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn FindDebugInfoFile(filename: ::windows::core::PCSTR, symbolpath: ::windows::core::PCSTR, debugfilepath: ::windows::core::PSTR) -> super::super::super::Foundation::HANDLE; } - ::core::mem::transmute(FindDebugInfoFile(filename.into_param().abi(), symbolpath.into_param().abi(), ::core::mem::transmute(debugfilepath))) + let result__ = FindDebugInfoFile(filename.into_param().abi(), symbolpath.into_param().abi(), ::core::mem::transmute(debugfilepath)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -9151,14 +9152,15 @@ pub unsafe fn FindDebugInfoFile<'a, Param0: ::windows::core::IntoParam<'a, ::win #[doc = "*Required features: `\"Win32_System_Diagnostics_Debug\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn FindDebugInfoFileEx<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(filename: Param0, symbolpath: Param1, debugfilepath: ::windows::core::PSTR, callback: PFIND_DEBUG_FILE_CALLBACK, callerdata: *const ::core::ffi::c_void) -> super::super::super::Foundation::HANDLE { +pub unsafe fn FindDebugInfoFileEx<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(filename: Param0, symbolpath: Param1, debugfilepath: ::windows::core::PSTR, callback: PFIND_DEBUG_FILE_CALLBACK, callerdata: *const ::core::ffi::c_void) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn FindDebugInfoFileEx(filename: ::windows::core::PCSTR, symbolpath: ::windows::core::PCSTR, debugfilepath: ::windows::core::PSTR, callback: ::windows::core::RawPtr, callerdata: *const ::core::ffi::c_void) -> super::super::super::Foundation::HANDLE; } - ::core::mem::transmute(FindDebugInfoFileEx(filename.into_param().abi(), symbolpath.into_param().abi(), ::core::mem::transmute(debugfilepath), ::core::mem::transmute(callback), ::core::mem::transmute(callerdata))) + let result__ = FindDebugInfoFileEx(filename.into_param().abi(), symbolpath.into_param().abi(), ::core::mem::transmute(debugfilepath), ::core::mem::transmute(callback), ::core::mem::transmute(callerdata)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -9166,14 +9168,15 @@ pub unsafe fn FindDebugInfoFileEx<'a, Param0: ::windows::core::IntoParam<'a, ::w #[doc = "*Required features: `\"Win32_System_Diagnostics_Debug\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn FindDebugInfoFileExW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(filename: Param0, symbolpath: Param1, debugfilepath: ::windows::core::PWSTR, callback: PFIND_DEBUG_FILE_CALLBACKW, callerdata: *const ::core::ffi::c_void) -> super::super::super::Foundation::HANDLE { +pub unsafe fn FindDebugInfoFileExW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(filename: Param0, symbolpath: Param1, debugfilepath: ::windows::core::PWSTR, callback: PFIND_DEBUG_FILE_CALLBACKW, callerdata: *const ::core::ffi::c_void) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn FindDebugInfoFileExW(filename: ::windows::core::PCWSTR, symbolpath: ::windows::core::PCWSTR, debugfilepath: ::windows::core::PWSTR, callback: ::windows::core::RawPtr, callerdata: *const ::core::ffi::c_void) -> super::super::super::Foundation::HANDLE; } - ::core::mem::transmute(FindDebugInfoFileExW(filename.into_param().abi(), symbolpath.into_param().abi(), ::core::mem::transmute(debugfilepath), ::core::mem::transmute(callback), ::core::mem::transmute(callerdata))) + let result__ = FindDebugInfoFileExW(filename.into_param().abi(), symbolpath.into_param().abi(), ::core::mem::transmute(debugfilepath), ::core::mem::transmute(callback), ::core::mem::transmute(callerdata)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -9181,14 +9184,15 @@ pub unsafe fn FindDebugInfoFileExW<'a, Param0: ::windows::core::IntoParam<'a, :: #[doc = "*Required features: `\"Win32_System_Diagnostics_Debug\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn FindExecutableImage<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(filename: Param0, symbolpath: Param1, imagefilepath: ::windows::core::PSTR) -> super::super::super::Foundation::HANDLE { +pub unsafe fn FindExecutableImage<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(filename: Param0, symbolpath: Param1, imagefilepath: ::windows::core::PSTR) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn FindExecutableImage(filename: ::windows::core::PCSTR, symbolpath: ::windows::core::PCSTR, imagefilepath: ::windows::core::PSTR) -> super::super::super::Foundation::HANDLE; } - ::core::mem::transmute(FindExecutableImage(filename.into_param().abi(), symbolpath.into_param().abi(), ::core::mem::transmute(imagefilepath))) + let result__ = FindExecutableImage(filename.into_param().abi(), symbolpath.into_param().abi(), ::core::mem::transmute(imagefilepath)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -9196,14 +9200,15 @@ pub unsafe fn FindExecutableImage<'a, Param0: ::windows::core::IntoParam<'a, ::w #[doc = "*Required features: `\"Win32_System_Diagnostics_Debug\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn FindExecutableImageEx<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(filename: Param0, symbolpath: Param1, imagefilepath: ::windows::core::PSTR, callback: PFIND_EXE_FILE_CALLBACK, callerdata: *const ::core::ffi::c_void) -> super::super::super::Foundation::HANDLE { +pub unsafe fn FindExecutableImageEx<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(filename: Param0, symbolpath: Param1, imagefilepath: ::windows::core::PSTR, callback: PFIND_EXE_FILE_CALLBACK, callerdata: *const ::core::ffi::c_void) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn FindExecutableImageEx(filename: ::windows::core::PCSTR, symbolpath: ::windows::core::PCSTR, imagefilepath: ::windows::core::PSTR, callback: ::windows::core::RawPtr, callerdata: *const ::core::ffi::c_void) -> super::super::super::Foundation::HANDLE; } - ::core::mem::transmute(FindExecutableImageEx(filename.into_param().abi(), symbolpath.into_param().abi(), ::core::mem::transmute(imagefilepath), ::core::mem::transmute(callback), ::core::mem::transmute(callerdata))) + let result__ = FindExecutableImageEx(filename.into_param().abi(), symbolpath.into_param().abi(), ::core::mem::transmute(imagefilepath), ::core::mem::transmute(callback), ::core::mem::transmute(callerdata)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -9211,14 +9216,15 @@ pub unsafe fn FindExecutableImageEx<'a, Param0: ::windows::core::IntoParam<'a, : #[doc = "*Required features: `\"Win32_System_Diagnostics_Debug\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn FindExecutableImageExW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(filename: Param0, symbolpath: Param1, imagefilepath: ::windows::core::PWSTR, callback: PFIND_EXE_FILE_CALLBACKW, callerdata: *const ::core::ffi::c_void) -> super::super::super::Foundation::HANDLE { +pub unsafe fn FindExecutableImageExW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(filename: Param0, symbolpath: Param1, imagefilepath: ::windows::core::PWSTR, callback: PFIND_EXE_FILE_CALLBACKW, callerdata: *const ::core::ffi::c_void) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn FindExecutableImageExW(filename: ::windows::core::PCWSTR, symbolpath: ::windows::core::PCWSTR, imagefilepath: ::windows::core::PWSTR, callback: ::windows::core::RawPtr, callerdata: *const ::core::ffi::c_void) -> super::super::super::Foundation::HANDLE; } - ::core::mem::transmute(FindExecutableImageExW(filename.into_param().abi(), symbolpath.into_param().abi(), ::core::mem::transmute(imagefilepath), ::core::mem::transmute(callback), ::core::mem::transmute(callerdata))) + let result__ = FindExecutableImageExW(filename.into_param().abi(), symbolpath.into_param().abi(), ::core::mem::transmute(imagefilepath), ::core::mem::transmute(callback), ::core::mem::transmute(callerdata)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -58633,14 +58639,15 @@ pub unsafe fn SymEnumerateSymbolsW64<'a, Param0: ::windows::core::IntoParam<'a, #[doc = "*Required features: `\"Win32_System_Diagnostics_Debug\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn SymFindDebugInfoFile<'a, Param0: ::windows::core::IntoParam<'a, super::super::super::Foundation::HANDLE>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(hprocess: Param0, filename: Param1, debugfilepath: ::windows::core::PSTR, callback: PFIND_DEBUG_FILE_CALLBACK, callerdata: *const ::core::ffi::c_void) -> super::super::super::Foundation::HANDLE { +pub unsafe fn SymFindDebugInfoFile<'a, Param0: ::windows::core::IntoParam<'a, super::super::super::Foundation::HANDLE>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(hprocess: Param0, filename: Param1, debugfilepath: ::windows::core::PSTR, callback: PFIND_DEBUG_FILE_CALLBACK, callerdata: *const ::core::ffi::c_void) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn SymFindDebugInfoFile(hprocess: super::super::super::Foundation::HANDLE, filename: ::windows::core::PCSTR, debugfilepath: ::windows::core::PSTR, callback: ::windows::core::RawPtr, callerdata: *const ::core::ffi::c_void) -> super::super::super::Foundation::HANDLE; } - ::core::mem::transmute(SymFindDebugInfoFile(hprocess.into_param().abi(), filename.into_param().abi(), ::core::mem::transmute(debugfilepath), ::core::mem::transmute(callback), ::core::mem::transmute(callerdata))) + let result__ = SymFindDebugInfoFile(hprocess.into_param().abi(), filename.into_param().abi(), ::core::mem::transmute(debugfilepath), ::core::mem::transmute(callback), ::core::mem::transmute(callerdata)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -58648,14 +58655,15 @@ pub unsafe fn SymFindDebugInfoFile<'a, Param0: ::windows::core::IntoParam<'a, su #[doc = "*Required features: `\"Win32_System_Diagnostics_Debug\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn SymFindDebugInfoFileW<'a, Param0: ::windows::core::IntoParam<'a, super::super::super::Foundation::HANDLE>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(hprocess: Param0, filename: Param1, debugfilepath: ::windows::core::PWSTR, callback: PFIND_DEBUG_FILE_CALLBACKW, callerdata: *const ::core::ffi::c_void) -> super::super::super::Foundation::HANDLE { +pub unsafe fn SymFindDebugInfoFileW<'a, Param0: ::windows::core::IntoParam<'a, super::super::super::Foundation::HANDLE>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(hprocess: Param0, filename: Param1, debugfilepath: ::windows::core::PWSTR, callback: PFIND_DEBUG_FILE_CALLBACKW, callerdata: *const ::core::ffi::c_void) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn SymFindDebugInfoFileW(hprocess: super::super::super::Foundation::HANDLE, filename: ::windows::core::PCWSTR, debugfilepath: ::windows::core::PWSTR, callback: ::windows::core::RawPtr, callerdata: *const ::core::ffi::c_void) -> super::super::super::Foundation::HANDLE; } - ::core::mem::transmute(SymFindDebugInfoFileW(hprocess.into_param().abi(), filename.into_param().abi(), ::core::mem::transmute(debugfilepath), ::core::mem::transmute(callback), ::core::mem::transmute(callerdata))) + let result__ = SymFindDebugInfoFileW(hprocess.into_param().abi(), filename.into_param().abi(), ::core::mem::transmute(debugfilepath), ::core::mem::transmute(callback), ::core::mem::transmute(callerdata)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -58663,14 +58671,15 @@ pub unsafe fn SymFindDebugInfoFileW<'a, Param0: ::windows::core::IntoParam<'a, s #[doc = "*Required features: `\"Win32_System_Diagnostics_Debug\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn SymFindExecutableImage<'a, Param0: ::windows::core::IntoParam<'a, super::super::super::Foundation::HANDLE>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(hprocess: Param0, filename: Param1, imagefilepath: ::windows::core::PSTR, callback: PFIND_EXE_FILE_CALLBACK, callerdata: *const ::core::ffi::c_void) -> super::super::super::Foundation::HANDLE { +pub unsafe fn SymFindExecutableImage<'a, Param0: ::windows::core::IntoParam<'a, super::super::super::Foundation::HANDLE>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(hprocess: Param0, filename: Param1, imagefilepath: ::windows::core::PSTR, callback: PFIND_EXE_FILE_CALLBACK, callerdata: *const ::core::ffi::c_void) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn SymFindExecutableImage(hprocess: super::super::super::Foundation::HANDLE, filename: ::windows::core::PCSTR, imagefilepath: ::windows::core::PSTR, callback: ::windows::core::RawPtr, callerdata: *const ::core::ffi::c_void) -> super::super::super::Foundation::HANDLE; } - ::core::mem::transmute(SymFindExecutableImage(hprocess.into_param().abi(), filename.into_param().abi(), ::core::mem::transmute(imagefilepath), ::core::mem::transmute(callback), ::core::mem::transmute(callerdata))) + let result__ = SymFindExecutableImage(hprocess.into_param().abi(), filename.into_param().abi(), ::core::mem::transmute(imagefilepath), ::core::mem::transmute(callback), ::core::mem::transmute(callerdata)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -58678,14 +58687,15 @@ pub unsafe fn SymFindExecutableImage<'a, Param0: ::windows::core::IntoParam<'a, #[doc = "*Required features: `\"Win32_System_Diagnostics_Debug\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn SymFindExecutableImageW<'a, Param0: ::windows::core::IntoParam<'a, super::super::super::Foundation::HANDLE>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(hprocess: Param0, filename: Param1, imagefilepath: ::windows::core::PWSTR, callback: PFIND_EXE_FILE_CALLBACKW, callerdata: *const ::core::ffi::c_void) -> super::super::super::Foundation::HANDLE { +pub unsafe fn SymFindExecutableImageW<'a, Param0: ::windows::core::IntoParam<'a, super::super::super::Foundation::HANDLE>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(hprocess: Param0, filename: Param1, imagefilepath: ::windows::core::PWSTR, callback: PFIND_EXE_FILE_CALLBACKW, callerdata: *const ::core::ffi::c_void) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn SymFindExecutableImageW(hprocess: super::super::super::Foundation::HANDLE, filename: ::windows::core::PCWSTR, imagefilepath: ::windows::core::PWSTR, callback: ::windows::core::RawPtr, callerdata: *const ::core::ffi::c_void) -> super::super::super::Foundation::HANDLE; } - ::core::mem::transmute(SymFindExecutableImageW(hprocess.into_param().abi(), filename.into_param().abi(), ::core::mem::transmute(imagefilepath), ::core::mem::transmute(callback), ::core::mem::transmute(callerdata))) + let result__ = SymFindExecutableImageW(hprocess.into_param().abi(), filename.into_param().abi(), ::core::mem::transmute(imagefilepath), ::core::mem::transmute(callback), ::core::mem::transmute(callerdata)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); diff --git a/crates/libs/windows/src/Windows/Win32/System/Diagnostics/Etw/mod.rs b/crates/libs/windows/src/Windows/Win32/System/Diagnostics/Etw/mod.rs index 662208ed2d..099cd9191a 100644 --- a/crates/libs/windows/src/Windows/Win32/System/Diagnostics/Etw/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/System/Diagnostics/Etw/mod.rs @@ -5325,14 +5325,7 @@ impl ::core::fmt::Debug for TDH_CONTEXT_TYPE { pub struct TDH_HANDLE(pub isize); impl TDH_HANDLE { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for TDH_HANDLE { diff --git a/crates/libs/windows/src/Windows/Win32/System/Diagnostics/ProcessSnapshotting/mod.rs b/crates/libs/windows/src/Windows/Win32/System/Diagnostics/ProcessSnapshotting/mod.rs index db83d02291..8b3b69b795 100644 --- a/crates/libs/windows/src/Windows/Win32/System/Diagnostics/ProcessSnapshotting/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/System/Diagnostics/ProcessSnapshotting/mod.rs @@ -4,14 +4,7 @@ pub struct HPSS(pub isize); impl HPSS { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HPSS { @@ -38,14 +31,7 @@ unsafe impl ::windows::core::Abi for HPSS { pub struct HPSSWALK(pub isize); impl HPSSWALK { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HPSSWALK { diff --git a/crates/libs/windows/src/Windows/Win32/System/Diagnostics/ToolHelp/mod.rs b/crates/libs/windows/src/Windows/Win32/System/Diagnostics/ToolHelp/mod.rs index 373502cd29..c648080007 100644 --- a/crates/libs/windows/src/Windows/Win32/System/Diagnostics/ToolHelp/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/System/Diagnostics/ToolHelp/mod.rs @@ -67,14 +67,15 @@ impl ::core::ops::Not for CREATE_TOOLHELP_SNAPSHOT_FLAGS { #[doc = "*Required features: `\"Win32_System_Diagnostics_ToolHelp\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn CreateToolhelp32Snapshot(dwflags: CREATE_TOOLHELP_SNAPSHOT_FLAGS, th32processid: u32) -> super::super::super::Foundation::HANDLE { +pub unsafe fn CreateToolhelp32Snapshot(dwflags: CREATE_TOOLHELP_SNAPSHOT_FLAGS, th32processid: u32) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateToolhelp32Snapshot(dwflags: CREATE_TOOLHELP_SNAPSHOT_FLAGS, th32processid: u32) -> super::super::super::Foundation::HANDLE; } - ::core::mem::transmute(CreateToolhelp32Snapshot(::core::mem::transmute(dwflags), ::core::mem::transmute(th32processid))) + let result__ = CreateToolhelp32Snapshot(::core::mem::transmute(dwflags), ::core::mem::transmute(th32processid)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); diff --git a/crates/libs/windows/src/Windows/Win32/System/ErrorReporting/mod.rs b/crates/libs/windows/src/Windows/Win32/System/ErrorReporting/mod.rs index 6104f6e6f1..d6a66ffffc 100644 --- a/crates/libs/windows/src/Windows/Win32/System/ErrorReporting/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/System/ErrorReporting/mod.rs @@ -81,14 +81,7 @@ impl ::core::fmt::Debug for EFaultRepRetVal { pub struct HREPORT(pub isize); impl HREPORT { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HREPORT { @@ -115,14 +108,7 @@ unsafe impl ::windows::core::Abi for HREPORT { pub struct HREPORTSTORE(pub isize); impl HREPORTSTORE { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HREPORTSTORE { diff --git a/crates/libs/windows/src/Windows/Win32/System/EventLog/mod.rs b/crates/libs/windows/src/Windows/Win32/System/EventLog/mod.rs index d176ab354f..ec977c0687 100644 --- a/crates/libs/windows/src/Windows/Win32/System/EventLog/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/System/EventLog/mod.rs @@ -1276,14 +1276,7 @@ pub const EVT_WRITE_ACCESS: u32 = 2u32; pub struct EventLogHandle(pub isize); impl EventLogHandle { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for EventLogHandle { @@ -1310,14 +1303,7 @@ unsafe impl ::windows::core::Abi for EventLogHandle { pub struct EventSourceHandle(pub isize); impl EventSourceHandle { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for EventSourceHandle { @@ -1914,56 +1900,60 @@ pub unsafe fn NotifyChangeEventLog<'a, Param0: ::windows::core::IntoParam<'a, Ev } #[doc = "*Required features: `\"Win32_System_EventLog\"`*"] #[inline] -pub unsafe fn OpenBackupEventLogA<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(lpuncservername: Param0, lpfilename: Param1) -> EventLogHandle { +pub unsafe fn OpenBackupEventLogA<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(lpuncservername: Param0, lpfilename: Param1) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn OpenBackupEventLogA(lpuncservername: ::windows::core::PCSTR, lpfilename: ::windows::core::PCSTR) -> EventLogHandle; } - ::core::mem::transmute(OpenBackupEventLogA(lpuncservername.into_param().abi(), lpfilename.into_param().abi())) + let result__ = OpenBackupEventLogA(lpuncservername.into_param().abi(), lpfilename.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); } #[doc = "*Required features: `\"Win32_System_EventLog\"`*"] #[inline] -pub unsafe fn OpenBackupEventLogW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(lpuncservername: Param0, lpfilename: Param1) -> EventLogHandle { +pub unsafe fn OpenBackupEventLogW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(lpuncservername: Param0, lpfilename: Param1) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn OpenBackupEventLogW(lpuncservername: ::windows::core::PCWSTR, lpfilename: ::windows::core::PCWSTR) -> EventLogHandle; } - ::core::mem::transmute(OpenBackupEventLogW(lpuncservername.into_param().abi(), lpfilename.into_param().abi())) + let result__ = OpenBackupEventLogW(lpuncservername.into_param().abi(), lpfilename.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); } #[doc = "*Required features: `\"Win32_System_EventLog\"`*"] #[inline] -pub unsafe fn OpenEventLogA<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(lpuncservername: Param0, lpsourcename: Param1) -> EventLogHandle { +pub unsafe fn OpenEventLogA<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(lpuncservername: Param0, lpsourcename: Param1) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn OpenEventLogA(lpuncservername: ::windows::core::PCSTR, lpsourcename: ::windows::core::PCSTR) -> EventLogHandle; } - ::core::mem::transmute(OpenEventLogA(lpuncservername.into_param().abi(), lpsourcename.into_param().abi())) + let result__ = OpenEventLogA(lpuncservername.into_param().abi(), lpsourcename.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); } #[doc = "*Required features: `\"Win32_System_EventLog\"`*"] #[inline] -pub unsafe fn OpenEventLogW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(lpuncservername: Param0, lpsourcename: Param1) -> EventLogHandle { +pub unsafe fn OpenEventLogW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(lpuncservername: Param0, lpsourcename: Param1) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn OpenEventLogW(lpuncservername: ::windows::core::PCWSTR, lpsourcename: ::windows::core::PCWSTR) -> EventLogHandle; } - ::core::mem::transmute(OpenEventLogW(lpuncservername.into_param().abi(), lpsourcename.into_param().abi())) + let result__ = OpenEventLogW(lpuncservername.into_param().abi(), lpsourcename.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -2062,28 +2052,30 @@ pub unsafe fn ReadEventLogW<'a, Param0: ::windows::core::IntoParam<'a, EventLogH } #[doc = "*Required features: `\"Win32_System_EventLog\"`*"] #[inline] -pub unsafe fn RegisterEventSourceA<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(lpuncservername: Param0, lpsourcename: Param1) -> EventSourceHandle { +pub unsafe fn RegisterEventSourceA<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(lpuncservername: Param0, lpsourcename: Param1) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn RegisterEventSourceA(lpuncservername: ::windows::core::PCSTR, lpsourcename: ::windows::core::PCSTR) -> EventSourceHandle; } - ::core::mem::transmute(RegisterEventSourceA(lpuncservername.into_param().abi(), lpsourcename.into_param().abi())) + let result__ = RegisterEventSourceA(lpuncservername.into_param().abi(), lpsourcename.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); } #[doc = "*Required features: `\"Win32_System_EventLog\"`*"] #[inline] -pub unsafe fn RegisterEventSourceW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(lpuncservername: Param0, lpsourcename: Param1) -> EventSourceHandle { +pub unsafe fn RegisterEventSourceW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(lpuncservername: Param0, lpsourcename: Param1) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn RegisterEventSourceW(lpuncservername: ::windows::core::PCWSTR, lpsourcename: ::windows::core::PCWSTR) -> EventSourceHandle; } - ::core::mem::transmute(RegisterEventSourceW(lpuncservername.into_param().abi(), lpsourcename.into_param().abi())) + let result__ = RegisterEventSourceW(lpuncservername.into_param().abi(), lpsourcename.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); diff --git a/crates/libs/windows/src/Windows/Win32/System/GroupPolicy/mod.rs b/crates/libs/windows/src/Windows/Win32/System/GroupPolicy/mod.rs index af233b3a5c..0575bede60 100644 --- a/crates/libs/windows/src/Windows/Win32/System/GroupPolicy/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/System/GroupPolicy/mod.rs @@ -80,14 +80,7 @@ pub unsafe fn CreateGPOLink<'a, Param0: ::windows::core::IntoParam<'a, ::windows pub struct CriticalPolicySectionHandle(pub isize); impl CriticalPolicySectionHandle { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for CriticalPolicySectionHandle { @@ -140,14 +133,15 @@ pub unsafe fn DeleteGPOLink<'a, Param0: ::windows::core::IntoParam<'a, ::windows #[doc = "*Required features: `\"Win32_System_GroupPolicy\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn EnterCriticalPolicySection<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>>(bmachine: Param0) -> super::super::Foundation::HANDLE { +pub unsafe fn EnterCriticalPolicySection<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>>(bmachine: Param0) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn EnterCriticalPolicySection(bmachine: super::super::Foundation::BOOL) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(EnterCriticalPolicySection(bmachine.into_param().abi())) + let result__ = EnterCriticalPolicySection(bmachine.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); diff --git a/crates/libs/windows/src/Windows/Win32/System/HostCompute/mod.rs b/crates/libs/windows/src/Windows/Win32/System/HostCompute/mod.rs index f2eeaff11b..4ed1726f3d 100644 --- a/crates/libs/windows/src/Windows/Win32/System/HostCompute/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/System/HostCompute/mod.rs @@ -4,14 +4,7 @@ pub struct HCS_CALLBACK(pub isize); impl HCS_CALLBACK { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HCS_CALLBACK { diff --git a/crates/libs/windows/src/Windows/Win32/System/HostComputeSystem/mod.rs b/crates/libs/windows/src/Windows/Win32/System/HostComputeSystem/mod.rs index 2db3e1955f..aa27504bbd 100644 --- a/crates/libs/windows/src/Windows/Win32/System/HostComputeSystem/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/System/HostComputeSystem/mod.rs @@ -298,14 +298,7 @@ impl ::core::fmt::Debug for HCS_NOTIFICATION_FLAGS { pub struct HCS_OPERATION(pub isize); impl HCS_OPERATION { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HCS_OPERATION { @@ -391,14 +384,7 @@ impl ::core::fmt::Debug for HCS_OPERATION_TYPE { pub struct HCS_PROCESS(pub isize); impl HCS_PROCESS { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HCS_PROCESS { @@ -467,14 +453,7 @@ impl ::core::default::Default for HCS_PROCESS_INFORMATION { pub struct HCS_SYSTEM(pub isize); impl HCS_SYSTEM { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HCS_SYSTEM { diff --git a/crates/libs/windows/src/Windows/Win32/System/Hypervisor/mod.rs b/crates/libs/windows/src/Windows/Win32/System/Hypervisor/mod.rs index ca06120ea6..9c506ed5b1 100644 --- a/crates/libs/windows/src/Windows/Win32/System/Hypervisor/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/System/Hypervisor/mod.rs @@ -3837,14 +3837,7 @@ impl ::core::fmt::Debug for WHV_PARTITION_COUNTER_SET { pub struct WHV_PARTITION_HANDLE(pub isize); impl WHV_PARTITION_HANDLE { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for WHV_PARTITION_HANDLE { diff --git a/crates/libs/windows/src/Windows/Win32/System/IO/mod.rs b/crates/libs/windows/src/Windows/Win32/System/IO/mod.rs index 60dadfb3bc..79a2a86e48 100644 --- a/crates/libs/windows/src/Windows/Win32/System/IO/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/System/IO/mod.rs @@ -62,14 +62,15 @@ pub unsafe fn CancelSynchronousIo<'a, Param0: ::windows::core::IntoParam<'a, sup #[doc = "*Required features: `\"Win32_System_IO\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn CreateIoCompletionPort<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>>(filehandle: Param0, existingcompletionport: Param1, completionkey: usize, numberofconcurrentthreads: u32) -> super::super::Foundation::HANDLE { +pub unsafe fn CreateIoCompletionPort<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>>(filehandle: Param0, existingcompletionport: Param1, completionkey: usize, numberofconcurrentthreads: u32) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateIoCompletionPort(filehandle: super::super::Foundation::HANDLE, existingcompletionport: super::super::Foundation::HANDLE, completionkey: usize, numberofconcurrentthreads: u32) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(CreateIoCompletionPort(filehandle.into_param().abi(), existingcompletionport.into_param().abi(), ::core::mem::transmute(completionkey), ::core::mem::transmute(numberofconcurrentthreads))) + let result__ = CreateIoCompletionPort(filehandle.into_param().abi(), existingcompletionport.into_param().abi(), ::core::mem::transmute(completionkey), ::core::mem::transmute(numberofconcurrentthreads)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); diff --git a/crates/libs/windows/src/Windows/Win32/System/JobObjects/mod.rs b/crates/libs/windows/src/Windows/Win32/System/JobObjects/mod.rs index f87e9b7fad..3c41361da3 100644 --- a/crates/libs/windows/src/Windows/Win32/System/JobObjects/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/System/JobObjects/mod.rs @@ -17,14 +17,15 @@ pub unsafe fn AssignProcessToJobObject<'a, Param0: ::windows::core::IntoParam<'a #[doc = "*Required features: `\"Win32_System_JobObjects\"`, `\"Win32_Foundation\"`, `\"Win32_Security\"`*"] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Security"))] #[inline] -pub unsafe fn CreateJobObjectA<'a, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(lpjobattributes: *const super::super::Security::SECURITY_ATTRIBUTES, lpname: Param1) -> super::super::Foundation::HANDLE { +pub unsafe fn CreateJobObjectA<'a, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(lpjobattributes: *const super::super::Security::SECURITY_ATTRIBUTES, lpname: Param1) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateJobObjectA(lpjobattributes: *const super::super::Security::SECURITY_ATTRIBUTES, lpname: ::windows::core::PCSTR) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(CreateJobObjectA(::core::mem::transmute(lpjobattributes), lpname.into_param().abi())) + let result__ = CreateJobObjectA(::core::mem::transmute(lpjobattributes), lpname.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -32,14 +33,15 @@ pub unsafe fn CreateJobObjectA<'a, Param1: ::windows::core::IntoParam<'a, ::wind #[doc = "*Required features: `\"Win32_System_JobObjects\"`, `\"Win32_Foundation\"`, `\"Win32_Security\"`*"] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Security"))] #[inline] -pub unsafe fn CreateJobObjectW<'a, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(lpjobattributes: *const super::super::Security::SECURITY_ATTRIBUTES, lpname: Param1) -> super::super::Foundation::HANDLE { +pub unsafe fn CreateJobObjectW<'a, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(lpjobattributes: *const super::super::Security::SECURITY_ATTRIBUTES, lpname: Param1) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateJobObjectW(lpjobattributes: *const super::super::Security::SECURITY_ATTRIBUTES, lpname: ::windows::core::PCWSTR) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(CreateJobObjectW(::core::mem::transmute(lpjobattributes), lpname.into_param().abi())) + let result__ = CreateJobObjectW(::core::mem::transmute(lpjobattributes), lpname.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -1774,14 +1776,15 @@ impl ::core::default::Default for JOB_SET_ARRAY { #[doc = "*Required features: `\"Win32_System_JobObjects\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn OpenJobObjectA<'a, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>, Param2: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(dwdesiredaccess: u32, binherithandle: Param1, lpname: Param2) -> super::super::Foundation::HANDLE { +pub unsafe fn OpenJobObjectA<'a, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>, Param2: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(dwdesiredaccess: u32, binherithandle: Param1, lpname: Param2) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn OpenJobObjectA(dwdesiredaccess: u32, binherithandle: super::super::Foundation::BOOL, lpname: ::windows::core::PCSTR) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(OpenJobObjectA(::core::mem::transmute(dwdesiredaccess), binherithandle.into_param().abi(), lpname.into_param().abi())) + let result__ = OpenJobObjectA(::core::mem::transmute(dwdesiredaccess), binherithandle.into_param().abi(), lpname.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -1789,14 +1792,15 @@ pub unsafe fn OpenJobObjectA<'a, Param1: ::windows::core::IntoParam<'a, super::s #[doc = "*Required features: `\"Win32_System_JobObjects\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn OpenJobObjectW<'a, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>, Param2: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(dwdesiredaccess: u32, binherithandle: Param1, lpname: Param2) -> super::super::Foundation::HANDLE { +pub unsafe fn OpenJobObjectW<'a, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>, Param2: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(dwdesiredaccess: u32, binherithandle: Param1, lpname: Param2) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn OpenJobObjectW(dwdesiredaccess: u32, binherithandle: super::super::Foundation::BOOL, lpname: ::windows::core::PCWSTR) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(OpenJobObjectW(::core::mem::transmute(dwdesiredaccess), binherithandle.into_param().abi(), lpname.into_param().abi())) + let result__ = OpenJobObjectW(::core::mem::transmute(dwdesiredaccess), binherithandle.into_param().abi(), lpname.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); diff --git a/crates/libs/windows/src/Windows/Win32/System/LibraryLoader/mod.rs b/crates/libs/windows/src/Windows/Win32/System/LibraryLoader/mod.rs index fd8d65856a..f81fd8d702 100644 --- a/crates/libs/windows/src/Windows/Win32/System/LibraryLoader/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/System/LibraryLoader/mod.rs @@ -16,14 +16,15 @@ pub unsafe fn AddDllDirectory<'a, Param0: ::windows::core::IntoParam<'a, ::windo #[doc = "*Required features: `\"Win32_System_LibraryLoader\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn BeginUpdateResourceA<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>>(pfilename: Param0, bdeleteexistingresources: Param1) -> super::super::Foundation::HANDLE { +pub unsafe fn BeginUpdateResourceA<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>>(pfilename: Param0, bdeleteexistingresources: Param1) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn BeginUpdateResourceA(pfilename: ::windows::core::PCSTR, bdeleteexistingresources: super::super::Foundation::BOOL) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(BeginUpdateResourceA(pfilename.into_param().abi(), bdeleteexistingresources.into_param().abi())) + let result__ = BeginUpdateResourceA(pfilename.into_param().abi(), bdeleteexistingresources.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -31,14 +32,15 @@ pub unsafe fn BeginUpdateResourceA<'a, Param0: ::windows::core::IntoParam<'a, :: #[doc = "*Required features: `\"Win32_System_LibraryLoader\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn BeginUpdateResourceW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>>(pfilename: Param0, bdeleteexistingresources: Param1) -> super::super::Foundation::HANDLE { +pub unsafe fn BeginUpdateResourceW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>>(pfilename: Param0, bdeleteexistingresources: Param1) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn BeginUpdateResourceW(pfilename: ::windows::core::PCWSTR, bdeleteexistingresources: super::super::Foundation::BOOL) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(BeginUpdateResourceW(pfilename.into_param().abi(), bdeleteexistingresources.into_param().abi())) + let result__ = BeginUpdateResourceW(pfilename.into_param().abi(), bdeleteexistingresources.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -329,14 +331,15 @@ pub const FIND_RESOURCE_DIRECTORY_TYPES: u32 = 256u32; #[doc = "*Required features: `\"Win32_System_LibraryLoader\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn FindResourceA<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HINSTANCE>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>, Param2: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(hmodule: Param0, lpname: Param1, lptype: Param2) -> super::super::Foundation::HRSRC { +pub unsafe fn FindResourceA<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HINSTANCE>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>, Param2: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(hmodule: Param0, lpname: Param1, lptype: Param2) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn FindResourceA(hmodule: super::super::Foundation::HINSTANCE, lpname: ::windows::core::PCSTR, lptype: ::windows::core::PCSTR) -> super::super::Foundation::HRSRC; } - ::core::mem::transmute(FindResourceA(hmodule.into_param().abi(), lpname.into_param().abi(), lptype.into_param().abi())) + let result__ = FindResourceA(hmodule.into_param().abi(), lpname.into_param().abi(), lptype.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -344,14 +347,15 @@ pub unsafe fn FindResourceA<'a, Param0: ::windows::core::IntoParam<'a, super::su #[doc = "*Required features: `\"Win32_System_LibraryLoader\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn FindResourceExA<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HINSTANCE>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>, Param2: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(hmodule: Param0, lptype: Param1, lpname: Param2, wlanguage: u16) -> super::super::Foundation::HRSRC { +pub unsafe fn FindResourceExA<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HINSTANCE>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>, Param2: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(hmodule: Param0, lptype: Param1, lpname: Param2, wlanguage: u16) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn FindResourceExA(hmodule: super::super::Foundation::HINSTANCE, lptype: ::windows::core::PCSTR, lpname: ::windows::core::PCSTR, wlanguage: u16) -> super::super::Foundation::HRSRC; } - ::core::mem::transmute(FindResourceExA(hmodule.into_param().abi(), lptype.into_param().abi(), lpname.into_param().abi(), ::core::mem::transmute(wlanguage))) + let result__ = FindResourceExA(hmodule.into_param().abi(), lptype.into_param().abi(), lpname.into_param().abi(), ::core::mem::transmute(wlanguage)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); diff --git a/crates/libs/windows/src/Windows/Win32/System/Mailslots/mod.rs b/crates/libs/windows/src/Windows/Win32/System/Mailslots/mod.rs index 51d1b2773f..111c1c9a3b 100644 --- a/crates/libs/windows/src/Windows/Win32/System/Mailslots/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/System/Mailslots/mod.rs @@ -2,14 +2,15 @@ #[doc = "*Required features: `\"Win32_System_Mailslots\"`, `\"Win32_Foundation\"`, `\"Win32_Security\"`*"] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Security"))] #[inline] -pub unsafe fn CreateMailslotA<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(lpname: Param0, nmaxmessagesize: u32, lreadtimeout: u32, lpsecurityattributes: *const super::super::Security::SECURITY_ATTRIBUTES) -> super::super::Foundation::HANDLE { +pub unsafe fn CreateMailslotA<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(lpname: Param0, nmaxmessagesize: u32, lreadtimeout: u32, lpsecurityattributes: *const super::super::Security::SECURITY_ATTRIBUTES) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateMailslotA(lpname: ::windows::core::PCSTR, nmaxmessagesize: u32, lreadtimeout: u32, lpsecurityattributes: *const super::super::Security::SECURITY_ATTRIBUTES) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(CreateMailslotA(lpname.into_param().abi(), ::core::mem::transmute(nmaxmessagesize), ::core::mem::transmute(lreadtimeout), ::core::mem::transmute(lpsecurityattributes))) + let result__ = CreateMailslotA(lpname.into_param().abi(), ::core::mem::transmute(nmaxmessagesize), ::core::mem::transmute(lreadtimeout), ::core::mem::transmute(lpsecurityattributes)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -17,14 +18,15 @@ pub unsafe fn CreateMailslotA<'a, Param0: ::windows::core::IntoParam<'a, ::windo #[doc = "*Required features: `\"Win32_System_Mailslots\"`, `\"Win32_Foundation\"`, `\"Win32_Security\"`*"] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Security"))] #[inline] -pub unsafe fn CreateMailslotW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(lpname: Param0, nmaxmessagesize: u32, lreadtimeout: u32, lpsecurityattributes: *const super::super::Security::SECURITY_ATTRIBUTES) -> super::super::Foundation::HANDLE { +pub unsafe fn CreateMailslotW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(lpname: Param0, nmaxmessagesize: u32, lreadtimeout: u32, lpsecurityattributes: *const super::super::Security::SECURITY_ATTRIBUTES) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateMailslotW(lpname: ::windows::core::PCWSTR, nmaxmessagesize: u32, lreadtimeout: u32, lpsecurityattributes: *const super::super::Security::SECURITY_ATTRIBUTES) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(CreateMailslotW(lpname.into_param().abi(), ::core::mem::transmute(nmaxmessagesize), ::core::mem::transmute(lreadtimeout), ::core::mem::transmute(lpsecurityattributes))) + let result__ = CreateMailslotW(lpname.into_param().abi(), ::core::mem::transmute(nmaxmessagesize), ::core::mem::transmute(lreadtimeout), ::core::mem::transmute(lpsecurityattributes)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); diff --git a/crates/libs/windows/src/Windows/Win32/System/Memory/mod.rs b/crates/libs/windows/src/Windows/Win32/System/Memory/mod.rs index d6dcbd1376..fa7d3052e1 100644 --- a/crates/libs/windows/src/Windows/Win32/System/Memory/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/System/Memory/mod.rs @@ -95,14 +95,15 @@ impl ::core::default::Default for CFG_CALL_TARGET_INFO { #[doc = "*Required features: `\"Win32_System_Memory\"`, `\"Win32_Foundation\"`, `\"Win32_Security\"`*"] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Security"))] #[inline] -pub unsafe fn CreateFileMapping2<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>, Param6: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(file: Param0, securityattributes: *const super::super::Security::SECURITY_ATTRIBUTES, desiredaccess: u32, pageprotection: PAGE_PROTECTION_FLAGS, allocationattributes: u32, maximumsize: u64, name: Param6, extendedparameters: &mut [MEM_EXTENDED_PARAMETER]) -> super::super::Foundation::HANDLE { +pub unsafe fn CreateFileMapping2<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>, Param6: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(file: Param0, securityattributes: *const super::super::Security::SECURITY_ATTRIBUTES, desiredaccess: u32, pageprotection: PAGE_PROTECTION_FLAGS, allocationattributes: u32, maximumsize: u64, name: Param6, extendedparameters: &mut [MEM_EXTENDED_PARAMETER]) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateFileMapping2(file: super::super::Foundation::HANDLE, securityattributes: *const super::super::Security::SECURITY_ATTRIBUTES, desiredaccess: u32, pageprotection: PAGE_PROTECTION_FLAGS, allocationattributes: u32, maximumsize: u64, name: ::windows::core::PCWSTR, extendedparameters: *mut MEM_EXTENDED_PARAMETER, parametercount: u32) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(CreateFileMapping2(file.into_param().abi(), ::core::mem::transmute(securityattributes), ::core::mem::transmute(desiredaccess), ::core::mem::transmute(pageprotection), ::core::mem::transmute(allocationattributes), ::core::mem::transmute(maximumsize), name.into_param().abi(), ::core::mem::transmute(::windows::core::as_mut_ptr_or_null(extendedparameters)), extendedparameters.len() as _)) + let result__ = CreateFileMapping2(file.into_param().abi(), ::core::mem::transmute(securityattributes), ::core::mem::transmute(desiredaccess), ::core::mem::transmute(pageprotection), ::core::mem::transmute(allocationattributes), ::core::mem::transmute(maximumsize), name.into_param().abi(), ::core::mem::transmute(::windows::core::as_mut_ptr_or_null(extendedparameters)), extendedparameters.len() as _); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -110,14 +111,15 @@ pub unsafe fn CreateFileMapping2<'a, Param0: ::windows::core::IntoParam<'a, supe #[doc = "*Required features: `\"Win32_System_Memory\"`, `\"Win32_Foundation\"`, `\"Win32_Security\"`*"] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Security"))] #[inline] -pub unsafe fn CreateFileMappingA<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>, Param5: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(hfile: Param0, lpfilemappingattributes: *const super::super::Security::SECURITY_ATTRIBUTES, flprotect: PAGE_PROTECTION_FLAGS, dwmaximumsizehigh: u32, dwmaximumsizelow: u32, lpname: Param5) -> super::super::Foundation::HANDLE { +pub unsafe fn CreateFileMappingA<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>, Param5: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(hfile: Param0, lpfilemappingattributes: *const super::super::Security::SECURITY_ATTRIBUTES, flprotect: PAGE_PROTECTION_FLAGS, dwmaximumsizehigh: u32, dwmaximumsizelow: u32, lpname: Param5) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateFileMappingA(hfile: super::super::Foundation::HANDLE, lpfilemappingattributes: *const super::super::Security::SECURITY_ATTRIBUTES, flprotect: PAGE_PROTECTION_FLAGS, dwmaximumsizehigh: u32, dwmaximumsizelow: u32, lpname: ::windows::core::PCSTR) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(CreateFileMappingA(hfile.into_param().abi(), ::core::mem::transmute(lpfilemappingattributes), ::core::mem::transmute(flprotect), ::core::mem::transmute(dwmaximumsizehigh), ::core::mem::transmute(dwmaximumsizelow), lpname.into_param().abi())) + let result__ = CreateFileMappingA(hfile.into_param().abi(), ::core::mem::transmute(lpfilemappingattributes), ::core::mem::transmute(flprotect), ::core::mem::transmute(dwmaximumsizehigh), ::core::mem::transmute(dwmaximumsizelow), lpname.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -125,14 +127,15 @@ pub unsafe fn CreateFileMappingA<'a, Param0: ::windows::core::IntoParam<'a, supe #[doc = "*Required features: `\"Win32_System_Memory\"`, `\"Win32_Foundation\"`, `\"Win32_Security\"`*"] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Security"))] #[inline] -pub unsafe fn CreateFileMappingFromApp<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>, Param4: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(hfile: Param0, securityattributes: *const super::super::Security::SECURITY_ATTRIBUTES, pageprotection: PAGE_PROTECTION_FLAGS, maximumsize: u64, name: Param4) -> super::super::Foundation::HANDLE { +pub unsafe fn CreateFileMappingFromApp<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>, Param4: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(hfile: Param0, securityattributes: *const super::super::Security::SECURITY_ATTRIBUTES, pageprotection: PAGE_PROTECTION_FLAGS, maximumsize: u64, name: Param4) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateFileMappingFromApp(hfile: super::super::Foundation::HANDLE, securityattributes: *const super::super::Security::SECURITY_ATTRIBUTES, pageprotection: PAGE_PROTECTION_FLAGS, maximumsize: u64, name: ::windows::core::PCWSTR) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(CreateFileMappingFromApp(hfile.into_param().abi(), ::core::mem::transmute(securityattributes), ::core::mem::transmute(pageprotection), ::core::mem::transmute(maximumsize), name.into_param().abi())) + let result__ = CreateFileMappingFromApp(hfile.into_param().abi(), ::core::mem::transmute(securityattributes), ::core::mem::transmute(pageprotection), ::core::mem::transmute(maximumsize), name.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -140,14 +143,15 @@ pub unsafe fn CreateFileMappingFromApp<'a, Param0: ::windows::core::IntoParam<'a #[doc = "*Required features: `\"Win32_System_Memory\"`, `\"Win32_Foundation\"`, `\"Win32_Security\"`*"] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Security"))] #[inline] -pub unsafe fn CreateFileMappingNumaA<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>, Param5: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(hfile: Param0, lpfilemappingattributes: *const super::super::Security::SECURITY_ATTRIBUTES, flprotect: PAGE_PROTECTION_FLAGS, dwmaximumsizehigh: u32, dwmaximumsizelow: u32, lpname: Param5, nndpreferred: u32) -> super::super::Foundation::HANDLE { +pub unsafe fn CreateFileMappingNumaA<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>, Param5: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(hfile: Param0, lpfilemappingattributes: *const super::super::Security::SECURITY_ATTRIBUTES, flprotect: PAGE_PROTECTION_FLAGS, dwmaximumsizehigh: u32, dwmaximumsizelow: u32, lpname: Param5, nndpreferred: u32) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateFileMappingNumaA(hfile: super::super::Foundation::HANDLE, lpfilemappingattributes: *const super::super::Security::SECURITY_ATTRIBUTES, flprotect: PAGE_PROTECTION_FLAGS, dwmaximumsizehigh: u32, dwmaximumsizelow: u32, lpname: ::windows::core::PCSTR, nndpreferred: u32) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(CreateFileMappingNumaA(hfile.into_param().abi(), ::core::mem::transmute(lpfilemappingattributes), ::core::mem::transmute(flprotect), ::core::mem::transmute(dwmaximumsizehigh), ::core::mem::transmute(dwmaximumsizelow), lpname.into_param().abi(), ::core::mem::transmute(nndpreferred))) + let result__ = CreateFileMappingNumaA(hfile.into_param().abi(), ::core::mem::transmute(lpfilemappingattributes), ::core::mem::transmute(flprotect), ::core::mem::transmute(dwmaximumsizehigh), ::core::mem::transmute(dwmaximumsizelow), lpname.into_param().abi(), ::core::mem::transmute(nndpreferred)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -155,14 +159,15 @@ pub unsafe fn CreateFileMappingNumaA<'a, Param0: ::windows::core::IntoParam<'a, #[doc = "*Required features: `\"Win32_System_Memory\"`, `\"Win32_Foundation\"`, `\"Win32_Security\"`*"] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Security"))] #[inline] -pub unsafe fn CreateFileMappingNumaW<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>, Param5: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(hfile: Param0, lpfilemappingattributes: *const super::super::Security::SECURITY_ATTRIBUTES, flprotect: PAGE_PROTECTION_FLAGS, dwmaximumsizehigh: u32, dwmaximumsizelow: u32, lpname: Param5, nndpreferred: u32) -> super::super::Foundation::HANDLE { +pub unsafe fn CreateFileMappingNumaW<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>, Param5: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(hfile: Param0, lpfilemappingattributes: *const super::super::Security::SECURITY_ATTRIBUTES, flprotect: PAGE_PROTECTION_FLAGS, dwmaximumsizehigh: u32, dwmaximumsizelow: u32, lpname: Param5, nndpreferred: u32) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateFileMappingNumaW(hfile: super::super::Foundation::HANDLE, lpfilemappingattributes: *const super::super::Security::SECURITY_ATTRIBUTES, flprotect: PAGE_PROTECTION_FLAGS, dwmaximumsizehigh: u32, dwmaximumsizelow: u32, lpname: ::windows::core::PCWSTR, nndpreferred: u32) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(CreateFileMappingNumaW(hfile.into_param().abi(), ::core::mem::transmute(lpfilemappingattributes), ::core::mem::transmute(flprotect), ::core::mem::transmute(dwmaximumsizehigh), ::core::mem::transmute(dwmaximumsizelow), lpname.into_param().abi(), ::core::mem::transmute(nndpreferred))) + let result__ = CreateFileMappingNumaW(hfile.into_param().abi(), ::core::mem::transmute(lpfilemappingattributes), ::core::mem::transmute(flprotect), ::core::mem::transmute(dwmaximumsizehigh), ::core::mem::transmute(dwmaximumsizelow), lpname.into_param().abi(), ::core::mem::transmute(nndpreferred)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -170,14 +175,15 @@ pub unsafe fn CreateFileMappingNumaW<'a, Param0: ::windows::core::IntoParam<'a, #[doc = "*Required features: `\"Win32_System_Memory\"`, `\"Win32_Foundation\"`, `\"Win32_Security\"`*"] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Security"))] #[inline] -pub unsafe fn CreateFileMappingW<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>, Param5: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(hfile: Param0, lpfilemappingattributes: *const super::super::Security::SECURITY_ATTRIBUTES, flprotect: PAGE_PROTECTION_FLAGS, dwmaximumsizehigh: u32, dwmaximumsizelow: u32, lpname: Param5) -> super::super::Foundation::HANDLE { +pub unsafe fn CreateFileMappingW<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>, Param5: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(hfile: Param0, lpfilemappingattributes: *const super::super::Security::SECURITY_ATTRIBUTES, flprotect: PAGE_PROTECTION_FLAGS, dwmaximumsizehigh: u32, dwmaximumsizelow: u32, lpname: Param5) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateFileMappingW(hfile: super::super::Foundation::HANDLE, lpfilemappingattributes: *const super::super::Security::SECURITY_ATTRIBUTES, flprotect: PAGE_PROTECTION_FLAGS, dwmaximumsizehigh: u32, dwmaximumsizelow: u32, lpname: ::windows::core::PCWSTR) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(CreateFileMappingW(hfile.into_param().abi(), ::core::mem::transmute(lpfilemappingattributes), ::core::mem::transmute(flprotect), ::core::mem::transmute(dwmaximumsizehigh), ::core::mem::transmute(dwmaximumsizelow), lpname.into_param().abi())) + let result__ = CreateFileMappingW(hfile.into_param().abi(), ::core::mem::transmute(lpfilemappingattributes), ::core::mem::transmute(flprotect), ::core::mem::transmute(dwmaximumsizehigh), ::core::mem::transmute(dwmaximumsizelow), lpname.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -185,14 +191,15 @@ pub unsafe fn CreateFileMappingW<'a, Param0: ::windows::core::IntoParam<'a, supe #[doc = "*Required features: `\"Win32_System_Memory\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn CreateMemoryResourceNotification(notificationtype: MEMORY_RESOURCE_NOTIFICATION_TYPE) -> super::super::Foundation::HANDLE { +pub unsafe fn CreateMemoryResourceNotification(notificationtype: MEMORY_RESOURCE_NOTIFICATION_TYPE) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateMemoryResourceNotification(notificationtype: MEMORY_RESOURCE_NOTIFICATION_TYPE) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(CreateMemoryResourceNotification(::core::mem::transmute(notificationtype))) + let result__ = CreateMemoryResourceNotification(::core::mem::transmute(notificationtype)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -408,14 +415,15 @@ pub unsafe fn GetMemoryErrorHandlingCapabilities(capabilities: *mut u32) -> supe } #[doc = "*Required features: `\"Win32_System_Memory\"`*"] #[inline] -pub unsafe fn GetProcessHeap() -> HeapHandle { +pub unsafe fn GetProcessHeap() -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn GetProcessHeap() -> HeapHandle; } - ::core::mem::transmute(GetProcessHeap()) + let result__ = GetProcessHeap(); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -771,14 +779,15 @@ pub unsafe fn HeapCompact<'a, Param0: ::windows::core::IntoParam<'a, HeapHandle> } #[doc = "*Required features: `\"Win32_System_Memory\"`*"] #[inline] -pub unsafe fn HeapCreate(floptions: HEAP_FLAGS, dwinitialsize: usize, dwmaximumsize: usize) -> HeapHandle { +pub unsafe fn HeapCreate(floptions: HEAP_FLAGS, dwinitialsize: usize, dwmaximumsize: usize) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn HeapCreate(floptions: HEAP_FLAGS, dwinitialsize: usize, dwmaximumsize: usize) -> HeapHandle; } - ::core::mem::transmute(HeapCreate(::core::mem::transmute(floptions), ::core::mem::transmute(dwinitialsize), ::core::mem::transmute(dwmaximumsize))) + let result__ = HeapCreate(::core::mem::transmute(floptions), ::core::mem::transmute(dwinitialsize), ::core::mem::transmute(dwmaximumsize)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -818,14 +827,7 @@ pub unsafe fn HeapFree<'a, Param0: ::windows::core::IntoParam<'a, HeapHandle>>(h pub struct HeapHandle(pub isize); impl HeapHandle { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HeapHandle { @@ -1801,14 +1803,15 @@ pub unsafe fn OpenDedicatedMemoryPartition<'a, Param0: ::windows::core::IntoPara #[doc = "*Required features: `\"Win32_System_Memory\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn OpenFileMappingA<'a, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>, Param2: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(dwdesiredaccess: u32, binherithandle: Param1, lpname: Param2) -> super::super::Foundation::HANDLE { +pub unsafe fn OpenFileMappingA<'a, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>, Param2: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(dwdesiredaccess: u32, binherithandle: Param1, lpname: Param2) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn OpenFileMappingA(dwdesiredaccess: u32, binherithandle: super::super::Foundation::BOOL, lpname: ::windows::core::PCSTR) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(OpenFileMappingA(::core::mem::transmute(dwdesiredaccess), binherithandle.into_param().abi(), lpname.into_param().abi())) + let result__ = OpenFileMappingA(::core::mem::transmute(dwdesiredaccess), binherithandle.into_param().abi(), lpname.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -1816,14 +1819,15 @@ pub unsafe fn OpenFileMappingA<'a, Param1: ::windows::core::IntoParam<'a, super: #[doc = "*Required features: `\"Win32_System_Memory\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn OpenFileMappingFromApp<'a, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>, Param2: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(desiredaccess: u32, inherithandle: Param1, name: Param2) -> super::super::Foundation::HANDLE { +pub unsafe fn OpenFileMappingFromApp<'a, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>, Param2: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(desiredaccess: u32, inherithandle: Param1, name: Param2) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn OpenFileMappingFromApp(desiredaccess: u32, inherithandle: super::super::Foundation::BOOL, name: ::windows::core::PCWSTR) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(OpenFileMappingFromApp(::core::mem::transmute(desiredaccess), inherithandle.into_param().abi(), name.into_param().abi())) + let result__ = OpenFileMappingFromApp(::core::mem::transmute(desiredaccess), inherithandle.into_param().abi(), name.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -1831,14 +1835,15 @@ pub unsafe fn OpenFileMappingFromApp<'a, Param1: ::windows::core::IntoParam<'a, #[doc = "*Required features: `\"Win32_System_Memory\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn OpenFileMappingW<'a, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>, Param2: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(dwdesiredaccess: u32, binherithandle: Param1, lpname: Param2) -> super::super::Foundation::HANDLE { +pub unsafe fn OpenFileMappingW<'a, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>, Param2: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(dwdesiredaccess: u32, binherithandle: Param1, lpname: Param2) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn OpenFileMappingW(dwdesiredaccess: u32, binherithandle: super::super::Foundation::BOOL, lpname: ::windows::core::PCWSTR) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(OpenFileMappingW(::core::mem::transmute(dwdesiredaccess), binherithandle.into_param().abi(), lpname.into_param().abi())) + let result__ = OpenFileMappingW(::core::mem::transmute(dwdesiredaccess), binherithandle.into_param().abi(), lpname.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); diff --git a/crates/libs/windows/src/Windows/Win32/System/Performance/mod.rs b/crates/libs/windows/src/Windows/Win32/System/Performance/mod.rs index dc8aa51e31..f1f3ccac92 100644 --- a/crates/libs/windows/src/Windows/Win32/System/Performance/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/System/Performance/mod.rs @@ -11642,14 +11642,7 @@ pub unsafe fn PerfOpenQueryHandle<'a, Param0: ::windows::core::IntoParam<'a, ::w pub struct PerfProviderHandle(pub isize); impl PerfProviderHandle { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for PerfProviderHandle { @@ -11719,14 +11712,7 @@ pub unsafe fn PerfQueryCounterSetRegistrationInfo<'a, Param0: ::windows::core::I pub struct PerfQueryHandle(pub isize); impl PerfQueryHandle { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for PerfQueryHandle { diff --git a/crates/libs/windows/src/Windows/Win32/System/Pipes/mod.rs b/crates/libs/windows/src/Windows/Win32/System/Pipes/mod.rs index 2402ee71f2..69c068a791 100644 --- a/crates/libs/windows/src/Windows/Win32/System/Pipes/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/System/Pipes/mod.rs @@ -47,14 +47,15 @@ pub unsafe fn ConnectNamedPipe<'a, Param0: ::windows::core::IntoParam<'a, super: #[doc = "*Required features: `\"Win32_System_Pipes\"`, `\"Win32_Foundation\"`, `\"Win32_Security\"`, `\"Win32_Storage_FileSystem\"`*"] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Security", feature = "Win32_Storage_FileSystem"))] #[inline] -pub unsafe fn CreateNamedPipeA<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(lpname: Param0, dwopenmode: super::super::Storage::FileSystem::FILE_FLAGS_AND_ATTRIBUTES, dwpipemode: NAMED_PIPE_MODE, nmaxinstances: u32, noutbuffersize: u32, ninbuffersize: u32, ndefaulttimeout: u32, lpsecurityattributes: *const super::super::Security::SECURITY_ATTRIBUTES) -> super::super::Foundation::HANDLE { +pub unsafe fn CreateNamedPipeA<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(lpname: Param0, dwopenmode: super::super::Storage::FileSystem::FILE_FLAGS_AND_ATTRIBUTES, dwpipemode: NAMED_PIPE_MODE, nmaxinstances: u32, noutbuffersize: u32, ninbuffersize: u32, ndefaulttimeout: u32, lpsecurityattributes: *const super::super::Security::SECURITY_ATTRIBUTES) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateNamedPipeA(lpname: ::windows::core::PCSTR, dwopenmode: super::super::Storage::FileSystem::FILE_FLAGS_AND_ATTRIBUTES, dwpipemode: NAMED_PIPE_MODE, nmaxinstances: u32, noutbuffersize: u32, ninbuffersize: u32, ndefaulttimeout: u32, lpsecurityattributes: *const super::super::Security::SECURITY_ATTRIBUTES) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(CreateNamedPipeA(lpname.into_param().abi(), ::core::mem::transmute(dwopenmode), ::core::mem::transmute(dwpipemode), ::core::mem::transmute(nmaxinstances), ::core::mem::transmute(noutbuffersize), ::core::mem::transmute(ninbuffersize), ::core::mem::transmute(ndefaulttimeout), ::core::mem::transmute(lpsecurityattributes))) + let result__ = CreateNamedPipeA(lpname.into_param().abi(), ::core::mem::transmute(dwopenmode), ::core::mem::transmute(dwpipemode), ::core::mem::transmute(nmaxinstances), ::core::mem::transmute(noutbuffersize), ::core::mem::transmute(ninbuffersize), ::core::mem::transmute(ndefaulttimeout), ::core::mem::transmute(lpsecurityattributes)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); diff --git a/crates/libs/windows/src/Windows/Win32/System/Power/mod.rs b/crates/libs/windows/src/Windows/Win32/System/Power/mod.rs index 32a0b9c664..83e509d5c9 100644 --- a/crates/libs/windows/src/Windows/Win32/System/Power/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/System/Power/mod.rs @@ -1452,14 +1452,7 @@ pub unsafe fn GetSystemPowerStatus(lpsystempowerstatus: *mut SYSTEM_POWER_STATUS pub struct HPOWERNOTIFY(pub isize); impl HPOWERNOTIFY { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HPOWERNOTIFY { @@ -2588,14 +2581,15 @@ pub unsafe fn PowerCreatePossibleSetting<'a, Param0: ::windows::core::IntoParam< #[doc = "*Required features: `\"Win32_System_Power\"`, `\"Win32_Foundation\"`, `\"Win32_System_Threading\"`*"] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Threading"))] #[inline] -pub unsafe fn PowerCreateRequest(context: *const super::Threading::REASON_CONTEXT) -> super::super::Foundation::HANDLE { +pub unsafe fn PowerCreateRequest(context: *const super::Threading::REASON_CONTEXT) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn PowerCreateRequest(context: *const super::Threading::REASON_CONTEXT) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(PowerCreateRequest(::core::mem::transmute(context))) + let result__ = PowerCreateRequest(::core::mem::transmute(context)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -3504,14 +3498,15 @@ pub unsafe fn ReadPwrScheme(uiid: u32, ppowerpolicy: *mut POWER_POLICY) -> super #[doc = "*Required features: `\"Win32_System_Power\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn RegisterPowerSettingNotification<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>>(hrecipient: Param0, powersettingguid: *const ::windows::core::GUID, flags: u32) -> HPOWERNOTIFY { +pub unsafe fn RegisterPowerSettingNotification<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>>(hrecipient: Param0, powersettingguid: *const ::windows::core::GUID, flags: u32) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn RegisterPowerSettingNotification(hrecipient: super::super::Foundation::HANDLE, powersettingguid: *const ::windows::core::GUID, flags: u32) -> HPOWERNOTIFY; } - ::core::mem::transmute(RegisterPowerSettingNotification(hrecipient.into_param().abi(), ::core::mem::transmute(powersettingguid), ::core::mem::transmute(flags))) + let result__ = RegisterPowerSettingNotification(hrecipient.into_param().abi(), ::core::mem::transmute(powersettingguid), ::core::mem::transmute(flags)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -3519,14 +3514,15 @@ pub unsafe fn RegisterPowerSettingNotification<'a, Param0: ::windows::core::Into #[doc = "*Required features: `\"Win32_System_Power\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn RegisterSuspendResumeNotification<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>>(hrecipient: Param0, flags: u32) -> HPOWERNOTIFY { +pub unsafe fn RegisterSuspendResumeNotification<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>>(hrecipient: Param0, flags: u32) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn RegisterSuspendResumeNotification(hrecipient: super::super::Foundation::HANDLE, flags: u32) -> HPOWERNOTIFY; } - ::core::mem::transmute(RegisterSuspendResumeNotification(hrecipient.into_param().abi(), ::core::mem::transmute(flags))) + let result__ = RegisterSuspendResumeNotification(hrecipient.into_param().abi(), ::core::mem::transmute(flags)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); diff --git a/crates/libs/windows/src/Windows/Win32/System/Registry/mod.rs b/crates/libs/windows/src/Windows/Win32/System/Registry/mod.rs index ea8c841f67..0b5199e82a 100644 --- a/crates/libs/windows/src/Windows/Win32/System/Registry/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/System/Registry/mod.rs @@ -177,14 +177,7 @@ pub unsafe fn GetRegistryValueWithFallbackW<'a, Param0: ::windows::core::IntoPar pub struct HKEY(pub isize); impl HKEY { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HKEY { diff --git a/crates/libs/windows/src/Windows/Win32/System/RemoteDesktop/mod.rs b/crates/libs/windows/src/Windows/Win32/System/RemoteDesktop/mod.rs index e401ffd84f..10d6fae4b6 100644 --- a/crates/libs/windows/src/Windows/Win32/System/RemoteDesktop/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/System/RemoteDesktop/mod.rs @@ -670,14 +670,7 @@ pub const FORCE_REJOIN_IN_CLUSTERMODE: u32 = 3u32; pub struct HwtsVirtualChannelHandle(pub isize); impl HwtsVirtualChannelHandle { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HwtsVirtualChannelHandle { @@ -14306,28 +14299,30 @@ pub unsafe fn WTSVirtualChannelClose<'a, Param0: ::windows::core::IntoParam<'a, #[doc = "*Required features: `\"Win32_System_RemoteDesktop\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn WTSVirtualChannelOpen<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>, Param2: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(hserver: Param0, sessionid: u32, pvirtualname: Param2) -> HwtsVirtualChannelHandle { +pub unsafe fn WTSVirtualChannelOpen<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>, Param2: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(hserver: Param0, sessionid: u32, pvirtualname: Param2) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn WTSVirtualChannelOpen(hserver: super::super::Foundation::HANDLE, sessionid: u32, pvirtualname: ::windows::core::PCSTR) -> HwtsVirtualChannelHandle; } - ::core::mem::transmute(WTSVirtualChannelOpen(hserver.into_param().abi(), ::core::mem::transmute(sessionid), pvirtualname.into_param().abi())) + let result__ = WTSVirtualChannelOpen(hserver.into_param().abi(), ::core::mem::transmute(sessionid), pvirtualname.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); } #[doc = "*Required features: `\"Win32_System_RemoteDesktop\"`*"] #[inline] -pub unsafe fn WTSVirtualChannelOpenEx<'a, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(sessionid: u32, pvirtualname: Param1, flags: u32) -> HwtsVirtualChannelHandle { +pub unsafe fn WTSVirtualChannelOpenEx<'a, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(sessionid: u32, pvirtualname: Param1, flags: u32) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn WTSVirtualChannelOpenEx(sessionid: u32, pvirtualname: ::windows::core::PCSTR, flags: u32) -> HwtsVirtualChannelHandle; } - ::core::mem::transmute(WTSVirtualChannelOpenEx(::core::mem::transmute(sessionid), pvirtualname.into_param().abi(), ::core::mem::transmute(flags))) + let result__ = WTSVirtualChannelOpenEx(::core::mem::transmute(sessionid), pvirtualname.into_param().abi(), ::core::mem::transmute(flags)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); diff --git a/crates/libs/windows/src/Windows/Win32/System/Services/mod.rs b/crates/libs/windows/src/Windows/Win32/System/Services/mod.rs index 34381d92c9..0a8f6b239f 100644 --- a/crates/libs/windows/src/Windows/Win32/System/Services/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/System/Services/mod.rs @@ -161,28 +161,15 @@ pub unsafe fn CreateServiceA<'a, Param0: ::windows::core::IntoParam<'a, super::s lpdependencies: Param10, lpservicestartname: Param11, lppassword: Param12, -) -> super::super::Security::SC_HANDLE { +) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateServiceA(hscmanager: super::super::Security::SC_HANDLE, lpservicename: ::windows::core::PCSTR, lpdisplayname: ::windows::core::PCSTR, dwdesiredaccess: u32, dwservicetype: ENUM_SERVICE_TYPE, dwstarttype: SERVICE_START_TYPE, dwerrorcontrol: SERVICE_ERROR, lpbinarypathname: ::windows::core::PCSTR, lploadordergroup: ::windows::core::PCSTR, lpdwtagid: *mut u32, lpdependencies: ::windows::core::PCSTR, lpservicestartname: ::windows::core::PCSTR, lppassword: ::windows::core::PCSTR) -> super::super::Security::SC_HANDLE; } - ::core::mem::transmute(CreateServiceA( - hscmanager.into_param().abi(), - lpservicename.into_param().abi(), - lpdisplayname.into_param().abi(), - ::core::mem::transmute(dwdesiredaccess), - ::core::mem::transmute(dwservicetype), - ::core::mem::transmute(dwstarttype), - ::core::mem::transmute(dwerrorcontrol), - lpbinarypathname.into_param().abi(), - lploadordergroup.into_param().abi(), - ::core::mem::transmute(lpdwtagid), - lpdependencies.into_param().abi(), - lpservicestartname.into_param().abi(), - lppassword.into_param().abi(), - )) + let result__ = CreateServiceA(hscmanager.into_param().abi(), lpservicename.into_param().abi(), lpdisplayname.into_param().abi(), ::core::mem::transmute(dwdesiredaccess), ::core::mem::transmute(dwservicetype), ::core::mem::transmute(dwstarttype), ::core::mem::transmute(dwerrorcontrol), lpbinarypathname.into_param().abi(), lploadordergroup.into_param().abi(), ::core::mem::transmute(lpdwtagid), lpdependencies.into_param().abi(), lpservicestartname.into_param().abi(), lppassword.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -204,28 +191,15 @@ pub unsafe fn CreateServiceW<'a, Param0: ::windows::core::IntoParam<'a, super::s lpdependencies: Param10, lpservicestartname: Param11, lppassword: Param12, -) -> super::super::Security::SC_HANDLE { +) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateServiceW(hscmanager: super::super::Security::SC_HANDLE, lpservicename: ::windows::core::PCWSTR, lpdisplayname: ::windows::core::PCWSTR, dwdesiredaccess: u32, dwservicetype: ENUM_SERVICE_TYPE, dwstarttype: SERVICE_START_TYPE, dwerrorcontrol: SERVICE_ERROR, lpbinarypathname: ::windows::core::PCWSTR, lploadordergroup: ::windows::core::PCWSTR, lpdwtagid: *mut u32, lpdependencies: ::windows::core::PCWSTR, lpservicestartname: ::windows::core::PCWSTR, lppassword: ::windows::core::PCWSTR) -> super::super::Security::SC_HANDLE; } - ::core::mem::transmute(CreateServiceW( - hscmanager.into_param().abi(), - lpservicename.into_param().abi(), - lpdisplayname.into_param().abi(), - ::core::mem::transmute(dwdesiredaccess), - ::core::mem::transmute(dwservicetype), - ::core::mem::transmute(dwstarttype), - ::core::mem::transmute(dwerrorcontrol), - lpbinarypathname.into_param().abi(), - lploadordergroup.into_param().abi(), - ::core::mem::transmute(lpdwtagid), - lpdependencies.into_param().abi(), - lpservicestartname.into_param().abi(), - lppassword.into_param().abi(), - )) + let result__ = CreateServiceW(hscmanager.into_param().abi(), lpservicename.into_param().abi(), lpdisplayname.into_param().abi(), ::core::mem::transmute(dwdesiredaccess), ::core::mem::transmute(dwservicetype), ::core::mem::transmute(dwstarttype), ::core::mem::transmute(dwerrorcontrol), lpbinarypathname.into_param().abi(), lploadordergroup.into_param().abi(), ::core::mem::transmute(lpdwtagid), lpdependencies.into_param().abi(), lpservicestartname.into_param().abi(), lppassword.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -769,14 +743,15 @@ pub unsafe fn NotifyServiceStatusChangeW<'a, Param0: ::windows::core::IntoParam< #[doc = "*Required features: `\"Win32_System_Services\"`, `\"Win32_Security\"`*"] #[cfg(feature = "Win32_Security")] #[inline] -pub unsafe fn OpenSCManagerA<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(lpmachinename: Param0, lpdatabasename: Param1, dwdesiredaccess: u32) -> super::super::Security::SC_HANDLE { +pub unsafe fn OpenSCManagerA<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(lpmachinename: Param0, lpdatabasename: Param1, dwdesiredaccess: u32) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn OpenSCManagerA(lpmachinename: ::windows::core::PCSTR, lpdatabasename: ::windows::core::PCSTR, dwdesiredaccess: u32) -> super::super::Security::SC_HANDLE; } - ::core::mem::transmute(OpenSCManagerA(lpmachinename.into_param().abi(), lpdatabasename.into_param().abi(), ::core::mem::transmute(dwdesiredaccess))) + let result__ = OpenSCManagerA(lpmachinename.into_param().abi(), lpdatabasename.into_param().abi(), ::core::mem::transmute(dwdesiredaccess)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -784,14 +759,15 @@ pub unsafe fn OpenSCManagerA<'a, Param0: ::windows::core::IntoParam<'a, ::window #[doc = "*Required features: `\"Win32_System_Services\"`, `\"Win32_Security\"`*"] #[cfg(feature = "Win32_Security")] #[inline] -pub unsafe fn OpenSCManagerW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(lpmachinename: Param0, lpdatabasename: Param1, dwdesiredaccess: u32) -> super::super::Security::SC_HANDLE { +pub unsafe fn OpenSCManagerW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(lpmachinename: Param0, lpdatabasename: Param1, dwdesiredaccess: u32) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn OpenSCManagerW(lpmachinename: ::windows::core::PCWSTR, lpdatabasename: ::windows::core::PCWSTR, dwdesiredaccess: u32) -> super::super::Security::SC_HANDLE; } - ::core::mem::transmute(OpenSCManagerW(lpmachinename.into_param().abi(), lpdatabasename.into_param().abi(), ::core::mem::transmute(dwdesiredaccess))) + let result__ = OpenSCManagerW(lpmachinename.into_param().abi(), lpdatabasename.into_param().abi(), ::core::mem::transmute(dwdesiredaccess)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -799,14 +775,15 @@ pub unsafe fn OpenSCManagerW<'a, Param0: ::windows::core::IntoParam<'a, ::window #[doc = "*Required features: `\"Win32_System_Services\"`, `\"Win32_Security\"`*"] #[cfg(feature = "Win32_Security")] #[inline] -pub unsafe fn OpenServiceA<'a, Param0: ::windows::core::IntoParam<'a, super::super::Security::SC_HANDLE>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(hscmanager: Param0, lpservicename: Param1, dwdesiredaccess: u32) -> super::super::Security::SC_HANDLE { +pub unsafe fn OpenServiceA<'a, Param0: ::windows::core::IntoParam<'a, super::super::Security::SC_HANDLE>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(hscmanager: Param0, lpservicename: Param1, dwdesiredaccess: u32) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn OpenServiceA(hscmanager: super::super::Security::SC_HANDLE, lpservicename: ::windows::core::PCSTR, dwdesiredaccess: u32) -> super::super::Security::SC_HANDLE; } - ::core::mem::transmute(OpenServiceA(hscmanager.into_param().abi(), lpservicename.into_param().abi(), ::core::mem::transmute(dwdesiredaccess))) + let result__ = OpenServiceA(hscmanager.into_param().abi(), lpservicename.into_param().abi(), ::core::mem::transmute(dwdesiredaccess)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -814,14 +791,15 @@ pub unsafe fn OpenServiceA<'a, Param0: ::windows::core::IntoParam<'a, super::sup #[doc = "*Required features: `\"Win32_System_Services\"`, `\"Win32_Security\"`*"] #[cfg(feature = "Win32_Security")] #[inline] -pub unsafe fn OpenServiceW<'a, Param0: ::windows::core::IntoParam<'a, super::super::Security::SC_HANDLE>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(hscmanager: Param0, lpservicename: Param1, dwdesiredaccess: u32) -> super::super::Security::SC_HANDLE { +pub unsafe fn OpenServiceW<'a, Param0: ::windows::core::IntoParam<'a, super::super::Security::SC_HANDLE>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(hscmanager: Param0, lpservicename: Param1, dwdesiredaccess: u32) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn OpenServiceW(hscmanager: super::super::Security::SC_HANDLE, lpservicename: ::windows::core::PCWSTR, dwdesiredaccess: u32) -> super::super::Security::SC_HANDLE; } - ::core::mem::transmute(OpenServiceW(hscmanager.into_param().abi(), lpservicename.into_param().abi(), ::core::mem::transmute(dwdesiredaccess))) + let result__ = OpenServiceW(hscmanager.into_param().abi(), lpservicename.into_param().abi(), ::core::mem::transmute(dwdesiredaccess)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -1123,56 +1101,60 @@ pub unsafe fn QueryServiceStatusEx<'a, Param0: ::windows::core::IntoParam<'a, su pub const RPC_INTERFACE_EVENT_GUID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xbc90d167_9470_4139_a9ba_be0bbbf5b74d); #[doc = "*Required features: `\"Win32_System_Services\"`*"] #[inline] -pub unsafe fn RegisterServiceCtrlHandlerA<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(lpservicename: Param0, lphandlerproc: LPHANDLER_FUNCTION) -> SERVICE_STATUS_HANDLE { +pub unsafe fn RegisterServiceCtrlHandlerA<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(lpservicename: Param0, lphandlerproc: LPHANDLER_FUNCTION) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn RegisterServiceCtrlHandlerA(lpservicename: ::windows::core::PCSTR, lphandlerproc: ::windows::core::RawPtr) -> SERVICE_STATUS_HANDLE; } - ::core::mem::transmute(RegisterServiceCtrlHandlerA(lpservicename.into_param().abi(), ::core::mem::transmute(lphandlerproc))) + let result__ = RegisterServiceCtrlHandlerA(lpservicename.into_param().abi(), ::core::mem::transmute(lphandlerproc)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); } #[doc = "*Required features: `\"Win32_System_Services\"`*"] #[inline] -pub unsafe fn RegisterServiceCtrlHandlerExA<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(lpservicename: Param0, lphandlerproc: LPHANDLER_FUNCTION_EX, lpcontext: *const ::core::ffi::c_void) -> SERVICE_STATUS_HANDLE { +pub unsafe fn RegisterServiceCtrlHandlerExA<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(lpservicename: Param0, lphandlerproc: LPHANDLER_FUNCTION_EX, lpcontext: *const ::core::ffi::c_void) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn RegisterServiceCtrlHandlerExA(lpservicename: ::windows::core::PCSTR, lphandlerproc: ::windows::core::RawPtr, lpcontext: *const ::core::ffi::c_void) -> SERVICE_STATUS_HANDLE; } - ::core::mem::transmute(RegisterServiceCtrlHandlerExA(lpservicename.into_param().abi(), ::core::mem::transmute(lphandlerproc), ::core::mem::transmute(lpcontext))) + let result__ = RegisterServiceCtrlHandlerExA(lpservicename.into_param().abi(), ::core::mem::transmute(lphandlerproc), ::core::mem::transmute(lpcontext)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); } #[doc = "*Required features: `\"Win32_System_Services\"`*"] #[inline] -pub unsafe fn RegisterServiceCtrlHandlerExW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(lpservicename: Param0, lphandlerproc: LPHANDLER_FUNCTION_EX, lpcontext: *const ::core::ffi::c_void) -> SERVICE_STATUS_HANDLE { +pub unsafe fn RegisterServiceCtrlHandlerExW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(lpservicename: Param0, lphandlerproc: LPHANDLER_FUNCTION_EX, lpcontext: *const ::core::ffi::c_void) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn RegisterServiceCtrlHandlerExW(lpservicename: ::windows::core::PCWSTR, lphandlerproc: ::windows::core::RawPtr, lpcontext: *const ::core::ffi::c_void) -> SERVICE_STATUS_HANDLE; } - ::core::mem::transmute(RegisterServiceCtrlHandlerExW(lpservicename.into_param().abi(), ::core::mem::transmute(lphandlerproc), ::core::mem::transmute(lpcontext))) + let result__ = RegisterServiceCtrlHandlerExW(lpservicename.into_param().abi(), ::core::mem::transmute(lphandlerproc), ::core::mem::transmute(lpcontext)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); } #[doc = "*Required features: `\"Win32_System_Services\"`*"] #[inline] -pub unsafe fn RegisterServiceCtrlHandlerW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(lpservicename: Param0, lphandlerproc: LPHANDLER_FUNCTION) -> SERVICE_STATUS_HANDLE { +pub unsafe fn RegisterServiceCtrlHandlerW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(lpservicename: Param0, lphandlerproc: LPHANDLER_FUNCTION) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn RegisterServiceCtrlHandlerW(lpservicename: ::windows::core::PCWSTR, lphandlerproc: ::windows::core::RawPtr) -> SERVICE_STATUS_HANDLE; } - ::core::mem::transmute(RegisterServiceCtrlHandlerW(lpservicename.into_param().abi(), ::core::mem::transmute(lphandlerproc))) + let result__ = RegisterServiceCtrlHandlerW(lpservicename.into_param().abi(), ::core::mem::transmute(lphandlerproc)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -2532,14 +2514,7 @@ impl ::core::fmt::Debug for SERVICE_STATUS_CURRENT_STATE { pub struct SERVICE_STATUS_HANDLE(pub isize); impl SERVICE_STATUS_HANDLE { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for SERVICE_STATUS_HANDLE { diff --git a/crates/libs/windows/src/Windows/Win32/System/StationsAndDesktops/mod.rs b/crates/libs/windows/src/Windows/Win32/System/StationsAndDesktops/mod.rs index ca3695ddd6..b5f6c545ad 100644 --- a/crates/libs/windows/src/Windows/Win32/System/StationsAndDesktops/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/System/StationsAndDesktops/mod.rs @@ -263,14 +263,15 @@ pub unsafe fn CloseWindowStation<'a, Param0: ::windows::core::IntoParam<'a, HWIN #[doc = "*Required features: `\"Win32_System_StationsAndDesktops\"`, `\"Win32_Foundation\"`, `\"Win32_Graphics_Gdi\"`, `\"Win32_Security\"`*"] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_Security"))] #[inline] -pub unsafe fn CreateDesktopA<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(lpszdesktop: Param0, lpszdevice: Param1, pdevmode: *mut super::super::Graphics::Gdi::DEVMODEA, dwflags: u32, dwdesiredaccess: u32, lpsa: *const super::super::Security::SECURITY_ATTRIBUTES) -> HDESK { +pub unsafe fn CreateDesktopA<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(lpszdesktop: Param0, lpszdevice: Param1, pdevmode: *mut super::super::Graphics::Gdi::DEVMODEA, dwflags: u32, dwdesiredaccess: u32, lpsa: *const super::super::Security::SECURITY_ATTRIBUTES) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateDesktopA(lpszdesktop: ::windows::core::PCSTR, lpszdevice: ::windows::core::PCSTR, pdevmode: *mut super::super::Graphics::Gdi::DEVMODEA, dwflags: u32, dwdesiredaccess: u32, lpsa: *const super::super::Security::SECURITY_ATTRIBUTES) -> HDESK; } - ::core::mem::transmute(CreateDesktopA(lpszdesktop.into_param().abi(), lpszdevice.into_param().abi(), ::core::mem::transmute(pdevmode), ::core::mem::transmute(dwflags), ::core::mem::transmute(dwdesiredaccess), ::core::mem::transmute(lpsa))) + let result__ = CreateDesktopA(lpszdesktop.into_param().abi(), lpszdevice.into_param().abi(), ::core::mem::transmute(pdevmode), ::core::mem::transmute(dwflags), ::core::mem::transmute(dwdesiredaccess), ::core::mem::transmute(lpsa)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -278,14 +279,15 @@ pub unsafe fn CreateDesktopA<'a, Param0: ::windows::core::IntoParam<'a, ::window #[doc = "*Required features: `\"Win32_System_StationsAndDesktops\"`, `\"Win32_Foundation\"`, `\"Win32_Graphics_Gdi\"`, `\"Win32_Security\"`*"] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_Security"))] #[inline] -pub unsafe fn CreateDesktopExA<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(lpszdesktop: Param0, lpszdevice: Param1, pdevmode: *mut super::super::Graphics::Gdi::DEVMODEA, dwflags: u32, dwdesiredaccess: u32, lpsa: *const super::super::Security::SECURITY_ATTRIBUTES, ulheapsize: u32, pvoid: *mut ::core::ffi::c_void) -> HDESK { +pub unsafe fn CreateDesktopExA<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(lpszdesktop: Param0, lpszdevice: Param1, pdevmode: *mut super::super::Graphics::Gdi::DEVMODEA, dwflags: u32, dwdesiredaccess: u32, lpsa: *const super::super::Security::SECURITY_ATTRIBUTES, ulheapsize: u32, pvoid: *mut ::core::ffi::c_void) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateDesktopExA(lpszdesktop: ::windows::core::PCSTR, lpszdevice: ::windows::core::PCSTR, pdevmode: *mut super::super::Graphics::Gdi::DEVMODEA, dwflags: u32, dwdesiredaccess: u32, lpsa: *const super::super::Security::SECURITY_ATTRIBUTES, ulheapsize: u32, pvoid: *mut ::core::ffi::c_void) -> HDESK; } - ::core::mem::transmute(CreateDesktopExA(lpszdesktop.into_param().abi(), lpszdevice.into_param().abi(), ::core::mem::transmute(pdevmode), ::core::mem::transmute(dwflags), ::core::mem::transmute(dwdesiredaccess), ::core::mem::transmute(lpsa), ::core::mem::transmute(ulheapsize), ::core::mem::transmute(pvoid))) + let result__ = CreateDesktopExA(lpszdesktop.into_param().abi(), lpszdevice.into_param().abi(), ::core::mem::transmute(pdevmode), ::core::mem::transmute(dwflags), ::core::mem::transmute(dwdesiredaccess), ::core::mem::transmute(lpsa), ::core::mem::transmute(ulheapsize), ::core::mem::transmute(pvoid)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -293,14 +295,15 @@ pub unsafe fn CreateDesktopExA<'a, Param0: ::windows::core::IntoParam<'a, ::wind #[doc = "*Required features: `\"Win32_System_StationsAndDesktops\"`, `\"Win32_Foundation\"`, `\"Win32_Graphics_Gdi\"`, `\"Win32_Security\"`*"] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_Security"))] #[inline] -pub unsafe fn CreateDesktopExW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(lpszdesktop: Param0, lpszdevice: Param1, pdevmode: *mut super::super::Graphics::Gdi::DEVMODEW, dwflags: u32, dwdesiredaccess: u32, lpsa: *const super::super::Security::SECURITY_ATTRIBUTES, ulheapsize: u32, pvoid: *mut ::core::ffi::c_void) -> HDESK { +pub unsafe fn CreateDesktopExW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(lpszdesktop: Param0, lpszdevice: Param1, pdevmode: *mut super::super::Graphics::Gdi::DEVMODEW, dwflags: u32, dwdesiredaccess: u32, lpsa: *const super::super::Security::SECURITY_ATTRIBUTES, ulheapsize: u32, pvoid: *mut ::core::ffi::c_void) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateDesktopExW(lpszdesktop: ::windows::core::PCWSTR, lpszdevice: ::windows::core::PCWSTR, pdevmode: *mut super::super::Graphics::Gdi::DEVMODEW, dwflags: u32, dwdesiredaccess: u32, lpsa: *const super::super::Security::SECURITY_ATTRIBUTES, ulheapsize: u32, pvoid: *mut ::core::ffi::c_void) -> HDESK; } - ::core::mem::transmute(CreateDesktopExW(lpszdesktop.into_param().abi(), lpszdevice.into_param().abi(), ::core::mem::transmute(pdevmode), ::core::mem::transmute(dwflags), ::core::mem::transmute(dwdesiredaccess), ::core::mem::transmute(lpsa), ::core::mem::transmute(ulheapsize), ::core::mem::transmute(pvoid))) + let result__ = CreateDesktopExW(lpszdesktop.into_param().abi(), lpszdevice.into_param().abi(), ::core::mem::transmute(pdevmode), ::core::mem::transmute(dwflags), ::core::mem::transmute(dwdesiredaccess), ::core::mem::transmute(lpsa), ::core::mem::transmute(ulheapsize), ::core::mem::transmute(pvoid)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -308,14 +311,15 @@ pub unsafe fn CreateDesktopExW<'a, Param0: ::windows::core::IntoParam<'a, ::wind #[doc = "*Required features: `\"Win32_System_StationsAndDesktops\"`, `\"Win32_Foundation\"`, `\"Win32_Graphics_Gdi\"`, `\"Win32_Security\"`*"] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_Security"))] #[inline] -pub unsafe fn CreateDesktopW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(lpszdesktop: Param0, lpszdevice: Param1, pdevmode: *mut super::super::Graphics::Gdi::DEVMODEW, dwflags: u32, dwdesiredaccess: u32, lpsa: *const super::super::Security::SECURITY_ATTRIBUTES) -> HDESK { +pub unsafe fn CreateDesktopW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(lpszdesktop: Param0, lpszdevice: Param1, pdevmode: *mut super::super::Graphics::Gdi::DEVMODEW, dwflags: u32, dwdesiredaccess: u32, lpsa: *const super::super::Security::SECURITY_ATTRIBUTES) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateDesktopW(lpszdesktop: ::windows::core::PCWSTR, lpszdevice: ::windows::core::PCWSTR, pdevmode: *mut super::super::Graphics::Gdi::DEVMODEW, dwflags: u32, dwdesiredaccess: u32, lpsa: *const super::super::Security::SECURITY_ATTRIBUTES) -> HDESK; } - ::core::mem::transmute(CreateDesktopW(lpszdesktop.into_param().abi(), lpszdevice.into_param().abi(), ::core::mem::transmute(pdevmode), ::core::mem::transmute(dwflags), ::core::mem::transmute(dwdesiredaccess), ::core::mem::transmute(lpsa))) + let result__ = CreateDesktopW(lpszdesktop.into_param().abi(), lpszdevice.into_param().abi(), ::core::mem::transmute(pdevmode), ::core::mem::transmute(dwflags), ::core::mem::transmute(dwdesiredaccess), ::core::mem::transmute(lpsa)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -323,14 +327,15 @@ pub unsafe fn CreateDesktopW<'a, Param0: ::windows::core::IntoParam<'a, ::window #[doc = "*Required features: `\"Win32_System_StationsAndDesktops\"`, `\"Win32_Foundation\"`, `\"Win32_Security\"`*"] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Security"))] #[inline] -pub unsafe fn CreateWindowStationA<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(lpwinsta: Param0, dwflags: u32, dwdesiredaccess: u32, lpsa: *const super::super::Security::SECURITY_ATTRIBUTES) -> HWINSTA { +pub unsafe fn CreateWindowStationA<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(lpwinsta: Param0, dwflags: u32, dwdesiredaccess: u32, lpsa: *const super::super::Security::SECURITY_ATTRIBUTES) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateWindowStationA(lpwinsta: ::windows::core::PCSTR, dwflags: u32, dwdesiredaccess: u32, lpsa: *const super::super::Security::SECURITY_ATTRIBUTES) -> HWINSTA; } - ::core::mem::transmute(CreateWindowStationA(lpwinsta.into_param().abi(), ::core::mem::transmute(dwflags), ::core::mem::transmute(dwdesiredaccess), ::core::mem::transmute(lpsa))) + let result__ = CreateWindowStationA(lpwinsta.into_param().abi(), ::core::mem::transmute(dwflags), ::core::mem::transmute(dwdesiredaccess), ::core::mem::transmute(lpsa)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -338,14 +343,15 @@ pub unsafe fn CreateWindowStationA<'a, Param0: ::windows::core::IntoParam<'a, :: #[doc = "*Required features: `\"Win32_System_StationsAndDesktops\"`, `\"Win32_Foundation\"`, `\"Win32_Security\"`*"] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Security"))] #[inline] -pub unsafe fn CreateWindowStationW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(lpwinsta: Param0, dwflags: u32, dwdesiredaccess: u32, lpsa: *const super::super::Security::SECURITY_ATTRIBUTES) -> HWINSTA { +pub unsafe fn CreateWindowStationW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(lpwinsta: Param0, dwflags: u32, dwdesiredaccess: u32, lpsa: *const super::super::Security::SECURITY_ATTRIBUTES) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateWindowStationW(lpwinsta: ::windows::core::PCWSTR, dwflags: u32, dwdesiredaccess: u32, lpsa: *const super::super::Security::SECURITY_ATTRIBUTES) -> HWINSTA; } - ::core::mem::transmute(CreateWindowStationW(lpwinsta.into_param().abi(), ::core::mem::transmute(dwflags), ::core::mem::transmute(dwdesiredaccess), ::core::mem::transmute(lpsa))) + let result__ = CreateWindowStationW(lpwinsta.into_param().abi(), ::core::mem::transmute(dwflags), ::core::mem::transmute(dwdesiredaccess), ::core::mem::transmute(lpsa)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -433,28 +439,30 @@ pub unsafe fn EnumWindowStationsW<'a, Param1: ::windows::core::IntoParam<'a, sup } #[doc = "*Required features: `\"Win32_System_StationsAndDesktops\"`*"] #[inline] -pub unsafe fn GetProcessWindowStation() -> HWINSTA { +pub unsafe fn GetProcessWindowStation() -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn GetProcessWindowStation() -> HWINSTA; } - ::core::mem::transmute(GetProcessWindowStation()) + let result__ = GetProcessWindowStation(); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); } #[doc = "*Required features: `\"Win32_System_StationsAndDesktops\"`*"] #[inline] -pub unsafe fn GetThreadDesktop(dwthreadid: u32) -> HDESK { +pub unsafe fn GetThreadDesktop(dwthreadid: u32) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn GetThreadDesktop(dwthreadid: u32) -> HDESK; } - ::core::mem::transmute(GetThreadDesktop(::core::mem::transmute(dwthreadid))) + let result__ = GetThreadDesktop(::core::mem::transmute(dwthreadid)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -494,14 +502,7 @@ pub unsafe fn GetUserObjectInformationW<'a, Param0: ::windows::core::IntoParam<' pub struct HDESK(pub isize); impl HDESK { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HDESK { @@ -528,14 +529,7 @@ unsafe impl ::windows::core::Abi for HDESK { pub struct HWINSTA(pub isize); impl HWINSTA { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HWINSTA { @@ -560,14 +554,15 @@ unsafe impl ::windows::core::Abi for HWINSTA { #[doc = "*Required features: `\"Win32_System_StationsAndDesktops\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn OpenDesktopA<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>, Param2: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>>(lpszdesktop: Param0, dwflags: u32, finherit: Param2, dwdesiredaccess: u32) -> HDESK { +pub unsafe fn OpenDesktopA<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>, Param2: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>>(lpszdesktop: Param0, dwflags: u32, finherit: Param2, dwdesiredaccess: u32) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn OpenDesktopA(lpszdesktop: ::windows::core::PCSTR, dwflags: u32, finherit: super::super::Foundation::BOOL, dwdesiredaccess: u32) -> HDESK; } - ::core::mem::transmute(OpenDesktopA(lpszdesktop.into_param().abi(), ::core::mem::transmute(dwflags), finherit.into_param().abi(), ::core::mem::transmute(dwdesiredaccess))) + let result__ = OpenDesktopA(lpszdesktop.into_param().abi(), ::core::mem::transmute(dwflags), finherit.into_param().abi(), ::core::mem::transmute(dwdesiredaccess)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -575,14 +570,15 @@ pub unsafe fn OpenDesktopA<'a, Param0: ::windows::core::IntoParam<'a, ::windows: #[doc = "*Required features: `\"Win32_System_StationsAndDesktops\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn OpenDesktopW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>, Param2: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>>(lpszdesktop: Param0, dwflags: u32, finherit: Param2, dwdesiredaccess: u32) -> HDESK { +pub unsafe fn OpenDesktopW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>, Param2: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>>(lpszdesktop: Param0, dwflags: u32, finherit: Param2, dwdesiredaccess: u32) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn OpenDesktopW(lpszdesktop: ::windows::core::PCWSTR, dwflags: u32, finherit: super::super::Foundation::BOOL, dwdesiredaccess: u32) -> HDESK; } - ::core::mem::transmute(OpenDesktopW(lpszdesktop.into_param().abi(), ::core::mem::transmute(dwflags), finherit.into_param().abi(), ::core::mem::transmute(dwdesiredaccess))) + let result__ = OpenDesktopW(lpszdesktop.into_param().abi(), ::core::mem::transmute(dwflags), finherit.into_param().abi(), ::core::mem::transmute(dwdesiredaccess)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -590,14 +586,15 @@ pub unsafe fn OpenDesktopW<'a, Param0: ::windows::core::IntoParam<'a, ::windows: #[doc = "*Required features: `\"Win32_System_StationsAndDesktops\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn OpenInputDesktop<'a, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>>(dwflags: u32, finherit: Param1, dwdesiredaccess: u32) -> HDESK { +pub unsafe fn OpenInputDesktop<'a, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>>(dwflags: u32, finherit: Param1, dwdesiredaccess: u32) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn OpenInputDesktop(dwflags: u32, finherit: super::super::Foundation::BOOL, dwdesiredaccess: u32) -> HDESK; } - ::core::mem::transmute(OpenInputDesktop(::core::mem::transmute(dwflags), finherit.into_param().abi(), ::core::mem::transmute(dwdesiredaccess))) + let result__ = OpenInputDesktop(::core::mem::transmute(dwflags), finherit.into_param().abi(), ::core::mem::transmute(dwdesiredaccess)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -605,14 +602,15 @@ pub unsafe fn OpenInputDesktop<'a, Param1: ::windows::core::IntoParam<'a, super: #[doc = "*Required features: `\"Win32_System_StationsAndDesktops\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn OpenWindowStationA<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>>(lpszwinsta: Param0, finherit: Param1, dwdesiredaccess: u32) -> HWINSTA { +pub unsafe fn OpenWindowStationA<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>>(lpszwinsta: Param0, finherit: Param1, dwdesiredaccess: u32) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn OpenWindowStationA(lpszwinsta: ::windows::core::PCSTR, finherit: super::super::Foundation::BOOL, dwdesiredaccess: u32) -> HWINSTA; } - ::core::mem::transmute(OpenWindowStationA(lpszwinsta.into_param().abi(), finherit.into_param().abi(), ::core::mem::transmute(dwdesiredaccess))) + let result__ = OpenWindowStationA(lpszwinsta.into_param().abi(), finherit.into_param().abi(), ::core::mem::transmute(dwdesiredaccess)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -620,14 +618,15 @@ pub unsafe fn OpenWindowStationA<'a, Param0: ::windows::core::IntoParam<'a, ::wi #[doc = "*Required features: `\"Win32_System_StationsAndDesktops\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn OpenWindowStationW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>>(lpszwinsta: Param0, finherit: Param1, dwdesiredaccess: u32) -> HWINSTA { +pub unsafe fn OpenWindowStationW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>>(lpszwinsta: Param0, finherit: Param1, dwdesiredaccess: u32) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn OpenWindowStationW(lpszwinsta: ::windows::core::PCWSTR, finherit: super::super::Foundation::BOOL, dwdesiredaccess: u32) -> HWINSTA; } - ::core::mem::transmute(OpenWindowStationW(lpszwinsta.into_param().abi(), finherit.into_param().abi(), ::core::mem::transmute(dwdesiredaccess))) + let result__ = OpenWindowStationW(lpszwinsta.into_param().abi(), finherit.into_param().abi(), ::core::mem::transmute(dwdesiredaccess)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); diff --git a/crates/libs/windows/src/Windows/Win32/System/SystemInformation/mod.rs b/crates/libs/windows/src/Windows/Win32/System/SystemInformation/mod.rs index 3f09eaade5..1481a88cef 100644 --- a/crates/libs/windows/src/Windows/Win32/System/SystemInformation/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/System/SystemInformation/mod.rs @@ -400,18 +400,6 @@ pub unsafe fn EnumSystemFirmwareTables(firmwaretableprovidersignature: FIRMWARE_ #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq)] pub struct FIRMWARE_TABLE_ID(pub u32); -impl FIRMWARE_TABLE_ID { - pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } - } -} impl ::core::default::Default for FIRMWARE_TABLE_ID { fn default() -> Self { unsafe { ::core::mem::zeroed() } diff --git a/crates/libs/windows/src/Windows/Win32/System/Threading/mod.rs b/crates/libs/windows/src/Windows/Win32/System/Threading/mod.rs index bddc6032d3..1e4ee51332 100644 --- a/crates/libs/windows/src/Windows/Win32/System/Threading/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/System/Threading/mod.rs @@ -276,14 +276,15 @@ pub unsafe fn AvRtWaitOnThreadOrderingGroup<'a, Param0: ::windows::core::IntoPar #[doc = "*Required features: `\"Win32_System_Threading\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn AvSetMmMaxThreadCharacteristicsA<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(firsttask: Param0, secondtask: Param1, taskindex: *mut u32) -> super::super::Foundation::HANDLE { +pub unsafe fn AvSetMmMaxThreadCharacteristicsA<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(firsttask: Param0, secondtask: Param1, taskindex: *mut u32) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn AvSetMmMaxThreadCharacteristicsA(firsttask: ::windows::core::PCSTR, secondtask: ::windows::core::PCSTR, taskindex: *mut u32) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(AvSetMmMaxThreadCharacteristicsA(firsttask.into_param().abi(), secondtask.into_param().abi(), ::core::mem::transmute(taskindex))) + let result__ = AvSetMmMaxThreadCharacteristicsA(firsttask.into_param().abi(), secondtask.into_param().abi(), ::core::mem::transmute(taskindex)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -291,14 +292,15 @@ pub unsafe fn AvSetMmMaxThreadCharacteristicsA<'a, Param0: ::windows::core::Into #[doc = "*Required features: `\"Win32_System_Threading\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn AvSetMmMaxThreadCharacteristicsW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(firsttask: Param0, secondtask: Param1, taskindex: *mut u32) -> super::super::Foundation::HANDLE { +pub unsafe fn AvSetMmMaxThreadCharacteristicsW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(firsttask: Param0, secondtask: Param1, taskindex: *mut u32) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn AvSetMmMaxThreadCharacteristicsW(firsttask: ::windows::core::PCWSTR, secondtask: ::windows::core::PCWSTR, taskindex: *mut u32) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(AvSetMmMaxThreadCharacteristicsW(firsttask.into_param().abi(), secondtask.into_param().abi(), ::core::mem::transmute(taskindex))) + let result__ = AvSetMmMaxThreadCharacteristicsW(firsttask.into_param().abi(), secondtask.into_param().abi(), ::core::mem::transmute(taskindex)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -306,14 +308,15 @@ pub unsafe fn AvSetMmMaxThreadCharacteristicsW<'a, Param0: ::windows::core::Into #[doc = "*Required features: `\"Win32_System_Threading\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn AvSetMmThreadCharacteristicsA<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(taskname: Param0, taskindex: *mut u32) -> super::super::Foundation::HANDLE { +pub unsafe fn AvSetMmThreadCharacteristicsA<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(taskname: Param0, taskindex: *mut u32) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn AvSetMmThreadCharacteristicsA(taskname: ::windows::core::PCSTR, taskindex: *mut u32) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(AvSetMmThreadCharacteristicsA(taskname.into_param().abi(), ::core::mem::transmute(taskindex))) + let result__ = AvSetMmThreadCharacteristicsA(taskname.into_param().abi(), ::core::mem::transmute(taskindex)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -321,14 +324,15 @@ pub unsafe fn AvSetMmThreadCharacteristicsA<'a, Param0: ::windows::core::IntoPar #[doc = "*Required features: `\"Win32_System_Threading\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn AvSetMmThreadCharacteristicsW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(taskname: Param0, taskindex: *mut u32) -> super::super::Foundation::HANDLE { +pub unsafe fn AvSetMmThreadCharacteristicsW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(taskname: Param0, taskindex: *mut u32) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn AvSetMmThreadCharacteristicsW(taskname: ::windows::core::PCWSTR, taskindex: *mut u32) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(AvSetMmThreadCharacteristicsW(taskname.into_param().abi(), ::core::mem::transmute(taskindex))) + let result__ = AvSetMmThreadCharacteristicsW(taskname.into_param().abi(), ::core::mem::transmute(taskindex)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -353,14 +357,7 @@ pub unsafe fn AvSetMmThreadPriority<'a, Param0: ::windows::core::IntoParam<'a, s pub struct BoundaryDescriptorHandle(pub isize); impl BoundaryDescriptorHandle { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for BoundaryDescriptorHandle { @@ -690,14 +687,15 @@ pub unsafe fn ConvertThreadToFiberEx(lpparameter: *const ::core::ffi::c_void, dw } #[doc = "*Required features: `\"Win32_System_Threading\"`*"] #[inline] -pub unsafe fn CreateBoundaryDescriptorA<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(name: Param0, flags: u32) -> BoundaryDescriptorHandle { +pub unsafe fn CreateBoundaryDescriptorA<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(name: Param0, flags: u32) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateBoundaryDescriptorA(name: ::windows::core::PCSTR, flags: u32) -> BoundaryDescriptorHandle; } - ::core::mem::transmute(CreateBoundaryDescriptorA(name.into_param().abi(), ::core::mem::transmute(flags))) + let result__ = CreateBoundaryDescriptorA(name.into_param().abi(), ::core::mem::transmute(flags)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -719,14 +717,15 @@ pub unsafe fn CreateBoundaryDescriptorW<'a, Param0: ::windows::core::IntoParam<' #[doc = "*Required features: `\"Win32_System_Threading\"`, `\"Win32_Foundation\"`, `\"Win32_Security\"`*"] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Security"))] #[inline] -pub unsafe fn CreateEventA<'a, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>, Param2: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>, Param3: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(lpeventattributes: *const super::super::Security::SECURITY_ATTRIBUTES, bmanualreset: Param1, binitialstate: Param2, lpname: Param3) -> super::super::Foundation::HANDLE { +pub unsafe fn CreateEventA<'a, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>, Param2: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>, Param3: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(lpeventattributes: *const super::super::Security::SECURITY_ATTRIBUTES, bmanualreset: Param1, binitialstate: Param2, lpname: Param3) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateEventA(lpeventattributes: *const super::super::Security::SECURITY_ATTRIBUTES, bmanualreset: super::super::Foundation::BOOL, binitialstate: super::super::Foundation::BOOL, lpname: ::windows::core::PCSTR) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(CreateEventA(::core::mem::transmute(lpeventattributes), bmanualreset.into_param().abi(), binitialstate.into_param().abi(), lpname.into_param().abi())) + let result__ = CreateEventA(::core::mem::transmute(lpeventattributes), bmanualreset.into_param().abi(), binitialstate.into_param().abi(), lpname.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -734,14 +733,15 @@ pub unsafe fn CreateEventA<'a, Param1: ::windows::core::IntoParam<'a, super::sup #[doc = "*Required features: `\"Win32_System_Threading\"`, `\"Win32_Foundation\"`, `\"Win32_Security\"`*"] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Security"))] #[inline] -pub unsafe fn CreateEventExA<'a, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(lpeventattributes: *const super::super::Security::SECURITY_ATTRIBUTES, lpname: Param1, dwflags: CREATE_EVENT, dwdesiredaccess: u32) -> super::super::Foundation::HANDLE { +pub unsafe fn CreateEventExA<'a, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(lpeventattributes: *const super::super::Security::SECURITY_ATTRIBUTES, lpname: Param1, dwflags: CREATE_EVENT, dwdesiredaccess: u32) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateEventExA(lpeventattributes: *const super::super::Security::SECURITY_ATTRIBUTES, lpname: ::windows::core::PCSTR, dwflags: CREATE_EVENT, dwdesiredaccess: u32) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(CreateEventExA(::core::mem::transmute(lpeventattributes), lpname.into_param().abi(), ::core::mem::transmute(dwflags), ::core::mem::transmute(dwdesiredaccess))) + let result__ = CreateEventExA(::core::mem::transmute(lpeventattributes), lpname.into_param().abi(), ::core::mem::transmute(dwflags), ::core::mem::transmute(dwdesiredaccess)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -749,14 +749,15 @@ pub unsafe fn CreateEventExA<'a, Param1: ::windows::core::IntoParam<'a, ::window #[doc = "*Required features: `\"Win32_System_Threading\"`, `\"Win32_Foundation\"`, `\"Win32_Security\"`*"] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Security"))] #[inline] -pub unsafe fn CreateEventExW<'a, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(lpeventattributes: *const super::super::Security::SECURITY_ATTRIBUTES, lpname: Param1, dwflags: CREATE_EVENT, dwdesiredaccess: u32) -> super::super::Foundation::HANDLE { +pub unsafe fn CreateEventExW<'a, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(lpeventattributes: *const super::super::Security::SECURITY_ATTRIBUTES, lpname: Param1, dwflags: CREATE_EVENT, dwdesiredaccess: u32) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateEventExW(lpeventattributes: *const super::super::Security::SECURITY_ATTRIBUTES, lpname: ::windows::core::PCWSTR, dwflags: CREATE_EVENT, dwdesiredaccess: u32) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(CreateEventExW(::core::mem::transmute(lpeventattributes), lpname.into_param().abi(), ::core::mem::transmute(dwflags), ::core::mem::transmute(dwdesiredaccess))) + let result__ = CreateEventExW(::core::mem::transmute(lpeventattributes), lpname.into_param().abi(), ::core::mem::transmute(dwflags), ::core::mem::transmute(dwdesiredaccess)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -764,14 +765,15 @@ pub unsafe fn CreateEventExW<'a, Param1: ::windows::core::IntoParam<'a, ::window #[doc = "*Required features: `\"Win32_System_Threading\"`, `\"Win32_Foundation\"`, `\"Win32_Security\"`*"] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Security"))] #[inline] -pub unsafe fn CreateEventW<'a, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>, Param2: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>, Param3: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(lpeventattributes: *const super::super::Security::SECURITY_ATTRIBUTES, bmanualreset: Param1, binitialstate: Param2, lpname: Param3) -> super::super::Foundation::HANDLE { +pub unsafe fn CreateEventW<'a, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>, Param2: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>, Param3: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(lpeventattributes: *const super::super::Security::SECURITY_ATTRIBUTES, bmanualreset: Param1, binitialstate: Param2, lpname: Param3) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateEventW(lpeventattributes: *const super::super::Security::SECURITY_ATTRIBUTES, bmanualreset: super::super::Foundation::BOOL, binitialstate: super::super::Foundation::BOOL, lpname: ::windows::core::PCWSTR) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(CreateEventW(::core::mem::transmute(lpeventattributes), bmanualreset.into_param().abi(), binitialstate.into_param().abi(), lpname.into_param().abi())) + let result__ = CreateEventW(::core::mem::transmute(lpeventattributes), bmanualreset.into_param().abi(), binitialstate.into_param().abi(), lpname.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -807,14 +809,15 @@ pub unsafe fn CreateFiberEx(dwstackcommitsize: usize, dwstackreservesize: usize, #[doc = "*Required features: `\"Win32_System_Threading\"`, `\"Win32_Foundation\"`, `\"Win32_Security\"`*"] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Security"))] #[inline] -pub unsafe fn CreateMutexA<'a, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>, Param2: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(lpmutexattributes: *const super::super::Security::SECURITY_ATTRIBUTES, binitialowner: Param1, lpname: Param2) -> super::super::Foundation::HANDLE { +pub unsafe fn CreateMutexA<'a, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>, Param2: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(lpmutexattributes: *const super::super::Security::SECURITY_ATTRIBUTES, binitialowner: Param1, lpname: Param2) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateMutexA(lpmutexattributes: *const super::super::Security::SECURITY_ATTRIBUTES, binitialowner: super::super::Foundation::BOOL, lpname: ::windows::core::PCSTR) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(CreateMutexA(::core::mem::transmute(lpmutexattributes), binitialowner.into_param().abi(), lpname.into_param().abi())) + let result__ = CreateMutexA(::core::mem::transmute(lpmutexattributes), binitialowner.into_param().abi(), lpname.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -822,14 +825,15 @@ pub unsafe fn CreateMutexA<'a, Param1: ::windows::core::IntoParam<'a, super::sup #[doc = "*Required features: `\"Win32_System_Threading\"`, `\"Win32_Foundation\"`, `\"Win32_Security\"`*"] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Security"))] #[inline] -pub unsafe fn CreateMutexExA<'a, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(lpmutexattributes: *const super::super::Security::SECURITY_ATTRIBUTES, lpname: Param1, dwflags: u32, dwdesiredaccess: u32) -> super::super::Foundation::HANDLE { +pub unsafe fn CreateMutexExA<'a, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(lpmutexattributes: *const super::super::Security::SECURITY_ATTRIBUTES, lpname: Param1, dwflags: u32, dwdesiredaccess: u32) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateMutexExA(lpmutexattributes: *const super::super::Security::SECURITY_ATTRIBUTES, lpname: ::windows::core::PCSTR, dwflags: u32, dwdesiredaccess: u32) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(CreateMutexExA(::core::mem::transmute(lpmutexattributes), lpname.into_param().abi(), ::core::mem::transmute(dwflags), ::core::mem::transmute(dwdesiredaccess))) + let result__ = CreateMutexExA(::core::mem::transmute(lpmutexattributes), lpname.into_param().abi(), ::core::mem::transmute(dwflags), ::core::mem::transmute(dwdesiredaccess)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -837,14 +841,15 @@ pub unsafe fn CreateMutexExA<'a, Param1: ::windows::core::IntoParam<'a, ::window #[doc = "*Required features: `\"Win32_System_Threading\"`, `\"Win32_Foundation\"`, `\"Win32_Security\"`*"] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Security"))] #[inline] -pub unsafe fn CreateMutexExW<'a, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(lpmutexattributes: *const super::super::Security::SECURITY_ATTRIBUTES, lpname: Param1, dwflags: u32, dwdesiredaccess: u32) -> super::super::Foundation::HANDLE { +pub unsafe fn CreateMutexExW<'a, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(lpmutexattributes: *const super::super::Security::SECURITY_ATTRIBUTES, lpname: Param1, dwflags: u32, dwdesiredaccess: u32) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateMutexExW(lpmutexattributes: *const super::super::Security::SECURITY_ATTRIBUTES, lpname: ::windows::core::PCWSTR, dwflags: u32, dwdesiredaccess: u32) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(CreateMutexExW(::core::mem::transmute(lpmutexattributes), lpname.into_param().abi(), ::core::mem::transmute(dwflags), ::core::mem::transmute(dwdesiredaccess))) + let result__ = CreateMutexExW(::core::mem::transmute(lpmutexattributes), lpname.into_param().abi(), ::core::mem::transmute(dwflags), ::core::mem::transmute(dwdesiredaccess)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -852,14 +857,15 @@ pub unsafe fn CreateMutexExW<'a, Param1: ::windows::core::IntoParam<'a, ::window #[doc = "*Required features: `\"Win32_System_Threading\"`, `\"Win32_Foundation\"`, `\"Win32_Security\"`*"] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Security"))] #[inline] -pub unsafe fn CreateMutexW<'a, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>, Param2: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(lpmutexattributes: *const super::super::Security::SECURITY_ATTRIBUTES, binitialowner: Param1, lpname: Param2) -> super::super::Foundation::HANDLE { +pub unsafe fn CreateMutexW<'a, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>, Param2: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(lpmutexattributes: *const super::super::Security::SECURITY_ATTRIBUTES, binitialowner: Param1, lpname: Param2) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateMutexW(lpmutexattributes: *const super::super::Security::SECURITY_ATTRIBUTES, binitialowner: super::super::Foundation::BOOL, lpname: ::windows::core::PCWSTR) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(CreateMutexW(::core::mem::transmute(lpmutexattributes), binitialowner.into_param().abi(), lpname.into_param().abi())) + let result__ = CreateMutexW(::core::mem::transmute(lpmutexattributes), binitialowner.into_param().abi(), lpname.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -867,14 +873,15 @@ pub unsafe fn CreateMutexW<'a, Param1: ::windows::core::IntoParam<'a, super::sup #[doc = "*Required features: `\"Win32_System_Threading\"`, `\"Win32_Foundation\"`, `\"Win32_Security\"`*"] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Security"))] #[inline] -pub unsafe fn CreatePrivateNamespaceA<'a, Param2: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(lpprivatenamespaceattributes: *const super::super::Security::SECURITY_ATTRIBUTES, lpboundarydescriptor: *const ::core::ffi::c_void, lpaliasprefix: Param2) -> NamespaceHandle { +pub unsafe fn CreatePrivateNamespaceA<'a, Param2: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(lpprivatenamespaceattributes: *const super::super::Security::SECURITY_ATTRIBUTES, lpboundarydescriptor: *const ::core::ffi::c_void, lpaliasprefix: Param2) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreatePrivateNamespaceA(lpprivatenamespaceattributes: *const super::super::Security::SECURITY_ATTRIBUTES, lpboundarydescriptor: *const ::core::ffi::c_void, lpaliasprefix: ::windows::core::PCSTR) -> NamespaceHandle; } - ::core::mem::transmute(CreatePrivateNamespaceA(::core::mem::transmute(lpprivatenamespaceattributes), ::core::mem::transmute(lpboundarydescriptor), lpaliasprefix.into_param().abi())) + let result__ = CreatePrivateNamespaceA(::core::mem::transmute(lpprivatenamespaceattributes), ::core::mem::transmute(lpboundarydescriptor), lpaliasprefix.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -987,14 +994,15 @@ pub unsafe fn CreateProcessWithTokenW<'a, Param0: ::windows::core::IntoParam<'a, #[doc = "*Required features: `\"Win32_System_Threading\"`, `\"Win32_Foundation\"`, `\"Win32_Security\"`*"] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Security"))] #[inline] -pub unsafe fn CreateRemoteThread<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>>(hprocess: Param0, lpthreadattributes: *const super::super::Security::SECURITY_ATTRIBUTES, dwstacksize: usize, lpstartaddress: LPTHREAD_START_ROUTINE, lpparameter: *const ::core::ffi::c_void, dwcreationflags: u32, lpthreadid: *mut u32) -> super::super::Foundation::HANDLE { +pub unsafe fn CreateRemoteThread<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>>(hprocess: Param0, lpthreadattributes: *const super::super::Security::SECURITY_ATTRIBUTES, dwstacksize: usize, lpstartaddress: LPTHREAD_START_ROUTINE, lpparameter: *const ::core::ffi::c_void, dwcreationflags: u32, lpthreadid: *mut u32) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateRemoteThread(hprocess: super::super::Foundation::HANDLE, lpthreadattributes: *const super::super::Security::SECURITY_ATTRIBUTES, dwstacksize: usize, lpstartaddress: ::windows::core::RawPtr, lpparameter: *const ::core::ffi::c_void, dwcreationflags: u32, lpthreadid: *mut u32) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(CreateRemoteThread(hprocess.into_param().abi(), ::core::mem::transmute(lpthreadattributes), ::core::mem::transmute(dwstacksize), ::core::mem::transmute(lpstartaddress), ::core::mem::transmute(lpparameter), ::core::mem::transmute(dwcreationflags), ::core::mem::transmute(lpthreadid))) + let result__ = CreateRemoteThread(hprocess.into_param().abi(), ::core::mem::transmute(lpthreadattributes), ::core::mem::transmute(dwstacksize), ::core::mem::transmute(lpstartaddress), ::core::mem::transmute(lpparameter), ::core::mem::transmute(dwcreationflags), ::core::mem::transmute(lpthreadid)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -1002,14 +1010,15 @@ pub unsafe fn CreateRemoteThread<'a, Param0: ::windows::core::IntoParam<'a, supe #[doc = "*Required features: `\"Win32_System_Threading\"`, `\"Win32_Foundation\"`, `\"Win32_Security\"`*"] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Security"))] #[inline] -pub unsafe fn CreateRemoteThreadEx<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>, Param6: ::windows::core::IntoParam<'a, LPPROC_THREAD_ATTRIBUTE_LIST>>(hprocess: Param0, lpthreadattributes: *const super::super::Security::SECURITY_ATTRIBUTES, dwstacksize: usize, lpstartaddress: LPTHREAD_START_ROUTINE, lpparameter: *const ::core::ffi::c_void, dwcreationflags: u32, lpattributelist: Param6, lpthreadid: *mut u32) -> super::super::Foundation::HANDLE { +pub unsafe fn CreateRemoteThreadEx<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>, Param6: ::windows::core::IntoParam<'a, LPPROC_THREAD_ATTRIBUTE_LIST>>(hprocess: Param0, lpthreadattributes: *const super::super::Security::SECURITY_ATTRIBUTES, dwstacksize: usize, lpstartaddress: LPTHREAD_START_ROUTINE, lpparameter: *const ::core::ffi::c_void, dwcreationflags: u32, lpattributelist: Param6, lpthreadid: *mut u32) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateRemoteThreadEx(hprocess: super::super::Foundation::HANDLE, lpthreadattributes: *const super::super::Security::SECURITY_ATTRIBUTES, dwstacksize: usize, lpstartaddress: ::windows::core::RawPtr, lpparameter: *const ::core::ffi::c_void, dwcreationflags: u32, lpattributelist: LPPROC_THREAD_ATTRIBUTE_LIST, lpthreadid: *mut u32) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(CreateRemoteThreadEx(hprocess.into_param().abi(), ::core::mem::transmute(lpthreadattributes), ::core::mem::transmute(dwstacksize), ::core::mem::transmute(lpstartaddress), ::core::mem::transmute(lpparameter), ::core::mem::transmute(dwcreationflags), lpattributelist.into_param().abi(), ::core::mem::transmute(lpthreadid))) + let result__ = CreateRemoteThreadEx(hprocess.into_param().abi(), ::core::mem::transmute(lpthreadattributes), ::core::mem::transmute(dwstacksize), ::core::mem::transmute(lpstartaddress), ::core::mem::transmute(lpparameter), ::core::mem::transmute(dwcreationflags), lpattributelist.into_param().abi(), ::core::mem::transmute(lpthreadid)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -1017,14 +1026,15 @@ pub unsafe fn CreateRemoteThreadEx<'a, Param0: ::windows::core::IntoParam<'a, su #[doc = "*Required features: `\"Win32_System_Threading\"`, `\"Win32_Foundation\"`, `\"Win32_Security\"`*"] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Security"))] #[inline] -pub unsafe fn CreateSemaphoreA<'a, Param3: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(lpsemaphoreattributes: *const super::super::Security::SECURITY_ATTRIBUTES, linitialcount: i32, lmaximumcount: i32, lpname: Param3) -> super::super::Foundation::HANDLE { +pub unsafe fn CreateSemaphoreA<'a, Param3: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(lpsemaphoreattributes: *const super::super::Security::SECURITY_ATTRIBUTES, linitialcount: i32, lmaximumcount: i32, lpname: Param3) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateSemaphoreA(lpsemaphoreattributes: *const super::super::Security::SECURITY_ATTRIBUTES, linitialcount: i32, lmaximumcount: i32, lpname: ::windows::core::PCSTR) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(CreateSemaphoreA(::core::mem::transmute(lpsemaphoreattributes), ::core::mem::transmute(linitialcount), ::core::mem::transmute(lmaximumcount), lpname.into_param().abi())) + let result__ = CreateSemaphoreA(::core::mem::transmute(lpsemaphoreattributes), ::core::mem::transmute(linitialcount), ::core::mem::transmute(lmaximumcount), lpname.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -1032,14 +1042,15 @@ pub unsafe fn CreateSemaphoreA<'a, Param3: ::windows::core::IntoParam<'a, ::wind #[doc = "*Required features: `\"Win32_System_Threading\"`, `\"Win32_Foundation\"`, `\"Win32_Security\"`*"] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Security"))] #[inline] -pub unsafe fn CreateSemaphoreExA<'a, Param3: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(lpsemaphoreattributes: *const super::super::Security::SECURITY_ATTRIBUTES, linitialcount: i32, lmaximumcount: i32, lpname: Param3, dwflags: u32, dwdesiredaccess: u32) -> super::super::Foundation::HANDLE { +pub unsafe fn CreateSemaphoreExA<'a, Param3: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(lpsemaphoreattributes: *const super::super::Security::SECURITY_ATTRIBUTES, linitialcount: i32, lmaximumcount: i32, lpname: Param3, dwflags: u32, dwdesiredaccess: u32) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateSemaphoreExA(lpsemaphoreattributes: *const super::super::Security::SECURITY_ATTRIBUTES, linitialcount: i32, lmaximumcount: i32, lpname: ::windows::core::PCSTR, dwflags: u32, dwdesiredaccess: u32) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(CreateSemaphoreExA(::core::mem::transmute(lpsemaphoreattributes), ::core::mem::transmute(linitialcount), ::core::mem::transmute(lmaximumcount), lpname.into_param().abi(), ::core::mem::transmute(dwflags), ::core::mem::transmute(dwdesiredaccess))) + let result__ = CreateSemaphoreExA(::core::mem::transmute(lpsemaphoreattributes), ::core::mem::transmute(linitialcount), ::core::mem::transmute(lmaximumcount), lpname.into_param().abi(), ::core::mem::transmute(dwflags), ::core::mem::transmute(dwdesiredaccess)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -1047,14 +1058,15 @@ pub unsafe fn CreateSemaphoreExA<'a, Param3: ::windows::core::IntoParam<'a, ::wi #[doc = "*Required features: `\"Win32_System_Threading\"`, `\"Win32_Foundation\"`, `\"Win32_Security\"`*"] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Security"))] #[inline] -pub unsafe fn CreateSemaphoreExW<'a, Param3: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(lpsemaphoreattributes: *const super::super::Security::SECURITY_ATTRIBUTES, linitialcount: i32, lmaximumcount: i32, lpname: Param3, dwflags: u32, dwdesiredaccess: u32) -> super::super::Foundation::HANDLE { +pub unsafe fn CreateSemaphoreExW<'a, Param3: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(lpsemaphoreattributes: *const super::super::Security::SECURITY_ATTRIBUTES, linitialcount: i32, lmaximumcount: i32, lpname: Param3, dwflags: u32, dwdesiredaccess: u32) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateSemaphoreExW(lpsemaphoreattributes: *const super::super::Security::SECURITY_ATTRIBUTES, linitialcount: i32, lmaximumcount: i32, lpname: ::windows::core::PCWSTR, dwflags: u32, dwdesiredaccess: u32) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(CreateSemaphoreExW(::core::mem::transmute(lpsemaphoreattributes), ::core::mem::transmute(linitialcount), ::core::mem::transmute(lmaximumcount), lpname.into_param().abi(), ::core::mem::transmute(dwflags), ::core::mem::transmute(dwdesiredaccess))) + let result__ = CreateSemaphoreExW(::core::mem::transmute(lpsemaphoreattributes), ::core::mem::transmute(linitialcount), ::core::mem::transmute(lmaximumcount), lpname.into_param().abi(), ::core::mem::transmute(dwflags), ::core::mem::transmute(dwdesiredaccess)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -1062,14 +1074,15 @@ pub unsafe fn CreateSemaphoreExW<'a, Param3: ::windows::core::IntoParam<'a, ::wi #[doc = "*Required features: `\"Win32_System_Threading\"`, `\"Win32_Foundation\"`, `\"Win32_Security\"`*"] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Security"))] #[inline] -pub unsafe fn CreateSemaphoreW<'a, Param3: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(lpsemaphoreattributes: *const super::super::Security::SECURITY_ATTRIBUTES, linitialcount: i32, lmaximumcount: i32, lpname: Param3) -> super::super::Foundation::HANDLE { +pub unsafe fn CreateSemaphoreW<'a, Param3: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(lpsemaphoreattributes: *const super::super::Security::SECURITY_ATTRIBUTES, linitialcount: i32, lmaximumcount: i32, lpname: Param3) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateSemaphoreW(lpsemaphoreattributes: *const super::super::Security::SECURITY_ATTRIBUTES, linitialcount: i32, lmaximumcount: i32, lpname: ::windows::core::PCWSTR) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(CreateSemaphoreW(::core::mem::transmute(lpsemaphoreattributes), ::core::mem::transmute(linitialcount), ::core::mem::transmute(lmaximumcount), lpname.into_param().abi())) + let result__ = CreateSemaphoreW(::core::mem::transmute(lpsemaphoreattributes), ::core::mem::transmute(linitialcount), ::core::mem::transmute(lmaximumcount), lpname.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -1077,14 +1090,15 @@ pub unsafe fn CreateSemaphoreW<'a, Param3: ::windows::core::IntoParam<'a, ::wind #[doc = "*Required features: `\"Win32_System_Threading\"`, `\"Win32_Foundation\"`, `\"Win32_Security\"`*"] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Security"))] #[inline] -pub unsafe fn CreateThread(lpthreadattributes: *const super::super::Security::SECURITY_ATTRIBUTES, dwstacksize: usize, lpstartaddress: LPTHREAD_START_ROUTINE, lpparameter: *const ::core::ffi::c_void, dwcreationflags: THREAD_CREATION_FLAGS, lpthreadid: *mut u32) -> super::super::Foundation::HANDLE { +pub unsafe fn CreateThread(lpthreadattributes: *const super::super::Security::SECURITY_ATTRIBUTES, dwstacksize: usize, lpstartaddress: LPTHREAD_START_ROUTINE, lpparameter: *const ::core::ffi::c_void, dwcreationflags: THREAD_CREATION_FLAGS, lpthreadid: *mut u32) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateThread(lpthreadattributes: *const super::super::Security::SECURITY_ATTRIBUTES, dwstacksize: usize, lpstartaddress: ::windows::core::RawPtr, lpparameter: *const ::core::ffi::c_void, dwcreationflags: THREAD_CREATION_FLAGS, lpthreadid: *mut u32) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(CreateThread(::core::mem::transmute(lpthreadattributes), ::core::mem::transmute(dwstacksize), ::core::mem::transmute(lpstartaddress), ::core::mem::transmute(lpparameter), ::core::mem::transmute(dwcreationflags), ::core::mem::transmute(lpthreadid))) + let result__ = CreateThread(::core::mem::transmute(lpthreadattributes), ::core::mem::transmute(dwstacksize), ::core::mem::transmute(lpstartaddress), ::core::mem::transmute(lpparameter), ::core::mem::transmute(dwcreationflags), ::core::mem::transmute(lpthreadid)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -1177,14 +1191,15 @@ pub unsafe fn CreateThreadpoolWork(pfnwk: PTP_WORK_CALLBACK, pv: *mut ::core::ff #[doc = "*Required features: `\"Win32_System_Threading\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn CreateTimerQueue() -> super::super::Foundation::HANDLE { +pub unsafe fn CreateTimerQueue() -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateTimerQueue() -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(CreateTimerQueue()) + let result__ = CreateTimerQueue(); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -1237,14 +1252,15 @@ pub unsafe fn CreateUmsThreadContext(lpumsthread: *mut *mut ::core::ffi::c_void) #[doc = "*Required features: `\"Win32_System_Threading\"`, `\"Win32_Foundation\"`, `\"Win32_Security\"`*"] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Security"))] #[inline] -pub unsafe fn CreateWaitableTimerExW<'a, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(lptimerattributes: *const super::super::Security::SECURITY_ATTRIBUTES, lptimername: Param1, dwflags: u32, dwdesiredaccess: u32) -> super::super::Foundation::HANDLE { +pub unsafe fn CreateWaitableTimerExW<'a, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(lptimerattributes: *const super::super::Security::SECURITY_ATTRIBUTES, lptimername: Param1, dwflags: u32, dwdesiredaccess: u32) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateWaitableTimerExW(lptimerattributes: *const super::super::Security::SECURITY_ATTRIBUTES, lptimername: ::windows::core::PCWSTR, dwflags: u32, dwdesiredaccess: u32) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(CreateWaitableTimerExW(::core::mem::transmute(lptimerattributes), lptimername.into_param().abi(), ::core::mem::transmute(dwflags), ::core::mem::transmute(dwdesiredaccess))) + let result__ = CreateWaitableTimerExW(::core::mem::transmute(lptimerattributes), lptimername.into_param().abi(), ::core::mem::transmute(dwflags), ::core::mem::transmute(dwdesiredaccess)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -1252,14 +1268,15 @@ pub unsafe fn CreateWaitableTimerExW<'a, Param1: ::windows::core::IntoParam<'a, #[doc = "*Required features: `\"Win32_System_Threading\"`, `\"Win32_Foundation\"`, `\"Win32_Security\"`*"] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Security"))] #[inline] -pub unsafe fn CreateWaitableTimerW<'a, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>, Param2: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(lptimerattributes: *const super::super::Security::SECURITY_ATTRIBUTES, bmanualreset: Param1, lptimername: Param2) -> super::super::Foundation::HANDLE { +pub unsafe fn CreateWaitableTimerW<'a, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>, Param2: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(lptimerattributes: *const super::super::Security::SECURITY_ATTRIBUTES, bmanualreset: Param1, lptimername: Param2) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateWaitableTimerW(lptimerattributes: *const super::super::Security::SECURITY_ATTRIBUTES, bmanualreset: super::super::Foundation::BOOL, lptimername: ::windows::core::PCWSTR) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(CreateWaitableTimerW(::core::mem::transmute(lptimerattributes), bmanualreset.into_param().abi(), lptimername.into_param().abi())) + let result__ = CreateWaitableTimerW(::core::mem::transmute(lptimerattributes), bmanualreset.into_param().abi(), lptimername.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -2943,14 +2960,7 @@ pub type LPFIBER_START_ROUTINE = ::core::option::Option bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0.is_null() } } impl ::core::default::Default for LPPROC_THREAD_ATTRIBUTE_LIST { @@ -3131,14 +3141,7 @@ pub const MUTEX_MODIFY_STATE: u32 = 1u32; pub struct NamespaceHandle(pub isize); impl NamespaceHandle { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for NamespaceHandle { @@ -3208,14 +3211,15 @@ pub unsafe fn NtSetInformationThread<'a, Param0: ::windows::core::IntoParam<'a, #[doc = "*Required features: `\"Win32_System_Threading\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn OpenEventA<'a, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>, Param2: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(dwdesiredaccess: u32, binherithandle: Param1, lpname: Param2) -> super::super::Foundation::HANDLE { +pub unsafe fn OpenEventA<'a, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>, Param2: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(dwdesiredaccess: u32, binherithandle: Param1, lpname: Param2) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn OpenEventA(dwdesiredaccess: u32, binherithandle: super::super::Foundation::BOOL, lpname: ::windows::core::PCSTR) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(OpenEventA(::core::mem::transmute(dwdesiredaccess), binherithandle.into_param().abi(), lpname.into_param().abi())) + let result__ = OpenEventA(::core::mem::transmute(dwdesiredaccess), binherithandle.into_param().abi(), lpname.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -3223,14 +3227,15 @@ pub unsafe fn OpenEventA<'a, Param1: ::windows::core::IntoParam<'a, super::super #[doc = "*Required features: `\"Win32_System_Threading\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn OpenEventW<'a, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>, Param2: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(dwdesiredaccess: u32, binherithandle: Param1, lpname: Param2) -> super::super::Foundation::HANDLE { +pub unsafe fn OpenEventW<'a, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>, Param2: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(dwdesiredaccess: u32, binherithandle: Param1, lpname: Param2) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn OpenEventW(dwdesiredaccess: u32, binherithandle: super::super::Foundation::BOOL, lpname: ::windows::core::PCWSTR) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(OpenEventW(::core::mem::transmute(dwdesiredaccess), binherithandle.into_param().abi(), lpname.into_param().abi())) + let result__ = OpenEventW(::core::mem::transmute(dwdesiredaccess), binherithandle.into_param().abi(), lpname.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -3238,14 +3243,15 @@ pub unsafe fn OpenEventW<'a, Param1: ::windows::core::IntoParam<'a, super::super #[doc = "*Required features: `\"Win32_System_Threading\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn OpenMutexW<'a, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>, Param2: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(dwdesiredaccess: u32, binherithandle: Param1, lpname: Param2) -> super::super::Foundation::HANDLE { +pub unsafe fn OpenMutexW<'a, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>, Param2: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(dwdesiredaccess: u32, binherithandle: Param1, lpname: Param2) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn OpenMutexW(dwdesiredaccess: u32, binherithandle: super::super::Foundation::BOOL, lpname: ::windows::core::PCWSTR) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(OpenMutexW(::core::mem::transmute(dwdesiredaccess), binherithandle.into_param().abi(), lpname.into_param().abi())) + let result__ = OpenMutexW(::core::mem::transmute(dwdesiredaccess), binherithandle.into_param().abi(), lpname.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -3281,14 +3287,15 @@ pub unsafe fn OpenPrivateNamespaceW<'a, Param1: ::windows::core::IntoParam<'a, : #[doc = "*Required features: `\"Win32_System_Threading\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn OpenProcess<'a, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>>(dwdesiredaccess: PROCESS_ACCESS_RIGHTS, binherithandle: Param1, dwprocessid: u32) -> super::super::Foundation::HANDLE { +pub unsafe fn OpenProcess<'a, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>>(dwdesiredaccess: PROCESS_ACCESS_RIGHTS, binherithandle: Param1, dwprocessid: u32) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn OpenProcess(dwdesiredaccess: PROCESS_ACCESS_RIGHTS, binherithandle: super::super::Foundation::BOOL, dwprocessid: u32) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(OpenProcess(::core::mem::transmute(dwdesiredaccess), binherithandle.into_param().abi(), ::core::mem::transmute(dwprocessid))) + let result__ = OpenProcess(::core::mem::transmute(dwdesiredaccess), binherithandle.into_param().abi(), ::core::mem::transmute(dwprocessid)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -3311,14 +3318,15 @@ pub unsafe fn OpenProcessToken<'a, Param0: ::windows::core::IntoParam<'a, super: #[doc = "*Required features: `\"Win32_System_Threading\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn OpenSemaphoreW<'a, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>, Param2: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(dwdesiredaccess: u32, binherithandle: Param1, lpname: Param2) -> super::super::Foundation::HANDLE { +pub unsafe fn OpenSemaphoreW<'a, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>, Param2: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(dwdesiredaccess: u32, binherithandle: Param1, lpname: Param2) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn OpenSemaphoreW(dwdesiredaccess: u32, binherithandle: super::super::Foundation::BOOL, lpname: ::windows::core::PCWSTR) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(OpenSemaphoreW(::core::mem::transmute(dwdesiredaccess), binherithandle.into_param().abi(), lpname.into_param().abi())) + let result__ = OpenSemaphoreW(::core::mem::transmute(dwdesiredaccess), binherithandle.into_param().abi(), lpname.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -3326,14 +3334,15 @@ pub unsafe fn OpenSemaphoreW<'a, Param1: ::windows::core::IntoParam<'a, super::s #[doc = "*Required features: `\"Win32_System_Threading\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn OpenThread<'a, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>>(dwdesiredaccess: THREAD_ACCESS_RIGHTS, binherithandle: Param1, dwthreadid: u32) -> super::super::Foundation::HANDLE { +pub unsafe fn OpenThread<'a, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>>(dwdesiredaccess: THREAD_ACCESS_RIGHTS, binherithandle: Param1, dwthreadid: u32) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn OpenThread(dwdesiredaccess: THREAD_ACCESS_RIGHTS, binherithandle: super::super::Foundation::BOOL, dwthreadid: u32) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(OpenThread(::core::mem::transmute(dwdesiredaccess), binherithandle.into_param().abi(), ::core::mem::transmute(dwthreadid))) + let result__ = OpenThread(::core::mem::transmute(dwdesiredaccess), binherithandle.into_param().abi(), ::core::mem::transmute(dwthreadid)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -3356,14 +3365,15 @@ pub unsafe fn OpenThreadToken<'a, Param0: ::windows::core::IntoParam<'a, super:: #[doc = "*Required features: `\"Win32_System_Threading\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn OpenWaitableTimerW<'a, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>, Param2: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(dwdesiredaccess: u32, binherithandle: Param1, lptimername: Param2) -> super::super::Foundation::HANDLE { +pub unsafe fn OpenWaitableTimerW<'a, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>, Param2: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(dwdesiredaccess: u32, binherithandle: Param1, lptimername: Param2) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn OpenWaitableTimerW(dwdesiredaccess: u32, binherithandle: super::super::Foundation::BOOL, lptimername: ::windows::core::PCWSTR) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(OpenWaitableTimerW(::core::mem::transmute(dwdesiredaccess), binherithandle.into_param().abi(), lptimername.into_param().abi())) + let result__ = OpenWaitableTimerW(::core::mem::transmute(dwdesiredaccess), binherithandle.into_param().abi(), lptimername.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -4622,18 +4632,6 @@ pub type PTP_CLEANUP_GROUP_CANCEL_CALLBACK = ::core::option::Option bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } - } -} impl ::core::default::Default for PTP_POOL { fn default() -> Self { unsafe { ::core::mem::zeroed() } @@ -6928,14 +6926,7 @@ pub unsafe fn TerminateThread<'a, Param0: ::windows::core::IntoParam<'a, super:: pub struct TimerQueueHandle(pub isize); impl TimerQueueHandle { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == 0 } } impl ::core::default::Default for TimerQueueHandle { diff --git a/crates/libs/windows/src/Windows/Win32/System/WinRT/mod.rs b/crates/libs/windows/src/Windows/Win32/System/WinRT/mod.rs index daf5f915b1..54dd6c34dc 100644 --- a/crates/libs/windows/src/Windows/Win32/System/WinRT/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/System/WinRT/mod.rs @@ -69,14 +69,7 @@ impl ::core::fmt::Debug for ACTIVATIONTYPE { pub struct APARTMENT_SHUTDOWN_REGISTRATION_COOKIE(pub isize); impl APARTMENT_SHUTDOWN_REGISTRATION_COOKIE { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for APARTMENT_SHUTDOWN_REGISTRATION_COOKIE { @@ -473,14 +466,7 @@ pub unsafe fn GetRestrictedErrorInfo() -> ::windows::core::Result bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HSTRING_BUFFER { @@ -3551,14 +3537,7 @@ pub type PINSPECT_MEMORY_CALLBACK = ::core::option::Option bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for ROPARAMIIDHANDLE { diff --git a/crates/libs/windows/src/Windows/Win32/System/WindowsProgramming/mod.rs b/crates/libs/windows/src/Windows/Win32/System/WindowsProgramming/mod.rs index cfdfc70b26..f5d33eee0d 100644 --- a/crates/libs/windows/src/Windows/Win32/System/WindowsProgramming/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/System/WindowsProgramming/mod.rs @@ -1986,14 +1986,7 @@ impl ::core::default::Default for FEATURE_ERROR { pub struct FEATURE_STATE_CHANGE_SUBSCRIPTION(pub isize); impl FEATURE_STATE_CHANGE_SUBSCRIPTION { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for FEATURE_STATE_CHANGE_SUBSCRIPTION { @@ -2020,14 +2013,7 @@ unsafe impl ::windows::core::Abi for FEATURE_STATE_CHANGE_SUBSCRIPTION { pub struct FH_SERVICE_PIPE_HANDLE(pub isize); impl FH_SERVICE_PIPE_HANDLE { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for FH_SERVICE_PIPE_HANDLE { @@ -3023,14 +3009,7 @@ pub const HINSTANCE_ERROR: u32 = 32u32; pub struct HWINWATCH(pub isize); impl HWINWATCH { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HWINWATCH { diff --git a/crates/libs/windows/src/Windows/Win32/UI/Accessibility/mod.rs b/crates/libs/windows/src/Windows/Win32/UI/Accessibility/mod.rs index 0a602369ac..a03425f34c 100644 --- a/crates/libs/windows/src/Windows/Win32/UI/Accessibility/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/UI/Accessibility/mod.rs @@ -1337,14 +1337,7 @@ impl ::core::ops::Not for HIGHCONTRASTW_FLAGS { pub struct HUIAEVENT(pub isize); impl HUIAEVENT { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HUIAEVENT { @@ -1371,14 +1364,7 @@ unsafe impl ::windows::core::Abi for HUIAEVENT { pub struct HUIANODE(pub isize); impl HUIANODE { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HUIANODE { @@ -1405,14 +1391,7 @@ unsafe impl ::windows::core::Abi for HUIANODE { pub struct HUIAPATTERNOBJECT(pub isize); impl HUIAPATTERNOBJECT { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HUIAPATTERNOBJECT { @@ -1439,14 +1418,7 @@ unsafe impl ::windows::core::Abi for HUIAPATTERNOBJECT { pub struct HUIATEXTRANGE(pub isize); impl HUIATEXTRANGE { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HUIATEXTRANGE { @@ -1473,14 +1445,7 @@ unsafe impl ::windows::core::Abi for HUIATEXTRANGE { pub struct HWINEVENTHOOK(pub isize); impl HWINEVENTHOOK { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HWINEVENTHOOK { diff --git a/crates/libs/windows/src/Windows/Win32/UI/Animation/mod.rs b/crates/libs/windows/src/Windows/Win32/UI/Animation/mod.rs index 6c334abbfc..3235549917 100644 --- a/crates/libs/windows/src/Windows/Win32/UI/Animation/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/UI/Animation/mod.rs @@ -2783,18 +2783,6 @@ impl ::core::fmt::Debug for UI_ANIMATION_IDLE_BEHAVIOR { #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq)] pub struct UI_ANIMATION_KEYFRAME(pub isize); -impl UI_ANIMATION_KEYFRAME { - pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } - } -} impl ::core::default::Default for UI_ANIMATION_KEYFRAME { fn default() -> Self { unsafe { ::core::mem::zeroed() } diff --git a/crates/libs/windows/src/Windows/Win32/UI/ColorSystem/mod.rs b/crates/libs/windows/src/Windows/Win32/UI/ColorSystem/mod.rs index 763e67409d..51360647e4 100644 --- a/crates/libs/windows/src/Windows/Win32/UI/ColorSystem/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/UI/ColorSystem/mod.rs @@ -2188,14 +2188,7 @@ pub unsafe fn GetStandardColorSpaceProfileW<'a, Param0: ::windows::core::IntoPar pub struct HCOLORSPACE(pub isize); impl HCOLORSPACE { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HCOLORSPACE { diff --git a/crates/libs/windows/src/Windows/Win32/UI/Controls/mod.rs b/crates/libs/windows/src/Windows/Win32/UI/Controls/mod.rs index 32612e9b5d..5dc4ac497b 100644 --- a/crates/libs/windows/src/Windows/Win32/UI/Controls/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/UI/Controls/mod.rs @@ -1541,14 +1541,15 @@ pub unsafe fn CloseThemeData(htheme: isize) -> ::windows::core::Result<()> { #[doc = "*Required features: `\"Win32_UI_Controls\"`, `\"Win32_Foundation\"`, `\"Win32_Graphics_Gdi\"`*"] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] #[inline] -pub unsafe fn CreateMappedBitmap<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HINSTANCE>>(hinstance: Param0, idbitmap: isize, wflags: u32, lpcolormap: *const COLORMAP, inummaps: i32) -> super::super::Graphics::Gdi::HBITMAP { +pub unsafe fn CreateMappedBitmap<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HINSTANCE>>(hinstance: Param0, idbitmap: isize, wflags: u32, lpcolormap: *const COLORMAP, inummaps: i32) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateMappedBitmap(hinstance: super::super::Foundation::HINSTANCE, idbitmap: isize, wflags: u32, lpcolormap: *const COLORMAP, inummaps: i32) -> super::super::Graphics::Gdi::HBITMAP; } - ::core::mem::transmute(CreateMappedBitmap(hinstance.into_param().abi(), ::core::mem::transmute(idbitmap), ::core::mem::transmute(wflags), ::core::mem::transmute(lpcolormap), ::core::mem::transmute(inummaps))) + let result__ = CreateMappedBitmap(hinstance.into_param().abi(), ::core::mem::transmute(idbitmap), ::core::mem::transmute(wflags), ::core::mem::transmute(lpcolormap), ::core::mem::transmute(inummaps)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -1616,14 +1617,15 @@ pub unsafe fn CreateStatusWindowW<'a, Param1: ::windows::core::IntoParam<'a, ::w #[doc = "*Required features: `\"Win32_UI_Controls\"`, `\"Win32_UI_WindowsAndMessaging\"`*"] #[cfg(feature = "Win32_UI_WindowsAndMessaging")] #[inline] -pub unsafe fn CreateSyntheticPointerDevice(pointertype: super::WindowsAndMessaging::POINTER_INPUT_TYPE, maxcount: u32, mode: POINTER_FEEDBACK_MODE) -> HSYNTHETICPOINTERDEVICE { +pub unsafe fn CreateSyntheticPointerDevice(pointertype: super::WindowsAndMessaging::POINTER_INPUT_TYPE, maxcount: u32, mode: POINTER_FEEDBACK_MODE) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateSyntheticPointerDevice(pointertype: super::WindowsAndMessaging::POINTER_INPUT_TYPE, maxcount: u32, mode: POINTER_FEEDBACK_MODE) -> HSYNTHETICPOINTERDEVICE; } - ::core::mem::transmute(CreateSyntheticPointerDevice(::core::mem::transmute(pointertype), ::core::mem::transmute(maxcount), ::core::mem::transmute(mode))) + let result__ = CreateSyntheticPointerDevice(::core::mem::transmute(pointertype), ::core::mem::transmute(maxcount), ::core::mem::transmute(mode)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -5109,14 +5111,7 @@ pub const HDM_SETUNICODEFORMAT: u32 = 8197u32; pub struct HDPA(pub isize); impl HDPA { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HDPA { @@ -5143,14 +5138,7 @@ unsafe impl ::windows::core::Abi for HDPA { pub struct HDSA(pub isize); impl HDSA { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HDSA { @@ -5320,14 +5308,7 @@ pub const HHT_TORIGHT: u32 = 1024u32; pub struct HIMAGELIST(pub isize); impl HIMAGELIST { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HIMAGELIST { @@ -5416,14 +5397,7 @@ pub const HOVER_DEFAULT: u32 = 4294967295u32; pub struct HPROPSHEETPAGE(pub isize); impl HPROPSHEETPAGE { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HPROPSHEETPAGE { @@ -5450,14 +5424,7 @@ unsafe impl ::windows::core::Abi for HPROPSHEETPAGE { pub struct HSYNTHETICPOINTERDEVICE(pub isize); impl HSYNTHETICPOINTERDEVICE { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HSYNTHETICPOINTERDEVICE { @@ -5482,18 +5449,6 @@ unsafe impl ::windows::core::Abi for HSYNTHETICPOINTERDEVICE { #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq)] pub struct HTREEITEM(pub isize); -impl HTREEITEM { - pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } - } -} impl ::core::default::Default for HTREEITEM { fn default() -> Self { unsafe { ::core::mem::zeroed() } diff --git a/crates/libs/windows/src/Windows/Win32/UI/HiDpi/mod.rs b/crates/libs/windows/src/Windows/Win32/UI/HiDpi/mod.rs index 143a79e5d0..3ea43380e3 100644 --- a/crates/libs/windows/src/Windows/Win32/UI/HiDpi/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/UI/HiDpi/mod.rs @@ -181,14 +181,7 @@ impl ::core::fmt::Debug for DPI_AWARENESS { pub struct DPI_AWARENESS_CONTEXT(pub isize); impl DPI_AWARENESS_CONTEXT { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for DPI_AWARENESS_CONTEXT { diff --git a/crates/libs/windows/src/Windows/Win32/UI/Input/KeyboardAndMouse/mod.rs b/crates/libs/windows/src/Windows/Win32/UI/Input/KeyboardAndMouse/mod.rs index d608a0d47a..5756d8716e 100644 --- a/crates/libs/windows/src/Windows/Win32/UI/Input/KeyboardAndMouse/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/UI/Input/KeyboardAndMouse/mod.rs @@ -45,14 +45,15 @@ pub const AX_KBD_DESKTOP_TYPE: u32 = 1u32; #[doc = "*Required features: `\"Win32_UI_Input_KeyboardAndMouse\"`, `\"Win32_UI_TextServices\"`*"] #[cfg(feature = "Win32_UI_TextServices")] #[inline] -pub unsafe fn ActivateKeyboardLayout<'a, Param0: ::windows::core::IntoParam<'a, super::super::TextServices::HKL>>(hkl: Param0, flags: ACTIVATE_KEYBOARD_LAYOUT_FLAGS) -> super::super::TextServices::HKL { +pub unsafe fn ActivateKeyboardLayout<'a, Param0: ::windows::core::IntoParam<'a, super::super::TextServices::HKL>>(hkl: Param0, flags: ACTIVATE_KEYBOARD_LAYOUT_FLAGS) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn ActivateKeyboardLayout(hkl: super::super::TextServices::HKL, flags: ACTIVATE_KEYBOARD_LAYOUT_FLAGS) -> super::super::TextServices::HKL; } - ::core::mem::transmute(ActivateKeyboardLayout(hkl.into_param().abi(), ::core::mem::transmute(flags))) + let result__ = ActivateKeyboardLayout(hkl.into_param().abi(), ::core::mem::transmute(flags)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -1106,14 +1107,15 @@ impl ::core::default::Default for LIGATURE5 { #[doc = "*Required features: `\"Win32_UI_Input_KeyboardAndMouse\"`, `\"Win32_UI_TextServices\"`*"] #[cfg(feature = "Win32_UI_TextServices")] #[inline] -pub unsafe fn LoadKeyboardLayoutA<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(pwszklid: Param0, flags: ACTIVATE_KEYBOARD_LAYOUT_FLAGS) -> super::super::TextServices::HKL { +pub unsafe fn LoadKeyboardLayoutA<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(pwszklid: Param0, flags: ACTIVATE_KEYBOARD_LAYOUT_FLAGS) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn LoadKeyboardLayoutA(pwszklid: ::windows::core::PCSTR, flags: ACTIVATE_KEYBOARD_LAYOUT_FLAGS) -> super::super::TextServices::HKL; } - ::core::mem::transmute(LoadKeyboardLayoutA(pwszklid.into_param().abi(), ::core::mem::transmute(flags))) + let result__ = LoadKeyboardLayoutA(pwszklid.into_param().abi(), ::core::mem::transmute(flags)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -1121,14 +1123,15 @@ pub unsafe fn LoadKeyboardLayoutA<'a, Param0: ::windows::core::IntoParam<'a, ::w #[doc = "*Required features: `\"Win32_UI_Input_KeyboardAndMouse\"`, `\"Win32_UI_TextServices\"`*"] #[cfg(feature = "Win32_UI_TextServices")] #[inline] -pub unsafe fn LoadKeyboardLayoutW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(pwszklid: Param0, flags: ACTIVATE_KEYBOARD_LAYOUT_FLAGS) -> super::super::TextServices::HKL { +pub unsafe fn LoadKeyboardLayoutW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(pwszklid: Param0, flags: ACTIVATE_KEYBOARD_LAYOUT_FLAGS) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn LoadKeyboardLayoutW(pwszklid: ::windows::core::PCWSTR, flags: ACTIVATE_KEYBOARD_LAYOUT_FLAGS) -> super::super::TextServices::HKL; } - ::core::mem::transmute(LoadKeyboardLayoutW(pwszklid.into_param().abi(), ::core::mem::transmute(flags))) + let result__ = LoadKeyboardLayoutW(pwszklid.into_param().abi(), ::core::mem::transmute(flags)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); diff --git a/crates/libs/windows/src/Windows/Win32/UI/Input/Touch/mod.rs b/crates/libs/windows/src/Windows/Win32/UI/Input/Touch/mod.rs index 8c3ddf613c..c17dbe7f7d 100644 --- a/crates/libs/windows/src/Windows/Win32/UI/Input/Touch/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/UI/Input/Touch/mod.rs @@ -281,14 +281,7 @@ pub unsafe fn GetTouchInputInfo<'a, Param0: ::windows::core::IntoParam<'a, HTOUC pub struct HGESTUREINFO(pub isize); impl HGESTUREINFO { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HGESTUREINFO { @@ -315,14 +308,7 @@ unsafe impl ::windows::core::Abi for HGESTUREINFO { pub struct HTOUCHINPUT(pub isize); impl HTOUCHINPUT { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HTOUCHINPUT { diff --git a/crates/libs/windows/src/Windows/Win32/UI/Input/mod.rs b/crates/libs/windows/src/Windows/Win32/UI/Input/mod.rs index ccaf76b0e4..1205fdeaca 100644 --- a/crates/libs/windows/src/Windows/Win32/UI/Input/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/UI/Input/mod.rs @@ -152,14 +152,7 @@ pub unsafe fn GetRegisteredRawInputDevices(prawinputdevices: *mut RAWINPUTDEVICE pub struct HRAWINPUT(pub isize); impl HRAWINPUT { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HRAWINPUT { diff --git a/crates/libs/windows/src/Windows/Win32/UI/InteractionContext/mod.rs b/crates/libs/windows/src/Windows/Win32/UI/InteractionContext/mod.rs index 63033f83be..87b514f7d1 100644 --- a/crates/libs/windows/src/Windows/Win32/UI/InteractionContext/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/UI/InteractionContext/mod.rs @@ -324,14 +324,7 @@ pub unsafe fn GetTranslationParameterInteractionContext<'a, Param0: ::windows::c pub struct HINTERACTIONCONTEXT(pub isize); impl HINTERACTIONCONTEXT { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HINTERACTIONCONTEXT { diff --git a/crates/libs/windows/src/Windows/Win32/UI/Shell/mod.rs b/crates/libs/windows/src/Windows/Win32/UI/Shell/mod.rs index f7ec75a96e..1636a95ad3 100644 --- a/crates/libs/windows/src/Windows/Win32/UI/Shell/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/UI/Shell/mod.rs @@ -10376,14 +10376,7 @@ pub unsafe fn GetWindowSubclass<'a, Param0: ::windows::core::IntoParam<'a, super pub struct HDROP(pub isize); impl HDROP { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HDROP { @@ -11216,14 +11209,7 @@ pub const HOMEGROUP_SECURITY_GROUP_MULTI: &'static str = "HUG"; pub struct HPSXA(pub isize); impl HPSXA { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HPSXA { @@ -72793,14 +72779,7 @@ pub unsafe fn SetWindowSubclass<'a, Param0: ::windows::core::IntoParam<'a, super pub struct ShFindChangeNotificationHandle(pub isize); impl ShFindChangeNotificationHandle { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for ShFindChangeNotificationHandle { diff --git a/crates/libs/windows/src/Windows/Win32/UI/TabletPC/mod.rs b/crates/libs/windows/src/Windows/Win32/UI/TabletPC/mod.rs index 94e00aaca9..a063298e48 100644 --- a/crates/libs/windows/src/Windows/Win32/UI/TabletPC/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/UI/TabletPC/mod.rs @@ -3014,14 +3014,7 @@ pub unsafe fn GetUnicodeRanges<'a, Param0: ::windows::core::IntoParam<'a, HRECOG pub struct HRECOALT(pub isize); impl HRECOALT { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HRECOALT { @@ -3048,14 +3041,7 @@ unsafe impl ::windows::core::Abi for HRECOALT { pub struct HRECOCONTEXT(pub isize); impl HRECOCONTEXT { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HRECOCONTEXT { @@ -3082,14 +3068,7 @@ unsafe impl ::windows::core::Abi for HRECOCONTEXT { pub struct HRECOGNIZER(pub isize); impl HRECOGNIZER { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HRECOGNIZER { @@ -3116,14 +3095,7 @@ unsafe impl ::windows::core::Abi for HRECOGNIZER { pub struct HRECOLATTICE(pub isize); impl HRECOLATTICE { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HRECOLATTICE { @@ -3150,14 +3122,7 @@ unsafe impl ::windows::core::Abi for HRECOLATTICE { pub struct HRECOWORDLIST(pub isize); impl HRECOWORDLIST { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HRECOWORDLIST { diff --git a/crates/libs/windows/src/Windows/Win32/UI/TextServices/mod.rs b/crates/libs/windows/src/Windows/Win32/UI/TextServices/mod.rs index 40338fc22f..de554d6b03 100644 --- a/crates/libs/windows/src/Windows/Win32/UI/TextServices/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/UI/TextServices/mod.rs @@ -224,14 +224,7 @@ pub const GXFPF_ROUND_NEAREST: u32 = 1u32; pub struct HKL(pub isize); impl HKL { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HKL { diff --git a/crates/libs/windows/src/Windows/Win32/UI/WindowsAndMessaging/mod.rs b/crates/libs/windows/src/Windows/Win32/UI/WindowsAndMessaging/mod.rs index 214f2e5fc9..13c9d70bf8 100644 --- a/crates/libs/windows/src/Windows/Win32/UI/WindowsAndMessaging/mod.rs +++ b/crates/libs/windows/src/Windows/Win32/UI/WindowsAndMessaging/mod.rs @@ -1840,14 +1840,15 @@ pub unsafe fn CopyAcceleratorTableW<'a, Param0: ::windows::core::IntoParam<'a, H } #[doc = "*Required features: `\"Win32_UI_WindowsAndMessaging\"`*"] #[inline] -pub unsafe fn CopyIcon<'a, Param0: ::windows::core::IntoParam<'a, HICON>>(hicon: Param0) -> HICON { +pub unsafe fn CopyIcon<'a, Param0: ::windows::core::IntoParam<'a, HICON>>(hicon: Param0) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CopyIcon(hicon: HICON) -> HICON; } - ::core::mem::transmute(CopyIcon(hicon.into_param().abi())) + let result__ = CopyIcon(hicon.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -1855,42 +1856,45 @@ pub unsafe fn CopyIcon<'a, Param0: ::windows::core::IntoParam<'a, HICON>>(hicon: #[doc = "*Required features: `\"Win32_UI_WindowsAndMessaging\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn CopyImage<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>>(h: Param0, r#type: GDI_IMAGE_TYPE, cx: i32, cy: i32, flags: IMAGE_FLAGS) -> super::super::Foundation::HANDLE { +pub unsafe fn CopyImage<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HANDLE>>(h: Param0, r#type: GDI_IMAGE_TYPE, cx: i32, cy: i32, flags: IMAGE_FLAGS) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CopyImage(h: super::super::Foundation::HANDLE, r#type: GDI_IMAGE_TYPE, cx: i32, cy: i32, flags: IMAGE_FLAGS) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(CopyImage(h.into_param().abi(), ::core::mem::transmute(r#type), ::core::mem::transmute(cx), ::core::mem::transmute(cy), ::core::mem::transmute(flags))) + let result__ = CopyImage(h.into_param().abi(), ::core::mem::transmute(r#type), ::core::mem::transmute(cx), ::core::mem::transmute(cy), ::core::mem::transmute(flags)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); } #[doc = "*Required features: `\"Win32_UI_WindowsAndMessaging\"`*"] #[inline] -pub unsafe fn CreateAcceleratorTableA(paccel: &[ACCEL]) -> HACCEL { +pub unsafe fn CreateAcceleratorTableA(paccel: &[ACCEL]) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateAcceleratorTableA(paccel: *const ACCEL, caccel: i32) -> HACCEL; } - ::core::mem::transmute(CreateAcceleratorTableA(::core::mem::transmute(::windows::core::as_ptr_or_null(paccel)), paccel.len() as _)) + let result__ = CreateAcceleratorTableA(::core::mem::transmute(::windows::core::as_ptr_or_null(paccel)), paccel.len() as _); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); } #[doc = "*Required features: `\"Win32_UI_WindowsAndMessaging\"`*"] #[inline] -pub unsafe fn CreateAcceleratorTableW(paccel: &[ACCEL]) -> HACCEL { +pub unsafe fn CreateAcceleratorTableW(paccel: &[ACCEL]) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateAcceleratorTableW(paccel: *const ACCEL, caccel: i32) -> HACCEL; } - ::core::mem::transmute(CreateAcceleratorTableW(::core::mem::transmute(::windows::core::as_ptr_or_null(paccel)), paccel.len() as _)) + let result__ = CreateAcceleratorTableW(::core::mem::transmute(::windows::core::as_ptr_or_null(paccel)), paccel.len() as _); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -1913,14 +1917,15 @@ pub unsafe fn CreateCaret<'a, Param0: ::windows::core::IntoParam<'a, super::supe #[doc = "*Required features: `\"Win32_UI_WindowsAndMessaging\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn CreateCursor<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HINSTANCE>>(hinst: Param0, xhotspot: i32, yhotspot: i32, nwidth: i32, nheight: i32, pvandplane: *const ::core::ffi::c_void, pvxorplane: *const ::core::ffi::c_void) -> HCURSOR { +pub unsafe fn CreateCursor<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HINSTANCE>>(hinst: Param0, xhotspot: i32, yhotspot: i32, nwidth: i32, nheight: i32, pvandplane: *const ::core::ffi::c_void, pvxorplane: *const ::core::ffi::c_void) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateCursor(hinst: super::super::Foundation::HINSTANCE, xhotspot: i32, yhotspot: i32, nwidth: i32, nheight: i32, pvandplane: *const ::core::ffi::c_void, pvxorplane: *const ::core::ffi::c_void) -> HCURSOR; } - ::core::mem::transmute(CreateCursor(hinst.into_param().abi(), ::core::mem::transmute(xhotspot), ::core::mem::transmute(yhotspot), ::core::mem::transmute(nwidth), ::core::mem::transmute(nheight), ::core::mem::transmute(pvandplane), ::core::mem::transmute(pvxorplane))) + let result__ = CreateCursor(hinst.into_param().abi(), ::core::mem::transmute(xhotspot), ::core::mem::transmute(yhotspot), ::core::mem::transmute(nwidth), ::core::mem::transmute(nheight), ::core::mem::transmute(pvandplane), ::core::mem::transmute(pvxorplane)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -1988,14 +1993,15 @@ pub unsafe fn CreateDialogParamW<'a, Param0: ::windows::core::IntoParam<'a, supe #[doc = "*Required features: `\"Win32_UI_WindowsAndMessaging\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn CreateIcon<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HINSTANCE>>(hinstance: Param0, nwidth: i32, nheight: i32, cplanes: u8, cbitspixel: u8, lpbandbits: *const u8, lpbxorbits: *const u8) -> HICON { +pub unsafe fn CreateIcon<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HINSTANCE>>(hinstance: Param0, nwidth: i32, nheight: i32, cplanes: u8, cbitspixel: u8, lpbandbits: *const u8, lpbxorbits: *const u8) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateIcon(hinstance: super::super::Foundation::HINSTANCE, nwidth: i32, nheight: i32, cplanes: u8, cbitspixel: u8, lpbandbits: *const u8, lpbxorbits: *const u8) -> HICON; } - ::core::mem::transmute(CreateIcon(hinstance.into_param().abi(), ::core::mem::transmute(nwidth), ::core::mem::transmute(nheight), ::core::mem::transmute(cplanes), ::core::mem::transmute(cbitspixel), ::core::mem::transmute(lpbandbits), ::core::mem::transmute(lpbxorbits))) + let result__ = CreateIcon(hinstance.into_param().abi(), ::core::mem::transmute(nwidth), ::core::mem::transmute(nheight), ::core::mem::transmute(cplanes), ::core::mem::transmute(cbitspixel), ::core::mem::transmute(lpbandbits), ::core::mem::transmute(lpbxorbits)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -2003,14 +2009,15 @@ pub unsafe fn CreateIcon<'a, Param0: ::windows::core::IntoParam<'a, super::super #[doc = "*Required features: `\"Win32_UI_WindowsAndMessaging\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn CreateIconFromResource<'a, Param2: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>>(presbits: *const u8, dwressize: u32, ficon: Param2, dwver: u32) -> HICON { +pub unsafe fn CreateIconFromResource<'a, Param2: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>>(presbits: *const u8, dwressize: u32, ficon: Param2, dwver: u32) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateIconFromResource(presbits: *const u8, dwressize: u32, ficon: super::super::Foundation::BOOL, dwver: u32) -> HICON; } - ::core::mem::transmute(CreateIconFromResource(::core::mem::transmute(presbits), ::core::mem::transmute(dwressize), ficon.into_param().abi(), ::core::mem::transmute(dwver))) + let result__ = CreateIconFromResource(::core::mem::transmute(presbits), ::core::mem::transmute(dwressize), ficon.into_param().abi(), ::core::mem::transmute(dwver)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -2018,14 +2025,15 @@ pub unsafe fn CreateIconFromResource<'a, Param2: ::windows::core::IntoParam<'a, #[doc = "*Required features: `\"Win32_UI_WindowsAndMessaging\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn CreateIconFromResourceEx<'a, Param2: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>>(presbits: *const u8, dwressize: u32, ficon: Param2, dwver: u32, cxdesired: i32, cydesired: i32, flags: IMAGE_FLAGS) -> HICON { +pub unsafe fn CreateIconFromResourceEx<'a, Param2: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>>(presbits: *const u8, dwressize: u32, ficon: Param2, dwver: u32, cxdesired: i32, cydesired: i32, flags: IMAGE_FLAGS) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateIconFromResourceEx(presbits: *const u8, dwressize: u32, ficon: super::super::Foundation::BOOL, dwver: u32, cxdesired: i32, cydesired: i32, flags: IMAGE_FLAGS) -> HICON; } - ::core::mem::transmute(CreateIconFromResourceEx(::core::mem::transmute(presbits), ::core::mem::transmute(dwressize), ficon.into_param().abi(), ::core::mem::transmute(dwver), ::core::mem::transmute(cxdesired), ::core::mem::transmute(cydesired), ::core::mem::transmute(flags))) + let result__ = CreateIconFromResourceEx(::core::mem::transmute(presbits), ::core::mem::transmute(dwressize), ficon.into_param().abi(), ::core::mem::transmute(dwver), ::core::mem::transmute(cxdesired), ::core::mem::transmute(cydesired), ::core::mem::transmute(flags)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -2033,14 +2041,15 @@ pub unsafe fn CreateIconFromResourceEx<'a, Param2: ::windows::core::IntoParam<'a #[doc = "*Required features: `\"Win32_UI_WindowsAndMessaging\"`, `\"Win32_Foundation\"`, `\"Win32_Graphics_Gdi\"`*"] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] #[inline] -pub unsafe fn CreateIconIndirect(piconinfo: *const ICONINFO) -> HICON { +pub unsafe fn CreateIconIndirect(piconinfo: *const ICONINFO) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateIconIndirect(piconinfo: *const ICONINFO) -> HICON; } - ::core::mem::transmute(CreateIconIndirect(::core::mem::transmute(piconinfo))) + let result__ = CreateIconIndirect(::core::mem::transmute(piconinfo)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -2077,28 +2086,30 @@ pub unsafe fn CreateMDIWindowW<'a, Param0: ::windows::core::IntoParam<'a, ::wind } #[doc = "*Required features: `\"Win32_UI_WindowsAndMessaging\"`*"] #[inline] -pub unsafe fn CreateMenu() -> HMENU { +pub unsafe fn CreateMenu() -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateMenu() -> HMENU; } - ::core::mem::transmute(CreateMenu()) + let result__ = CreateMenu(); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); } #[doc = "*Required features: `\"Win32_UI_WindowsAndMessaging\"`*"] #[inline] -pub unsafe fn CreatePopupMenu() -> HMENU { +pub unsafe fn CreatePopupMenu() -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreatePopupMenu() -> HMENU; } - ::core::mem::transmute(CreatePopupMenu()) + let result__ = CreatePopupMenu(); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -5374,14 +5385,7 @@ pub unsafe fn GetWindowWord<'a, Param0: ::windows::core::IntoParam<'a, super::su pub struct HACCEL(pub isize); impl HACCEL { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HACCEL { @@ -5533,14 +5537,7 @@ pub const HCF_LOGONDESKTOP: u32 = 256u32; pub struct HCURSOR(pub isize); impl HCURSOR { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HCURSOR { @@ -5632,14 +5629,7 @@ pub const HELP_WM_HELP: u32 = 12u32; pub struct HHOOK(pub isize); impl HHOOK { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HHOOK { @@ -5666,14 +5656,7 @@ unsafe impl ::windows::core::Abi for HHOOK { pub struct HICON(pub isize); impl HICON { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HICON { @@ -5706,14 +5689,7 @@ pub const HKL_PREV: u32 = 0u32; pub struct HMENU(pub isize); impl HMENU { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HMENU { @@ -7073,14 +7049,15 @@ pub const LR_COLOR: u32 = 2u32; #[doc = "*Required features: `\"Win32_UI_WindowsAndMessaging\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn LoadAcceleratorsA<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HINSTANCE>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(hinstance: Param0, lptablename: Param1) -> HACCEL { +pub unsafe fn LoadAcceleratorsA<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HINSTANCE>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(hinstance: Param0, lptablename: Param1) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn LoadAcceleratorsA(hinstance: super::super::Foundation::HINSTANCE, lptablename: ::windows::core::PCSTR) -> HACCEL; } - ::core::mem::transmute(LoadAcceleratorsA(hinstance.into_param().abi(), lptablename.into_param().abi())) + let result__ = LoadAcceleratorsA(hinstance.into_param().abi(), lptablename.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -7088,14 +7065,15 @@ pub unsafe fn LoadAcceleratorsA<'a, Param0: ::windows::core::IntoParam<'a, super #[doc = "*Required features: `\"Win32_UI_WindowsAndMessaging\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn LoadAcceleratorsW<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HINSTANCE>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(hinstance: Param0, lptablename: Param1) -> HACCEL { +pub unsafe fn LoadAcceleratorsW<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HINSTANCE>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(hinstance: Param0, lptablename: Param1) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn LoadAcceleratorsW(hinstance: super::super::Foundation::HINSTANCE, lptablename: ::windows::core::PCWSTR) -> HACCEL; } - ::core::mem::transmute(LoadAcceleratorsW(hinstance.into_param().abi(), lptablename.into_param().abi())) + let result__ = LoadAcceleratorsW(hinstance.into_param().abi(), lptablename.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -7103,42 +7081,45 @@ pub unsafe fn LoadAcceleratorsW<'a, Param0: ::windows::core::IntoParam<'a, super #[doc = "*Required features: `\"Win32_UI_WindowsAndMessaging\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn LoadCursorA<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HINSTANCE>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(hinstance: Param0, lpcursorname: Param1) -> HCURSOR { +pub unsafe fn LoadCursorA<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HINSTANCE>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(hinstance: Param0, lpcursorname: Param1) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn LoadCursorA(hinstance: super::super::Foundation::HINSTANCE, lpcursorname: ::windows::core::PCSTR) -> HCURSOR; } - ::core::mem::transmute(LoadCursorA(hinstance.into_param().abi(), lpcursorname.into_param().abi())) + let result__ = LoadCursorA(hinstance.into_param().abi(), lpcursorname.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); } #[doc = "*Required features: `\"Win32_UI_WindowsAndMessaging\"`*"] #[inline] -pub unsafe fn LoadCursorFromFileA<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(lpfilename: Param0) -> HCURSOR { +pub unsafe fn LoadCursorFromFileA<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(lpfilename: Param0) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn LoadCursorFromFileA(lpfilename: ::windows::core::PCSTR) -> HCURSOR; } - ::core::mem::transmute(LoadCursorFromFileA(lpfilename.into_param().abi())) + let result__ = LoadCursorFromFileA(lpfilename.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); } #[doc = "*Required features: `\"Win32_UI_WindowsAndMessaging\"`*"] #[inline] -pub unsafe fn LoadCursorFromFileW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(lpfilename: Param0) -> HCURSOR { +pub unsafe fn LoadCursorFromFileW<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(lpfilename: Param0) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn LoadCursorFromFileW(lpfilename: ::windows::core::PCWSTR) -> HCURSOR; } - ::core::mem::transmute(LoadCursorFromFileW(lpfilename.into_param().abi())) + let result__ = LoadCursorFromFileW(lpfilename.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -7146,14 +7127,15 @@ pub unsafe fn LoadCursorFromFileW<'a, Param0: ::windows::core::IntoParam<'a, ::w #[doc = "*Required features: `\"Win32_UI_WindowsAndMessaging\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn LoadCursorW<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HINSTANCE>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(hinstance: Param0, lpcursorname: Param1) -> HCURSOR { +pub unsafe fn LoadCursorW<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HINSTANCE>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(hinstance: Param0, lpcursorname: Param1) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn LoadCursorW(hinstance: super::super::Foundation::HINSTANCE, lpcursorname: ::windows::core::PCWSTR) -> HCURSOR; } - ::core::mem::transmute(LoadCursorW(hinstance.into_param().abi(), lpcursorname.into_param().abi())) + let result__ = LoadCursorW(hinstance.into_param().abi(), lpcursorname.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -7161,14 +7143,15 @@ pub unsafe fn LoadCursorW<'a, Param0: ::windows::core::IntoParam<'a, super::supe #[doc = "*Required features: `\"Win32_UI_WindowsAndMessaging\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn LoadIconA<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HINSTANCE>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(hinstance: Param0, lpiconname: Param1) -> HICON { +pub unsafe fn LoadIconA<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HINSTANCE>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(hinstance: Param0, lpiconname: Param1) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn LoadIconA(hinstance: super::super::Foundation::HINSTANCE, lpiconname: ::windows::core::PCSTR) -> HICON; } - ::core::mem::transmute(LoadIconA(hinstance.into_param().abi(), lpiconname.into_param().abi())) + let result__ = LoadIconA(hinstance.into_param().abi(), lpiconname.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -7176,14 +7159,15 @@ pub unsafe fn LoadIconA<'a, Param0: ::windows::core::IntoParam<'a, super::super: #[doc = "*Required features: `\"Win32_UI_WindowsAndMessaging\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn LoadIconW<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HINSTANCE>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(hinstance: Param0, lpiconname: Param1) -> HICON { +pub unsafe fn LoadIconW<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HINSTANCE>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(hinstance: Param0, lpiconname: Param1) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn LoadIconW(hinstance: super::super::Foundation::HINSTANCE, lpiconname: ::windows::core::PCWSTR) -> HICON; } - ::core::mem::transmute(LoadIconW(hinstance.into_param().abi(), lpiconname.into_param().abi())) + let result__ = LoadIconW(hinstance.into_param().abi(), lpiconname.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -7191,14 +7175,15 @@ pub unsafe fn LoadIconW<'a, Param0: ::windows::core::IntoParam<'a, super::super: #[doc = "*Required features: `\"Win32_UI_WindowsAndMessaging\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn LoadImageA<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HINSTANCE>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(hinst: Param0, name: Param1, r#type: GDI_IMAGE_TYPE, cx: i32, cy: i32, fuload: IMAGE_FLAGS) -> super::super::Foundation::HANDLE { +pub unsafe fn LoadImageA<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HINSTANCE>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(hinst: Param0, name: Param1, r#type: GDI_IMAGE_TYPE, cx: i32, cy: i32, fuload: IMAGE_FLAGS) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn LoadImageA(hinst: super::super::Foundation::HINSTANCE, name: ::windows::core::PCSTR, r#type: GDI_IMAGE_TYPE, cx: i32, cy: i32, fuload: IMAGE_FLAGS) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(LoadImageA(hinst.into_param().abi(), name.into_param().abi(), ::core::mem::transmute(r#type), ::core::mem::transmute(cx), ::core::mem::transmute(cy), ::core::mem::transmute(fuload))) + let result__ = LoadImageA(hinst.into_param().abi(), name.into_param().abi(), ::core::mem::transmute(r#type), ::core::mem::transmute(cx), ::core::mem::transmute(cy), ::core::mem::transmute(fuload)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -7206,14 +7191,15 @@ pub unsafe fn LoadImageA<'a, Param0: ::windows::core::IntoParam<'a, super::super #[doc = "*Required features: `\"Win32_UI_WindowsAndMessaging\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn LoadImageW<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HINSTANCE>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(hinst: Param0, name: Param1, r#type: GDI_IMAGE_TYPE, cx: i32, cy: i32, fuload: IMAGE_FLAGS) -> super::super::Foundation::HANDLE { +pub unsafe fn LoadImageW<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HINSTANCE>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(hinst: Param0, name: Param1, r#type: GDI_IMAGE_TYPE, cx: i32, cy: i32, fuload: IMAGE_FLAGS) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn LoadImageW(hinst: super::super::Foundation::HINSTANCE, name: ::windows::core::PCWSTR, r#type: GDI_IMAGE_TYPE, cx: i32, cy: i32, fuload: IMAGE_FLAGS) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(LoadImageW(hinst.into_param().abi(), name.into_param().abi(), ::core::mem::transmute(r#type), ::core::mem::transmute(cx), ::core::mem::transmute(cy), ::core::mem::transmute(fuload))) + let result__ = LoadImageW(hinst.into_param().abi(), name.into_param().abi(), ::core::mem::transmute(r#type), ::core::mem::transmute(cx), ::core::mem::transmute(cy), ::core::mem::transmute(fuload)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -7221,42 +7207,45 @@ pub unsafe fn LoadImageW<'a, Param0: ::windows::core::IntoParam<'a, super::super #[doc = "*Required features: `\"Win32_UI_WindowsAndMessaging\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn LoadMenuA<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HINSTANCE>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(hinstance: Param0, lpmenuname: Param1) -> HMENU { +pub unsafe fn LoadMenuA<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HINSTANCE>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(hinstance: Param0, lpmenuname: Param1) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn LoadMenuA(hinstance: super::super::Foundation::HINSTANCE, lpmenuname: ::windows::core::PCSTR) -> HMENU; } - ::core::mem::transmute(LoadMenuA(hinstance.into_param().abi(), lpmenuname.into_param().abi())) + let result__ = LoadMenuA(hinstance.into_param().abi(), lpmenuname.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); } #[doc = "*Required features: `\"Win32_UI_WindowsAndMessaging\"`*"] #[inline] -pub unsafe fn LoadMenuIndirectA(lpmenutemplate: *const ::core::ffi::c_void) -> HMENU { +pub unsafe fn LoadMenuIndirectA(lpmenutemplate: *const ::core::ffi::c_void) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn LoadMenuIndirectA(lpmenutemplate: *const ::core::ffi::c_void) -> HMENU; } - ::core::mem::transmute(LoadMenuIndirectA(::core::mem::transmute(lpmenutemplate))) + let result__ = LoadMenuIndirectA(::core::mem::transmute(lpmenutemplate)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); } #[doc = "*Required features: `\"Win32_UI_WindowsAndMessaging\"`*"] #[inline] -pub unsafe fn LoadMenuIndirectW(lpmenutemplate: *const ::core::ffi::c_void) -> HMENU { +pub unsafe fn LoadMenuIndirectW(lpmenutemplate: *const ::core::ffi::c_void) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn LoadMenuIndirectW(lpmenutemplate: *const ::core::ffi::c_void) -> HMENU; } - ::core::mem::transmute(LoadMenuIndirectW(::core::mem::transmute(lpmenutemplate))) + let result__ = LoadMenuIndirectW(::core::mem::transmute(lpmenutemplate)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -7264,14 +7253,15 @@ pub unsafe fn LoadMenuIndirectW(lpmenutemplate: *const ::core::ffi::c_void) -> H #[doc = "*Required features: `\"Win32_UI_WindowsAndMessaging\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn LoadMenuW<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HINSTANCE>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(hinstance: Param0, lpmenuname: Param1) -> HMENU { +pub unsafe fn LoadMenuW<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HINSTANCE>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(hinstance: Param0, lpmenuname: Param1) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn LoadMenuW(hinstance: super::super::Foundation::HINSTANCE, lpmenuname: ::windows::core::PCWSTR) -> HMENU; } - ::core::mem::transmute(LoadMenuW(hinstance.into_param().abi(), lpmenuname.into_param().abi())) + let result__ = LoadMenuW(hinstance.into_param().abi(), lpmenuname.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -11137,14 +11127,15 @@ pub unsafe fn RemoveMenu<'a, Param0: ::windows::core::IntoParam<'a, HMENU>>(hmen #[doc = "*Required features: `\"Win32_UI_WindowsAndMessaging\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn RemovePropA<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HWND>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(hwnd: Param0, lpstring: Param1) -> super::super::Foundation::HANDLE { +pub unsafe fn RemovePropA<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HWND>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(hwnd: Param0, lpstring: Param1) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn RemovePropA(hwnd: super::super::Foundation::HWND, lpstring: ::windows::core::PCSTR) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(RemovePropA(hwnd.into_param().abi(), lpstring.into_param().abi())) + let result__ = RemovePropA(hwnd.into_param().abi(), lpstring.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -11152,14 +11143,15 @@ pub unsafe fn RemovePropA<'a, Param0: ::windows::core::IntoParam<'a, super::supe #[doc = "*Required features: `\"Win32_UI_WindowsAndMessaging\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn RemovePropW<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HWND>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(hwnd: Param0, lpstring: Param1) -> super::super::Foundation::HANDLE { +pub unsafe fn RemovePropW<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HWND>, Param1: ::windows::core::IntoParam<'a, ::windows::core::PCWSTR>>(hwnd: Param0, lpstring: Param1) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn RemovePropW(hwnd: super::super::Foundation::HWND, lpstring: ::windows::core::PCWSTR) -> super::super::Foundation::HANDLE; } - ::core::mem::transmute(RemovePropW(hwnd.into_param().abi(), lpstring.into_param().abi())) + let result__ = RemovePropW(hwnd.into_param().abi(), lpstring.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -13846,14 +13838,15 @@ pub unsafe fn SetWindowsHookA(nfiltertype: i32, pfnfilterproc: HOOKPROC) -> HHOO #[doc = "*Required features: `\"Win32_UI_WindowsAndMessaging\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn SetWindowsHookExA<'a, Param2: ::windows::core::IntoParam<'a, super::super::Foundation::HINSTANCE>>(idhook: WINDOWS_HOOK_ID, lpfn: HOOKPROC, hmod: Param2, dwthreadid: u32) -> HHOOK { +pub unsafe fn SetWindowsHookExA<'a, Param2: ::windows::core::IntoParam<'a, super::super::Foundation::HINSTANCE>>(idhook: WINDOWS_HOOK_ID, lpfn: HOOKPROC, hmod: Param2, dwthreadid: u32) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn SetWindowsHookExA(idhook: WINDOWS_HOOK_ID, lpfn: ::windows::core::RawPtr, hmod: super::super::Foundation::HINSTANCE, dwthreadid: u32) -> HHOOK; } - ::core::mem::transmute(SetWindowsHookExA(::core::mem::transmute(idhook), ::core::mem::transmute(lpfn), hmod.into_param().abi(), ::core::mem::transmute(dwthreadid))) + let result__ = SetWindowsHookExA(::core::mem::transmute(idhook), ::core::mem::transmute(lpfn), hmod.into_param().abi(), ::core::mem::transmute(dwthreadid)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -13861,14 +13854,15 @@ pub unsafe fn SetWindowsHookExA<'a, Param2: ::windows::core::IntoParam<'a, super #[doc = "*Required features: `\"Win32_UI_WindowsAndMessaging\"`, `\"Win32_Foundation\"`*"] #[cfg(feature = "Win32_Foundation")] #[inline] -pub unsafe fn SetWindowsHookExW<'a, Param2: ::windows::core::IntoParam<'a, super::super::Foundation::HINSTANCE>>(idhook: WINDOWS_HOOK_ID, lpfn: HOOKPROC, hmod: Param2, dwthreadid: u32) -> HHOOK { +pub unsafe fn SetWindowsHookExW<'a, Param2: ::windows::core::IntoParam<'a, super::super::Foundation::HINSTANCE>>(idhook: WINDOWS_HOOK_ID, lpfn: HOOKPROC, hmod: Param2, dwthreadid: u32) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn SetWindowsHookExW(idhook: WINDOWS_HOOK_ID, lpfn: ::windows::core::RawPtr, hmod: super::super::Foundation::HINSTANCE, dwthreadid: u32) -> HHOOK; } - ::core::mem::transmute(SetWindowsHookExW(::core::mem::transmute(idhook), ::core::mem::transmute(lpfn), hmod.into_param().abi(), ::core::mem::transmute(dwthreadid))) + let result__ = SetWindowsHookExW(::core::mem::transmute(idhook), ::core::mem::transmute(lpfn), hmod.into_param().abi(), ::core::mem::transmute(dwthreadid)); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); diff --git a/crates/libs/windows/src/core/bindings.rs b/crates/libs/windows/src/core/bindings.rs index cd8c609bb6..9fa26d35ae 100644 --- a/crates/libs/windows/src/core/bindings.rs +++ b/crates/libs/windows/src/core/bindings.rs @@ -1354,22 +1354,16 @@ pub unsafe fn GetLastError() -> WIN32_ERROR { unimplemented!("Unsupported target OS"); } #[repr(transparent)] +#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq)] pub struct HANDLE(pub isize); impl HANDLE { pub fn is_invalid(&self) -> bool { - self.0 == 0 || self.0 == -1 - } - pub fn ok(self) -> ::windows::core::Result { - if self.is_invalid() { - Err(::windows::core::Error::from_win32()) - } else { - Ok(self) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HANDLE { fn default() -> Self { - Self(0) + unsafe { ::core::mem::zeroed() } } } impl ::core::clone::Clone for HANDLE { @@ -1378,12 +1372,6 @@ impl ::core::clone::Clone for HANDLE { } } impl ::core::marker::Copy for HANDLE {} -impl ::core::cmp::PartialEq for HANDLE { - fn eq(&self, other: &Self) -> bool { - self.0 == other.0 - } -} -impl ::core::cmp::Eq for HANDLE {} impl ::core::fmt::Debug for HANDLE { fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { f.debug_tuple("HANDLE").field(&self.0).finish() @@ -1395,18 +1383,6 @@ unsafe impl ::windows::core::Abi for HANDLE { #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq)] pub struct HINSTANCE(pub isize); -impl HINSTANCE { - pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } - } -} impl ::core::default::Default for HINSTANCE { fn default() -> Self { unsafe { ::core::mem::zeroed() } @@ -1849,14 +1825,15 @@ pub unsafe fn LoadLibraryA<'a, Param0: ::windows::core::IntoParam<'a, ::windows: unimplemented!("Unsupported target OS"); } #[inline] -pub unsafe fn GetProcessHeap() -> HeapHandle { +pub unsafe fn GetProcessHeap() -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn GetProcessHeap() -> HeapHandle; } - ::core::mem::transmute(GetProcessHeap()) + let result__ = GetProcessHeap(); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); @@ -1959,14 +1936,7 @@ pub unsafe fn HeapFree<'a, Param0: ::windows::core::IntoParam<'a, HeapHandle>>(h pub struct HeapHandle(pub isize); impl HeapHandle { pub fn is_invalid(&self) -> bool { - *self == unsafe { ::core::mem::zeroed() } - } - pub fn ok(self) -> ::windows::core::Result { - if !self.is_invalid() { - Ok(self) - } else { - Err(::windows::core::Error::from_win32()) - } + self.0 == -1 || self.0 == 0 } } impl ::core::default::Default for HeapHandle { @@ -1989,14 +1959,15 @@ unsafe impl ::windows::core::Abi for HeapHandle { type Abi = Self; } #[inline] -pub unsafe fn CreateEventA<'a, Param1: ::windows::core::IntoParam<'a, BOOL>, Param2: ::windows::core::IntoParam<'a, BOOL>, Param3: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(lpeventattributes: *const SECURITY_ATTRIBUTES, bmanualreset: Param1, binitialstate: Param2, lpname: Param3) -> HANDLE { +pub unsafe fn CreateEventA<'a, Param1: ::windows::core::IntoParam<'a, BOOL>, Param2: ::windows::core::IntoParam<'a, BOOL>, Param3: ::windows::core::IntoParam<'a, ::windows::core::PCSTR>>(lpeventattributes: *const SECURITY_ATTRIBUTES, bmanualreset: Param1, binitialstate: Param2, lpname: Param3) -> ::windows::core::Result { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateEventA(lpeventattributes: *const SECURITY_ATTRIBUTES, bmanualreset: BOOL, binitialstate: BOOL, lpname: ::windows::core::PCSTR) -> HANDLE; } - ::core::mem::transmute(CreateEventA(::core::mem::transmute(lpeventattributes), bmanualreset.into_param().abi(), binitialstate.into_param().abi(), lpname.into_param().abi())) + let result__ = CreateEventA(::core::mem::transmute(lpeventattributes), bmanualreset.into_param().abi(), binitialstate.into_param().abi(), lpname.into_param().abi()); + (!result__.is_invalid()).then(|| result__).ok_or_else(::windows::core::Error::from_win32) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); diff --git a/crates/libs/windows/src/core/delay_load.rs b/crates/libs/windows/src/core/delay_load.rs index b4c4f4744e..d49fb131e4 100644 --- a/crates/libs/windows/src/core/delay_load.rs +++ b/crates/libs/windows/src/core/delay_load.rs @@ -6,7 +6,8 @@ pub fn delay_load(library: &[u8], function: &[u8]) -> RawPtr { unsafe { let library = LoadLibraryA(PCSTR(library.as_ptr())); - if library.is_invalid() { + // TODO: workaround for https://github.com/microsoft/win32metadata/issues/863 + if library.0 == 0 { return core::ptr::null_mut(); } diff --git a/crates/libs/windows/src/core/heap.rs b/crates/libs/windows/src/core/heap.rs index 8a6eb851c3..413cea2a01 100644 --- a/crates/libs/windows/src/core/heap.rs +++ b/crates/libs/windows/src/core/heap.rs @@ -3,7 +3,7 @@ use bindings::*; // TODO: why not Option pub fn heap_alloc(bytes: usize) -> Result { - let ptr = unsafe { HeapAlloc(GetProcessHeap(), HEAP_NONE, bytes) }; + let ptr = unsafe { HeapAlloc(GetProcessHeap()?, HEAP_NONE, bytes) }; if ptr.is_null() { Err(E_OUTOFMEMORY.into()) @@ -14,5 +14,7 @@ pub fn heap_alloc(bytes: usize) -> Result { /// # Safety pub unsafe fn heap_free(ptr: RawPtr) { - HeapFree(GetProcessHeap(), HEAP_NONE, ptr); + if let Ok(heap) = GetProcessHeap() { + HeapFree(heap, HEAP_NONE, ptr); + } } diff --git a/crates/libs/windows/src/core/waiter.rs b/crates/libs/windows/src/core/waiter.rs index e1edaff0f4..7d718ebe6a 100644 --- a/crates/libs/windows/src/core/waiter.rs +++ b/crates/libs/windows/src/core/waiter.rs @@ -6,10 +6,10 @@ pub struct Waiter(HANDLE); pub struct WaiterSignaler(HANDLE); impl Waiter { - pub fn new() -> (Waiter, WaiterSignaler) { + pub fn new() -> Result<(Waiter, WaiterSignaler)> { unsafe { - let handle = CreateEventA(core::ptr::null_mut(), true, false, None); - (Waiter(handle), WaiterSignaler(handle)) + let handle = CreateEventA(core::ptr::null_mut(), true, false, None)?; + Ok((Waiter(handle), WaiterSignaler(handle))) } } } diff --git a/crates/samples/create_window/src/main.rs b/crates/samples/create_window/src/main.rs index 208b80042d..e85b3ab9e6 100644 --- a/crates/samples/create_window/src/main.rs +++ b/crates/samples/create_window/src/main.rs @@ -8,7 +8,7 @@ fn main() -> Result<()> { let window_class = "window"; let wc = WNDCLASSA { - hCursor: LoadCursorW(None, IDC_ARROW), + hCursor: LoadCursorW(None, IDC_ARROW)?, hInstance: instance, lpszClassName: PCSTR(b"window\0".as_ptr()), diff --git a/crates/samples/direct2d/src/main.rs b/crates/samples/direct2d/src/main.rs index ef0c693702..386dbcc993 100644 --- a/crates/samples/direct2d/src/main.rs +++ b/crates/samples/direct2d/src/main.rs @@ -313,7 +313,7 @@ impl Window { debug_assert!(instance.0 != 0); let wc = WNDCLASSA { - hCursor: LoadCursorW(None, IDC_HAND), + hCursor: LoadCursorW(None, IDC_HAND)?, hInstance: instance, lpszClassName: PCSTR(b"window\0".as_ptr()), diff --git a/crates/samples/direct3d12/src/main.rs b/crates/samples/direct3d12/src/main.rs index e1e1d5d876..9fad94d26e 100644 --- a/crates/samples/direct3d12/src/main.rs +++ b/crates/samples/direct3d12/src/main.rs @@ -45,14 +45,13 @@ where S: DXSample, { let instance = unsafe { GetModuleHandleA(None) }; - debug_assert!(!instance.is_invalid()); let wc = WNDCLASSEXA { cbSize: std::mem::size_of::() as u32, style: CS_HREDRAW | CS_VREDRAW, lpfnWndProc: Some(wndproc::), hInstance: instance, - hCursor: unsafe { LoadCursorW(None, IDC_ARROW) }, + hCursor: unsafe { LoadCursorW(None, IDC_ARROW)? }, lpszClassName: PCSTR(b"RustWindowClass\0".as_ptr()), ..Default::default() }; @@ -90,10 +89,8 @@ where &mut sample as *mut _ as _, ) }; - debug_assert!(!hwnd.is_invalid()); sample.bind_to_window(&hwnd)?; - unsafe { ShowWindow(hwnd, SW_SHOW) }; loop { @@ -307,7 +304,7 @@ mod d3d12_hello_triangle { let fence_value = 1; - let fence_event = unsafe { CreateEventA(std::ptr::null(), false, false, None) }; + let fence_event = unsafe { CreateEventA(std::ptr::null(), false, false, None)? }; self.resources = Some(Resources { command_queue, diff --git a/crates/samples/kernel_event/src/main.rs b/crates/samples/kernel_event/src/main.rs index d552bb94d1..11f4e4898b 100644 --- a/crates/samples/kernel_event/src/main.rs +++ b/crates/samples/kernel_event/src/main.rs @@ -5,9 +5,7 @@ use windows::{ fn main() -> windows::core::Result<()> { unsafe { - let event = CreateEventW(std::ptr::null(), true, false, None); - - assert!(event.0 != 0); + let event = CreateEventW(std::ptr::null(), true, false, None)?; SetEvent(event).ok()?; diff --git a/crates/samples/overlapped/src/main.rs b/crates/samples/overlapped/src/main.rs index 4986181328..4d9395a3ca 100644 --- a/crates/samples/overlapped/src/main.rs +++ b/crates/samples/overlapped/src/main.rs @@ -5,19 +5,15 @@ fn main() -> Result<()> { let mut filename = std::env::current_dir().unwrap(); filename.push("message.txt"); - let file = CreateFileA(filename.as_path().to_str().unwrap(), FILE_GENERIC_READ, FILE_SHARE_READ, std::ptr::null(), OPEN_EXISTING, FILE_FLAG_OVERLAPPED, None); - - file.ok()?; + let file = CreateFileA(filename.as_path().to_str().unwrap(), FILE_GENERIC_READ, FILE_SHARE_READ, std::ptr::null(), OPEN_EXISTING, FILE_FLAG_OVERLAPPED, None)?; let mut overlapped = OVERLAPPED { Anonymous: OVERLAPPED_0 { Anonymous: OVERLAPPED_0_0 { Offset: 9, OffsetHigh: 0 } }, - hEvent: CreateEventA(std::ptr::null(), true, false, None), + hEvent: CreateEventA(std::ptr::null(), true, false, None)?, Internal: 0, InternalHigh: 0, }; - overlapped.hEvent.ok()?; - let mut buffer: [u8; 12] = Default::default(); let read_ok = ReadFile(file, buffer.as_mut_ptr() as _, 12, std::ptr::null_mut(), &mut overlapped); diff --git a/crates/tests/handles/tests/legacy.rs b/crates/tests/handles/tests/legacy.rs index c03149ed83..435aea2fe2 100644 --- a/crates/tests/handles/tests/legacy.rs +++ b/crates/tests/handles/tests/legacy.rs @@ -11,15 +11,6 @@ fn handle() { assert!(HANDLE(0).is_invalid()); assert!(HANDLE(-1).is_invalid()); - assert!(HANDLE(1).ok().is_ok()); - assert!(HANDLE(1).ok().unwrap() == HANDLE(1)); - - unsafe { SetLastError(ERROR_INVALID_WINDOW_HANDLE) }; - assert!(HANDLE(0).ok().err().unwrap().code() == ERROR_INVALID_WINDOW_HANDLE.into()); - - unsafe { SetLastError(ERROR_FILE_NOT_FOUND) }; - assert!(HANDLE(-1).ok().err().unwrap().code() == ERROR_FILE_NOT_FOUND.into()); - assert!(core::mem::size_of::() == core::mem::size_of::()); } diff --git a/crates/tests/handles/tests/win.rs b/crates/tests/handles/tests/win.rs index 0c27a6a393..cb5d45a1f2 100644 --- a/crates/tests/handles/tests/win.rs +++ b/crates/tests/handles/tests/win.rs @@ -1,11 +1,10 @@ use windows::{Win32::Foundation::*, Win32::Graphics::Gdi::*, Win32::System::Registry::*}; #[test] -fn boolean() { - let underlying: u8 = 123; - let handle: BOOLEAN = BOOLEAN(underlying); +fn handle() { + let underlying: isize = 123; + let handle: HANDLE = HANDLE(underlying); assert!(!handle.is_invalid()); - assert!(handle.ok().unwrap() == handle); let copy = handle; assert!(copy == handle); @@ -13,10 +12,28 @@ fn boolean() { let clone = handle.clone(); assert!(clone == handle); - let default = BOOLEAN::default(); + let default = HANDLE::default(); assert!(default.is_invalid()); - assert!(format!("{:?}", handle) == "BOOLEAN(123)"); + assert_eq!(format!("{:?}", handle), "HANDLE(123)"); +} + +#[test] +fn psid() { + let underlying: *mut std::ffi::c_void = std::ptr::null_mut(); + let handle: PSID = PSID(underlying); + assert!(handle.is_invalid()); + + let copy = handle; + assert!(copy == handle); + + let clone = handle.clone(); + assert!(clone == handle); + + let default = PSID::default(); + assert!(default.is_invalid()); + + assert_eq!(format!("{:?}", handle), "PSID(0x0)"); } #[test] diff --git a/crates/tests/win32/tests/win32.rs b/crates/tests/win32/tests/win32.rs index 27d3480b81..35cfcad6ef 100644 --- a/crates/tests/win32/tests/win32.rs +++ b/crates/tests/win32/tests/win32.rs @@ -92,9 +92,7 @@ fn constant() { #[test] fn function() -> windows::core::Result<()> { unsafe { - let event = CreateEventW(core::ptr::null(), true, false, PCWSTR(core::ptr::null())); - assert!(event.0 != 0); - + let event = CreateEventW(core::ptr::null(), true, false, PCWSTR(core::ptr::null()))?; SetEvent(event).ok()?; let result = WaitForSingleObject(event, 0);