Inserting the Program Object
This part of the tutorial uses the Visual Studio ATL Object wizard to add a class that supports the IDebugProgram2 and IDebugProgram2 interfaces.
To insert the program object
In Solution Explorer, right-click the TextInterpreter module and click Add Class.
Click the ATL category, click an ATL Simple Object, and click Add.
Type Program for the short name; the other fields will automatically be filled in.
Clear the Attributed option.
Change the Interface to IDebugProgramNode2.
Click Next or click the Options link on the left.
Change the Interface from Dual to Custom.
Click Finish to add the ATL object to the project.
Open the TextInterpreter.idl file.
Remove the IDebugProgramNode2 interface declaration; it will look similar to the following lines (the uuid may be different):
[ object, uuid(6E5E5228-435D-4353-8413-BB54FEC7BF6C), helpstring("IDebugProgramNode2 Interface"), pointer_default(unique) ] interface IDebugProgramNode2 : IUnknown{ };
Open the Program.h file and add the following bold lines. These are the declarations for the methods on the IDebugProgramNode2 interface.
END_COM_MAP() //////////////////////////////////////////////////////////// // IDebugProgramNode2 STDMETHOD(CreatePendingBreakpoint)( IDebugBreakpointRequest2 *pBPRequest, IDebugPendingBreakpoint2** ppPendingBP); STDMETHOD(GetProgramName)(BSTR* pbstrProgramName); STDMETHOD(GetHostName)(DWORD dwHostNameType, BSTR* pbstrHostName); STDMETHOD(GetHostPid)(AD_PROCESS_ID *pHostProcessId); STDMETHOD(GetHostMachineName_V7)(BSTR* pbstrHostMachineName); STDMETHOD(Attach_V7)( IDebugProgram2* pMDMProgram, IDebugEventCallback2* pCallback, DWORD dwReason); STDMETHOD(GetEngineInfo)(BSTR* pbstrEngine, GUID* pguidEngine); STDMETHOD(DetachDebugger_V7)(void);
Open the Program.cpp file and add the following bold lines. These are the definitions for the IDebugProgramNode2 interface methods. These will all return E_NOTIMPL for the moment.
// CProgram ////////////////////////////////////////////////////////////////////////////// // IDebugProgramNode2 methods HRESULT CProgram::GetProgramName(BSTR* pbstrProgramName) { return E_NOTIMPL; } HRESULT CProgram::GetHostName(DWORD dwHostNameType, BSTR* pbstrHostName) { return E_NOTIMPL; } HRESULT CProgram::GetHostMachineName_V7(BSTR* pbstrHostMachineName) { return E_NOTIMPL; } HRESULT CProgram::DetachDebugger_V7(void) { return E_NOTIMPL; } HRESULT CProgram::Attach_V7(IDebugProgram2* pMDMProgram, IDebugEventCallback2* pCallback, DWORD dwReason) { return E_NOTIMPL; } HRESULT CProgram::GetEngineInfo(BSTR* pbstrEngine, GUID* pguidEngine) { //TODO: RETURN ENGINE INFO return E_NOTIMPL; } HRESULT CProgram::GetHostPid(AD_PROCESS_ID *pHostProcessId) { //TODO: RETURN HOST PID return E_NOTIMPL; } HRESULT CProgram::CreatePendingBreakpoint(IDebugBreakpointRequest2 *pBPRequest, IDebugPendingBreakpoint2 **ppPendingBP) { //TODO: CREATE BREAKPOINT return E_NOTIMPL; }
Build the project to make sure there are no errors.