Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you find a COM's interfaces without typelib?

Is it possible to find all interfaces (classes, parameters, ect..) normally registered with Component Object Model's (COM) TypeLib even though the TypeLib is completely empty? If so how would you go about doing this? I believe another term for this is an "Anonymous COM". I am sure that accessible interfaces exist for this COM because i have an application that is using a class that isn't listed in the TypeLib.

like image 304
rook Avatar asked Mar 02 '10 18:03

rook


1 Answers

If the type library is blank, then there is no way that you can find information about the types in a COM library.

You need at least a coclass entry in the typelib to find an implementation of IUnknown.

If you have that, then you can actually create instances of the class and then call QueryInterface on IUnknown for the IDispatch implementation (if one exists).

If an IDispatch interface exists, you can then call GetTypeInfo to get information about the interfaces that are implemented.

If you need to make late-bound calls to IDispatch, then you will need to call the Invoke method.

Note, you mention the type library, but it is common practice for in-process COM servers to embed the type library in the dll that is the implementation of the types represented in the library. Are you sure that you haven't checked that as well? Or are you sure you have the type library and it is indeed blank?

If the type lib is indeed blank and the dll doesn't contain it, it's completely possible that the type lib was "private" in the sense that other clients were compiled against it. COM doesn't need a type-lib at runtime necessarily. The pattern for exposing IClassFactory interface implementations is to export a standard DLL function with a well-known signature.

One could easily call LoadLibrary, then call GetProcAddress and cast the result to IClassFactory. From there, they would use the private GUID and IID that they know (not from the type library) as well as the COM interfaces that they have defined privately and work from there.

The only reasoning I can think of for something like this is a form of obfuscation and/or addressing privacy/security concerns, only allowing clients the producer of the server approves of to call it.

It doesn't help you, but could explain why you are seeing a type library with no information in it and at the same time, see other clients consume the library.

like image 167
casperOne Avatar answered Sep 29 '22 00:09

casperOne