From 2611e9b1d112d123f0da64ccabe4f1be47606b5a Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sat, 10 Dec 2022 02:36:17 +0100 Subject: [PATCH] Add missing WinRT bindings --- .../TerraFX.Interop.Windows.D2D1.projitems | 4 ++++ .../WinRT/winrt/hstring/HSTRING_HEADER.cs | 17 +++++++++++++++++ .../WinRT/winrt/roapi/WinRT.cs | 16 ++++++++++++++++ .../WinRT/winrt/winstring/WinRT.cs | 15 +++++++++++++++ .../Windows/other/helper-types/HSTRING.cs | 13 +++++++++++++ 5 files changed, 65 insertions(+) create mode 100644 src/TerraFX.Interop.Windows.D2D1/WinRT/winrt/hstring/HSTRING_HEADER.cs create mode 100644 src/TerraFX.Interop.Windows.D2D1/WinRT/winrt/roapi/WinRT.cs create mode 100644 src/TerraFX.Interop.Windows.D2D1/WinRT/winrt/winstring/WinRT.cs create mode 100644 src/TerraFX.Interop.Windows.D2D1/Windows/other/helper-types/HSTRING.cs diff --git a/src/TerraFX.Interop.Windows.D2D1/TerraFX.Interop.Windows.D2D1.projitems b/src/TerraFX.Interop.Windows.D2D1/TerraFX.Interop.Windows.D2D1.projitems index 478f8ba5..cfa82c7b 100644 --- a/src/TerraFX.Interop.Windows.D2D1/TerraFX.Interop.Windows.D2D1.projitems +++ b/src/TerraFX.Interop.Windows.D2D1/TerraFX.Interop.Windows.D2D1.projitems @@ -57,6 +57,7 @@ + @@ -73,5 +74,8 @@ + + + \ No newline at end of file diff --git a/src/TerraFX.Interop.Windows.D2D1/WinRT/winrt/hstring/HSTRING_HEADER.cs b/src/TerraFX.Interop.Windows.D2D1/WinRT/winrt/hstring/HSTRING_HEADER.cs new file mode 100644 index 00000000..c22767c3 --- /dev/null +++ b/src/TerraFX.Interop.Windows.D2D1/WinRT/winrt/hstring/HSTRING_HEADER.cs @@ -0,0 +1,17 @@ +// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. + +// Ported from winrt/hstring.h in the Windows SDK for Windows 10.0.22621.0 +// Original source is Copyright © Microsoft. All rights reserved. + +namespace TerraFX.Interop.WinRT; + +internal partial struct HSTRING_HEADER +{ + [NativeTypeName("union (anonymous union at C:/Program Files (x86)/Windows Kits/10/Include/10.0.22621.0/winrt/hstring.h:80:5)")] + public _Reserved_e__Union Reserved; + + public unsafe partial struct _Reserved_e__Union + { + internal fixed byte Reserved1[24]; + } +} \ No newline at end of file diff --git a/src/TerraFX.Interop.Windows.D2D1/WinRT/winrt/roapi/WinRT.cs b/src/TerraFX.Interop.Windows.D2D1/WinRT/winrt/roapi/WinRT.cs new file mode 100644 index 00000000..0e955b67 --- /dev/null +++ b/src/TerraFX.Interop.Windows.D2D1/WinRT/winrt/roapi/WinRT.cs @@ -0,0 +1,16 @@ +// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. + +// Ported from winrt/roapi.h in the Windows SDK for Windows 10.0.22621.0 +// Original source is Copyright © Microsoft. All rights reserved. + +using System; +using System.Runtime.InteropServices; +using TerraFX.Interop.Windows; + +namespace TerraFX.Interop.WinRT; + +internal static unsafe partial class WinRT +{ + [DllImport("combase", ExactSpelling = true)] + public static extern HRESULT RoGetActivationFactory(HSTRING activatableClassId, [NativeTypeName("const IID &")] Guid* iid, void** factory); +} \ No newline at end of file diff --git a/src/TerraFX.Interop.Windows.D2D1/WinRT/winrt/winstring/WinRT.cs b/src/TerraFX.Interop.Windows.D2D1/WinRT/winrt/winstring/WinRT.cs new file mode 100644 index 00000000..ef4c8562 --- /dev/null +++ b/src/TerraFX.Interop.Windows.D2D1/WinRT/winrt/winstring/WinRT.cs @@ -0,0 +1,15 @@ +// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. + +// Ported from winrt/winstring.h in the Windows SDK for Windows 10.0.22621.0 +// Original source is Copyright © Microsoft. All rights reserved. + +using System.Runtime.InteropServices; +using TerraFX.Interop.Windows; + +namespace TerraFX.Interop.WinRT; + +internal static unsafe partial class WinRT +{ + [DllImport("combase", ExactSpelling = true)] + public static extern HRESULT WindowsCreateStringReference([NativeTypeName("PCWSTR")] ushort* sourceString, [NativeTypeName("UINT32")] uint length, HSTRING_HEADER* hstringHeader, HSTRING* @string); +} \ No newline at end of file diff --git a/src/TerraFX.Interop.Windows.D2D1/Windows/other/helper-types/HSTRING.cs b/src/TerraFX.Interop.Windows.D2D1/Windows/other/helper-types/HSTRING.cs new file mode 100644 index 00000000..5cc0abeb --- /dev/null +++ b/src/TerraFX.Interop.Windows.D2D1/Windows/other/helper-types/HSTRING.cs @@ -0,0 +1,13 @@ +// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. + +namespace TerraFX.Interop.WinRT; + +internal readonly unsafe partial struct HSTRING +{ + public readonly void* Value; + + public HSTRING(void* value) + { + Value = value; + } +} \ No newline at end of file