How do you find COM interfaces without typelib?

Is it possible to find all the interfaces (classes, parameters, ect ..) that are usually registered with ObjectList (COM) TypeLib, although TypeLib is completely empty? If so, how would you do it? I believe another term for this is “Anonymous COM”. I'm sure there are interfaces available for this COM, because I have an application that uses a class that is not listed in TypeLib.

+7
reflection com activex typelib
source share
2 answers

If the type library is empty, then you cannot find type information in the COM library.

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

If you have this, you can actually instantiate the class and then call QueryInterface in IUnknown for IDispatch (if one exists).

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

If you need to make late calls in IDispatch, you will need to call the Invoke method.

Note that you are mentioning a type library, but it is common practice for COM servers to process the implementation of a type library in a DLL, which is an implementation of the types represented in the library. Are you sure you have not checked this yet? Or are you sure you have a type library, and is it really empty?

If the lib type is really empty and the dll does not contain it, it is entirely possible that the lib type was "private" in the sense that other clients were compiled against it. COM does not need the lib type at runtime. The template for demonstrating the implementation of the IClassFactory interface is to export a standard DLL function with a well-known signature.

You can easily call LoadLibrary , then call GetProcAddress and pass the result to IClassFactory. From there, they will use the private GUID and IID that they know (not from the type library), as well as the COM interfaces that they have identified privately and work from there.

The only reason I can think of something like this is a form of obfuscation and / or a solution to privacy / security problems, only allowing customers whom the server manufacturer approves of calling it.

This will not help you, but it may explain why you see a type library that has no information, and at the same time see that other clients are consuming the library.

+8
source share

Do not use the type library in COM programming quite often. Any scripting language does this; it uses IDispatch to detect supported methods and properties at runtime. IDispatch :: GetIDsOfNames () or IDispatch :: GetTypeInfo () gets this ball. This is called late binding. It is slow, but it does not matter in the scripting language.

Another standard way is a header file created by MIDL from an .idl file that describes interfaces and co-classes. You will find many of these in the include Windows SDK, for example mshtml.h. But this is only suitable for unmanaged C / C ++ code.

Using COM without a type library in a managed language such as C # is difficult, but not impossible. VB.NET is the best language, it supports late binding out of the box. C # will improve when version 4.0 arrives, it has a new “dynamic” keyword.

+5
source share

All Articles