diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fa1ce532c8..1fe0316a3c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -239,6 +239,8 @@ jobs: run: cargo test -p test_linux --target ${{ matrix.target }} ${{ matrix.etc }} - name: Test test_literals run: cargo test -p test_literals --target ${{ matrix.target }} ${{ matrix.etc }} + - name: Test test_marshal + run: cargo test -p test_marshal --target ${{ matrix.target }} ${{ matrix.etc }} - name: Test test_match run: cargo test -p test_match --target ${{ matrix.target }} ${{ matrix.etc }} - name: Test test_metadata @@ -257,10 +259,10 @@ jobs: run: cargo test -p test_numerics --target ${{ matrix.target }} ${{ matrix.etc }} - name: Test test_overloads run: cargo test -p test_overloads --target ${{ matrix.target }} ${{ matrix.etc }} - - name: Test test_overloads_client - run: cargo test -p test_overloads_client --target ${{ matrix.target }} ${{ matrix.etc }} - name: Clean run: cargo clean + - name: Test test_overloads_client + run: cargo test -p test_overloads_client --target ${{ matrix.target }} ${{ matrix.etc }} - name: Test test_query_signature run: cargo test -p test_query_signature --target ${{ matrix.target }} ${{ matrix.etc }} - name: Test test_readme @@ -359,10 +361,10 @@ jobs: run: cargo test -p windows-numerics --target ${{ matrix.target }} ${{ matrix.etc }} - name: Test windows-registry run: cargo test -p windows-registry --target ${{ matrix.target }} ${{ matrix.etc }} - - name: Test windows-result - run: cargo test -p windows-result --target ${{ matrix.target }} ${{ matrix.etc }} - name: Clean run: cargo clean + - name: Test windows-result + run: cargo test -p windows-result --target ${{ matrix.target }} ${{ matrix.etc }} - name: Test windows-strings run: cargo test -p windows-strings --target ${{ matrix.target }} ${{ matrix.etc }} - name: Test windows-sys diff --git a/crates/libs/bindgen/src/types/delegate.rs b/crates/libs/bindgen/src/types/delegate.rs index 00756ef28d..c55ce247be 100644 --- a/crates/libs/bindgen/src/types/delegate.rs +++ b/crates/libs/bindgen/src/types/delegate.rs @@ -140,6 +140,9 @@ impl Delegate { *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); } else { core::ptr::null_mut() }; diff --git a/crates/libs/core/src/imp/com_bindings.rs b/crates/libs/core/src/imp/com_bindings.rs index 63ad8c9baa..8158597b3f 100644 --- a/crates/libs/core/src/imp/com_bindings.rs +++ b/crates/libs/core/src/imp/com_bindings.rs @@ -260,4 +260,5 @@ impl windows_core::RuntimeName for IWeakReferenceSource {} pub const JSCRIPT_E_CANTEXECUTE: windows_core::HRESULT = windows_core::HRESULT(0x89020001_u32 as _); pub const REGDB_E_CLASSNOTREG: windows_core::HRESULT = windows_core::HRESULT(0x80040154_u32 as _); pub const RPC_E_DISCONNECTED: windows_core::HRESULT = windows_core::HRESULT(0x80010108_u32 as _); +pub const S_OK: windows_core::HRESULT = windows_core::HRESULT(0x0_u32 as _); pub const TYPE_E_TYPEMISMATCH: windows_core::HRESULT = windows_core::HRESULT(0x80028CA0_u32 as _); diff --git a/crates/libs/core/src/imp/factory_cache.rs b/crates/libs/core/src/imp/factory_cache.rs index 37e2e786d6..e60abb3ad4 100644 --- a/crates/libs/core/src/imp/factory_cache.rs +++ b/crates/libs/core/src/imp/factory_cache.rs @@ -40,7 +40,7 @@ impl FactoryCache { } // Otherwise, we load the factory the usual way. - let factory = factory::()?; + let factory = load_factory::()?; // If the factory is agile, we can safely cache it. if factory.cast::().is_ok() { @@ -70,7 +70,7 @@ unsafe impl Sync for FactoryCache {} /// Attempts to load the factory object for the given WinRT class. /// This can be used to access COM interfaces implemented on a Windows Runtime class factory. -pub fn factory() -> crate::Result { +pub fn load_factory() -> crate::Result { let mut factory: Option = None; let name = crate::HSTRING::from(C::NAME); diff --git a/crates/libs/core/src/imp/marshaler.rs b/crates/libs/core/src/imp/marshaler.rs new file mode 100644 index 0000000000..2ef9d847a3 --- /dev/null +++ b/crates/libs/core/src/imp/marshaler.rs @@ -0,0 +1,268 @@ +use super::*; +use crate::{IUnknown, IUnknown_Vtbl, Interface, GUID, HRESULT}; +use core::ffi::c_void; +use core::mem::{transmute, transmute_copy}; +use core::ptr::null_mut; + +windows_link::link!("ole32.dll" "system" fn CoCreateFreeThreadedMarshaler(punkouter: *mut c_void, ppunkmarshal: *mut *mut c_void) -> HRESULT); + +pub unsafe fn marshaler(outer: IUnknown, result: *mut *mut c_void) -> HRESULT { + unsafe { + let mut marshaler_raw = null_mut(); + _ = CoCreateFreeThreadedMarshaler(null_mut(), &mut marshaler_raw); + assert!(!marshaler_raw.is_null(), "allocation failed"); + let marshaler: IUnknown = transmute(marshaler_raw); + + _ = (marshaler.vtable().QueryInterface)( + transmute_copy(&marshaler), + &IMarshal::IID, + &mut marshaler_raw, + ); + + debug_assert!(!marshaler_raw.is_null()); + let marshaler: IMarshal = transmute(marshaler_raw); + + let marshaler = Marshaler { + vtable: &Marshaler::VTABLE, + outer, + marshaler, + count: RefCount::new(1), + }; + + debug_assert!(!result.is_null()); + *result = transmute::, *mut c_void>(Box::new(marshaler)); + S_OK + } +} + +#[repr(C)] +struct Marshaler { + vtable: *const IMarshal_Vtbl, + outer: IUnknown, + marshaler: IMarshal, + count: RefCount, +} + +impl Marshaler { + const VTABLE: IMarshal_Vtbl = IMarshal_Vtbl { + base__: IUnknown_Vtbl { + QueryInterface: Self::QueryInterface, + AddRef: Self::AddRef, + Release: Self::Release, + }, + GetUnmarshalClass: Self::GetUnmarshalClass, + GetMarshalSizeMax: Self::GetMarshalSizeMax, + MarshalInterface: Self::MarshalInterface, + UnmarshalInterface: Self::UnmarshalInterface, + ReleaseMarshalData: Self::ReleaseMarshalData, + DisconnectObject: Self::DisconnectObject, + }; + + unsafe extern "system" fn QueryInterface( + this: *mut c_void, + iid: *const GUID, + interface: *mut *mut c_void, + ) -> HRESULT { + unsafe { + let this = this as *mut *mut c_void as *mut Self; + + if iid.is_null() || interface.is_null() { + return E_POINTER; + } + + if *iid == IMarshal::IID { + *interface = &mut (*this).vtable as *mut _ as _; + (*this).count.add_ref(); + return S_OK; + } + + ((*this).outer.vtable().QueryInterface)(transmute_copy(&(*this).outer), iid, interface) + } + } + + unsafe extern "system" fn AddRef(this: *mut c_void) -> u32 { + unsafe { + let this = this as *mut *mut c_void as *mut Self; + (*this).count.add_ref() + } + } + + unsafe extern "system" fn Release(this: *mut c_void) -> u32 { + unsafe { + let this = this as *mut *mut c_void as *mut Self; + let remaining = (*this).count.release(); + + if remaining == 0 { + let _ = Box::from_raw(this); + } + + remaining + } + } + + unsafe extern "system" fn GetUnmarshalClass( + this: *mut c_void, + riid: *const GUID, + pv: *const c_void, + dwdestcontext: u32, + pvdestcontext: *const c_void, + mshlflags: u32, + pcid: *mut GUID, + ) -> HRESULT { + unsafe { + let this = this as *mut *mut c_void as *mut Self; + + ((*this).marshaler.vtable().GetUnmarshalClass)( + transmute_copy(&(*this).marshaler), + riid, + pv, + dwdestcontext, + pvdestcontext, + mshlflags, + pcid, + ) + } + } + + unsafe extern "system" fn GetMarshalSizeMax( + this: *mut c_void, + riid: *const GUID, + pv: *const c_void, + dwdestcontext: u32, + pvdestcontext: *const c_void, + mshlflags: u32, + psize: *mut u32, + ) -> HRESULT { + unsafe { + let this = this as *mut *mut c_void as *mut Self; + + ((*this).marshaler.vtable().GetMarshalSizeMax)( + transmute_copy(&(*this).marshaler), + riid, + pv, + dwdestcontext, + pvdestcontext, + mshlflags, + psize, + ) + } + } + + unsafe extern "system" fn MarshalInterface( + this: *mut c_void, + pstm: *mut c_void, + riid: *const GUID, + pv: *const c_void, + dwdestcontext: u32, + pvdestcontext: *const c_void, + mshlflags: u32, + ) -> HRESULT { + unsafe { + let this = this as *mut *mut c_void as *mut Self; + + ((*this).marshaler.vtable().MarshalInterface)( + transmute_copy(&(*this).marshaler), + pstm, + riid, + pv, + dwdestcontext, + pvdestcontext, + mshlflags, + ) + } + } + + unsafe extern "system" fn UnmarshalInterface( + this: *mut c_void, + pstm: *mut c_void, + riid: *const GUID, + ppv: *mut *mut c_void, + ) -> HRESULT { + unsafe { + let this = this as *mut *mut c_void as *mut Self; + + ((*this).marshaler.vtable().UnmarshalInterface)( + transmute_copy(&(*this).marshaler), + pstm, + riid, + ppv, + ) + } + } + + unsafe extern "system" fn ReleaseMarshalData(this: *mut c_void, pstm: *mut c_void) -> HRESULT { + unsafe { + let this = this as *mut *mut c_void as *mut Self; + + ((*this).marshaler.vtable().ReleaseMarshalData)( + transmute_copy(&(*this).marshaler), + pstm, + ) + } + } + + unsafe extern "system" fn DisconnectObject(this: *mut c_void, dwreserved: u32) -> HRESULT { + unsafe { + let this = this as *mut *mut c_void as *mut Self; + + ((*this).marshaler.vtable().DisconnectObject)( + transmute_copy(&(*this).marshaler), + dwreserved, + ) + } + } +} + +#[repr(transparent)] +#[derive(Clone)] +pub struct IMarshal(IUnknown); + +unsafe impl Interface for IMarshal { + type Vtable = IMarshal_Vtbl; + const IID: GUID = GUID::from_u128(0x00000003_0000_0000_c000_000000000046); +} + +#[repr(C)] +pub struct IMarshal_Vtbl { + base__: IUnknown_Vtbl, + + GetUnmarshalClass: unsafe extern "system" fn( + *mut c_void, + *const GUID, + *const c_void, + u32, + *const c_void, + u32, + *mut GUID, + ) -> HRESULT, + + GetMarshalSizeMax: unsafe extern "system" fn( + *mut c_void, + *const GUID, + *const c_void, + u32, + *const c_void, + u32, + *mut u32, + ) -> HRESULT, + + MarshalInterface: unsafe extern "system" fn( + *mut c_void, + *mut c_void, + *const GUID, + *const c_void, + u32, + *const c_void, + u32, + ) -> HRESULT, + + UnmarshalInterface: unsafe extern "system" fn( + *mut c_void, + *mut c_void, + *const GUID, + *mut *mut c_void, + ) -> HRESULT, + + ReleaseMarshalData: unsafe extern "system" fn(*mut c_void, *mut c_void) -> HRESULT, + DisconnectObject: unsafe extern "system" fn(*mut c_void, u32) -> HRESULT, +} diff --git a/crates/libs/core/src/imp/weak_ref_count.rs b/crates/libs/core/src/imp/weak_ref_count.rs index d45709f876..6ea2363559 100644 --- a/crates/libs/core/src/imp/weak_ref_count.rs +++ b/crates/libs/core/src/imp/weak_ref_count.rs @@ -1,5 +1,5 @@ use super::*; -use crate::Interface; +use crate::{IUnknown, IUnknown_Vtbl, Interface, GUID, HRESULT}; use core::ffi::c_void; use core::mem::{transmute, transmute_copy}; use core::ptr::null_mut; @@ -49,7 +49,7 @@ impl WeakRefCount { } /// # Safety - pub unsafe fn query(&self, iid: &crate::GUID, object: *mut c_void) -> *mut c_void { + pub unsafe fn query(&self, iid: &GUID, object: *mut c_void) -> *mut c_void { unsafe { if iid != &IWeakReferenceSource::IID { return null_mut(); @@ -129,7 +129,7 @@ impl TearOff { } const STRONG_VTABLE: IWeakReferenceSource_Vtbl = IWeakReferenceSource_Vtbl { - base__: crate::IUnknown_Vtbl { + base__: IUnknown_Vtbl { QueryInterface: Self::StrongQueryInterface, AddRef: Self::StrongAddRef, Release: Self::StrongRelease, @@ -138,7 +138,7 @@ impl TearOff { }; const WEAK_VTABLE: IWeakReference_Vtbl = IWeakReference_Vtbl { - base__: crate::IUnknown_Vtbl { + base__: IUnknown_Vtbl { QueryInterface: Self::WeakQueryInterface, AddRef: Self::WeakAddRef, Release: Self::WeakRelease, @@ -158,13 +158,9 @@ impl TearOff { unsafe { transmute(value << 1) } } - unsafe fn query_interface( - &self, - iid: *const crate::GUID, - interface: *mut *mut c_void, - ) -> crate::HRESULT { + unsafe fn query_interface(&self, iid: *const GUID, interface: *mut *mut c_void) -> HRESULT { unsafe { - ((*(*(self.object as *mut *mut crate::IUnknown_Vtbl))).QueryInterface)( + ((*(*(self.object as *mut *mut IUnknown_Vtbl))).QueryInterface)( self.object, iid, interface, @@ -174,9 +170,9 @@ impl TearOff { unsafe extern "system" fn StrongQueryInterface( ptr: *mut c_void, - iid: *const crate::GUID, + iid: *const GUID, interface: *mut *mut c_void, - ) -> crate::HRESULT { + ) -> HRESULT { unsafe { let this = Self::from_strong_ptr(ptr); @@ -189,7 +185,7 @@ impl TearOff { if *iid == IWeakReferenceSource::IID { *interface = ptr; this.strong_count.add_ref(); - return crate::HRESULT(0); + return HRESULT(0); } // As the tear-off is sharing the identity of the object, simply delegate any remaining @@ -200,9 +196,9 @@ impl TearOff { unsafe extern "system" fn WeakQueryInterface( ptr: *mut c_void, - iid: *const crate::GUID, + iid: *const GUID, interface: *mut *mut c_void, - ) -> crate::HRESULT { + ) -> HRESULT { unsafe { let this = Self::from_weak_ptr(ptr); @@ -215,11 +211,17 @@ impl TearOff { // the object. *interface = if *iid == IWeakReference::IID - || *iid == crate::IUnknown::IID + || *iid == IUnknown::IID || *iid == IAgileObject::IID { ptr } else { + #[cfg(windows)] + if *iid == IMarshal::IID { + this.weak_count.add_ref(); + return marshaler(transmute::<*mut c_void, IUnknown>(ptr), interface); + } + null_mut() }; @@ -227,7 +229,7 @@ impl TearOff { E_NOINTERFACE } else { this.weak_count.add_ref(); - crate::HRESULT(0) + HRESULT(0) } } } @@ -256,7 +258,7 @@ impl TearOff { // Forward strong `Release` to the object so that it can destroy itself. It will then // decrement its weak reference and allow the tear-off to be released as needed. - ((*(*(this.object as *mut *mut crate::IUnknown_Vtbl))).Release)(this.object) + ((*(*(this.object as *mut *mut IUnknown_Vtbl))).Release)(this.object) } } @@ -280,7 +282,7 @@ impl TearOff { unsafe extern "system" fn StrongDowngrade( ptr: *mut c_void, interface: *mut *mut c_void, - ) -> crate::HRESULT { + ) -> HRESULT { unsafe { let this = Self::from_strong_ptr(ptr); @@ -289,15 +291,15 @@ impl TearOff { // reference. *interface = &mut this.weak_vtable as *mut _ as _; this.weak_count.add_ref(); - crate::HRESULT(0) + HRESULT(0) } } unsafe extern "system" fn WeakUpgrade( ptr: *mut c_void, - iid: *const crate::GUID, + iid: *const GUID, interface: *mut *mut c_void, - ) -> crate::HRESULT { + ) -> HRESULT { unsafe { let this = Self::from_weak_ptr(ptr); @@ -318,7 +320,7 @@ impl TearOff { }) .unwrap_or_else(|_| { *interface = null_mut(); - crate::HRESULT(0) + HRESULT(0) }) } } diff --git a/crates/libs/core/src/imp/windows.rs b/crates/libs/core/src/imp/windows.rs index ab8ec2418b..d8dd81f06b 100644 --- a/crates/libs/core/src/imp/windows.rs +++ b/crates/libs/core/src/imp/windows.rs @@ -6,3 +6,6 @@ pub use generic_factory::*; mod bindings; pub use bindings::*; + +mod marshaler; +pub use marshaler::*; diff --git a/crates/libs/core/src/windows.rs b/crates/libs/core/src/windows.rs index cec1a0205a..6f055bbc3d 100644 --- a/crates/libs/core/src/windows.rs +++ b/crates/libs/core/src/windows.rs @@ -17,7 +17,7 @@ pub use windows_strings::*; /// Attempts to load the factory object for the given WinRT class. /// This can be used to access COM interfaces implemented on a Windows Runtime class factory. pub fn factory() -> Result { - imp::factory::() + imp::load_factory::() } impl Param for &BSTR { diff --git a/crates/libs/future/src/bindings.rs b/crates/libs/future/src/bindings.rs index 2e3b55e087..9f92d2cd1e 100644 --- a/crates/libs/future/src/bindings.rs +++ b/crates/libs/future/src/bindings.rs @@ -86,6 +86,12 @@ impl< || *iid == ::IID { &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler( + core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), + interface, + ); } else { core::ptr::null_mut() }; @@ -248,6 +254,12 @@ impl< || *iid == ::IID { &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler( + core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), + interface, + ); } else { core::ptr::null_mut() }; @@ -409,7 +421,7 @@ impl< if iid.is_null() || interface.is_null() { return windows_core::HRESULT(-2147467261); } - * interface = if * iid == < AsyncActionWithProgressCompletedHandler < TProgress > as windows_core::Interface >::IID || * iid == < windows_core::IUnknown as windows_core::Interface >::IID || * iid == < windows_core::imp::IAgileObject as windows_core::Interface >::IID { & mut ( * this ) . vtable as * mut _ as _ } else { core::ptr::null_mut ( ) } ; + * interface = if * iid == < AsyncActionWithProgressCompletedHandler < TProgress > as windows_core::Interface >::IID || * iid == < windows_core::IUnknown as windows_core::Interface >::IID || * iid == < windows_core::imp::IAgileObject as windows_core::Interface >::IID { & mut ( * this ) . vtable as * mut _ as _ } else if * iid == < windows_core::imp::IMarshal as windows_core::Interface >::IID { ( * this ) . count . add_ref ( ) ; return windows_core::imp::marshaler ( core::mem::transmute ( & mut ( * this ) . vtable as * mut _ as * mut core::ffi::c_void ) , interface ) ; } else { core::ptr::null_mut ( ) } ; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { @@ -568,6 +580,12 @@ impl< || *iid == ::IID { &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler( + core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), + interface, + ); } else { core::ptr::null_mut() }; @@ -742,7 +760,7 @@ impl< if iid.is_null() || interface.is_null() { return windows_core::HRESULT(-2147467261); } - * interface = if * iid == < AsyncOperationProgressHandler < TResult , TProgress > as windows_core::Interface >::IID || * iid == < windows_core::IUnknown as windows_core::Interface >::IID || * iid == < windows_core::imp::IAgileObject as windows_core::Interface >::IID { & mut ( * this ) . vtable as * mut _ as _ } else { core::ptr::null_mut ( ) } ; + * interface = if * iid == < AsyncOperationProgressHandler < TResult , TProgress > as windows_core::Interface >::IID || * iid == < windows_core::IUnknown as windows_core::Interface >::IID || * iid == < windows_core::imp::IAgileObject as windows_core::Interface >::IID { & mut ( * this ) . vtable as * mut _ as _ } else if * iid == < windows_core::imp::IMarshal as windows_core::Interface >::IID { ( * this ) . count . add_ref ( ) ; return windows_core::imp::marshaler ( core::mem::transmute ( & mut ( * this ) . vtable as * mut _ as * mut core::ffi::c_void ) , interface ) ; } else { core::ptr::null_mut ( ) } ; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { @@ -917,7 +935,7 @@ impl< if iid.is_null() || interface.is_null() { return windows_core::HRESULT(-2147467261); } - * interface = if * iid == < AsyncOperationWithProgressCompletedHandler < TResult , TProgress > as windows_core::Interface >::IID || * iid == < windows_core::IUnknown as windows_core::Interface >::IID || * iid == < windows_core::imp::IAgileObject as windows_core::Interface >::IID { & mut ( * this ) . vtable as * mut _ as _ } else { core::ptr::null_mut ( ) } ; + * interface = if * iid == < AsyncOperationWithProgressCompletedHandler < TResult , TProgress > as windows_core::Interface >::IID || * iid == < windows_core::IUnknown as windows_core::Interface >::IID || * iid == < windows_core::imp::IAgileObject as windows_core::Interface >::IID { & mut ( * this ) . vtable as * mut _ as _ } else if * iid == < windows_core::imp::IMarshal as windows_core::Interface >::IID { ( * this ) . count . add_ref ( ) ; return windows_core::imp::marshaler ( core::mem::transmute ( & mut ( * this ) . vtable as * mut _ as * mut core::ffi::c_void ) , interface ) ; } else { core::ptr::null_mut ( ) } ; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { diff --git a/crates/libs/implement/src/gen.rs b/crates/libs/implement/src/gen.rs index 661550dd31..14c186618c 100644 --- a/crates/libs/implement/src/gen.rs +++ b/crates/libs/implement/src/gen.rs @@ -314,6 +314,13 @@ fn gen_query_interface(inputs: &ImplementInputs) -> syn::ImplItemFn { } }; + let marshal_query = quote! { + #[cfg(windows)] + if iid == <::windows_core::imp::IMarshal as ::windows_core::Interface>::IID { + return ::windows_core::imp::marshaler(self.to_interface(), interface); + } + }; + let tear_off_query = quote! { let tear_off_ptr = self.count.query(&iid, &self.identity as *const _ as *mut _); if !tear_off_ptr.is_null() { @@ -338,6 +345,7 @@ fn gen_query_interface(inputs: &ImplementInputs) -> syn::ImplItemFn { let interface_ptr: *const ::core::ffi::c_void = 'found: { #identity_query #(#queries)* + #marshal_query #dynamic_cast_query #tear_off_query diff --git a/crates/libs/windows/src/Windows/ApplicationModel/Background/mod.rs b/crates/libs/windows/src/Windows/ApplicationModel/Background/mod.rs index c7cd37ed71..8ca37b2e59 100644 --- a/crates/libs/windows/src/Windows/ApplicationModel/Background/mod.rs +++ b/crates/libs/windows/src/Windows/ApplicationModel/Background/mod.rs @@ -614,7 +614,14 @@ impl, BackgroundTaskCanc if iid.is_null() || interface.is_null() { return windows_core::HRESULT(-2147467261); } - *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { @@ -736,7 +743,14 @@ impl, windows_core::R if iid.is_null() || interface.is_null() { return windows_core::HRESULT(-2147467261); } - *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { @@ -860,7 +874,14 @@ impl, windows_core::R if iid.is_null() || interface.is_null() { return windows_core::HRESULT(-2147467261); } - *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { diff --git a/crates/libs/windows/src/Windows/ApplicationModel/DataTransfer/mod.rs b/crates/libs/windows/src/Windows/ApplicationModel/DataTransfer/mod.rs index 873dda5a69..5481a513fb 100644 --- a/crates/libs/windows/src/Windows/ApplicationModel/DataTransfer/mod.rs +++ b/crates/libs/windows/src/Windows/ApplicationModel/DataTransfer/mod.rs @@ -1161,7 +1161,14 @@ impl) -> windows_core::Resul if iid.is_null() || interface.is_null() { return windows_core::HRESULT(-2147467261); } - *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { @@ -2311,7 +2318,14 @@ impl) -> windows_core::Re if iid.is_null() || interface.is_null() { return windows_core::HRESULT(-2147467261); } - *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { diff --git a/crates/libs/windows/src/Windows/ApplicationModel/Payments/mod.rs b/crates/libs/windows/src/Windows/ApplicationModel/Payments/mod.rs index d733f053ad..5af28b5d34 100644 --- a/crates/libs/windows/src/Windows/ApplicationModel/Payments/mod.rs +++ b/crates/libs/windows/src/Windows/ApplicationModel/Payments/mod.rs @@ -1401,7 +1401,14 @@ impl, windows_core::Ref<'_, Payme if iid.is_null() || interface.is_null() { return windows_core::HRESULT(-2147467261); } - *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { diff --git a/crates/libs/windows/src/Windows/Data/Text/mod.rs b/crates/libs/windows/src/Windows/Data/Text/mod.rs index 223b9527b5..6a659a8953 100644 --- a/crates/libs/windows/src/Windows/Data/Text/mod.rs +++ b/crates/libs/windows/src/Windows/Data/Text/mod.rs @@ -360,7 +360,14 @@ impl::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { @@ -1030,7 +1037,14 @@ impl> if iid.is_null() || interface.is_null() { return windows_core::HRESULT(-2147467261); } - *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { diff --git a/crates/libs/windows/src/Windows/Devices/SmartCards/mod.rs b/crates/libs/windows/src/Windows/Devices/SmartCards/mod.rs index 469f177cf1..44a3045b45 100644 --- a/crates/libs/windows/src/Windows/Devices/SmartCards/mod.rs +++ b/crates/libs/windows/src/Windows/Devices/SmartCards/mod.rs @@ -2925,7 +2925,14 @@ impl, windows_core::Ref<'_ if iid.is_null() || interface.is_null() { return windows_core::HRESULT(-2147467261); } - *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { diff --git a/crates/libs/windows/src/Windows/Devices/Sms/mod.rs b/crates/libs/windows/src/Windows/Devices/Sms/mod.rs index 6f08cc07cc..78b03b7e07 100644 --- a/crates/libs/windows/src/Windows/Devices/Sms/mod.rs +++ b/crates/libs/windows/src/Windows/Devices/Sms/mod.rs @@ -2089,7 +2089,14 @@ impl) -> windows_core::Result<()> + Se if iid.is_null() || interface.is_null() { return windows_core::HRESULT(-2147467261); } - *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { @@ -2466,7 +2473,14 @@ impl, windows_core::Ref<'_, SmsMessage if iid.is_null() || interface.is_null() { return windows_core::HRESULT(-2147467261); } - *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { diff --git a/crates/libs/windows/src/Windows/Foundation/Collections/mod.rs b/crates/libs/windows/src/Windows/Foundation/Collections/mod.rs index 594d4e14b0..67906f0667 100644 --- a/crates/libs/windows/src/Windows/Foundation/Collections/mod.rs +++ b/crates/libs/windows/src/Windows/Foundation/Collections/mod.rs @@ -695,7 +695,14 @@ impl as windows_core::Interface>::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == as windows_core::Interface>::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { @@ -1102,7 +1109,14 @@ impl as windows_core::Interface>::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == as windows_core::Interface>::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { diff --git a/crates/libs/windows/src/Windows/Foundation/mod.rs b/crates/libs/windows/src/Windows/Foundation/mod.rs index af1aef25b1..8f0fd3e988 100644 --- a/crates/libs/windows/src/Windows/Foundation/mod.rs +++ b/crates/libs/windows/src/Windows/Foundation/mod.rs @@ -91,7 +91,14 @@ impl windows_core::Result<()> + Send + 'static> DeferralCompletedH if iid.is_null() || interface.is_null() { return windows_core::HRESULT(-2147467261); } - *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { @@ -180,7 +187,14 @@ impl as windows_core::Interface>::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == as windows_core::Interface>::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { @@ -2498,7 +2512,14 @@ impl as windows_core::Interface>::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == as windows_core::Interface>::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { diff --git a/crates/libs/windows/src/Windows/Gaming/Preview/GamesEnumeration/mod.rs b/crates/libs/windows/src/Windows/Gaming/Preview/GamesEnumeration/mod.rs index 30c303c03a..64083dcad5 100644 --- a/crates/libs/windows/src/Windows/Gaming/Preview/GamesEnumeration/mod.rs +++ b/crates/libs/windows/src/Windows/Gaming/Preview/GamesEnumeration/mod.rs @@ -130,7 +130,14 @@ impl) -> windows_core::Result<()> if iid.is_null() || interface.is_null() { return windows_core::HRESULT(-2147467261); } - *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { @@ -330,7 +337,14 @@ impl windows_core::Result<()> + Send + 'stat if iid.is_null() || interface.is_null() { return windows_core::HRESULT(-2147467261); } - *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { diff --git a/crates/libs/windows/src/Windows/Graphics/Display/mod.rs b/crates/libs/windows/src/Windows/Graphics/Display/mod.rs index fded46aa39..bfe3d3a9e1 100644 --- a/crates/libs/windows/src/Windows/Graphics/Display/mod.rs +++ b/crates/libs/windows/src/Windows/Graphics/Display/mod.rs @@ -1027,7 +1027,14 @@ impl) -> windows_core if iid.is_null() || interface.is_null() { return windows_core::HRESULT(-2147467261); } - *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { diff --git a/crates/libs/windows/src/Windows/Graphics/Printing/mod.rs b/crates/libs/windows/src/Windows/Graphics/Printing/mod.rs index 1505516070..309b69f1cd 100644 --- a/crates/libs/windows/src/Windows/Graphics/Printing/mod.rs +++ b/crates/libs/windows/src/Windows/Graphics/Printing/mod.rs @@ -2100,7 +2100,14 @@ impl) -> windows_co if iid.is_null() || interface.is_null() { return windows_core::HRESULT(-2147467261); } - *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { diff --git a/crates/libs/windows/src/Windows/Graphics/Printing3D/mod.rs b/crates/libs/windows/src/Windows/Graphics/Printing3D/mod.rs index 988fe20d85..2c1d749734 100644 --- a/crates/libs/windows/src/Windows/Graphics/Printing3D/mod.rs +++ b/crates/libs/windows/src/Windows/Graphics/Printing3D/mod.rs @@ -882,7 +882,14 @@ impl) -> windows_ if iid.is_null() || interface.is_null() { return windows_core::HRESULT(-2147467261); } - *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { diff --git a/crates/libs/windows/src/Windows/Management/Setup/mod.rs b/crates/libs/windows/src/Windows/Management/Setup/mod.rs index 0367e66648..48a46728a4 100644 --- a/crates/libs/windows/src/Windows/Management/Setup/mod.rs +++ b/crates/libs/windows/src/Windows/Management/Setup/mod.rs @@ -197,7 +197,14 @@ impl::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { diff --git a/crates/libs/windows/src/Windows/Media/Capture/mod.rs b/crates/libs/windows/src/Windows/Media/Capture/mod.rs index 7265a196e0..7395155fb5 100644 --- a/crates/libs/windows/src/Windows/Media/Capture/mod.rs +++ b/crates/libs/windows/src/Windows/Media/Capture/mod.rs @@ -7140,7 +7140,14 @@ impl, windows_core::Ref<'_, MediaCa if iid.is_null() || interface.is_null() { return windows_core::HRESULT(-2147467261); } - *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { @@ -8085,7 +8092,14 @@ impl) -> windows_core::Result<()> + if iid.is_null() || interface.is_null() { return windows_core::HRESULT(-2147467261); } - *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { diff --git a/crates/libs/windows/src/Windows/Media/Devices/mod.rs b/crates/libs/windows/src/Windows/Media/Devices/mod.rs index 4c621c33d2..054c2a0885 100644 --- a/crates/libs/windows/src/Windows/Media/Devices/mod.rs +++ b/crates/libs/windows/src/Windows/Media/Devices/mod.rs @@ -533,7 +533,14 @@ impl) -> windows_core::Result<()> + if iid.is_null() || interface.is_null() { return windows_core::HRESULT(-2147467261); } - *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { @@ -884,7 +891,14 @@ impl, windows_core::Ref<'_, DialRequ if iid.is_null() || interface.is_null() { return windows_core::HRESULT(-2147467261); } - *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { @@ -3152,7 +3166,14 @@ impl, windows_core::Ref<'_, KeypadPr if iid.is_null() || interface.is_null() { return windows_core::HRESULT(-2147467261); } - *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { @@ -3848,7 +3869,14 @@ impl, windows_core::Ref<'_, RedialRe if iid.is_null() || interface.is_null() { return windows_core::HRESULT(-2147467261); } - *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { diff --git a/crates/libs/windows/src/Windows/Media/Protection/mod.rs b/crates/libs/windows/src/Windows/Media/Protection/mod.rs index dce16f3a0e..2d56bc6398 100644 --- a/crates/libs/windows/src/Windows/Media/Protection/mod.rs +++ b/crates/libs/windows/src/Windows/Media/Protection/mod.rs @@ -70,7 +70,14 @@ impl, windows_core::Ref<' if iid.is_null() || interface.is_null() { return windows_core::HRESULT(-2147467261); } - *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { @@ -671,7 +678,14 @@ impl) -> windows_core::Re if iid.is_null() || interface.is_null() { return windows_core::HRESULT(-2147467261); } - *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { @@ -934,7 +948,14 @@ impl, windows_core::Ref<' if iid.is_null() || interface.is_null() { return windows_core::HRESULT(-2147467261); } - *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { diff --git a/crates/libs/windows/src/Windows/Networking/Connectivity/mod.rs b/crates/libs/windows/src/Windows/Networking/Connectivity/mod.rs index 51805ef929..c610c4ec65 100644 --- a/crates/libs/windows/src/Windows/Networking/Connectivity/mod.rs +++ b/crates/libs/windows/src/Windows/Networking/Connectivity/mod.rs @@ -1819,7 +1819,14 @@ impl) -> windows_core if iid.is_null() || interface.is_null() { return windows_core::HRESULT(-2147467261); } - *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { diff --git a/crates/libs/windows/src/Windows/Networking/Proximity/mod.rs b/crates/libs/windows/src/Windows/Networking/Proximity/mod.rs index e0d04eb9fc..2a77f31b12 100644 --- a/crates/libs/windows/src/Windows/Networking/Proximity/mod.rs +++ b/crates/libs/windows/src/Windows/Networking/Proximity/mod.rs @@ -60,7 +60,14 @@ impl) -> windows_core::Result<() if iid.is_null() || interface.is_null() { return windows_core::HRESULT(-2147467261); } - *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { @@ -129,7 +136,14 @@ impl) -> windows_core::Result<() if iid.is_null() || interface.is_null() { return windows_core::HRESULT(-2147467261); } - *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { @@ -391,7 +405,14 @@ impl, windows_core::Ref<'_, Prox if iid.is_null() || interface.is_null() { return windows_core::HRESULT(-2147467261); } - *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { @@ -460,7 +481,14 @@ impl, i64) -> windows_core::Resu if iid.is_null() || interface.is_null() { return windows_core::HRESULT(-2147467261); } - *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { diff --git a/crates/libs/windows/src/Windows/Security/Isolation/mod.rs b/crates/libs/windows/src/Windows/Security/Isolation/mod.rs index 267ec9f2aa..3ec7619786 100644 --- a/crates/libs/windows/src/Windows/Security/Isolation/mod.rs +++ b/crates/libs/windows/src/Windows/Security/Isolation/mod.rs @@ -41,7 +41,14 @@ impl::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { @@ -2054,7 +2061,14 @@ impl::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { diff --git a/crates/libs/windows/src/Windows/Storage/Provider/mod.rs b/crates/libs/windows/src/Windows/Storage/Provider/mod.rs index 8b3ab700da..555c70738b 100644 --- a/crates/libs/windows/src/Windows/Storage/Provider/mod.rs +++ b/crates/libs/windows/src/Windows/Storage/Provider/mod.rs @@ -1955,7 +1955,14 @@ impl) if iid.is_null() || interface.is_null() { return windows_core::HRESULT(-2147467261); } - *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { diff --git a/crates/libs/windows/src/Windows/Storage/mod.rs b/crates/libs/windows/src/Windows/Storage/mod.rs index 6a665bb492..11a57ecbd1 100644 --- a/crates/libs/windows/src/Windows/Storage/mod.rs +++ b/crates/libs/windows/src/Windows/Storage/mod.rs @@ -645,7 +645,14 @@ impl) -> windows_core::Result< if iid.is_null() || interface.is_null() { return windows_core::HRESULT(-2147467261); } - *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { @@ -5722,7 +5729,14 @@ impl) -> windows_core::R if iid.is_null() || interface.is_null() { return windows_core::HRESULT(-2147467261); } - *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { diff --git a/crates/libs/windows/src/Windows/System/RemoteDesktop/Input/mod.rs b/crates/libs/windows/src/Windows/System/RemoteDesktop/Input/mod.rs index 17dbc02cce..8a334eb60f 100644 --- a/crates/libs/windows/src/Windows/System/RemoteDesktop/Input/mod.rs +++ b/crates/libs/windows/src/Windows/System/RemoteDesktop/Input/mod.rs @@ -204,7 +204,14 @@ impl windows_core::Result + Send + 'static> RemoteTextC if iid.is_null() || interface.is_null() { return windows_core::HRESULT(-2147467261); } - *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { diff --git a/crates/libs/windows/src/Windows/System/Threading/Core/mod.rs b/crates/libs/windows/src/Windows/System/Threading/Core/mod.rs index 5769e6e173..be3dd6e34e 100644 --- a/crates/libs/windows/src/Windows/System/Threading/Core/mod.rs +++ b/crates/libs/windows/src/Windows/System/Threading/Core/mod.rs @@ -137,7 +137,14 @@ impl, bool) -> windows_core::Resu if iid.is_null() || interface.is_null() { return windows_core::HRESULT(-2147467261); } - *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { diff --git a/crates/libs/windows/src/Windows/System/Threading/mod.rs b/crates/libs/windows/src/Windows/System/Threading/mod.rs index 27a89e0cf5..17ce369946 100644 --- a/crates/libs/windows/src/Windows/System/Threading/mod.rs +++ b/crates/libs/windows/src/Windows/System/Threading/mod.rs @@ -189,7 +189,14 @@ impl) -> windows_core::Result<() if iid.is_null() || interface.is_null() { return windows_core::HRESULT(-2147467261); } - *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { @@ -258,7 +265,14 @@ impl) -> windows_core::Result<() if iid.is_null() || interface.is_null() { return windows_core::HRESULT(-2147467261); } - *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { @@ -327,7 +341,14 @@ impl) -> windows_co if iid.is_null() || interface.is_null() { return windows_core::HRESULT(-2147467261); } - *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { diff --git a/crates/libs/windows/src/Windows/System/mod.rs b/crates/libs/windows/src/Windows/System/mod.rs index b504a8ed67..2baff50e04 100644 --- a/crates/libs/windows/src/Windows/System/mod.rs +++ b/crates/libs/windows/src/Windows/System/mod.rs @@ -1231,7 +1231,14 @@ impl windows_core::Result<()> + Send + 'static> DispatcherQueueHan if iid.is_null() || interface.is_null() { return windows_core::HRESULT(-2147467261); } - *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { diff --git a/crates/libs/windows/src/Windows/UI/ApplicationSettings/mod.rs b/crates/libs/windows/src/Windows/UI/ApplicationSettings/mod.rs index 5b80624254..524be17bc0 100644 --- a/crates/libs/windows/src/Windows/UI/ApplicationSettings/mod.rs +++ b/crates/libs/windows/src/Windows/UI/ApplicationSettings/mod.rs @@ -265,7 +265,14 @@ impl) -> windows_core::Result< if iid.is_null() || interface.is_null() { return windows_core::HRESULT(-2147467261); } - *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { @@ -938,7 +945,14 @@ impl, windows_core::Ref<'_, We if iid.is_null() || interface.is_null() { return windows_core::HRESULT(-2147467261); } - *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { @@ -1076,7 +1090,14 @@ impl) -> windows_core: if iid.is_null() || interface.is_null() { return windows_core::HRESULT(-2147467261); } - *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { diff --git a/crates/libs/windows/src/Windows/UI/Core/mod.rs b/crates/libs/windows/src/Windows/UI/Core/mod.rs index 5f90f88111..0baccccc92 100644 --- a/crates/libs/windows/src/Windows/UI/Core/mod.rs +++ b/crates/libs/windows/src/Windows/UI/Core/mod.rs @@ -2232,7 +2232,14 @@ impl windows_core::Result<()> + Send + 'static> DispatchedHandlerB if iid.is_null() || interface.is_null() { return windows_core::HRESULT(-2147467261); } - *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { @@ -4927,7 +4934,14 @@ impl) -> windows_core: if iid.is_null() || interface.is_null() { return windows_core::HRESULT(-2147467261); } - *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { diff --git a/crates/libs/windows/src/Windows/UI/Popups/mod.rs b/crates/libs/windows/src/Windows/UI/Popups/mod.rs index 4e1f22b22c..c295c839ff 100644 --- a/crates/libs/windows/src/Windows/UI/Popups/mod.rs +++ b/crates/libs/windows/src/Windows/UI/Popups/mod.rs @@ -540,7 +540,14 @@ impl) -> windows_core::Result<()> + S if iid.is_null() || interface.is_null() { return windows_core::HRESULT(-2147467261); } - *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { diff --git a/crates/libs/windows/src/Windows/UI/WebUI/Core/mod.rs b/crates/libs/windows/src/Windows/UI/WebUI/Core/mod.rs index c5b77ff28b..da7281187a 100644 --- a/crates/libs/windows/src/Windows/UI/WebUI/Core/mod.rs +++ b/crates/libs/windows/src/Windows/UI/WebUI/Core/mod.rs @@ -218,7 +218,14 @@ impl windows_core::Result<()> + Send + 'static> MenuClosedEventHan if iid.is_null() || interface.is_null() { return windows_core::HRESULT(-2147467261); } - *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { @@ -284,7 +291,14 @@ impl windows_core::Result<()> + Send + 'static> MenuOpenedEventHan if iid.is_null() || interface.is_null() { return windows_core::HRESULT(-2147467261); } - *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { @@ -353,7 +367,14 @@ impl) -> win if iid.is_null() || interface.is_null() { return windows_core::HRESULT(-2147467261); } - *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { diff --git a/crates/libs/windows/src/Windows/UI/WebUI/mod.rs b/crates/libs/windows/src/Windows/UI/WebUI/mod.rs index aefa8c4405..682d6d3d7a 100644 --- a/crates/libs/windows/src/Windows/UI/WebUI/mod.rs +++ b/crates/libs/windows/src/Windows/UI/WebUI/mod.rs @@ -64,7 +64,14 @@ impl, windows_core::R if iid.is_null() || interface.is_null() { return windows_core::HRESULT(-2147467261); } - *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { @@ -197,7 +204,14 @@ impl, windows_core::R if iid.is_null() || interface.is_null() { return windows_core::HRESULT(-2147467261); } - *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { @@ -306,7 +320,14 @@ impl, windows_core::R if iid.is_null() || interface.is_null() { return windows_core::HRESULT(-2147467261); } - *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { @@ -925,7 +946,14 @@ impl, windows_core::R if iid.is_null() || interface.is_null() { return windows_core::HRESULT(-2147467261); } - *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { @@ -995,7 +1023,14 @@ impl, windows_core::R if iid.is_null() || interface.is_null() { return windows_core::HRESULT(-2147467261); } - *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { @@ -1125,7 +1160,14 @@ impl) -> windows_core if iid.is_null() || interface.is_null() { return windows_core::HRESULT(-2147467261); } - *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { @@ -1256,7 +1298,14 @@ impl, windows_core::R if iid.is_null() || interface.is_null() { return windows_core::HRESULT(-2147467261); } - *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { &mut (*this).vtable as *mut _ as _ } else { core::ptr::null_mut() }; + *interface = if *iid == ::IID || *iid == ::IID || *iid == ::IID { + &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler(core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), interface); + } else { + core::ptr::null_mut() + }; if (*interface).is_null() { windows_core::HRESULT(-2147467262) } else { diff --git a/crates/tests/libs/bindgen/src/class_with_handler.rs b/crates/tests/libs/bindgen/src/class_with_handler.rs index 8f29acc589..b794b774dd 100644 --- a/crates/tests/libs/bindgen/src/class_with_handler.rs +++ b/crates/tests/libs/bindgen/src/class_with_handler.rs @@ -127,6 +127,12 @@ impl windows_core::Result<()> + Send + 'static> DeferralCompletedH || *iid == ::IID { &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler( + core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), + interface, + ); } else { core::ptr::null_mut() }; diff --git a/crates/tests/libs/bindgen/src/delegate.rs b/crates/tests/libs/bindgen/src/delegate.rs index bd739bc927..263adb5499 100644 --- a/crates/tests/libs/bindgen/src/delegate.rs +++ b/crates/tests/libs/bindgen/src/delegate.rs @@ -68,6 +68,12 @@ impl windows_core::Result<()> + Send + 'static> DeferralCompletedH || *iid == ::IID { &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler( + core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), + interface, + ); } else { core::ptr::null_mut() }; diff --git a/crates/tests/libs/bindgen/src/delegate_generic.rs b/crates/tests/libs/bindgen/src/delegate_generic.rs index a7577d50c9..3facc0cd0c 100644 --- a/crates/tests/libs/bindgen/src/delegate_generic.rs +++ b/crates/tests/libs/bindgen/src/delegate_generic.rs @@ -121,6 +121,12 @@ impl< || *iid == ::IID { &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler( + core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), + interface, + ); } else { core::ptr::null_mut() }; diff --git a/crates/tests/libs/implement/Cargo.toml b/crates/tests/libs/implement/Cargo.toml index 99accf007d..9af730d420 100644 --- a/crates/tests/libs/implement/Cargo.toml +++ b/crates/tests/libs/implement/Cargo.toml @@ -17,6 +17,7 @@ features = [ "Storage_Streams", "Win32_Graphics_Gdi", "Win32_System_Com_StructuredStorage", + "Win32_System_Com_Marshal", "Win32_System_Ole", "Win32_System_SystemServices", "Win32_System_WinRT_Composition", diff --git a/crates/tests/libs/implement/tests/query.rs b/crates/tests/libs/implement/tests/query.rs index 9d468d618e..13f0647db5 100644 --- a/crates/tests/libs/implement/tests/query.rs +++ b/crates/tests/libs/implement/tests/query.rs @@ -1,4 +1,7 @@ -use windows::{core::*, Foundation::*, Win32::Foundation::*, Win32::System::WinRT::*}; +use windows::{ + core::*, Foundation::*, Win32::Foundation::*, Win32::System::Com::Marshal::*, + Win32::System::Com::*, Win32::System::WinRT::*, +}; #[implement(IStringable)] struct Stringable; @@ -59,5 +62,11 @@ fn test_query(interface: &I) { let hr = interface.query(&IUnknown::IID, std::ptr::null_mut()); assert_eq!(hr, E_POINTER); } + + // Implementations support IAgileObject and IMarshal + { + interface.cast::().expect("IAgileObject"); + interface.cast::().expect("IMarshal"); + } } } diff --git a/crates/tests/misc/component/src/bindings.rs b/crates/tests/misc/component/src/bindings.rs index ebd3b01afb..d84ac37d33 100644 --- a/crates/tests/misc/component/src/bindings.rs +++ b/crates/tests/misc/component/src/bindings.rs @@ -77,6 +77,12 @@ impl windows_core::Result + Send + 'static> CallbackBox || *iid == ::IID { &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler( + core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), + interface, + ); } else { core::ptr::null_mut() }; diff --git a/crates/tests/misc/component_client/src/bindings.rs b/crates/tests/misc/component_client/src/bindings.rs index 2b9fac6501..4a67a368f8 100644 --- a/crates/tests/misc/component_client/src/bindings.rs +++ b/crates/tests/misc/component_client/src/bindings.rs @@ -77,6 +77,12 @@ impl windows_core::Result + Send + 'static> CallbackBox || *iid == ::IID { &mut (*this).vtable as *mut _ as _ + } else if *iid == ::IID { + (*this).count.add_ref(); + return windows_core::imp::marshaler( + core::mem::transmute(&mut (*this).vtable as *mut _ as *mut core::ffi::c_void), + interface, + ); } else { core::ptr::null_mut() }; diff --git a/crates/tests/misc/marshal/Cargo.toml b/crates/tests/misc/marshal/Cargo.toml new file mode 100644 index 0000000000..0f817ea8b2 --- /dev/null +++ b/crates/tests/misc/marshal/Cargo.toml @@ -0,0 +1,19 @@ +[package] +name = "test_marshal" +version = "0.0.0" +edition = "2021" +publish = false + +[lib] +doc = false +doctest = false + +[dependencies.windows-core] +workspace = true + +[dependencies.windows] +workspace = true +features = [ + "Foundation", + "Win32_System_Com_Marshal", +] diff --git a/crates/tests/misc/marshal/src/lib.rs b/crates/tests/misc/marshal/src/lib.rs new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/crates/tests/misc/marshal/src/lib.rs @@ -0,0 +1 @@ + diff --git a/crates/tests/misc/marshal/tests/implement.rs b/crates/tests/misc/marshal/tests/implement.rs new file mode 100644 index 0000000000..813700738a --- /dev/null +++ b/crates/tests/misc/marshal/tests/implement.rs @@ -0,0 +1,66 @@ +use windows::{core::*, Foundation::*, Win32::System::Com::Marshal::*, Win32::System::Com::*}; + +#[implement(IClassFactory)] +struct Factory; + +impl IClassFactory_Impl for Factory_Impl { + fn CreateInstance( + &self, + outer: Ref, + iid: *const GUID, + interface: *mut *mut core::ffi::c_void, + ) -> Result<()> { + unsafe { + assert!(outer.is_null(), "aggregation not supported"); + let unknown: IUnknown = Stringable.into(); + unknown.query(iid, interface).ok() + } + } + + fn LockServer(&self, lock: BOOL) -> Result<()> { + assert!(lock.as_bool()); + Ok(()) + } +} + +#[implement(IStringable)] +struct Stringable; + +impl IStringable_Impl for Stringable_Impl { + fn ToString(&self) -> Result { + Ok("Stringable".into()) + } +} + +const CLSID_SAMPLE: GUID = GUID::from_u128(0x58d39529_4975_4440_b7a6_6d71bfb59559); + +#[test] +fn test() { + unsafe { + CoIncrementMTAUsage().unwrap(); + let factory: IClassFactory = Factory.into(); + factory.cast::().expect("IAgileObject"); + factory.cast::().expect("IMarshal"); + + CoRegisterClassObject( + &CLSID_SAMPLE, + &factory, + CLSCTX_LOCAL_SERVER, + REGCLS_AGILE | REGCLS_MULTIPLEUSE, + ) + .expect("CoRegisterClassObject"); + + let stringable: IStringable = + CoCreateInstance(&CLSID_SAMPLE, None, CLSCTX_LOCAL_SERVER).expect("CoCreateInstance"); + + assert_eq!(stringable.ToString().unwrap(), "Stringable"); + + let stream = CoMarshalInterThreadInterfaceInStream(&IStringable::IID, &stringable).unwrap(); + let copy: IStringable = CoUnmarshalInterface(&stream).unwrap(); + + assert_eq!(copy.ToString().unwrap(), "Stringable"); + assert_eq!(stringable, copy); + + assert_eq!(copy, copy.downgrade().unwrap().upgrade().unwrap()); + } +} diff --git a/crates/tools/bindings/src/core_com.txt b/crates/tools/bindings/src/core_com.txt index 746390211d..ac06d6f839 100644 --- a/crates/tools/bindings/src/core_com.txt +++ b/crates/tools/bindings/src/core_com.txt @@ -20,4 +20,5 @@ REGDB_E_CLASSNOTREG RoGetAgileReference RPC_E_DISCONNECTED + S_OK TYPE_E_TYPEMISMATCH