Hi, Is there an available tool which hooks the windows COM runtime? I want to be able to see all the instances which get created, view queries to their interfaces, method calls, etc.
Thanks!
Hi, Is there an available tool which hooks the windows COM runtime? I want to be able to see all the instances which get created, view queries to their interfaces, method calls, etc.
Thanks!
With in-proc COM servers there's almost nothing to hook - the consumer calls CoCreateInstance() or CoGetClassObject() and that's all it does. All the rest is done inside the COM object implementation. You might want to look at ATL sources to see how it usually works inside - for example when the consumer calls QueryInterface() the call directly goes to the corresponding object and the object itself is the only entity to observe the call.
This is not very fortunate but is a direct consequence of how in-proc COM servers are implemented. The developer can use Process Monitor to notice the registry accesses corresponding to ClassId->Dll mapping discovery and extensive tracing inside the COM object to see what's going on. ATL has a bunch of useful stuff (like COM_INTERFACE_ENTRY_FUNC_BLIND macro) to incorporate tracing.
Check out http://www.nektra.com/products/com-spy-console, it's free.
to monitor the things you want you'll need to hook into system dlls and inject your blind delegators on interfaces queried. Needless to say how complex and error prone this task is, especially if consider that many implementors do not follow COM principles accurately. Though, some applications do that for their own purposes, without exposing this functionality.
If you really want to go this way - take a look at these:
You could try Jonas Blunck's COMTrace -- I'm not sure if it works on Windows 7, but it's worth a try.