Click or drag to resize

COMClassInfo Class

A helper class for determining the address of COM object functions for hooking given a COM class id (CLSID) and COM interface id (IID), or COM class type and COM interface type.

Inheritance Hierarchy
SystemObject
  EasyHookCOMClassInfo

Namespace:  EasyHook
Assembly:  EasyHook (in EasyHook.dll) Version: 2.7.6684.0 (2.7.6684.0)
Syntax
public class COMClassInfo

The COMClassInfo type exposes the following members.

Constructors
  NameDescription
Public methodCOMClassInfo(Guid, Guid, Int32)
Creates a new COMClassInfo instance using the COM class and interface Guids. The function indexes to retrieve the addresses for as defined by the order of the methods in the COM interface.
Public methodCOMClassInfo(Type, Type, String)
Creates a new COMClassInfo using the COM class and interface types. The function names to retrieve the addresses for should be provided as strings
Top
Properties
Methods
  NameDescription
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodIsModuleLoaded
Determines if the module containing the COM class is already loaded
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodQuery
Query the COM class for the specified method addresses. If not already loaded the COM module will be loaded.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Examples
The following three examples result in the same output:
// 1. Use imported Class and Interface Types
COMClassInfo cci1 = new COMClassInfo(typeof(CLSID_DirectInputDevice8), typeof(IID_IDirectInputDevice8W), "GetCapabilities");
// 2. Use Guid from class and interface types
COMClassInfo cci2 = new COMClassInfo(typeof(CLSID_DirectInputDevice8).GUID, typeof(IID_IDirectInputDevice8W).GUID, 3);
// 3. Use class and interface Guids directly (no need to have class and interface types defined)
COMClassInfo cci3 = new COMClassInfo(new Guid("25E609E5-B259-11CF-BFC7-444553540000"), new Guid("54D41081-DC15-4833-A41B-748F73A38179"), 3);

// Will output False if dinput8.dll is not already loaded
Console.WriteLine(cci1.IsModuleLoaded());
cci1.Query();
cci2.Query();
cci3.Query();
// Will output True as dinput8.dll will be loaded by .Query() if not already
Console.WriteLine(cci1.IsModuleLoaded());

// Output the function pointers we queried
Console.WriteLine(cci1.FunctionPointers[0]);
Console.WriteLine(cci2.FunctionPointers[0]);
Console.WriteLine(cci3.FunctionPointers[0]);

...

[ComVisible(true)]
[Guid("25E609E5-B259-11CF-BFC7-444553540000")]
public class CLSID_DirectInputDevice8
{
}

[ComVisible(true)]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("54D41081-DC15-4833-A41B-748F73A38179")]
public interface IID_IDirectInputDevice8W
{
    /*** IDirectInputDevice8W methods ***/
    int GetCapabilities(IntPtr deviceCaps); // fourth method due to IUnknown methods QueryInterface, AddRef and Release
    // other methods...
}
See Also