- In your COM object's IDL file, add a method that will be called from mdbg:
interface IHelper : IDispatch {
...
HRESULT HelperMethod([in] LONGLONG piunkCorDebugModule);
... - Add the method implementation:
STDMETHODIMP IHelper::HelperMethod(/*[in]*/ LONGLONG piunkCorDebugModule)
{
CComPtrspiCorDebugModule;
hr = ((IUnknown*) piunkCorModule)->QueryInterface(__uuidof(spiCorDebugModule.p),
(void**) &spiCorDebugModule.p);
... - Create a COM Interop assembly for your COM object so you can call it from managed code. Right click on mdbg (or your mdbg plugin) and select Add Reference. Click on the COM tab and select your COM object.
- Call the COM method from mdbg/plugin:
using System.Runtime.InteropServices;
IntPtr ptrUnkCorDebugModule = Marshal.GetIUnknownForObject(
module.CorModule.CorModuleInterface);
HelperLib.IHelper = new HelperLib.IHelper();
helper.HelperMethod(ptrUnkCorDebugModule);
Monday, May 29, 2006
Accessing mdbg COM wrappers from native C++
I needed a way to pass the Debugger COM object wrappers from mdbg to a COM library I wrote in native C++. Suppose you want to pass ICorDebugModule from mdbg (or, more likely, an mdbg plugin) to a C++ COM object:
Subscribe to:
Posts (Atom)