-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from MartinKuschnik/EventWatcher-Support
Event watcher support
- Loading branch information
Showing
26 changed files
with
798 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#include "pch.h" | ||
|
||
#include "EventSinkProxy.h" | ||
|
||
EventSinkProxy::EventSinkProxy(void* pEventSink, IndicateFunction indicateFunction, SetStatusFunction setStatusFunction) noexcept | ||
: _pEventSink(pEventSink), _indicateFunction(indicateFunction), _setStatusFunction(setStatusFunction) | ||
{ | ||
_lRef = 0; | ||
} | ||
|
||
ULONG EventSinkProxy::AddRef() | ||
{ | ||
return ::InterlockedIncrement(&_lRef); | ||
} | ||
|
||
ULONG EventSinkProxy::Release() | ||
{ | ||
long lRef = ::InterlockedDecrement(&_lRef); | ||
|
||
if (lRef == 0) | ||
delete this; | ||
|
||
return lRef; | ||
} | ||
|
||
HRESULT EventSinkProxy::QueryInterface(REFIID riid, void** ppv) | ||
{ | ||
if (riid == IID_IUnknown || riid == IID_IWbemObjectSink) | ||
{ | ||
*ppv = (IWbemObjectSink*)this; | ||
|
||
this->AddRef(); | ||
|
||
return WBEM_S_NO_ERROR; | ||
} | ||
|
||
return E_NOINTERFACE; | ||
} | ||
|
||
HRESULT EventSinkProxy::Indicate(long lObjectCount, IWbemClassObject** apObjArray) | ||
{ | ||
return this->_indicateFunction(this->_pEventSink, lObjectCount, apObjArray); | ||
} | ||
|
||
HRESULT EventSinkProxy::SetStatus(long lFlags, HRESULT hResult, wchar_t* strParam, IWbemClassObject* pObjParam) | ||
{ | ||
return this->_setStatusFunction(this->_pEventSink, lFlags, hResult, strParam, pObjParam); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#pragma once | ||
|
||
#include <Wbemidl.h> | ||
|
||
/// <summary> | ||
/// Proxy that forewardes the event calls to the managed sink. | ||
/// </summary> | ||
class EventSinkProxy : public IWbemObjectSink | ||
{ | ||
public: | ||
|
||
typedef HRESULT(*IndicateFunction)(void*, long, IWbemClassObject**); | ||
typedef HRESULT(*SetStatusFunction)(void*, long, HRESULT, wchar_t*, IWbemClassObject*); | ||
|
||
private: | ||
|
||
long _lRef; | ||
|
||
void* _pEventSink; | ||
const IndicateFunction _indicateFunction; | ||
const SetStatusFunction _setStatusFunction; | ||
|
||
public: | ||
EventSinkProxy(void* pEventSink, IndicateFunction indicateFunction, SetStatusFunction setStatusFunction) noexcept; | ||
|
||
~EventSinkProxy() noexcept = default; | ||
|
||
virtual ULONG STDMETHODCALLTYPE AddRef(); | ||
|
||
virtual ULONG STDMETHODCALLTYPE Release(); | ||
|
||
virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppv); | ||
|
||
virtual HRESULT STDMETHODCALLTYPE Indicate(long lObjectCount, IWbemClassObject** apObjArray); | ||
|
||
virtual HRESULT STDMETHODCALLTYPE SetStatus(long lFlags, HRESULT hResult, wchar_t* strParam, IWbemClassObject* pObjParam); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
namespace WmiLight | ||
{ | ||
using System; | ||
|
||
internal static class InterfaceIdentifier | ||
{ | ||
/// <summary> | ||
/// DC12A681-737F-11CF-884D-00AA004B2E24 | ||
/// </summary> | ||
public static readonly Guid IWbemClassObject = new Guid(0xDC12A681, 0x737F, 0x11CF, 0x88, 0x4D, 0x00, 0xAA, 0x00, 0x4B, 0x2E, 0x24); | ||
} | ||
} |
Oops, something went wrong.