1/* 2 * evntprov.h 3 * 4 * This file is part of the ReactOS PSDK package. 5 * 6 * Contributors: 7 * Created by Amine Khaldi. 8 * 9 * THIS SOFTWARE IS NOT COPYRIGHTED 10 * 11 * This source code is offered for use in the public domain. You may 12 * use, modify or distribute it freely. 13 * 14 * This code is distributed in the hope that it will be useful but 15 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY 16 * DISCLAIMED. This includes but is not limited to warranties of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 18 * 19 */ 20 21#ifndef _EVNTPROV_H_ 22#define _EVNTPROV_H_ 23 24#ifndef EVNTAPI 25#ifndef MIDL_PASS 26#ifdef _EVNT_SOURCE_ 27#define EVNTAPI __stdcall 28#else 29#define EVNTAPI DECLSPEC_IMPORT __stdcall 30#endif /* _EVNT_SOURCE_ */ 31#endif /* MIDL_PASS */ 32#endif /* EVNTAPI */ 33 34#ifdef __cplusplus 35extern "C" { 36#endif 37 38#include <guiddef.h> 39 40#define EVENT_MIN_LEVEL 0 41#define EVENT_MAX_LEVEL 0xff 42 43#define EVENT_ACTIVITY_CTRL_GET_ID 1 44#define EVENT_ACTIVITY_CTRL_SET_ID 2 45#define EVENT_ACTIVITY_CTRL_CREATE_ID 3 46#define EVENT_ACTIVITY_CTRL_GET_SET_ID 4 47#define EVENT_ACTIVITY_CTRL_CREATE_SET_ID 5 48 49typedef ULONGLONG REGHANDLE, *PREGHANDLE; 50 51#define MAX_EVENT_DATA_DESCRIPTORS 128 52#define MAX_EVENT_FILTER_DATA_SIZE 1024 53 54#define EVENT_FILTER_TYPE_SCHEMATIZED 0x80000000 55 56typedef struct _EVENT_DESCRIPTOR { 57 USHORT Id; 58 UCHAR Version; 59 UCHAR Channel; 60 UCHAR Level; 61 UCHAR Opcode; 62 USHORT Task; 63 ULONGLONG Keyword; 64} EVENT_DESCRIPTOR, *PEVENT_DESCRIPTOR; 65typedef const EVENT_DESCRIPTOR *PCEVENT_DESCRIPTOR; 66 67typedef struct _EVENT_DATA_DESCRIPTOR { 68 ULONGLONG Ptr; 69 ULONG Size; 70 ULONG Reserved; 71} EVENT_DATA_DESCRIPTOR, *PEVENT_DATA_DESCRIPTOR; 72 73struct _EVENT_FILTER_DESCRIPTOR { 74 ULONGLONG Ptr; 75 ULONG Size; 76 ULONG Type; 77}; 78#ifndef DEFINED_PEVENT_FILTER_DESC 79typedef struct _EVENT_FILTER_DESCRIPTOR EVENT_FILTER_DESCRIPTOR, *PEVENT_FILTER_DESCRIPTOR; 80#define DEFINED_PEVENT_FILTER_DESC 1 81#endif /* for evntrace.h */ 82 83typedef struct _EVENT_FILTER_HEADER { 84 USHORT Id; 85 UCHAR Version; 86 UCHAR Reserved[5]; 87 ULONGLONG InstanceId; 88 ULONG Size; 89 ULONG NextOffset; 90} EVENT_FILTER_HEADER, *PEVENT_FILTER_HEADER; 91 92 93#ifndef _ETW_KM_ /* for wdm.h */ 94 95typedef VOID 96(NTAPI *PENABLECALLBACK)( 97 LPCGUID SourceId, 98 ULONG IsEnabled, 99 UCHAR Level, 100 ULONGLONG MatchAnyKeyword, 101 ULONGLONG MatchAllKeyword, 102 PEVENT_FILTER_DESCRIPTOR FilterData, 103 PVOID CallbackContext); 104 105#if (_WIN32_WINNT >= 0x0600) 106ULONG EVNTAPI EventRegister( 107 LPCGUID ProviderId, 108 PENABLECALLBACK EnableCallback, 109 PVOID CallbackContext, 110 PREGHANDLE RegHandle 111); 112 113ULONG EVNTAPI EventUnregister( 114 REGHANDLE RegHandle 115); 116 117BOOLEAN EVNTAPI EventEnabled( 118 REGHANDLE RegHandle, 119 PCEVENT_DESCRIPTOR EventDescriptor 120); 121 122BOOLEAN EVNTAPI EventProviderEnabled( 123 REGHANDLE RegHandle, 124 UCHAR Level, 125 ULONGLONG Keyword 126); 127 128ULONG EVNTAPI EventWrite( 129 REGHANDLE RegHandle, 130 PCEVENT_DESCRIPTOR EventDescriptor, 131 ULONG UserDataCount, 132 PEVENT_DATA_DESCRIPTOR UserData 133); 134 135ULONG EVNTAPI EventWriteTransfer( 136 REGHANDLE RegHandle, 137 PCEVENT_DESCRIPTOR EventDescriptor, 138 LPCGUID ActivityId, 139 LPCGUID RelatedActivityId, 140 ULONG UserDataCount, 141 PEVENT_DATA_DESCRIPTOR UserData 142); 143 144ULONG EVNTAPI EventWriteString( 145 REGHANDLE RegHandle, 146 UCHAR Level, 147 ULONGLONG Keyword, 148 PCWSTR String 149); 150 151ULONG EVNTAPI EventActivityIdControl( 152 ULONG ControlCode, 153 LPGUID ActivityId 154); 155 156#endif /*(_WIN32_WINNT >= 0x0600)*/ 157 158#if (_WIN32_WINNT >= 0x0601) 159ULONG EVNTAPI EventWriteEx( 160 REGHANDLE RegHandle, 161 PCEVENT_DESCRIPTOR EventDescriptor, 162 ULONG64 Filter, 163 ULONG Flags, 164 LPCGUID ActivityId, 165 LPCGUID RelatedActivityId, 166 ULONG UserDataCount, 167 PEVENT_DATA_DESCRIPTOR UserData 168); 169#endif /*(_WIN32_WINNT >= 0x0601)*/ 170 171#endif /* _ETW_KM_ */ 172 173FORCEINLINE 174VOID 175EventDataDescCreate( 176 PEVENT_DATA_DESCRIPTOR EventDataDescriptor, 177 const VOID* DataPtr, 178 ULONG DataSize) 179{ 180 EventDataDescriptor->Ptr = (ULONGLONG)(ULONG_PTR)DataPtr; 181 EventDataDescriptor->Size = DataSize; 182 EventDataDescriptor->Reserved = 0; 183} 184 185FORCEINLINE 186VOID 187EventDescCreate( 188 PEVENT_DESCRIPTOR EventDescriptor, 189 USHORT Id, 190 UCHAR Version, 191 UCHAR Channel, 192 UCHAR Level, 193 USHORT Task, 194 UCHAR Opcode, 195 ULONGLONG Keyword) 196{ 197 EventDescriptor->Id = Id; 198 EventDescriptor->Version = Version; 199 EventDescriptor->Channel = Channel; 200 EventDescriptor->Level = Level; 201 EventDescriptor->Task = Task; 202 EventDescriptor->Opcode = Opcode; 203 EventDescriptor->Keyword = Keyword; 204} 205 206FORCEINLINE 207VOID 208EventDescZero( 209 PEVENT_DESCRIPTOR EventDescriptor) 210{ 211 memset(EventDescriptor, 0, sizeof(EVENT_DESCRIPTOR)); 212} 213 214FORCEINLINE 215USHORT 216EventDescGetId( 217 PCEVENT_DESCRIPTOR EventDescriptor) 218{ 219 return (EventDescriptor->Id); 220} 221 222FORCEINLINE 223UCHAR 224EventDescGetVersion( 225 PCEVENT_DESCRIPTOR EventDescriptor) 226{ 227 return (EventDescriptor->Version); 228} 229 230FORCEINLINE 231USHORT 232EventDescGetTask( 233 PCEVENT_DESCRIPTOR EventDescriptor) 234{ 235 return (EventDescriptor->Task); 236} 237 238FORCEINLINE 239UCHAR 240EventDescGetOpcode( 241 PCEVENT_DESCRIPTOR EventDescriptor) 242{ 243 return (EventDescriptor->Opcode); 244} 245 246FORCEINLINE 247UCHAR 248EventDescGetChannel( 249 PCEVENT_DESCRIPTOR EventDescriptor) 250{ 251 return (EventDescriptor->Channel); 252} 253 254FORCEINLINE 255UCHAR 256EventDescGetLevel( 257 PCEVENT_DESCRIPTOR EventDescriptor) 258{ 259 return (EventDescriptor->Level); 260} 261 262FORCEINLINE 263ULONGLONG 264EventDescGetKeyword( 265 PCEVENT_DESCRIPTOR EventDescriptor) 266{ 267 return (EventDescriptor->Keyword); 268} 269 270FORCEINLINE 271PEVENT_DESCRIPTOR 272EventDescSetId( 273 PEVENT_DESCRIPTOR EventDescriptor, 274 USHORT Id) 275{ 276 EventDescriptor->Id = Id; 277 return (EventDescriptor); 278} 279 280FORCEINLINE 281PEVENT_DESCRIPTOR 282EventDescSetVersion( 283 PEVENT_DESCRIPTOR EventDescriptor, 284 UCHAR Version) 285{ 286 EventDescriptor->Version = Version; 287 return (EventDescriptor); 288} 289 290FORCEINLINE 291PEVENT_DESCRIPTOR 292EventDescSetTask( 293 PEVENT_DESCRIPTOR EventDescriptor, 294 USHORT Task) 295{ 296 EventDescriptor->Task = Task; 297 return (EventDescriptor); 298} 299 300FORCEINLINE 301PEVENT_DESCRIPTOR 302EventDescSetOpcode( 303 PEVENT_DESCRIPTOR EventDescriptor, 304 UCHAR Opcode) 305{ 306 EventDescriptor->Opcode = Opcode; 307 return (EventDescriptor); 308} 309 310FORCEINLINE 311PEVENT_DESCRIPTOR 312EventDescSetLevel( 313 PEVENT_DESCRIPTOR EventDescriptor, 314 UCHAR Level) 315{ 316 EventDescriptor->Level = Level; 317 return (EventDescriptor); 318} 319 320FORCEINLINE 321PEVENT_DESCRIPTOR 322EventDescSetChannel( 323 PEVENT_DESCRIPTOR EventDescriptor, 324 UCHAR Channel) 325{ 326 EventDescriptor->Channel = Channel; 327 return (EventDescriptor); 328} 329 330FORCEINLINE 331PEVENT_DESCRIPTOR 332EventDescSetKeyword( 333 PEVENT_DESCRIPTOR EventDescriptor, 334 ULONGLONG Keyword) 335{ 336 EventDescriptor->Keyword = Keyword; 337 return (EventDescriptor); 338} 339 340 341FORCEINLINE 342PEVENT_DESCRIPTOR 343EventDescOrKeyword( 344 PEVENT_DESCRIPTOR EventDescriptor, 345 ULONGLONG Keyword) 346{ 347 EventDescriptor->Keyword |= Keyword; 348 return (EventDescriptor); 349} 350 351#ifdef __cplusplus 352} 353#endif 354 355#endif /* _EVNTPROV_H_ */ 356 357