<PackageReference Include="System.Drawing.Common" Version="10.0.0-preview.7.25380.108" />

IUnknown

struct IUnknown : IComIID
using System; using System.CodeDom.Compiler; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using Windows.Win32.Foundation; namespace Windows.Win32.System.Com { [Guid("00000000-0000-0000-C000-000000000046")] [GeneratedCode("Microsoft.Windows.CsWin32", "0.3.151+58e949951d.RR")] internal struct IUnknown : IComIID { internal static class CCW { private unsafe static readonly Vtbl* s_vtable = AllocateVTable(); private unsafe static Vtbl* AllocateVTable() { Vtbl* ptr = (Vtbl*)(long)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(CCW), sizeof(Vtbl)); ptr->QueryInterface_1 = (IntPtr)(void*); ptr->AddRef_2 = (IntPtr)(void*); ptr->Release_3 = (IntPtr)(void*); return ptr; } public unsafe static IUnknown* Create([Nullable(1)] Interface object) { return (IUnknown*)Lifetime<Vtbl, Interface>.Allocate(object, s_vtable); } [UnmanagedCallersOnly(CallConvs = new Type[] { typeof(CallConvStdcall) })] private unsafe static HRESULT QueryInterface(IUnknown* this, Guid* iid, void* ppObject) { if (iid == null || ppObject == null) return HRESULT.E_POINTER; if (!iid->Equals(IID_Guid)) { ppObject = null; return HRESULT.E_NOINTERFACE; } ppObject = this; Lifetime<Vtbl, Interface>.AddRef(this); return HRESULT.S_OK; } [UnmanagedCallersOnly(CallConvs = new Type[] { typeof(CallConvStdcall) })] private unsafe static uint AddRef(IUnknown* this) { return Lifetime<Vtbl, Interface>.AddRef(this); } [UnmanagedCallersOnly(CallConvs = new Type[] { typeof(CallConvStdcall) })] private unsafe static uint Release(IUnknown* this) { return Lifetime<Vtbl, Interface>.Release(this); } } internal interface Interface { unsafe HRESULT QueryInterface(Guid* riid, void** ppvObject); uint AddRef(); uint Release(); } internal struct Vtbl { internal IntPtr QueryInterface_1; internal IntPtr AddRef_2; internal IntPtr Release_3; } private unsafe void** lpVtbl; internal static readonly Guid IID_Guid = new Guid(0, 0, 0, 192, 0, 0, 0, 0, 0, 0, 70); [IsReadOnly] static unsafe ref Guid IComIID.Guid { [MethodImpl(MethodImplOptions.AggressiveInlining)] [return: IsReadOnly] get { return ref Unsafe.As<byte, Guid>(ref MemoryMarshal.GetReference(new ReadOnlySpan<byte>(&global::<PrivateImplementationDetails>.C0B8112A8998B72D19D314C4B80A0734CDD386CB917D2627CD68CC17D6080B65, 16))); } } internal unsafe HRESULT QueryInterface([In] [IsReadOnly] ref Guid riid, out void* ppvObject) { fixed (void** ppvObject2 = &ppvObject) { fixed (Guid* riid2 = &riid) { return QueryInterface(riid2, ppvObject2); } } } public unsafe HRESULT QueryInterface(Guid* riid, void** ppvObject) { IntPtr intPtr = (IntPtr)(*lpVtbl); return (HRESULT); } public unsafe uint AddRef() { IntPtr intPtr = (IntPtr)lpVtbl[1]; return (uint); } public unsafe uint Release() { IntPtr intPtr = (IntPtr)lpVtbl[2]; return (uint); } internal unsafe HRESULT QueryInterface<[IsUnmanaged] T>(out T* ppv) where T : struct { Guid riid = typeof(T).GUID; void* ppvObject; HRESULT result = QueryInterface(ref riid, out ppvObject); if (result.Succeeded) ppv = (T*)ppvObject; else ppv = null; return result; } } }