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