-
Notifications
You must be signed in to change notification settings - Fork 2
/
EventManager.cpp
74 lines (58 loc) · 1.76 KB
/
EventManager.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include "EventManager.h"
#include "Logger.h"
SHEventManager::SHEventManager(HostContext* context) {
hostContext = context;
m_cRef = 0;
}
SHEventManager::~SHEventManager() {}
//
// IUnknown
//
HRESULT STDMETHODCALLTYPE SHEventManager::QueryInterface(const IID &riid, void **ppv) {
if (!ppv)
return E_POINTER;
if (riid == IID_IUnknown || riid == IID_IActionOnCLREvent) {
*ppv = this;
AddRef();
return S_OK;
}
*ppv = NULL;
return E_NOINTERFACE;
}
ULONG STDMETHODCALLTYPE SHEventManager::AddRef() {
return InterlockedIncrement(&m_cRef);
}
ULONG STDMETHODCALLTYPE SHEventManager::Release() {
if (InterlockedDecrement(&m_cRef) == 0) {
delete this;
return 0;
}
return m_cRef;
}
//
// IActionOnCLREvent
//
STDMETHODIMP SHEventManager::OnEvent(EClrEvent event, PVOID data) {
switch (event) {
case Event_DomainUnload:
Logger::Debug("In EventManager::OnEvent: Event_DomainUnload, %d", data);
hostContext->OnDomainUnload((DWORD)data);
break;
case Event_ClrDisabled:
Logger::Debug("In EventManager::OnEvent: Event_ClrDisabled");
// TODO: recycle process (if not already shutting down!)
break;
case Event_MDAFired: {
// Managed debugging assistants events. See
// See http://msdn.microsoft.com/en-us/library/vstudio/d21c150d%28v=vs.100%29.aspx
MDAInfo* mdaInfo = (MDAInfo*) data;
Logger::Debug(L"In EventManager::OnEvent: Event_MDAFired : %s, %s", mdaInfo->lpMDACaption, mdaInfo->lpMDAMessage);
Logger::Info(L"Stack trace: %s", mdaInfo->lpStackTrace);
}
break;
case Event_StackOverflow:
// TODO: do we need to take some action? Or will the escalation policies suffice?
break;
}
return S_OK;
}