22#pragma warning(disable: 4505)  
   32template<
class _Ty, 
class _Ax>
 
   33static _Success_(
return == ERROR_SUCCESS) ULONG 
TdhGetProperty(_In_ PEVENT_RECORD pEvent, _In_ ULONG TdhContextCount, _In_reads_opt_(TdhContextCount) PTDH_CONTEXT pTdhContext, _In_ ULONG PropertyDataCount, _In_reads_(PropertyDataCount) PPROPERTY_DATA_DESCRIPTOR pPropertyData, _Inout_ std::vector<_Ty, _Ax> &aData)
 
   35    ULONG ulSize, ulResult;
 
   38    ulResult = TdhGetPropertySize(pEvent, TdhContextCount, pTdhContext, PropertyDataCount, pPropertyData, &ulSize);
 
   39    if (ulResult == ERROR_SUCCESS) {
 
   42            aData.resize((ulSize + 
sizeof(_Ty) - 1) / 
sizeof(_Ty));
 
   43            ulResult = 
TdhGetProperty(pEvent, TdhContextCount, pTdhContext, PropertyDataCount, pPropertyData, ulSize, 
reinterpret_cast<PBYTE
>(aData.data()));
 
 
   58static _Success_(
return == ERROR_SUCCESS) ULONG 
TdhGetEventInformation(_In_ PEVENT_RECORD pEvent, _In_ ULONG TdhContextCount, _In_reads_opt_(TdhContextCount) PTDH_CONTEXT pTdhContext, _Out_ std::unique_ptr<TRACE_EVENT_INFO> &info)
 
   61    ULONG ulSize = 
sizeof(szBuffer), ulResult;
 
   64    ulResult = 
TdhGetEventInformation(pEvent, TdhContextCount, pTdhContext, (PTRACE_EVENT_INFO)szBuffer, &ulSize);
 
   65    if (ulResult == ERROR_SUCCESS) {
 
   67        info.reset(
reinterpret_cast<PTRACE_EVENT_INFO
>(
new char[ulSize]));
 
   68        memcpy(info.get(), szBuffer, ulSize);
 
   70    } 
else if (ulResult == ERROR_INSUFFICIENT_BUFFER) {
 
   72        info.reset(
reinterpret_cast<PTRACE_EVENT_INFO
>(
new char[ulSize]));
 
 
   84static _Success_(
return == ERROR_SUCCESS) ULONG 
TdhGetEventMapInformation(_In_ PEVENT_RECORD pEvent, _In_ LPWSTR pMapName, _Inout_ std::unique_ptr<EVENT_MAP_INFO> &info)
 
   87    ULONG ulSize = 
sizeof(szBuffer), ulResult;
 
   91    if (ulResult == ERROR_SUCCESS) {
 
   93        info.reset(
reinterpret_cast<PEVENT_MAP_INFO
>(
new char[ulSize]));
 
   94        memcpy(info.get(), szBuffer, ulSize);
 
   96    } 
else if (ulResult == ERROR_INSUFFICIENT_BUFFER) {
 
   98        info.reset(
reinterpret_cast<PEVENT_MAP_INFO
>(
new char[ulSize]));
 
 
  127            Reserved = (ULONG)-1;   
 
 
  137        #pragma warning(suppress: 26495)  
  140            EventDataDescCreate(
this, &data, (ULONG)(
sizeof(data)));
 
 
  150        #pragma warning(suppress: 26495)  
  153            EventDataDescCreate(
this, &data, (ULONG)(
sizeof(data)));
 
 
  163        #pragma warning(suppress: 26495)  
  166            EventDataDescCreate(
this, &data, (ULONG)(
sizeof(data)));
 
 
  176        #pragma warning(suppress: 26495)  
  179            EventDataDescCreate(
this, &data, (ULONG)(
sizeof(data)));
 
 
  189        #pragma warning(suppress: 26495)  
  192            EventDataDescCreate(
this, &data, (ULONG)(
sizeof(data)));
 
 
  202        #pragma warning(suppress: 26495)  
  205            EventDataDescCreate(
this, &data, (ULONG)(
sizeof(data)));
 
 
  215        #pragma warning(suppress: 26495)  
  218            EventDataDescCreate(
this, &data, (ULONG)(
sizeof(data)));
 
 
  228        #pragma warning(suppress: 26495)  
  232                EventDataDescCreate(
this, data, (ULONG)((strlen(data) + 1) * 
sizeof(*data)));
 
  235                static const char null[] = 
"(null)";
 
  236                EventDataDescCreate(
this, null, 
sizeof(null));
 
 
  247        #pragma warning(suppress: 26495)  
  251                EventDataDescCreate(
this, data, (ULONG)((wcslen(data) + 1) * 
sizeof(*data)));
 
  254                static const wchar_t null[] = L
"(null)";
 
  255                EventDataDescCreate(
this, null, 
sizeof(null));
 
 
  266        #pragma warning(suppress: 26495)  
  267        template<
class _Elem, 
class _Traits, 
class _Ax>
 
  268        event_data(_In_ 
const std::basic_string<_Elem, _Traits, _Ax> &data)
 
  270            EventDataDescCreate(
this, data.c_str(), (ULONG)((data.length() + 1) * 
sizeof(_Elem)));
 
 
  281        #pragma warning(suppress: 26495)  
  282        event_data(_In_bytecount_(size) 
const void *data, _In_ ULONG size)
 
  284            EventDataDescCreate(
this, data, size);
 
 
 
  304            memset((EVENT_RECORD*)
this, 0, 
sizeof(EVENT_RECORD));
 
 
  323        event_rec(_In_ 
const EVENT_RECORD &other) : EVENT_RECORD(other)
 
 
  336            memset((EVENT_RECORD*)&other, 0, 
sizeof(EVENT_RECORD));
 
 
  345                delete reinterpret_cast<unsigned char*
>(ExtendedData);
 
  348                delete reinterpret_cast<unsigned char*
>(UserData);
 
 
  358            if (
this != std::addressof(other)) {
 
  359                (EVENT_RECORD&)*
this = other;
 
 
  374            if (
this != std::addressof(other)) {
 
  375                (EVENT_RECORD&)*
this = other;
 
 
  390            if (
this != std::addressof(other)) {
 
  391                (EVENT_RECORD&)*
this = other;
 
  392                memset((EVENT_RECORD*)&other, 0, 
sizeof(EVENT_RECORD));
 
 
  404        void set_extended_data(_In_ USHORT count, _In_count_(count) 
const EVENT_HEADER_EXTENDED_DATA_ITEM *data)
 
  407                delete reinterpret_cast<unsigned char*
>(ExtendedData);
 
 
  421                delete reinterpret_cast<unsigned char*
>(UserData);
 
 
  439                size_t data_size = 0;
 
  440                for (
size_t i = 0; i < count; i++)
 
  441                    data_size += data[i].DataSize;
 
  444                ExtendedData = 
reinterpret_cast<EVENT_HEADER_EXTENDED_DATA_ITEM*
>(
new unsigned char[
sizeof(EVENT_HEADER_EXTENDED_DATA_ITEM)*count + data_size]);
 
  447                memcpy(ExtendedData, data, 
sizeof(EVENT_HEADER_EXTENDED_DATA_ITEM) * count);
 
  450                unsigned char *ptr = 
reinterpret_cast<unsigned char*
>(ExtendedData + count);
 
  451                for (
size_t i = 0; i < count; i++) {
 
  452                    if (data[i].DataSize) {
 
  453                        memcpy(ptr, (
void*)(data[i].DataPtr), data[i].DataSize);
 
  454                        ExtendedData[i].DataPtr = (ULONGLONG)ptr;
 
  455                        ptr += data[i].DataSize;
 
  457                        ExtendedData[i].DataPtr = NULL;
 
  462            ExtendedDataCount = count;
 
 
  477                UserData = 
new unsigned char[size];
 
  480                memcpy(UserData, data, size);
 
  484            UserDataLength = size;
 
 
 
  520            if (ulRes == ERROR_SUCCESS)
 
 
  534        ULONG 
write(_In_ PCEVENT_DESCRIPTOR EventDescriptor)
 
  537            return EventWrite(
m_h, EventDescriptor, 0, NULL);
 
 
  549        ULONG 
write(_In_ PCEVENT_DESCRIPTOR EventDescriptor, _In_ ULONG UserDataCount = 0, _In_opt_count_(UserDataCount) PEVENT_DATA_DESCRIPTOR UserData = NULL)
 
  552            return EventWrite(
m_h, EventDescriptor, UserDataCount, UserData);
 
 
  566        ULONG 
write(_In_ PCEVENT_DESCRIPTOR EventDescriptor, _In_ 
const EVENT_DATA_DESCRIPTOR param1, ...)
 
  574                return EventWrite(
m_h, EventDescriptor, 0, NULL);
 
  577            va_start(arg, param1);
 
  578            va_list arg_start = arg;
 
  579            std::vector<EVENT_DATA_DESCRIPTOR> params;
 
  583            for (param_count = 1; param_count < MAX_EVENT_DATA_DESCRIPTORS; param_count++) {
 
  584                const EVENT_DATA_DESCRIPTOR &p = va_arg(arg, 
const EVENT_DATA_DESCRIPTOR);
 
  589            params.reserve(param_count);
 
  593            params.push_back(param1);
 
  595                const EVENT_DATA_DESCRIPTOR &p = va_arg(arg, 
const EVENT_DATA_DESCRIPTOR);
 
  604#pragma warning(disable: 28020) 
  605            return EventWrite(
m_h, EventDescriptor, param_count, params.data());
 
 
  620        ULONG 
write(_In_ PCEVENT_DESCRIPTOR EventDescriptor, _In_ va_list arg)
 
  624            va_list arg_start = arg;
 
  625            std::vector<EVENT_DATA_DESCRIPTOR> params;
 
  629            for (param_count = 0; param_count < MAX_EVENT_DATA_DESCRIPTORS; param_count++) {
 
  630                const EVENT_DATA_DESCRIPTOR &p = va_arg(arg, 
const EVENT_DATA_DESCRIPTOR);
 
  635            params.reserve(param_count);
 
  640                const EVENT_DATA_DESCRIPTOR &p = va_arg(arg, 
const EVENT_DATA_DESCRIPTOR);
 
  648#pragma warning(disable: 28020) 
  649            return EventWrite(
m_h, EventDescriptor, param_count, params.data());
 
 
  662        ULONG 
write(_In_ UCHAR Level, _In_ ULONGLONG Keyword, _In_z_ _Printf_format_string_ PCWSTR String, ...)
 
  670            va_start(arg, String);
 
  675            return EventWriteString(
m_h, Level, Keyword, msg.c_str());
 
 
  686            EventUnregister(
m_h);
 
 
  694        virtual void enable_callback(_In_ LPCGUID SourceId, _In_ ULONG IsEnabled, _In_ UCHAR Level, _In_ ULONGLONG MatchAnyKeyword, _In_ ULONGLONG MatchAllKeyword, _In_opt_ PEVENT_FILTER_DESCRIPTOR FilterData)
 
  696            UNREFERENCED_PARAMETER(SourceId);
 
  697            UNREFERENCED_PARAMETER(IsEnabled);
 
  698            UNREFERENCED_PARAMETER(Level);
 
  699            UNREFERENCED_PARAMETER(MatchAnyKeyword);
 
  700            UNREFERENCED_PARAMETER(MatchAllKeyword);
 
  701            UNREFERENCED_PARAMETER(FilterData);
 
 
  709        static VOID NTAPI 
enable_callback(_In_ LPCGUID SourceId, _In_ ULONG IsEnabled, _In_ UCHAR Level, _In_ ULONGLONG MatchAnyKeyword, _In_ ULONGLONG MatchAllKeyword, _In_opt_ PEVENT_FILTER_DESCRIPTOR FilterData, _Inout_opt_ PVOID CallbackContext)
 
 
 
  739            m_prop(reinterpret_cast<EVENT_TRACE_PROPERTIES*>(new char[prop->Wnode.BufferSize])),
 
  742            memcpy(
m_prop.get(), prop, prop->Wnode.BufferSize);
 
 
  751            m_prop(std::move(other.m_prop)),
 
 
  773            if (
this != std::addressof(other)) {
 
  775                m_prop                          = std::move(other.m_prop);
 
 
  785        operator const EVENT_TRACE_PROPERTIES*() 
const 
 
  797            const EVENT_TRACE_PROPERTIES *prop = 
m_prop.get();
 
  798            return reinterpret_cast<LPCTSTR
>(
reinterpret_cast<LPCBYTE
>(prop) + prop->LoggerNameOffset);
 
 
  824        ULONG 
create(_In_z_ LPCTSTR SessionName, _In_ 
const EVENT_TRACE_PROPERTIES *Properties)
 
  827            std::unique_ptr<EVENT_TRACE_PROPERTIES> prop(
reinterpret_cast<EVENT_TRACE_PROPERTIES*
>(
new char[Properties->Wnode.BufferSize]));
 
  828            memcpy(prop.get(), Properties, Properties->Wnode.BufferSize);
 
  829            ULONG ulRes = StartTrace(&h, SessionName, prop.get());
 
  830            if (ulRes == ERROR_SUCCESS)
 
  831                attach(h, prop.release());
 
 
  844        ULONG 
enable_trace(_In_ LPCGUID ProviderId, _In_ UCHAR Level, _In_opt_ ULONGLONG MatchAnyKeyword = 0, _In_opt_ ULONGLONG MatchAllKeyword = 0, _In_opt_ ULONG EnableProperty = 0, _In_opt_ PEVENT_FILTER_DESCRIPTOR EnableFilterDesc = NULL)
 
  847            return EnableTraceEx(
 
  851                EVENT_CONTROL_CODE_ENABLE_PROVIDER,
 
 
  868        ULONG 
disable_trace(_In_ LPCGUID ProviderId, _In_ UCHAR Level, _In_opt_ ULONGLONG MatchAnyKeyword = 0, _In_opt_ ULONGLONG MatchAllKeyword = 0, _In_opt_ ULONG EnableProperty = 0, _In_opt_ PEVENT_FILTER_DESCRIPTOR EnableFilterDesc = NULL)
 
  871            return EnableTraceEx(
 
  875                EVENT_CONTROL_CODE_DISABLE_PROVIDER,
 
 
  891            ControlTrace(
m_h, 
name(), 
m_prop.get(), EVENT_TRACE_CONTROL_STOP);
 
 
  895        std::unique_ptr<EVENT_TRACE_PROPERTIES> 
m_prop; 
 
 
  943            _In_opt_ LPCGUID                  SourceId,
 
  944            _In_     TRACEHANDLE              TraceHandle,
 
  945            _In_     LPCGUID                  ProviderId,
 
  947            _In_opt_ ULONGLONG                MatchAnyKeyword  = 0,
 
  948            _In_opt_ ULONGLONG                MatchAllKeyword  = 0,
 
  949            _In_opt_ ULONG                    EnableProperty   = 0,
 
  950            _In_opt_ PEVENT_FILTER_DESCRIPTOR EnableFilterDesc = NULL) :
 
  964                EVENT_CONTROL_CODE_ENABLE_PROVIDER,
 
 
  979            _In_           LPCGUID                  ProviderId,
 
  981            _In_opt_       ULONGLONG                MatchAnyKeyword  = 0,
 
  982            _In_opt_       ULONGLONG                MatchAllKeyword  = 0,
 
  983            _In_opt_       ULONG                    EnableProperty   = 0,
 
  984            _In_opt_       PEVENT_FILTER_DESCRIPTOR EnableFilterDesc = NULL) :
 
  986            m_source_id(&((const EVENT_TRACE_PROPERTIES*)session)->Wnode.Guid),
 
  998                EVENT_CONTROL_CODE_ENABLE_PROVIDER,
 
 
 1028                    EVENT_CONTROL_CODE_DISABLE_PROVIDER,
 
 
 
 1063            EventDataDescCreate(&
m_fn_name, pszFnName, (ULONG)(strlen(pszFnName) + 1)*
sizeof(*pszFnName));
 
 
 1084            other.m_event_dest = NULL;
 
 
 1101            if (
this != &other) {
 
 1102                assert(&
m_ep == &other.m_ep);
 
 
 1115            if (
this != &other) {
 
 1116                assert(&
m_ep == &other.m_ep);
 
 1119                other.m_event_dest = NULL;
 
 
 
 1148            EventDataDescCreate(
m_desc + 0, pszFnName, (ULONG)(strlen(pszFnName) + 1)*
sizeof(*pszFnName));
 
 
 1160            m_desc[0] = other.m_desc[0];
 
 
 1171            m_desc[0] = std::move(other.m_desc[0]);
 
 1172            other.m_event_dest = NULL;
 
 
 1191            if (
this != &other) {
 
 1192                assert(&
m_ep == &other.m_ep);
 
 1194                m_desc[0] = other.m_desc[0];
 
 1195                assert(&
m_result == &other.m_result);
 
 
 1206            if (
this != &other) {
 
 1207                assert(&
m_ep == &other.m_ep);
 
 1209                m_desc[0] = std::move(other.m_desc[0]);
 
 1210                assert(&
m_result == &other.m_result);
 
 1211                other.m_event_dest = NULL;
 
 
 
EVENT_DATA_DESCRIPTOR wrapper.
Definition ETW.h:118
event_data(const char &data)
Construct class pointing to an char.
Definition ETW.h:138
event_data(const wchar_t *data)
Construct class pointing to a wide string.
Definition ETW.h:248
event_data(const int &data)
Construct class pointing to an int.
Definition ETW.h:164
event_data(const void *data, ULONG size)
Construct class pointing to binary data.
Definition ETW.h:282
event_data(const GUID &data)
Construct class pointing to a GUID.
Definition ETW.h:216
event_data(const unsigned int &data)
Construct class pointing to an unsigned int.
Definition ETW.h:177
event_data(const char *data)
Construct class pointing to a string.
Definition ETW.h:229
event_data(const unsigned char &data)
Construct class pointing to an unsigned char.
Definition ETW.h:151
event_data(const std::basic_string< _Elem, _Traits, _Ax > &data)
Template to construct pointing to a std::basic_string<>.
Definition ETW.h:268
event_data(const unsigned long &data)
Construct class pointing to an unsigned long.
Definition ETW.h:203
event_data()
Construct empty class.
Definition ETW.h:123
event_data(const long &data)
Construct class pointing to a long.
Definition ETW.h:190
Helper template to write an event on entry/exit of scope with one parameter (typically result).
Definition ETW.h:1138
event_fn_auto_ret(const event_fn_auto_ret< T > &other)
Copies the object.
Definition ETW.h:1155
~event_fn_auto_ret()
Writes the event_dest event.
Definition ETW.h:1178
EVENT_DATA_DESCRIPTOR m_desc[2]
Function name and return value.
Definition ETW.h:1220
event_provider & m_ep
Reference to event provider in use.
Definition ETW.h:1218
event_fn_auto_ret(event_provider &ep, const EVENT_DESCRIPTOR *event_cons, const EVENT_DESCRIPTOR *event_dest, LPCSTR pszFnName, T &result)
Writes the event_cons event.
Definition ETW.h:1143
T & m_result
Function result.
Definition ETW.h:1221
event_fn_auto_ret & operator=(const event_fn_auto_ret< T > &other)
Copies the object.
Definition ETW.h:1189
const EVENT_DESCRIPTOR * m_event_dest
Event descriptor at destruction.
Definition ETW.h:1219
event_fn_auto_ret(event_fn_auto_ret< T > &&other)
Moves the object.
Definition ETW.h:1166
event_fn_auto_ret & operator=(event_fn_auto_ret< T > &&other)
Moves the object.
Definition ETW.h:1204
Helper class to write an event on entry/exit of scope.
Definition ETW.h:1054
const EVENT_DESCRIPTOR * m_event_dest
Event descriptor at destruction.
Definition ETW.h:1127
event_fn_auto(event_fn_auto &&other) noexcept
Moves the object.
Definition ETW.h:1079
event_fn_auto(event_provider &ep, const EVENT_DESCRIPTOR *event_cons, const EVENT_DESCRIPTOR *event_dest, LPCSTR pszFnName)
Writes the event_cons event.
Definition ETW.h:1059
~event_fn_auto()
Writes the event_dest event.
Definition ETW.h:1090
event_fn_auto & operator=(event_fn_auto &&other) noexcept
Moves the object.
Definition ETW.h:1113
event_fn_auto & operator=(const event_fn_auto &other)
Copies the object.
Definition ETW.h:1099
event_provider & m_ep
Reference to event provider in use.
Definition ETW.h:1126
EVENT_DATA_DESCRIPTOR m_fn_name
Function name.
Definition ETW.h:1128
event_fn_auto(const event_fn_auto &other)
Copies the object.
Definition ETW.h:1070
ETW event provider.
Definition ETW.h:492
ULONG write(PCEVENT_DESCRIPTOR EventDescriptor)
Writes an event with no parameters.
Definition ETW.h:534
ULONG write(PCEVENT_DESCRIPTOR EventDescriptor, ULONG UserDataCount=0, PEVENT_DATA_DESCRIPTOR UserData=NULL)
Writes an event with parameters stored in array.
Definition ETW.h:549
ULONG write(UCHAR Level, ULONGLONG Keyword, PCWSTR String,...)
Writes a string event.
Definition ETW.h:662
ULONG write(PCEVENT_DESCRIPTOR EventDescriptor, va_list arg)
Writes an event with variable number of parameters.
Definition ETW.h:620
virtual ~event_provider()
Closes the event provider.
Definition ETW.h:501
virtual void enable_callback(LPCGUID SourceId, ULONG IsEnabled, UCHAR Level, ULONGLONG MatchAnyKeyword, ULONGLONG MatchAllKeyword, PEVENT_FILTER_DESCRIPTOR FilterData)
Receive enable or disable notification requests.
Definition ETW.h:694
void free_internal() noexcept override
Releases the event provider.
Definition ETW.h:684
ULONG write(PCEVENT_DESCRIPTOR EventDescriptor, const EVENT_DATA_DESCRIPTOR param1,...)
Writes an event with one or more parameter.
Definition ETW.h:566
static VOID NTAPI enable_callback(LPCGUID SourceId, ULONG IsEnabled, UCHAR Level, ULONGLONG MatchAnyKeyword, ULONGLONG MatchAllKeyword, PEVENT_FILTER_DESCRIPTOR FilterData, PVOID CallbackContext)
Receive enable or disable notification requests.
Definition ETW.h:709
ULONG create(LPCGUID ProviderId)
Registers the event provider.
Definition ETW.h:516
EVENT_RECORD wrapper.
Definition ETW.h:297
void set_extended_data_internal(USHORT count, const EVENT_HEADER_EXTENDED_DATA_ITEM *data)
Sets event record extended data.
Definition ETW.h:433
void set_user_data(USHORT size, LPCVOID data)
Sets event record user data.
Definition ETW.h:418
event_rec & operator=(event_rec &&other) noexcept
Moves the event record.
Definition ETW.h:388
~event_rec()
Destroys event record data and frees the allocated memory.
Definition ETW.h:342
event_rec & operator=(const EVENT_RECORD &other)
Copies an existing event record.
Definition ETW.h:372
event_rec(const EVENT_RECORD &other)
Copies an existing event record.
Definition ETW.h:323
event_rec & operator=(const event_rec &other)
Copies an existing event record.
Definition ETW.h:356
void set_extended_data(USHORT count, const EVENT_HEADER_EXTENDED_DATA_ITEM *data)
Sets event record extended data.
Definition ETW.h:404
event_rec(event_rec &&other) noexcept
Moves the event record.
Definition ETW.h:334
event_rec()
Constructs a blank event record.
Definition ETW.h:302
void set_user_data_internal(USHORT size, LPCVOID data)
Sets event record user data.
Definition ETW.h:471
event_rec(const event_rec &other)
Copies an existing event record.
Definition ETW.h:312
ETW session.
Definition ETW.h:722
LPCTSTR name() const
Gets session name.
Definition ETW.h:795
event_session(event_session &&other) noexcept
Move constructor.
Definition ETW.h:750
event_session(handle_type h, const EVENT_TRACE_PROPERTIES *prop)
Initializes a new session with an already available object handle.
Definition ETW.h:738
event_session()
Initializes a new empty session.
Definition ETW.h:729
virtual ~event_session()
Closes the session.
Definition ETW.h:760
void free_internal() noexcept override
Releases the session.
Definition ETW.h:889
event_session & operator=(event_session &&other) noexcept
Move assignment.
Definition ETW.h:771
ULONG disable_trace(LPCGUID ProviderId, UCHAR Level, ULONGLONG MatchAnyKeyword=0, ULONGLONG MatchAllKeyword=0, ULONG EnableProperty=0, PEVENT_FILTER_DESCRIPTOR EnableFilterDesc=NULL)
Disables the specified event trace provider.
Definition ETW.h:868
ULONG enable_trace(LPCGUID ProviderId, UCHAR Level, ULONGLONG MatchAnyKeyword=0, ULONGLONG MatchAllKeyword=0, ULONG EnableProperty=0, PEVENT_FILTER_DESCRIPTOR EnableFilterDesc=NULL)
Enables the specified event trace provider.
Definition ETW.h:844
std::unique_ptr< EVENT_TRACE_PROPERTIES > m_prop
Session properties.
Definition ETW.h:895
ULONG create(LPCTSTR SessionName, const EVENT_TRACE_PROPERTIES *Properties)
Registers and starts an event tracing session.
Definition ETW.h:824
void attach(handle_type h, EVENT_TRACE_PROPERTIES *prop)
Sets a new session handle for the class.
Definition ETW.h:809
Helper class to enable event provider in constructor and disables it in destructor.
Definition ETW.h:935
UCHAR m_level
Logging level.
Definition ETW.h:1041
PEVENT_FILTER_DESCRIPTOR m_enable_filter_desc
Event filter descriptor.
Definition ETW.h:1045
ULONGLONG m_match_any_keyword
Keyword match mask (any)
Definition ETW.h:1042
event_trace_enabler(LPCGUID SourceId, TRACEHANDLE TraceHandle, LPCGUID ProviderId, UCHAR Level, ULONGLONG MatchAnyKeyword=0, ULONGLONG MatchAllKeyword=0, ULONG EnableProperty=0, PEVENT_FILTER_DESCRIPTOR EnableFilterDesc=NULL)
Enables event trace.
Definition ETW.h:942
ULONG m_status
Result of EnableTraceEx call.
Definition ETW.h:1037
TRACEHANDLE m_trace_handle
Trace handle.
Definition ETW.h:1040
virtual ~event_trace_enabler()
Disables event trace.
Definition ETW.h:1021
ULONG status() const
Return result of EnableTraceEx() call.
Definition ETW.h:1011
event_trace_enabler(const event_session &session, LPCGUID ProviderId, UCHAR Level, ULONGLONG MatchAnyKeyword=0, ULONGLONG MatchAllKeyword=0, ULONG EnableProperty=0, PEVENT_FILTER_DESCRIPTOR EnableFilterDesc=NULL)
Enables event trace.
Definition ETW.h:977
ULONGLONG m_match_all_keyword
Keyword match mask (all)
Definition ETW.h:1043
LPCGUID m_provider_id
Provider ID.
Definition ETW.h:1038
LPCGUID m_source_id
Session ID.
Definition ETW.h:1039
ULONG m_enable_property
Enable property.
Definition ETW.h:1044
ETW trace.
Definition ETW.h:904
virtual ~event_trace()
Closes the trace.
Definition ETW.h:913
void free_internal() noexcept override
Closes the trace.
Definition ETW.h:925
Base abstract template class to support generic object handle keeping.
Definition Common.h:874
handle() noexcept
Definition Common.h:889
handle_type m_h
Definition Common.h:1126
void attach(handle_type h) noexcept
Definition Common.h:1089
REGHANDLE handle_type
Definition Common.h:879
static ULONG TdhGetEventInformation(PEVENT_RECORD pEvent, ULONG TdhContextCount, PTDH_CONTEXT pTdhContext, std::unique_ptr< TRACE_EVENT_INFO > &info)
Retrieves metadata about an event.
Definition ETW.h:58
static ULONG TdhGetProperty(PEVENT_RECORD pEvent, ULONG TdhContextCount, PTDH_CONTEXT pTdhContext, ULONG PropertyDataCount, PPROPERTY_DATA_DESCRIPTOR pPropertyData, std::vector< _Ty, _Ax > &aData)
Retrieves a property value from the event data.
Definition ETW.h:33
static ULONG TdhGetEventMapInformation(PEVENT_RECORD pEvent, LPWSTR pMapName, std::unique_ptr< EVENT_MAP_INFO > &info)
Retrieves information about the event map contained in the event.
Definition ETW.h:84
static const event_data blank_event_data
Blank event data used as terminator.
Definition ETW.h:291
#define WINSTD_NONCOPYABLE(C)
Declares a class as non-copyable.
Definition Common.h:67
#define WINSTD_STACK_BUFFER_BYTES
Size of the stack buffer in bytes used for initial system function call.
Definition Common.h:94
#define WINSTD_HANDLE_IMPL(C, T, INVAL)
Implements default constructors and operators to prevent their auto-generation by compiler.
Definition Common.h:164
static const REGHANDLE invalid
Definition Common.h:884