I'm posting this just in case someone out there in the galaxy has a similar problem.
As it turns out, I had the correct approach, but, I made a simple mistake (an incorrect assumption).
If you open the mscorlib Type Library in the OLE/COM Object Viewer, and select one of the COM interfaces, it will produce the IDL code of the interface virtual function table's implemented methods in the correct vtable order. I did this, for example, with the System.Reflection._Assembly interface that exposes the public members of the System.Reflection.Assembly class to unmanaged code. What I didn't notice was that the System.Reflection._Assembly interface was derived from IDispatch, instead of IUnknown, like I was assuming. IUnknown has three methods and IDispatch has four methods (in addition to IUnknown's three methods),...so, my count of the offset to the correct COM method implementation function pointer within the interface vtable was off by 4x4bytes. Embarrassing,...
...Just for some serious overkill, here is the IDL output of the System.Reflection._Assembly interface (from OLE/COM Object Viewer):
[
odl,
uuid(17156360-2F1A-384A-BC52-FDE93C215C5B),
version(1.0),
dual,
oleautomation,
custom({0F21F359-AB84-41E8-9A78-36D110E6D2F9}, "System.Reflection.Assembly")
]
interface _Assembly : IDispatch {
[id(00000000), propget,
custom({54FC8F55-38DE-4703-9C4E-250351302B1C}, "1")]
HRESULT ToString([out, retval] BSTR* pRetVal);
[id(0x60020001)]
HRESULT Equals(
[in] VARIANT other,
[out, retval] VARIANT_BOOL* pRetVal);
[id(0x60020002)]
HRESULT GetHashCode([out, retval] long* pRetVal);
[id(0x60020003)]
HRESULT GetType([out, retval] _Type** pRetVal);
[id(0x60020004), propget]
HRESULT CodeBase([out, retval] BSTR* pRetVal);
[id(0x60020005), propget]
HRESULT EscapedCodeBase([out, retval] BSTR* pRetVal);
[id(0x60020006)]
HRESULT GetName([out, retval] _AssemblyName** pRetVal);
[id(0x60020007),
custom({0F21F359-AB84-41E8-9A78-36D110E6D2F9}, "GetName")]
HRESULT GetName_2(
[in] VARIANT_BOOL copiedName,
[out, retval] _AssemblyName** pRetVal);
[id(0x60020008), propget]
HRESULT FullName([out, retval] BSTR* pRetVal);
[id(0x60020009), propget]
HRESULT EntryPoint([out, retval] _MethodInfo** pRetVal);
[id(0x6002000a),
custom({0F21F359-AB84-41E8-9A78-36D110E6D2F9}, "GetType")]
HRESULT GetType_2(
[in] BSTR name,
[out, retval] _Type** pRetVal);
[id(0x6002000b),
custom({0F21F359-AB84-41E8-9A78-36D110E6D2F9}, "GetType")]
HRESULT GetType_3(
[in] BSTR name,
[in] VARIANT_BOOL throwOnError,
[out, retval] _Type** pRetVal);
[id(0x6002000c)]
HRESULT GetExportedTypes([out, retval] SAFEARRAY(_Type*)* pRetVal);
[id(0x6002000d)]
HRESULT GetTypes([out, retval] SAFEARRAY(_Type*)* pRetVal);
[id(0x6002000e)]
HRESULT GetManifestResourceStream(
[in] _Type* Type,
[in] BSTR name,
[out, retval] _Stream** pRetVal);
[id(0x6002000f),
custom({0F21F359-AB84-41E8-9A78-36D110E6D2F9}, "GetManifestResourceStream")]
HRESULT GetManifestResourceStream_2(
[in] BSTR name,
[out, retval] _Stream** pRetVal);
[id(0x60020010)]
HRESULT GetFile(
[in] BSTR name,
[out, retval] _FileStream** pRetVal);
[id(0x60020011)]
HRESULT GetFiles([out, retval] SAFEARRAY(_FileStream*)* pRetVal);
[id(0x60020012),
custom({0F21F359-AB84-41E8-9A78-36D110E6D2F9}, "GetFiles")]
HRESULT GetFiles_2(
[in] VARIANT_BOOL getResourceModules,
[out, retval] SAFEARRAY(_FileStream*)* pRetVal);
[id(0x60020013)]
HRESULT GetManifestResourceNames([out, retval] SAFEARRAY(BSTR)* pRetVal);
[id(0x60020014)]
HRESULT GetManifestResourceInfo(
[in] BSTR resourceName,
[out, retval] _ManifestResourceInfo** pRetVal);
[id(0x60020015), propget]
HRESULT Location([out, retval] BSTR* pRetVal);
[id(0x60020016), propget]
HRESULT Evidence([out, retval] _Evidence** pRetVal);
[id(0x60020017)]
HRESULT GetCustomAttributes(
[in] _Type* attributeType,
[in] VARIANT_BOOL inherit,
[out, retval] SAFEARRAY(VARIANT)* pRetVal);
[id(0x60020018),
custom({0F21F359-AB84-41E8-9A78-36D110E6D2F9}, "GetCustomAttributes")]
HRESULT GetCustomAttributes_2(
[in] VARIANT_BOOL inherit,
[out, retval] SAFEARRAY(VARIANT)* pRetVal);
[id(0x60020019)]
HRESULT IsDefined(
[in] _Type* attributeType,
[in] VARIANT_BOOL inherit,
[out, retval] VARIANT_BOOL* pRetVal);
[id(0x6002001a)]
HRESULT GetObjectData(
[in] _SerializationInfo* info,
[in] StreamingContext Context);
[id(0x6002001b)]
HRESULT add_ModuleResolve([in] _ModuleResolveEventHandler* value);
[id(0x6002001c)]
HRESULT remove_ModuleResolve([in] _ModuleResolveEventHandler* value);
[id(0x6002001d),
custom({0F21F359-AB84-41E8-9A78-36D110E6D2F9}, "GetType")]
HRESULT GetType_4(
[in] BSTR name,
[in] VARIANT_BOOL throwOnError,
[in] VARIANT_BOOL ignoreCase,
[out, retval] _Type** pRetVal);
[id(0x6002001e)]
HRESULT GetSatelliteAssembly(
[in] _CultureInfo* culture,
[out, retval] _Assembly** pRetVal);
[id(0x6002001f),
custom({0F21F359-AB84-41E8-9A78-36D110E6D2F9}, "GetSatelliteAssembly")]
HRESULT GetSatelliteAssembly_2(
[in] _CultureInfo* culture,
[in] _Version* Version,
[out, retval] _Assembly** pRetVal);
[id(0x60020020)]
HRESULT LoadModule(
[in] BSTR moduleName,
[in] SAFEARRAY(unsigned char) rawModule,
[out, retval] _Module** pRetVal);
[id(0x60020021),
custom({0F21F359-AB84-41E8-9A78-36D110E6D2F9}, "LoadModule")]
HRESULT LoadModule_2(
[in] BSTR moduleName,
[in] SAFEARRAY(unsigned char) rawModule,
[in] SAFEARRAY(unsigned char) rawSymbolStore,
[out, retval] _Module** pRetVal);
[id(0x60020022)]
HRESULT CreateInstance(
[in] BSTR typeName,
[out, retval] VARIANT* pRetVal);
[id(0x60020023),
custom({0F21F359-AB84-41E8-9A78-36D110E6D2F9}, "CreateInstance")]
HRESULT CreateInstance_2(
[in] BSTR typeName,
[in] VARIANT_BOOL ignoreCase,
[out, retval] VARIANT* pRetVal);
[id(0x60020024),
custom({0F21F359-AB84-41E8-9A78-36D110E6D2F9}, "CreateInstance")]
HRESULT CreateInstance_3(
[in] BSTR typeName,
[in] VARIANT_BOOL ignoreCase,
[in] BindingFlags bindingAttr,
[in] _Binder* Binder,
[in] SAFEARRAY(VARIANT) args,
[in] _CultureInfo* culture,
[in] SAFEARRAY(VARIANT) activationAttributes,
[out, retval] VARIANT* pRetVal);
[id(0x60020025)]
HRESULT GetLoadedModules([out, retval] SAFEARRAY(_Module*)* pRetVal);
[id(0x60020026),
custom({0F21F359-AB84-41E8-9A78-36D110E6D2F9}, "GetLoadedModules")]
HRESULT GetLoadedModules_2(
[in] VARIANT_BOOL getResourceModules,
[out, retval] SAFEARRAY(_Module*)* pRetVal);
[id(0x60020027)]
HRESULT GetModules([out, retval] SAFEARRAY(_Module*)* pRetVal);
[id(0x60020028),
custom({0F21F359-AB84-41E8-9A78-36D110E6D2F9}, "GetModules")]
HRESULT GetModules_2(
[in] VARIANT_BOOL getResourceModules,
[out, retval] SAFEARRAY(_Module*)* pRetVal);
[id(0x60020029)]
HRESULT GetModule(
[in] BSTR name,
[out, retval] _Module** pRetVal);
[id(0x6002002a)]
HRESULT GetReferencedAssemblies([out, retval] SAFEARRAY(_AssemblyName*)* pRetVal);
[id(0x6002002b), propget]
HRESULT GlobalAssemblyCache([out, retval] VARIANT_BOOL* pRetVal);
};
modified 13-Jul-16 16:17pm.
|