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