-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patheventsink.h
65 lines (50 loc) · 1.28 KB
/
eventsink.h
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
// EventSink.h
#pragma once
#define _WIN32_DCOM
#include <iostream>
using namespace std;
#include <vector>
#include <string>
#include <comdef.h>
#include <Wbemidl.h>
#pragma comment(lib, "wbemuuid.lib")
class EventSink : public IWbemObjectSink
{
LONG m_lRef;
bool bDone;
public:
struct procentry {
std::string name;
bool is_on = false;
bool operator==(const std::string& b) const {
return name == b;
}
};
std::vector<procentry> process_blacklist;
bool is_any_on() const {
for(const auto& b : process_blacklist) {
if(b.is_on) {
return true;
}
}
return false;
}
EventSink() { m_lRef = 0; }
~EventSink() { bDone = true; }
virtual ULONG STDMETHODCALLTYPE AddRef();
virtual ULONG STDMETHODCALLTYPE Release();
virtual HRESULT
STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppv);
virtual HRESULT STDMETHODCALLTYPE Indicate(
LONG lObjectCount,
IWbemClassObject __RPC_FAR *__RPC_FAR *apObjArray
);
virtual HRESULT STDMETHODCALLTYPE SetStatus(
/* [in] */ LONG lFlags,
/* [in] */ HRESULT hResult,
/* [in] */ BSTR strParam,
/* [in] */ IWbemClassObject __RPC_FAR *pObjParam
);
};
extern EventSink* pSink;
int makeeventsink(std::vector<std::string> blacklist_processes);