ReactOS 0.4.15-dev-7674-gc0b4db1
fxtelemetry.hpp
Go to the documentation of this file.
1/*++
2
3Copyright (c) Microsoft Corporation
4
5Module Name:
6
7 FxTelemetry.hpp
8
9Abstract:
10
11 This is the header file for core framework (Wdf0100 and Wudfx02000)
12 related telemetry.
13
14Author:
15
16
17
18Environment:
19
20 Both kernel and user mode
21
22Revision History:
23
24Notes:
25
26--*/
27
28#pragma once
29
30#include <strsafe.h>
31#include "fxtelemetrycommon.hpp"
32
33#if (FX_CORE_MODE == FX_CORE_KERNEL_MODE)
34#include "fxtelemetrykm.hpp"
35#else
36#include "fxtelemetryum.hpp"
37#endif
38
39#if defined(__cplusplus)
40extern "C" {
41#endif
42
43// TRACELOGGING_DECLARE_PROVIDER(g_TelemetryProvider); __REACTOS__
44
45#define FX_TELEMETRY_ENABLED(TraceHandle, Globals) \
46 (TraceHandle && IsDriverTelemetryContextInitialized(Globals)) \
47
48#define WDF_CENSUS_EVT_DATA_COMMON(FxGlobals) \
49 TraceLoggingStruct(1, "CensusCommonV1"), \
50 TraceLoggingGuid((FxGlobals)->TelemetryContext->DriverSessionGUID, "SessionGUID")
51
52//
53// For events that want to fire once per
54// session define a bit for use in DoOnceFlagsBitmap
55//
59
60//
61// Event name: WdfCensusEvtDrvLoad
62//
63// Source: Mode agnostic (UMDF and KMDF)
64//
65// Description: Written when a WDF client or cx calls WdfDriverCreate.
66// The event contains information about the driver version,
67// verifier options, service name and driver configuration
68// to track non-pnp drivers or WDF miniports.
69//
70// Frequency: If FX_TELEMETRY_ENABLED then everytime a driver calls WdfDriverCreate.
71//
72#define WDF_CENSUS_EVT_WRITE_DRIVER_LOAD(TraceHandle, Globals, DrvImage, WdfVersion) \
73 TraceLoggingWrite(TraceHandle, \
74 "WdfCensusEvtDrvLoad", \
75 WDF_TELEMETRY_EVT_KEYWORDS, \
76 WDF_CENSUS_EVT_DATA_COMMON(Globals), \
77 TraceLoggingStruct(9, "DriverInfo" ), \
78 TraceLoggingString((Globals)->Public.DriverName, "DriverService" ), \
79 TraceLoggingWideString(DrvImage, "DriverImage" ), \
80 TraceLoggingWideString(WdfVersion, "WdfVersion" ), \
81 TraceLoggingUInt32((Globals)->WdfBindInfo->Version.Major, "DriverVersionMajor" ), \
82 TraceLoggingUInt32((Globals)->WdfBindInfo->Version.Minor, "DriverVersionMinor" ), \
83 TraceLoggingBoolean((Globals)->FxVerifierOn, "FxVerifierOn" ), \
84 TraceLoggingBoolean(!!((Globals)->Public.DriverFlags & WdfDriverInitNonPnpDriver), "DriverNonPnP" ), \
85 TraceLoggingBoolean(!!((Globals)->Public.DriverFlags & WdfDriverInitNoDispatchOverride), "DriverNoDispatchOverride" ), \
86 TraceLoggingUInt32((Globals)->FxEnhancedVerifierOptions, "FxEnhancedVeriferOptions" ) \
87 );
88
89#define MIN_HOURS_BEFORE_NEXT_LOG 24
90#define BASE_10 (10)
91
92#define WDF_LAST_TELEMETRY_LOG_TIME_VALUE L"TimeOfLastTelemetryLog"
93#define WDF_DRIVER_IMAGE_NAME_VALUE L"ImagePath"
94
95//
96// bit-flags for tracking hardware info for device start telemetry event
97//
111
112//
113// wdf version strig example "01.011"
114//
115#define WDF_VERSION_STRING_SIZE_INCLUDING_SEPARATOR_CCH 10
116
118__inline
122 )
123{
125}
126
127VOID
129 _In_ PFX_TELEMETRY_CONTEXT* TelemetryContext
130 );
131
132__inline
135_In_ PFX_DRIVER_GLOBALS FxDrvGlobals
136)
137{
138 ASSERT(FxDrvGlobals);
139 return (NULL != FxDrvGlobals->TelemetryContext);
140}
141
142VOID
144 VOID
145 );
146
147VOID
149 VOID
150 );
151
152VOID
156 );
157
158VOID
162 );
163
169 );
170
171VOID
172__inline
176 )
177{
178 String->Buffer = (PWCHAR) &Info->Data[0];
179 String->MaximumLength = (USHORT) Info->DataLength;
180 String->Length = String->MaximumLength - sizeof(UNICODE_NULL);
181
182 //
183 // ensure string is null terminated
184 //
185 String->Buffer[String->Length/sizeof(WCHAR)] = UNICODE_NULL;
186}
187
188VOID
192 );
193
194#if defined(__cplusplus)
195}
196#endif
197
unsigned char BOOLEAN
PRTL_UNICODE_STRING_BUFFER Path
LONG NTSTATUS
Definition: precomp.h:26
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
#define NULL
Definition: types.h:112
DriverGlobals
#define FLAG_TO_BOOL(_Flags, _FlagMask)
Definition: fxobject.hpp:125
VOID RegisterTelemetryProvider(VOID)
VOID UnregisterTelemetryProvider(VOID)
BOOLEAN __inline IsDeviceInfoFlagSet(_In_ USHORT DeviceInfo, _In_ FxDeviceInfoFlags Flag)
enum _FX_TELEMETRY_DO_ONCE_BITS FX_TELEMETRY_DO_ONCE_BITS
VOID GetNameFromPath(_In_ PCUNICODE_STRING Path, _Out_ PUNICODE_STRING Name)
Definition: fxtelemetry.cpp:54
VOID __inline BuildStringFromPartialInfo(_In_ PKEY_VALUE_PARTIAL_INFORMATION Info, _Out_ PUNICODE_STRING String)
VOID LogDeviceStartTelemetryEvent(_In_ PFX_DRIVER_GLOBALS Globals, _In_opt_ FxDevice *Fdo)
_Must_inspect_result_ NTSTATUS GetImageName(_In_ PFX_DRIVER_GLOBALS DriverGlobals, _Out_ PUNICODE_STRING ImageName)
VOID AllocAndInitializeTelemetryContext(_In_ PFX_TELEMETRY_CONTEXT *TelemetryContext)
VOID LogDriverInfoStream(_In_ PFX_DRIVER_GLOBALS Globals, _In_opt_ FxDevice *Fdo)
FxDeviceInfoFlags
Definition: fxtelemetry.hpp:98
@ DeviceInfoHasStaticChildren
@ DeviceInfoLineBasedEdgeTriggeredInterrupt
@ DeviceInfoMsi22MultiMessageInterrupt
@ DeviceInfoMsiXOrSingleMsi22Interrupt
@ DeviceInfoDmaBusMaster
@ DeviceInfoIsUsingDriverWppRecorder
@ DeviceInfoDmaSystem
@ DeviceInfoLineBasedLevelTriggeredInterrupt
Definition: fxtelemetry.hpp:99
@ DeviceInfoDmaSystemDuplex
@ DeviceInfoHasDynamicChildren
@ DeviceInfoPassiveLevelInterrupt
_FX_TELEMETRY_DO_ONCE_BITS
Definition: fxtelemetry.hpp:56
@ DeviceStartEventBit
Definition: fxtelemetry.hpp:57
__inline BOOLEAN IsDriverTelemetryContextInitialized(_In_ PFX_DRIVER_GLOBALS FxDrvGlobals)
#define ASSERT(a)
Definition: mode.c:44
static const char * ImageName
Definition: image.c:34
#define _Must_inspect_result_
Definition: ms_sal.h:558
#define _Out_
Definition: ms_sal.h:345
#define _In_
Definition: ms_sal.h:308
#define _In_opt_
Definition: ms_sal.h:309
#define UNICODE_NULL
unsigned short USHORT
Definition: pedump.c:61
Definition: xml2sdb.h:80
uint16_t * PWCHAR
Definition: typedefs.h:56
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:690
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2433
_Must_inspect_result_ _In_ WDFDEVICE Fdo
Definition: wdffdo.h:461
__wchar_t WCHAR
Definition: xmlstorage.h:180