public static IntPtr Create(IntPtr vtable) { var instance = new ManualInterface { VTable = vtable }; var marshalledInstance = Marshal.AllocHGlobal(Marshal.SizeOf(instance)); Marshal.StructureToPtr(instance, marshalledInstance, false); return(marshalledInstance); }
public CustomQueryInterfaceResult GetInterface(ref Guid iid, out IntPtr ppv) { Console.WriteLine($"C# GetInterface({iid})"); if (iid != typeof(CppCom.IFoo).GUID) { ppv = IntPtr.Zero; return(CustomQueryInterfaceResult.NotHandled); } Interlocked.Increment(ref referenceCounter); if (marshalledInterface == IntPtr.Zero) { marshalledVTable = ManualVTable.Create( QueryInterfaceDetour, AddRefDetour, ReleaseDetour, BarDetour); marshalledInterface = ManualInterface.Create(marshalledVTable); } ppv = marshalledInterface; return(CustomQueryInterfaceResult.Handled); }
public static IntPtr Create(IntPtr vtable) { var instance = new ManualInterface { VTable = vtable }; var marshalledInstance = Marshal.AllocHGlobal(Marshal.SizeOf(instance)); Marshal.StructureToPtr(instance, marshalledInstance, false); return marshalledInstance; }