May I ask something about hooking method in COM Distach Interface?
Recently, I am making some utility which is kind of COM monitoring tool.
and I'm trying to hook Com object's interface while running time.
for that, I needed to use type lib.
following is a outline of my codes.
// Load Type Lib.
LoadRegTypeLib( TypeLibCLSID , wMajorVersion , wMinorVersion , lcid , &pTypeLib );
// Get Function Descriptor
pInterfaceTypeInfo->GetFuncDesc( iii , &pfuncdesc );
// Create Instance and Get Interface
CoCreateInstance( pClassAttr->guid , NULL, ClassContext, pInterfaceAttr->guid , (void**)&pUnknownObject );
// Get VTable
dwOrgFunctionPointer = *(DWORD*)pUnknownObject;
// adjust offset
dwOrgFunctionPointer += pfuncdesc->oVft;
// Get Function Pointer
dwOrgFunctionPointer = *(DWORD*)dwOrgFunctionPointer ;
// Hook
MyHookMethod( dwOrgFunctionPointer );
This was successful until I found some Com Object which has Dispatch Interface (not dual).
If some Com Object has just Dispatch Interface ( not dual ), there is no function pointers in VTable.
There are just MFC's function pointers like a GetTypeInfoCount, GetTypeInfo, GetIDsOfNames, Invoke.
moreover, pfuncdesc->oVft is always 0 for all functions belongs to that interface.
I know that I shoud use 'Invoke' method when I use these kind of com objects.
But problem is that Im trying to hook. I need function pointers.
How can I get those function pointers from IDispatch ?
There are only MFC's function pointers in IDispatch->vtable.
any advice will be appreciated.
Thnak you.