iunknown

Exposing events from .NET to COM

Hello everyone, recently I have been encountering problems with exposing events from .NET to COM. I have been successful with this example (conceptually taken from http://blogs.msdn.com/andreww/archive/2008/10/13/exposing-events-from-managed-add-in-objects.aspx): // The delegate type for our custom event. [ComVisible(false)] public de...

Implementing IUnknown, unresolved external symbol

Hello, I am trying to create a class that implements the IUnknown interface. I have the following code in the header file. #pragma once #include "stdafx.h" #include "Unknwn.h" class Vmr9Presenter : IVMRImagePresenter9, IVMRSurfaceAllocator9 { public: Vmr9Presenter(void); HRESULT Initialize(void); ~Vmr9Presenter(void); STDMETHODIMP ...

Is it worth checking for null pointer in QueryInterface() implementation?

IUnknown::QueryInterface() is passed a void** parameter denoting an address where to put the retrieved interface. STDMETHOD QueryInterface(/* [in] */ REFIID riid, /* [iid_is][out] */ void** ppvObject) Should the implementation of QueryInterface() check this pointer for being null (and then immediately return E_POINTER) or just write t...

Get IUnkown using window handle.

I know this may be a long shot so forgive me as I don't really know that much about COM. Basically what I am trying to do is get the pointer to the IUnknown interface for a running application, the problem is the only thing I know about the app is its main window handle. Would this be possible? ...

Implementing a COM "sink" in managed (C#) code

I have a legacy COM control (Core) that accepts an IUnknown to a sink. The purpose is to allow the Core to read/write data through this sink interface. The Core/Sink pointers are currently in use in legacy systems and are not easily modified. The problem I'm having is when I attempt to call the Core from managed code and pass in an obje...

Hook IDispatch v-table in C++

I'm trying to modify the behavior of an IDispatch interface already present in the system. To do this my plan was to hook into the objects v-table during runtime and modify the pointers so it points to a custom hook method instead. If I can get this to work I can add new methods and properties to already existing objects. Nice. First I...

Linker error with DXGI when passing IID_IDXGIDevice to IUnknown::QueryDevice

I am trying to separate Swapchain and Window creation from D3D10 device creation in my rendering framework meaning that I can't really use D3D10CreateDeviceAndSwapChain. I am running into an unexpected linker error when trying to build my test app. I am including DXGI.h and linking to DXGI.lib as well as D3D10 libraries but nothing else...

How to get IUnknown from WDM driver CreateInstance

In documentation (C++ example) LUnknown* pIUnknown = CreateInstance(slot); I try this >> import ctypes >> print type(ctypes.cdll.lcomp.CreateInstance(0)) <type 'int'> How to get IUNKNOWN and QueryInterface? ...

Problem with D3D & COM

all the D3D interfaces are derived from COM's IUnknown interface, so I though I'd take an easy route for releasing D3D objects and use something like this: __inline BOOL SafeRelease(IUnknown*& pUnknown) { if(pUnknown != NULL && FAILED(pUnknown->Release())) return FALSE; pUnknown = NULL; return TRUE; } this doesn't...

What is the correct way to cast when using ATL and IUnknownPtr?

During the modification of an existing ATL COM object I came across an article from the "The Old New Thing" blog called "The ways people mess up IUnknown::QueryInterface" and there was a discussion in the comments section that started when one of the respondents (Norman Diamond) pointed out that that in one of the article's examples that...

COM IUnknown and do I need a pointer to it first before calling CoGetClassObject?

In COM, when you want to create an instance of some COM Server object, do you first need to get a pointer to it's IUnknown interface and only then create a class object using CoGetClassObject? As far as I understand it, IUnknown is used to manage object lifetimes, so from my understanding, whatever object the client wants to create, one...

warnings about mystery interfaces in C# projects

Every time I build my C# Solution, I get a handful of warnings about interfaces that I've never seen or written. I tried Googling for some of them, but get no hits. Could these possibly be buried in an assembly I'm referencing? If so, is there any way to make these warnings go away? Interface 'IAlertable' is marked as [dual], but ...

Delphi: How to implement QueryInterface of IUnknown?

In Delphi, IUnknown is declared as: function QueryInterface(const IID: TGUID; out Obj): HResult; stdcall; Note: The output parameter is untyped In my TInterfacedObject descendant i need to handle QueryInterface, so i can return an object that supports the requested interface: function TFoo.QueryInterface(const IID: TGUID; out Obj): ...