| 1 | /** |
| 2 | * This file is part of the mingw-w64 runtime package. |
| 3 | * No warranty is given; refer to the file DISCLAIMER within this package. |
| 4 | */ |
| 5 | /* |
| 6 | * evntprov.h |
| 7 | * |
| 8 | * This file is part of the ReactOS PSDK package. |
| 9 | * |
| 10 | * Contributors: |
| 11 | * Created by Amine Khaldi. |
| 12 | * Extended by Kai Tietz for mingw-w64 |
| 13 | * |
| 14 | * THIS SOFTWARE IS NOT COPYRIGHTED |
| 15 | * |
| 16 | * This source code is offered for use in the public domain. You may |
| 17 | * use, modify or distribute it freely. |
| 18 | * |
| 19 | * This code is distributed in the hope that it will be useful but |
| 20 | * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY |
| 21 | * DISCLAIMED. This includes but is not limited to warranties of |
| 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 23 | * |
| 24 | */ |
| 25 | |
| 26 | #ifndef _EVNTPROV_H_ |
| 27 | #define _EVNTPROV_H_ |
| 28 | |
| 29 | #include <winapifamily.h> |
| 30 | |
| 31 | #if !defined (EVNTAPI) && !defined (__WIDL__) && !defined (MIDL_PASS) |
| 32 | #ifdef _EVNT_SOURCE_ |
| 33 | #ifdef _ARM_ |
| 34 | #define EVNTAPI |
| 35 | #else |
| 36 | #define EVNTAPI __stdcall |
| 37 | #endif |
| 38 | #else |
| 39 | #ifdef _ARM_ |
| 40 | #define EVNTAPI DECLSPEC_IMPORT |
| 41 | #else |
| 42 | #define EVNTAPI DECLSPEC_IMPORT __stdcall |
| 43 | #endif |
| 44 | #endif |
| 45 | #endif |
| 46 | |
| 47 | #define EVENT_MIN_LEVEL (0) |
| 48 | #define EVENT_MAX_LEVEL (0xff) |
| 49 | |
| 50 | #define EVENT_ACTIVITY_CTRL_GET_ID (1) |
| 51 | #define EVENT_ACTIVITY_CTRL_SET_ID (2) |
| 52 | #define EVENT_ACTIVITY_CTRL_CREATE_ID (3) |
| 53 | #define EVENT_ACTIVITY_CTRL_GET_SET_ID (4) |
| 54 | #define EVENT_ACTIVITY_CTRL_CREATE_SET_ID (5) |
| 55 | |
| 56 | #define EVENT_FILTER_TYPE_SCHEMATIZED (0x80000000) |
| 57 | #define EVENT_FILTER_TYPE_SYSTEM_FLAGS (0x80000001) |
| 58 | #define EVENT_FILTER_TYPE_TRACEHANDLE (0x80000002) |
| 59 | |
| 60 | #define MAX_EVENT_DATA_DESCRIPTORS (128) |
| 61 | #define MAX_EVENT_FILTER_DATA_SIZE (1024) |
| 62 | |
| 63 | #ifdef __cplusplus |
| 64 | extern "C" { |
| 65 | #endif |
| 66 | |
| 67 | #include <guiddef.h> |
| 68 | |
| 69 | typedef ULONGLONG REGHANDLE,*PREGHANDLE; |
| 70 | |
| 71 | typedef struct _EVENT_DATA_DESCRIPTOR { |
| 72 | ULONGLONG Ptr; |
| 73 | ULONG Size; |
| 74 | ULONG Reserved; |
| 75 | } EVENT_DATA_DESCRIPTOR,*PEVENT_DATA_DESCRIPTOR; |
| 76 | |
| 77 | #ifndef EVENT_DESCRIPTOR_DEF |
| 78 | #define EVENT_DESCRIPTOR_DEF |
| 79 | typedef struct _EVENT_DESCRIPTOR { |
| 80 | USHORT Id; |
| 81 | UCHAR Version; |
| 82 | UCHAR Channel; |
| 83 | UCHAR Level; |
| 84 | UCHAR Opcode; |
| 85 | USHORT Task; |
| 86 | ULONGLONG Keyword; |
| 87 | } EVENT_DESCRIPTOR,*PEVENT_DESCRIPTOR; |
| 88 | typedef const EVENT_DESCRIPTOR *PCEVENT_DESCRIPTOR; |
| 89 | #endif |
| 90 | |
| 91 | struct _EVENT_FILTER_DESCRIPTOR { |
| 92 | ULONGLONG Ptr; |
| 93 | ULONG Size; |
| 94 | ULONG Type; |
| 95 | }; |
| 96 | |
| 97 | #ifndef DEFINED_PEVENT_FILTER_DESC |
| 98 | #define DEFINED_PEVENT_FILTER_DESC |
| 99 | typedef struct _EVENT_FILTER_DESCRIPTOR EVENT_FILTER_DESCRIPTOR,*PEVENT_FILTER_DESCRIPTOR; |
| 100 | #endif /* for evntrace.h */ |
| 101 | |
| 102 | typedef struct _EVENT_FILTER_HEADER { |
| 103 | USHORT Id; |
| 104 | UCHAR Version; |
| 105 | UCHAR Reserved[5]; |
| 106 | ULONGLONG InstanceId; |
| 107 | ULONG Size; |
| 108 | ULONG NextOffset; |
| 109 | } EVENT_FILTER_HEADER,*PEVENT_FILTER_HEADER; |
| 110 | |
| 111 | #if !defined (_ETW_KM_) && !defined (__WIDL__) /* for wdm.h & widl */ |
| 112 | typedef enum _EVENT_INFO_CLASS { |
| 113 | EventProviderBinaryTrackInfo, |
| 114 | MaxEventInfo |
| 115 | } EVENT_INFO_CLASS; |
| 116 | |
| 117 | typedef VOID (NTAPI *PENABLECALLBACK) (LPCGUID SourceId, ULONG IsEnabled, UCHAR Level, ULONGLONG MatchAnyKeyword, ULONGLONG MatchAllKeyword, PEVENT_FILTER_DESCRIPTOR FilterData, PVOID CallbackContext); |
| 118 | |
| 119 | #if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP) |
| 120 | #if WINVER >= 0x0600 |
| 121 | BOOLEAN EVNTAPI EventEnabled (REGHANDLE RegHandle, PCEVENT_DESCRIPTOR EventDescriptor); |
| 122 | BOOLEAN EVNTAPI EventProviderEnabled (REGHANDLE RegHandle, UCHAR Level, ULONGLONG Keyword); |
| 123 | ULONG EVNTAPI EventWriteTransfer (REGHANDLE RegHandle, PCEVENT_DESCRIPTOR EventDescriptor, LPCGUID ActivityId, LPCGUID RelatedActivityId, ULONG UserDataCount, PEVENT_DATA_DESCRIPTOR UserData); |
| 124 | ULONG EVNTAPI EventWriteString (REGHANDLE RegHandle, UCHAR Level, ULONGLONG Keyword, PCWSTR String); |
| 125 | ULONG EVNTAPI EventActivityIdControl (ULONG ControlCode, LPGUID ActivityId); |
| 126 | #endif |
| 127 | #if WINVER >= 0x0601 |
| 128 | ULONG EVNTAPI EventWriteEx (REGHANDLE RegHandle, PCEVENT_DESCRIPTOR EventDescriptor, ULONG64 Filter, ULONG Flags, LPCGUID ActivityId, LPCGUID RelatedActivityId, ULONG UserDataCount, PEVENT_DATA_DESCRIPTOR UserData); |
| 129 | #endif |
| 130 | #endif |
| 131 | |
| 132 | #if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_APP) |
| 133 | #if WINVER >= 0x0600 |
| 134 | ULONG EVNTAPI EventRegister (LPCGUID ProviderId, PENABLECALLBACK EnableCallback, PVOID CallbackContext, PREGHANDLE RegHandle); |
| 135 | ULONG EVNTAPI EventUnregister (REGHANDLE RegHandle); |
| 136 | ULONG EVNTAPI EventWrite (REGHANDLE RegHandle, PCEVENT_DESCRIPTOR EventDescriptor, ULONG UserDataCount, PEVENT_DATA_DESCRIPTOR UserData); |
| 137 | #endif |
| 138 | #if WINVER >= 0x0602 |
| 139 | ULONG EVNTAPI EventSetInformation (REGHANDLE RegHandle, EVENT_INFO_CLASS InformationClass, PVOID EventInformation, ULONG InformationLength); |
| 140 | #endif |
| 141 | #endif |
| 142 | |
| 143 | #endif |
| 144 | |
| 145 | #if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_APP) |
| 146 | FORCEINLINE VOID EventDataDescCreate (PEVENT_DATA_DESCRIPTOR evp, const VOID *d, ULONG sz) { |
| 147 | evp->Ptr = (ULONGLONG) (ULONG_PTR) d; |
| 148 | evp->Size = sz; |
| 149 | evp->Reserved = 0; |
| 150 | } |
| 151 | #endif |
| 152 | |
| 153 | #if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP) |
| 154 | FORCEINLINE VOID EventDescCreate (PEVENT_DESCRIPTOR ev, USHORT Id, UCHAR ver, UCHAR ch, UCHAR lvl, USHORT t, UCHAR opc, ULONGLONG keyw) { |
| 155 | ev->Id = Id; |
| 156 | ev->Version = ver; |
| 157 | ev->Channel = ch; |
| 158 | ev->Level = lvl; |
| 159 | ev->Task = t; |
| 160 | ev->Opcode = opc; |
| 161 | ev->Keyword = keyw; |
| 162 | } |
| 163 | |
| 164 | FORCEINLINE UCHAR EventDescGetChannel (PCEVENT_DESCRIPTOR ev) { |
| 165 | return ev->Channel; |
| 166 | } |
| 167 | |
| 168 | FORCEINLINE USHORT EventDescGetId (PCEVENT_DESCRIPTOR ev) { |
| 169 | return ev->Id; |
| 170 | } |
| 171 | |
| 172 | FORCEINLINE ULONGLONG EventDescGetKeyword (PCEVENT_DESCRIPTOR ev) { |
| 173 | return ev->Keyword; |
| 174 | } |
| 175 | |
| 176 | FORCEINLINE UCHAR EventDescGetLevel (PCEVENT_DESCRIPTOR ev) { |
| 177 | return ev->Level; |
| 178 | } |
| 179 | |
| 180 | FORCEINLINE UCHAR EventDescGetOpcode (PCEVENT_DESCRIPTOR ev) { |
| 181 | return ev->Opcode; |
| 182 | } |
| 183 | |
| 184 | FORCEINLINE USHORT EventDescGetTask (PCEVENT_DESCRIPTOR ev) { |
| 185 | return ev->Task; |
| 186 | } |
| 187 | |
| 188 | FORCEINLINE PEVENT_DESCRIPTOR EventDescOrKeyword (PEVENT_DESCRIPTOR ev, ULONGLONG keyw) { |
| 189 | ev->Keyword |= keyw; |
| 190 | return ev; |
| 191 | } |
| 192 | |
| 193 | FORCEINLINE UCHAR EventDescGetVersion (PCEVENT_DESCRIPTOR ev) { |
| 194 | return ev->Version; |
| 195 | } |
| 196 | |
| 197 | FORCEINLINE PEVENT_DESCRIPTOR EventDescSetChannel (PEVENT_DESCRIPTOR ev, UCHAR ch) { |
| 198 | ev->Channel = ch; |
| 199 | return ev; |
| 200 | } |
| 201 | |
| 202 | FORCEINLINE PEVENT_DESCRIPTOR EventDescSetId (PEVENT_DESCRIPTOR ev, USHORT Id) { |
| 203 | ev->Id = Id; |
| 204 | return ev; |
| 205 | } |
| 206 | |
| 207 | FORCEINLINE PEVENT_DESCRIPTOR EventDescSetKeyword (PEVENT_DESCRIPTOR ev, ULONGLONG keyw) { |
| 208 | ev->Keyword = keyw; |
| 209 | return ev; |
| 210 | } |
| 211 | |
| 212 | FORCEINLINE PEVENT_DESCRIPTOR EventDescSetLevel (PEVENT_DESCRIPTOR ev, UCHAR lvl) { |
| 213 | ev->Level = lvl; |
| 214 | return ev; |
| 215 | } |
| 216 | |
| 217 | FORCEINLINE PEVENT_DESCRIPTOR EventDescSetOpcode (PEVENT_DESCRIPTOR ev, UCHAR opc) { |
| 218 | ev->Opcode = opc; |
| 219 | return ev; |
| 220 | } |
| 221 | |
| 222 | FORCEINLINE PEVENT_DESCRIPTOR EventDescSetTask (PEVENT_DESCRIPTOR ev, USHORT t) { |
| 223 | ev->Task = t; |
| 224 | return ev; |
| 225 | } |
| 226 | |
| 227 | FORCEINLINE PEVENT_DESCRIPTOR EventDescSetVersion (PEVENT_DESCRIPTOR ev, UCHAR ver) { |
| 228 | ev->Version = ver; |
| 229 | return ev; |
| 230 | } |
| 231 | |
| 232 | FORCEINLINE VOID EventDescZero (PEVENT_DESCRIPTOR ev) { |
| 233 | memset (ev, 0, sizeof (EVENT_DESCRIPTOR)); |
| 234 | } |
| 235 | #endif |
| 236 | |
| 237 | #ifdef __cplusplus |
| 238 | } |
| 239 | #endif |
| 240 | |
| 241 | #endif |