Reactos
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
36extern "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
48typedef 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
55typedef struct _EVENT_DATA_DESCRIPTOR {
56 ULONGLONG Ptr;
57 ULONG Size;
58 ULONG Reserved;
59} EVENT_DATA_DESCRIPTOR, *PEVENT_DATA_DESCRIPTOR;
60
61typedef 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;
70typedef const EVENT_DESCRIPTOR *PCEVENT_DESCRIPTOR;
71
72#ifndef _EVNTRACE_
73typedef struct _EVENT_FILTER_DESCRIPTOR {
74 ULONGLONG Ptr;
75 ULONG Size;
76 ULONG Type;
77} EVENT_FILTER_DESCRIPTOR, *PEVENT_FILTER_DESCRIPTOR;
78#endif
79
80typedef 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
91typedef 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_opt_ PEVENT_FILTER_DESCRIPTOR FilterData,
99 _Inout_opt_ PVOID CallbackContext);
100
101#if (WINVER >= _WIN32_WINNT_VISTA)
102ULONG
103EVNTAPI
104EventRegister(
105 _In_ LPCGUID ProviderId,
106 _In_opt_ PENABLECALLBACK EnableCallback,
107 _In_opt_ PVOID CallbackContext,
108 _Out_ PREGHANDLE RegHandle);
109
110ULONG
111EVNTAPI
112EventUnregister(
113 _In_ REGHANDLE RegHandle);
114
115BOOLEAN
116EVNTAPI
117EventEnabled(
118 _In_ REGHANDLE RegHandle,
119 _In_ PCEVENT_DESCRIPTOR EventDescriptor);
120
121BOOLEAN
122EVNTAPI
123EventProviderEnabled(
124 _In_ REGHANDLE RegHandle,
125 _In_ UCHAR Level,
126 _In_ ULONGLONG Keyword);
127
128ULONG
129EVNTAPI
130EventWrite(
131 _In_ REGHANDLE RegHandle,
132 _In_ PCEVENT_DESCRIPTOR EventDescriptor,
133 _In_ ULONG UserDataCount,
134 _In_reads_opt_(UserDataCount) PEVENT_DATA_DESCRIPTOR UserData);
135
136ULONG
137EVNTAPI
138EventWriteTransfer(
139 _In_ REGHANDLE RegHandle,
140 _In_ PCEVENT_DESCRIPTOR EventDescriptor,
141 _In_opt_ LPCGUID ActivityId,
142 _In_opt_ LPCGUID RelatedActivityId,
143 _In_ ULONG UserDataCount,
144 _In_reads_opt_(UserDataCount) PEVENT_DATA_DESCRIPTOR UserData);
145
146ULONG
147EVNTAPI
148EventWriteString(
149 _In_ REGHANDLE RegHandle,
150 _In_ UCHAR Level,
151 _In_ ULONGLONG Keyword,
152 _In_ PCWSTR String);
153
154ULONG
155EVNTAPI
156EventActivityIdControl(
157 _In_ ULONG ControlCode,
158 _Inout_ LPGUID ActivityId);
159
160#endif /* (WINVER >= _WIN32_WINNT_VISTA) */
161
162#if (WINVER >= _WIN32_WINNT_WIN7)
163ULONG
164EVNTAPI
165EventWriteEx(
166 _In_ REGHANDLE RegHandle,
167 _In_ PCEVENT_DESCRIPTOR EventDescriptor,
168 _In_ ULONG64 Filter,
169 _In_ ULONG Flags,
170 _In_opt_ LPCGUID ActivityId,
171 _In_opt_ LPCGUID RelatedActivityId,
172 _In_ ULONG UserDataCount,
173 _In_reads_opt_(UserDataCount) PEVENT_DATA_DESCRIPTOR UserData);
174#endif
175
176#endif // _ETW_KM_
177
178FORCEINLINE
179VOID
180EventDataDescCreate(
181 _Out_ PEVENT_DATA_DESCRIPTOR EventDataDescriptor,
182 _In_reads_bytes_(DataSize) 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
190FORCEINLINE
191VOID
192EventDescCreate(
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
211FORCEINLINE
212VOID
213EventDescZero(
214 _Out_ PEVENT_DESCRIPTOR EventDescriptor)
215{
216 memset(EventDescriptor, 0, sizeof(EVENT_DESCRIPTOR));
217}
218
219FORCEINLINE
220USHORT
221EventDescGetId(
222 _In_ PCEVENT_DESCRIPTOR EventDescriptor)
223{
224 return (EventDescriptor->Id);
225}
226
227FORCEINLINE
228UCHAR
229EventDescGetVersion(
230 _In_ PCEVENT_DESCRIPTOR EventDescriptor)
231{
232 return (EventDescriptor->Version);
233}
234
235FORCEINLINE
236USHORT
237EventDescGetTask(
238 _In_ PCEVENT_DESCRIPTOR EventDescriptor)
239{
240 return (EventDescriptor->Task);
241}
242
243FORCEINLINE
244UCHAR
245EventDescGetOpcode(
246 _In_ PCEVENT_DESCRIPTOR EventDescriptor)
247{
248 return (EventDescriptor->Opcode);
249}
250
251FORCEINLINE
252UCHAR
253EventDescGetChannel(
254 _In_ PCEVENT_DESCRIPTOR EventDescriptor)
255{
256 return (EventDescriptor->Channel);
257}
258
259FORCEINLINE
260UCHAR
261EventDescGetLevel(
262 _In_ PCEVENT_DESCRIPTOR EventDescriptor)
263{
264 return (EventDescriptor->Level);
265}
266
267FORCEINLINE
268ULONGLONG
269EventDescGetKeyword(
270 _In_ PCEVENT_DESCRIPTOR EventDescriptor)
271{
272 return (EventDescriptor->Keyword);
273}
274
275FORCEINLINE
276PEVENT_DESCRIPTOR
277EventDescSetId(
278 _In_ PEVENT_DESCRIPTOR EventDescriptor,
279 _In_ USHORT Id)
280{
281 EventDescriptor->Id = Id;
282 return (EventDescriptor);
283}
284
285FORCEINLINE
286PEVENT_DESCRIPTOR
287EventDescSetVersion(
288 _In_ PEVENT_DESCRIPTOR EventDescriptor,
289 _In_ UCHAR Version)
290{
291 EventDescriptor->Version = Version;
292 return (EventDescriptor);
293}
294
295FORCEINLINE
296PEVENT_DESCRIPTOR
297EventDescSetTask(
298 _In_ PEVENT_DESCRIPTOR EventDescriptor,
299 _In_ USHORT Task)
300{
301 EventDescriptor->Task = Task;
302 return (EventDescriptor);
303}
304
305FORCEINLINE
306PEVENT_DESCRIPTOR
307EventDescSetOpcode(
308 _In_ PEVENT_DESCRIPTOR EventDescriptor,
309 _In_ UCHAR Opcode)
310{
311 EventDescriptor->Opcode = Opcode;
312 return (EventDescriptor);
313}
314
315FORCEINLINE
316PEVENT_DESCRIPTOR
317EventDescSetLevel(
318 _In_ PEVENT_DESCRIPTOR EventDescriptor,
319 _In_ UCHAR Level)
320{
321 EventDescriptor->Level = Level;
322 return (EventDescriptor);
323}
324
325FORCEINLINE
326PEVENT_DESCRIPTOR
327EventDescSetChannel(
328 _In_ PEVENT_DESCRIPTOR EventDescriptor,
329 _In_ UCHAR Channel)
330{
331 EventDescriptor->Channel = Channel;
332 return (EventDescriptor);
333}
334
335FORCEINLINE
336PEVENT_DESCRIPTOR
337EventDescSetKeyword(
338 _In_ PEVENT_DESCRIPTOR EventDescriptor,
339 _In_ ULONGLONG Keyword)
340{
341 EventDescriptor->Keyword = Keyword;
342 return (EventDescriptor);
343}
344
345
346FORCEINLINE
347PEVENT_DESCRIPTOR
348EventDescOrKeyword(
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