// C++/WinRT v2.0.250303.1 // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. #pragma once #ifndef WINRT_Windows_Devices_Custom_H #define WINRT_Windows_Devices_Custom_H #include "winrt/base.h" static_assert(winrt::check_version(CPPWINRT_VERSION, "2.0.250303.1"), "Mismatched C++/WinRT headers."); #define CPPWINRT_VERSION "2.0.250303.1" #include "winrt/Windows.Devices.h" #include "winrt/impl/Windows.Foundation.2.h" #include "winrt/impl/Windows.Storage.Streams.2.h" #include "winrt/impl/Windows.Devices.Custom.2.h" namespace winrt::impl { template auto consume_Windows_Devices_Custom_ICustomDevice::InputStream() const { void* value{}; if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->get_InputStream(&value)); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->get_InputStream(&value)); } return winrt::Windows::Storage::Streams::IInputStream{ value, take_ownership_from_abi }; } template auto consume_Windows_Devices_Custom_ICustomDevice::OutputStream() const { void* value{}; if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->get_OutputStream(&value)); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->get_OutputStream(&value)); } return winrt::Windows::Storage::Streams::IOutputStream{ value, take_ownership_from_abi }; } template auto consume_Windows_Devices_Custom_ICustomDevice::SendIOControlAsync(winrt::Windows::Devices::Custom::IIOControlCode const& ioControlCode, winrt::Windows::Storage::Streams::IBuffer const& inputBuffer, winrt::Windows::Storage::Streams::IBuffer const& outputBuffer) const { void* operation{}; if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->SendIOControlAsync(*(void**)(&ioControlCode), *(void**)(&inputBuffer), *(void**)(&outputBuffer), &operation)); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->SendIOControlAsync(*(void**)(&ioControlCode), *(void**)(&inputBuffer), *(void**)(&outputBuffer), &operation)); } return winrt::Windows::Foundation::IAsyncOperation{ operation, take_ownership_from_abi }; } template auto consume_Windows_Devices_Custom_ICustomDevice::TrySendIOControlAsync(winrt::Windows::Devices::Custom::IIOControlCode const& ioControlCode, winrt::Windows::Storage::Streams::IBuffer const& inputBuffer, winrt::Windows::Storage::Streams::IBuffer const& outputBuffer) const { void* operation{}; if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->TrySendIOControlAsync(*(void**)(&ioControlCode), *(void**)(&inputBuffer), *(void**)(&outputBuffer), &operation)); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->TrySendIOControlAsync(*(void**)(&ioControlCode), *(void**)(&inputBuffer), *(void**)(&outputBuffer), &operation)); } return winrt::Windows::Foundation::IAsyncOperation{ operation, take_ownership_from_abi }; } template auto consume_Windows_Devices_Custom_ICustomDeviceStatics::GetDeviceSelector(winrt::guid const& classGuid) const { void* value{}; if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->GetDeviceSelector(impl::bind_in(classGuid), &value)); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->GetDeviceSelector(impl::bind_in(classGuid), &value)); } return hstring{ value, take_ownership_from_abi }; } template auto consume_Windows_Devices_Custom_ICustomDeviceStatics::FromIdAsync(param::hstring const& deviceId, winrt::Windows::Devices::Custom::DeviceAccessMode const& desiredAccess, winrt::Windows::Devices::Custom::DeviceSharingMode const& sharingMode) const { void* operation{}; if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->FromIdAsync(*(void**)(&deviceId), static_cast(desiredAccess), static_cast(sharingMode), &operation)); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->FromIdAsync(*(void**)(&deviceId), static_cast(desiredAccess), static_cast(sharingMode), &operation)); } return winrt::Windows::Foundation::IAsyncOperation{ operation, take_ownership_from_abi }; } template auto consume_Windows_Devices_Custom_IIOControlCode::AccessMode() const { winrt::Windows::Devices::Custom::IOControlAccessMode value{}; if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->get_AccessMode(reinterpret_cast(&value))); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->get_AccessMode(reinterpret_cast(&value))); } return value; } template auto consume_Windows_Devices_Custom_IIOControlCode::BufferingMethod() const { winrt::Windows::Devices::Custom::IOControlBufferingMethod value{}; if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->get_BufferingMethod(reinterpret_cast(&value))); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->get_BufferingMethod(reinterpret_cast(&value))); } return value; } template auto consume_Windows_Devices_Custom_IIOControlCode::Function() const { uint16_t value{}; if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->get_Function(&value)); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->get_Function(&value)); } return value; } template auto consume_Windows_Devices_Custom_IIOControlCode::DeviceType() const { uint16_t value{}; if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->get_DeviceType(&value)); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->get_DeviceType(&value)); } return value; } template auto consume_Windows_Devices_Custom_IIOControlCode::ControlCode() const { uint32_t value{}; if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->get_ControlCode(&value)); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->get_ControlCode(&value)); } return value; } template auto consume_Windows_Devices_Custom_IIOControlCodeFactory::CreateIOControlCode(uint16_t deviceType, uint16_t function, winrt::Windows::Devices::Custom::IOControlAccessMode const& accessMode, winrt::Windows::Devices::Custom::IOControlBufferingMethod const& bufferingMethod) const { void* instance{}; if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->CreateIOControlCode(deviceType, function, static_cast(accessMode), static_cast(bufferingMethod), &instance)); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->CreateIOControlCode(deviceType, function, static_cast(accessMode), static_cast(bufferingMethod), &instance)); } return winrt::Windows::Devices::Custom::IOControlCode{ instance, take_ownership_from_abi }; } template auto consume_Windows_Devices_Custom_IKnownDeviceTypesStatics::Unknown() const { uint16_t value{}; if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->get_Unknown(&value)); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->get_Unknown(&value)); } return value; } #ifndef WINRT_LEAN_AND_MEAN template struct produce : produce_base { int32_t __stdcall get_InputStream(void** value) noexcept final try { clear_abi(value); typename D::abi_guard guard(this->shim()); *value = detach_from(this->shim().InputStream()); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall get_OutputStream(void** value) noexcept final try { clear_abi(value); typename D::abi_guard guard(this->shim()); *value = detach_from(this->shim().OutputStream()); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall SendIOControlAsync(void* ioControlCode, void* inputBuffer, void* outputBuffer, void** operation) noexcept final try { clear_abi(operation); typename D::abi_guard guard(this->shim()); *operation = detach_from>(this->shim().SendIOControlAsync(*reinterpret_cast(&ioControlCode), *reinterpret_cast(&inputBuffer), *reinterpret_cast(&outputBuffer))); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall TrySendIOControlAsync(void* ioControlCode, void* inputBuffer, void* outputBuffer, void** operation) noexcept final try { clear_abi(operation); typename D::abi_guard guard(this->shim()); *operation = detach_from>(this->shim().TrySendIOControlAsync(*reinterpret_cast(&ioControlCode), *reinterpret_cast(&inputBuffer), *reinterpret_cast(&outputBuffer))); return 0; } catch (...) { return to_hresult(); } }; #endif #ifndef WINRT_LEAN_AND_MEAN template struct produce : produce_base { int32_t __stdcall GetDeviceSelector(winrt::guid classGuid, void** value) noexcept final try { clear_abi(value); typename D::abi_guard guard(this->shim()); *value = detach_from(this->shim().GetDeviceSelector(*reinterpret_cast(&classGuid))); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall FromIdAsync(void* deviceId, int32_t desiredAccess, int32_t sharingMode, void** operation) noexcept final try { clear_abi(operation); typename D::abi_guard guard(this->shim()); *operation = detach_from>(this->shim().FromIdAsync(*reinterpret_cast(&deviceId), *reinterpret_cast(&desiredAccess), *reinterpret_cast(&sharingMode))); return 0; } catch (...) { return to_hresult(); } }; #endif template struct produce : produce_base { int32_t __stdcall get_AccessMode(int32_t* value) noexcept final try { typename D::abi_guard guard(this->shim()); *value = detach_from(this->shim().AccessMode()); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall get_BufferingMethod(int32_t* value) noexcept final try { typename D::abi_guard guard(this->shim()); *value = detach_from(this->shim().BufferingMethod()); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall get_Function(uint16_t* value) noexcept final try { typename D::abi_guard guard(this->shim()); *value = detach_from(this->shim().Function()); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall get_DeviceType(uint16_t* value) noexcept final try { typename D::abi_guard guard(this->shim()); *value = detach_from(this->shim().DeviceType()); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall get_ControlCode(uint32_t* value) noexcept final try { typename D::abi_guard guard(this->shim()); *value = detach_from(this->shim().ControlCode()); return 0; } catch (...) { return to_hresult(); } }; #ifndef WINRT_LEAN_AND_MEAN template struct produce : produce_base { int32_t __stdcall CreateIOControlCode(uint16_t deviceType, uint16_t function, int32_t accessMode, int32_t bufferingMethod, void** instance) noexcept final try { clear_abi(instance); typename D::abi_guard guard(this->shim()); *instance = detach_from(this->shim().CreateIOControlCode(deviceType, function, *reinterpret_cast(&accessMode), *reinterpret_cast(&bufferingMethod))); return 0; } catch (...) { return to_hresult(); } }; #endif #ifndef WINRT_LEAN_AND_MEAN template struct produce : produce_base { int32_t __stdcall get_Unknown(uint16_t* value) noexcept final try { typename D::abi_guard guard(this->shim()); *value = detach_from(this->shim().Unknown()); return 0; } catch (...) { return to_hresult(); } }; #endif } WINRT_EXPORT namespace winrt::Windows::Devices::Custom { inline auto CustomDevice::GetDeviceSelector(winrt::guid const& classGuid) { return impl::call_factory([&](ICustomDeviceStatics const& f) { return f.GetDeviceSelector(classGuid); }); } inline auto CustomDevice::FromIdAsync(param::hstring const& deviceId, winrt::Windows::Devices::Custom::DeviceAccessMode const& desiredAccess, winrt::Windows::Devices::Custom::DeviceSharingMode const& sharingMode) { return impl::call_factory([&](ICustomDeviceStatics const& f) { return f.FromIdAsync(deviceId, desiredAccess, sharingMode); }); } inline IOControlCode::IOControlCode(uint16_t deviceType, uint16_t function, winrt::Windows::Devices::Custom::IOControlAccessMode const& accessMode, winrt::Windows::Devices::Custom::IOControlBufferingMethod const& bufferingMethod) : IOControlCode(impl::call_factory([&](IIOControlCodeFactory const& f) { return f.CreateIOControlCode(deviceType, function, accessMode, bufferingMethod); })) { } inline auto KnownDeviceTypes::Unknown() { return impl::call_factory_cast([](IKnownDeviceTypesStatics const& f) { return f.Unknown(); }); } } namespace std { #ifndef WINRT_LEAN_AND_MEAN template<> struct hash : winrt::impl::hash_base {}; template<> struct hash : winrt::impl::hash_base {}; template<> struct hash : winrt::impl::hash_base {}; template<> struct hash : winrt::impl::hash_base {}; template<> struct hash : winrt::impl::hash_base {}; template<> struct hash : winrt::impl::hash_base {}; template<> struct hash : winrt::impl::hash_base {}; template<> struct hash : winrt::impl::hash_base {}; #endif #ifdef __cpp_lib_format #endif } #endif