Fontes de evento (SDK do Visual Studio)
Há duas fontes de eventos: o DE (mecanismo de depuração) e o SDM (Gerenciador de Depuração de Sessão). Os eventos enviados de um DE têm um mecanismo diferente de NULL, enquanto os eventos enviados do SDM têm um mecanismo NULL.
Exemplo
O exemplo a seguir mostra como enviar o IDebugProgramCreateEvent2 do DE para o SDM.
CDebugProgramCreateEvent* pProgramCreateEvent = new CDebugProgramCreateEvent();
if (FAILED(pCallback->Event(m_pEngine, NULL, m_pProgram, NULL, pProgramCreateEvent, IID_IDebugProgramCreateEvent2, EVENT_ASYNCHRONOUS)))
{
// Handle failure here.
}
]
CEvent * pProgCreate = new CEvent(IID_IDebugProgramCreateEvent2, EVENT_ASYNCHRONOUS);
pProgCreate->SendEvent(pCallback, m_pEngine, (IDebugProgram2 *)this, NULL);
HRESULT CEvent::SendEvent(IDebugEventCallback2 *pCallback, IDebugEngine2 *pEngine, IDebugProgram2 *pProgram, IDebugThread2 *pThread) {
HRESULT hr;
if (m_dwAttrib & EVENT_STOPPING)
{
hr = SendStoppingEvent(pCallback, pEngine, pProgram, pThread);
}
else if (m_dwAttrib & EVENT_SYNCHRONOUS)
{
hr = SendSynchronousEvent(pCallback, pEngine, pProgram, pThread);
}
else
{
assert(m_dwAttrib == 0);
hr = SendAsynchronousEvent(pCallback, pEngine, pProgram, pThread);
}
return hr;
}
HRESULT CEvent::SendAsynchronousEvent(IDebugEventCallback2 *pCallback, IDebugEngine2 *pEngine, IDebugProgram2 *pProgram, IDebugThread2 *pThread) {
HRESULT hr;
// Make sure the CEvent object running this code is not deleted until the code completes.
AddRef();
pCallback->Event(pEngine, NULL, pProgram, pThread, (IDebugEvent2 *)this, m_riid, m_dwAttrib);
// No error recovery here.
hr = S_OK;
Release();
return hr;
}