fn apply_inner()

in crates/libs/core/src/types/common/security_credentials/windows_credentials.rs [30:62]


    fn apply_inner(
        &self,
        settings_interface: mssf_com::FabricClient::IFabricClientSettings2,
    ) -> crate::Result<()> {
        let remote_identities: Box<[PCWSTR]> = self
            .RemoteIdentities
            .iter()
            .map(WString::as_pcwstr)
            .collect();
        let remote_identities_ptr = if remote_identities.is_empty() {
            std::ptr::null()
        } else {
            remote_identities.as_ptr()
        };
        let mut value = FABRIC_WINDOWS_CREDENTIALS {
            RemoteSpn: self.RemoteSpn.as_pcwstr(),
            RemoteIdentityCount: u32::try_from(remote_identities.len()).unwrap(),
            RemoteIdentities: remote_identities_ptr,
            ProtectionLevel: self.ProtectionLevel.into(),
            Reserved: ptr::null_mut(),
        };
        let security_credentials = FABRIC_SECURITY_CREDENTIALS {
            Kind: FABRIC_SECURITY_CREDENTIAL_KIND_WINDOWS,
            Value: addr_of_mut!(value) as *mut c_void,
        };

        // SAFETY: COM interop. SetSecurityCredentials does not retain reference to the passed in data after function returns.
        let result = unsafe { settings_interface.SetSecurityCredentials(&security_credentials) }
            .map_err(crate::Error::from);
        #[cfg(miri)] // TODO: investigate what's wrong with windows_core::implement drop implement.
        Box::leak(Box::new(settings_interface));
        result
    }