ReactOS  0.4.15-dev-2947-g59e1b78
fxtelemetrykm.hpp File Reference
#include "fxldr.h"
Include dependency graph for fxtelemetrykm.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

union  FxTelemetryDriverInfo
 

Macros

#define KMDF_CENSUS_EVT_WRITE_DEVICE_START(TraceHandle, Globals, DriverConfig, SetupClass, BusEnum, HwID, Manafacturer)
 
#define TraceLoggingKmdfDriverConfigInfo(info, fieldName)
 

Functions

VOID RegistryWriteCurrentTime (_In_ PFX_DRIVER_GLOBALS DriverGlobals)
 
VOID RegistryReadLastLoggedTime (_In_ PFX_DRIVER_GLOBALS DriverGlobals, _Out_ PLARGE_INTEGER CurrentTime)
 
NTSTATUS GetHardwareIdAndSetupclassFromRegistry (_In_ FxDevice *Fdo, _Out_ PUNICODE_STRING HwIds, _Out_ PUNICODE_STRING SetupClass)
 
BOOLEAN IsLoggingEnabledAndNeeded (_In_ PFX_DRIVER_GLOBALS DriverGlobals)
 
_Must_inspect_result_ NTSTATUS FxQueryData (_In_ PFX_DRIVER_GLOBALS DriverGlobals, _In_ HANDLE Key, _In_ PCUNICODE_STRING ValueName, _In_ ULONG Tag, _Out_ PKEY_VALUE_PARTIAL_INFORMATION *Info)
 
VOID GetDriverInfo (_In_ PFX_DRIVER_GLOBALS Globals, _In_opt_ FxDevice *Fdo, _Out_ FxTelemetryDriverInfo *DriverInfo)
 
VOID FxGetDevicePropertyString (_In_ FxDevice *Fdo, _In_ DEVICE_REGISTRY_PROPERTY DeviceProperty, _Out_ PUNICODE_STRING PropertyString)
 
VOID GetFirstHardwareId (_Inout_ PUNICODE_STRING HardwareIds)
 
_Must_inspect_result_ __drv_maxIRQL (PASSIVE_LEVEL) NTSTATUS QueryAndAllocString(_In_ HANDLE Key
 

Variables

_Must_inspect_result_ _In_ PFX_DRIVER_GLOBALS Globals
 
_Must_inspect_result_ _In_ PFX_DRIVER_GLOBALS _In_ PCUNICODE_STRING ValueName
 
_Must_inspect_result_ _In_ PFX_DRIVER_GLOBALS _In_ PCUNICODE_STRING _Out_ PKEY_VALUE_PARTIAL_INFORMATIONInfo
 

Macro Definition Documentation

◆ KMDF_CENSUS_EVT_WRITE_DEVICE_START

#define KMDF_CENSUS_EVT_WRITE_DEVICE_START (   TraceHandle,
  Globals,
  DriverConfig,
  SetupClass,
  BusEnum,
  HwID,
  Manafacturer 
)
Value:
TraceLoggingWrite(TraceHandle, \
"KmdfCensusEvtDeviceStart", \
TraceLoggingString((Globals)->Public.DriverName, "DriverServiceName"), \
TraceLoggingWideString(SetupClass.m_UnicodeString.Buffer, "SetupClass"), \
TraceLoggingWideString(BusEnum.m_UnicodeString.Buffer, "BusEnumerator"), \
TraceLoggingWideString(HwID.m_UnicodeString.Buffer, "HardwareId"), \
TraceLoggingWideString(Manafacturer.m_UnicodeString.Buffer, "ManufacturerString") \
);
#define TraceLoggingKmdfDriverConfigInfo(info, fieldName)
#define WDF_CENSUS_EVT_DATA_COMMON(FxGlobals)
Definition: fxtelemetry.hpp:48
#define WDF_TELEMETRY_EVT_KEYWORDS
_Must_inspect_result_ _In_ PFX_DRIVER_GLOBALS Globals
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ PWDF_DRIVER_CONFIG DriverConfig
Definition: wdfdriver.h:213

Definition at line 47 of file fxtelemetrykm.hpp.

◆ TraceLoggingKmdfDriverConfigInfo

#define TraceLoggingKmdfDriverConfigInfo (   info,
  fieldName 
)
Value:
\
TraceLoggingStruct(23, fieldName), \
\
TraceLoggingUInt8(info.bitmap.IsNonPnpDriver, "IsNonPnpDriver" ), \
TraceLoggingUInt8(info.bitmap.IsNoDispatchOverride, "IsNoDispatchOverride" ), \
TraceLoggingUInt8(info.bitmap.IsVerifierOn, "IsVerifierOn" ), \
TraceLoggingUInt8(info.bitmap.IsEnhancedVerifierOn, "IsEnhancedVerifierOn" ), \
TraceLoggingUInt8(info.bitmap.IsFilter, "IsFilter" ), \
\
TraceLoggingUInt8(info.bitmap.IsUsingRemoveLockOption, "IsUsingRemoveLockOption" ), \
TraceLoggingUInt8(info.bitmap.IsUsingNonDefaultHardwareReleaseOrder, "IsUsingNonDefaultHardwareReleaseOrder" ), \
TraceLoggingUInt8(info.bitmap.IsPowerPolicyOwner, "IsPowerPolicyOwner" ), \
TraceLoggingUInt8(info.bitmap.IsS0IdleWakeFromS0Enabled, "IsS0IdleWakeFromS0Enabled" ), \
TraceLoggingUInt8(info.bitmap.IsS0IdleUsbSSEnabled, "IsS0IdleUsbSSEnabled" ), \
\
TraceLoggingUInt8(info.bitmap.IsS0IdleSystemManaged, "IsS0IdleSystemManaged" ), \
TraceLoggingUInt8(info.bitmap.IsSxWakeEnabled, "IsSxWakeEnabled" ), \
TraceLoggingUInt8(info.bitmap.IsUsingLevelTriggeredLineInterrupt, "IsUsingLevelTriggeredLineInterrupt" ), \
TraceLoggingUInt8(info.bitmap.IsUsingEdgeTriggeredLineInterrupt, "IsUsingEdgeTriggeredLineInterrupt" ), \
TraceLoggingUInt8(info.bitmap.IsUsingMsiXOrSingleMsi22Interrupt, "IsUsingMsiXOrSingleMsi22Interrupt" ), \
\
TraceLoggingUInt8(info.bitmap.IsUsingMsi22MultiMessageInterrupt, "IsUsingMsi22MultiMessageInterrupt" ), \
TraceLoggingUInt8(info.bitmap.IsUsingMultipleInterrupt, "IsUsingMultipleInterrupt" ), \
TraceLoggingUInt8(info.bitmap.IsUsingPassiveLevelInterrupt, "IsUsingPassiveLevelInterrupt" ), \
TraceLoggingUInt8(info.bitmap.IsUsingBusMasterDma, "IsUsingBusMasterDma" ), \
TraceLoggingUInt8(info.bitmap.IsUsingSystemDma, "IsUsingSystemDma" ), \
\
TraceLoggingUInt8(info.bitmap.IsUsingSystemDmaDuplex, "IsUsingSystemDmaDuplex" ), \
TraceLoggingUInt8(info.bitmap.IsUsingStaticBusEnumration, "IsUsingStaticBusEnumration" ), \
TraceLoggingUInt8(info.bitmap.IsUsingDynamicBusEnumeration, "IsUsingDynamicBusEnumeration" ) \

Definition at line 63 of file fxtelemetrykm.hpp.

Function Documentation

◆ __drv_maxIRQL()

_Must_inspect_result_ __drv_maxIRQL ( PASSIVE_LEVEL  )

◆ FxGetDevicePropertyString()

VOID FxGetDevicePropertyString ( _In_ FxDevice Fdo,
_In_ DEVICE_REGISTRY_PROPERTY  DeviceProperty,
_Out_ PUNICODE_STRING  PropertyString 
)

Definition at line 458 of file fxtelemetrykm.cpp.

463 {
464  MdDeviceObject pdo;
466  PFX_DRIVER_GLOBALS pFxDriverGlobals = Fdo->GetDriverGlobals();
467  ULONG length = 0;
468  PVOID buffer = NULL;
469 
470  ASSERT(PropertyString != NULL);
471  RtlZeroMemory(PropertyString, sizeof(UNICODE_STRING));
472 
473  pdo = Fdo->GetSafePhysicalDevice();
474  if (pdo == NULL) {
477  "Could not get PDO from FDO WDFDEVICE 0x%p, %!STATUS!",
478  Fdo->GetHandle(), status);
479  return;
480  }
481 
485  "Could not retrieve property %d length %d, %!STATUS!",
487  return;
488  }
489 
490  buffer = FxPoolAllocate(pFxDriverGlobals, PagedPool, length);
491  if (buffer == NULL) {
494  "Could not allocate memory for property %d length %d, %!STATUS!",
496  return;
497  }
498 
500  if (!NT_SUCCESS(status)) {
502  "Could not query for full buffer, size %d, for "
503  "property %d, %!STATUS!",
506  return;
507  }
508 
509  PropertyString->Buffer = (PWCH)buffer;
510  PropertyString->Length = (USHORT) length - sizeof(UNICODE_NULL);
511  PropertyString->MaximumLength = (USHORT) length;
512 
513  //
514  // ensure it's null terminated
515  //
516  PropertyString->Buffer[PropertyString->Length/sizeof(WCHAR)] = UNICODE_NULL;
517 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY DeviceProperty
Definition: wdfdevice.h:3767
LONG NTSTATUS
Definition: precomp.h:26
RtlZeroMemory(info, length)
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
GLuint buffer
Definition: glext.h:5915
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
NTSTATUS status
#define UNICODE_NULL
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
#define TRACINGDEVICE
Definition: dbgtrace.h:58
PFX_DRIVER_GLOBALS pFxDriverGlobals
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_Must_inspect_result_ _In_ WDFDEVICE Fdo
Definition: wdffdo.h:461
WCHAR * PWCH
Definition: ntbasedef.h:410
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
ASSERT(Info !=NULL)
unsigned short USHORT
Definition: pedump.c:61
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
#define NULL
Definition: types.h:112
static __inline NTSTATUS _GetDeviceProperty(_In_ MdDeviceObject DeviceObject, _In_ DEVICE_REGISTRY_PROPERTY DeviceProperty, _In_ ULONG BufferLength, _Out_opt_ PVOID PropertyBuffer, _Out_ PULONG ResultLength)
unsigned int ULONG
Definition: retypes.h:1
void FxPoolFree(__in_xcount(ptr is at an offset from AllocationStart) PVOID ptr)
Definition: wdfpool.cpp:361
Definition: ps.c:97

Referenced by LogDriverInfoStream().

◆ FxQueryData()

_Must_inspect_result_ NTSTATUS FxQueryData ( _In_ PFX_DRIVER_GLOBALS  DriverGlobals,
_In_ HANDLE  Key,
_In_ PCUNICODE_STRING  ValueName,
_In_ ULONG  Tag,
_Out_ PKEY_VALUE_PARTIAL_INFORMATION Info 
)

◆ GetDriverInfo()

VOID GetDriverInfo ( _In_ PFX_DRIVER_GLOBALS  Globals,
_In_opt_ FxDevice Fdo,
_Out_ FxTelemetryDriverInfo DriverInfo 
)

Definition at line 287 of file fxtelemetrykm.cpp.

292 {
293  FxPkgPnp* pnpPkg;
294  USHORT devInfo = 0;
295 
296  DriverInfo->bitmap.IsVerifierOn = Globals->FxVerifierOn;
298 
299  if (Fdo == NULL) {
300  //
301  // this is for non-pnp or noDispatchOverride.
302  //
303  DriverInfo->bitmap.IsNonPnpDriver = FLAG_TO_BOOL(Globals->Public.DriverFlags, WdfDriverInitNonPnpDriver);
304  DriverInfo->bitmap.IsNoDispatchOverride = FLAG_TO_BOOL(Globals->Public.DriverFlags, WdfDriverInitNoDispatchOverride);
305  }
306  else {
307  pnpPkg = Fdo->m_PkgPnp;
308  devInfo = Fdo->GetDeviceTelemetryInfoFlags();
309 
310  DriverInfo->bitmap.IsFilter = Fdo->GetFdoPkg()->IsFilter();
311  DriverInfo->bitmap.IsUsingRemoveLockOption = Fdo->IsRemoveLockEnabledForIo();
312  DriverInfo->bitmap.IsUsingNonDefaultHardwareReleaseOrder = pnpPkg->IsDefaultReleaseHardwareOrder();
313  DriverInfo->bitmap.IsPowerPolicyOwner = pnpPkg->IsPowerPolicyOwner();
314  DriverInfo->bitmap.IsS0IdleWakeFromS0Enabled = pnpPkg->IsS0IdleWakeFromS0Enabled();
315  DriverInfo->bitmap.IsS0IdleUsbSSEnabled = pnpPkg->IsS0IdleUsbSSEnabled();
316  DriverInfo->bitmap.IsS0IdleSystemManaged = pnpPkg->IsS0IdleSystemManaged();
317  DriverInfo->bitmap.IsSxWakeEnabled = pnpPkg->IsSxWakeEnabled();
318  DriverInfo->bitmap.IsUsingLevelTriggeredLineInterrupt = IsDeviceInfoFlagSet(devInfo, DeviceInfoLineBasedLevelTriggeredInterrupt);
319  DriverInfo->bitmap.IsUsingEdgeTriggeredLineInterrupt = IsDeviceInfoFlagSet(devInfo, DeviceInfoLineBasedEdgeTriggeredInterrupt);
320  DriverInfo->bitmap.IsUsingMsiXOrSingleMsi22Interrupt = IsDeviceInfoFlagSet(devInfo, DeviceInfoMsiXOrSingleMsi22Interrupt);
321  DriverInfo->bitmap.IsUsingMsi22MultiMessageInterrupt = IsDeviceInfoFlagSet(devInfo, DeviceInfoMsi22MultiMessageInterrupt);
322  DriverInfo->bitmap.IsUsingMultipleInterrupt = pnpPkg->HasMultipleInterrupts();
323  DriverInfo->bitmap.IsUsingPassiveLevelInterrupt = IsDeviceInfoFlagSet(devInfo, DeviceInfoPassiveLevelInterrupt);
324  DriverInfo->bitmap.IsUsingBusMasterDma = IsDeviceInfoFlagSet(devInfo, DeviceInfoDmaBusMaster);
325  DriverInfo->bitmap.IsUsingSystemDma = IsDeviceInfoFlagSet(devInfo, DeviceInfoDmaSystem);
326  DriverInfo->bitmap.IsUsingSystemDmaDuplex = IsDeviceInfoFlagSet(devInfo, DeviceInfoDmaSystemDuplex);
327  DriverInfo->bitmap.IsUsingStaticBusEnumration = IsDeviceInfoFlagSet(devInfo, DeviceInfoHasStaticChildren);
328  DriverInfo->bitmap.IsUsingDynamicBusEnumeration = IsDeviceInfoFlagSet(devInfo, DeviceInfoHasDynamicChildren);
329  }
330 }
#define FLAG_TO_BOOL(_Flags, _FlagMask)
Definition: fxobject.hpp:125
BOOLEAN FxVerifierOn
Definition: fxglobals.h:420
BOOLEAN IsS0IdleSystemManaged(VOID)
Definition: fxpkgpnp.hpp:3645
ULONG FxEnhancedVerifierOptions
Definition: fxglobals.h:518
_Must_inspect_result_ _In_ PFX_DRIVER_GLOBALS Globals
_Must_inspect_result_ _In_ WDFDEVICE Fdo
Definition: wdffdo.h:461
BOOLEAN IsPowerPolicyOwner(VOID)
Definition: fxpkgpnp.hpp:3612
BOOLEAN HasMultipleInterrupts(VOID)
Definition: fxpkgpnp.hpp:4066
DRIVER_INFORMATION DriverInfo
Definition: main.c:59
unsigned short USHORT
Definition: pedump.c:61
#define NULL
Definition: types.h:112
BOOLEAN __inline IsDeviceInfoFlagSet(_In_ USHORT DeviceInfo, _In_ FxDeviceInfoFlags Flag)
BOOLEAN IsDefaultReleaseHardwareOrder(VOID)
Definition: fxpkgpnp.hpp:4054
BOOLEAN IsS0IdleWakeFromS0Enabled(VOID)
Definition: fxpkgpnp.hpp:3632
BOOLEAN IsS0IdleUsbSSEnabled(VOID)
Definition: fxpkgpnp.hpp:3658
BOOLEAN IsSxWakeEnabled(VOID)
Definition: fxpkgpnp.hpp:3672

Referenced by LogDriverInfoStream().

◆ GetFirstHardwareId()

VOID GetFirstHardwareId ( _Inout_ PUNICODE_STRING  HardwareIds)

Definition at line 229 of file fxtelemetrykm.cpp.

246 {
247  PWCHAR curr;
248  USHORT lengthCch;
249 
250  ASSERT(HardwareIds != NULL);
251 
252  curr = (PWCHAR) HardwareIds->Buffer;
253  lengthCch = (HardwareIds->Length)/sizeof(WCHAR);
254 
255  //
256  // if the caller supplied NULL buffer, then nothing to do.
257  //
258  if (curr == NULL) {
259  RtlInitUnicodeString(HardwareIds, NULL);
260  return;
261  }
262 
263  //
264  // if the first element is NULL then update the length
265  //
266  if (*curr == UNICODE_NULL) {
267  HardwareIds->Length = 0;
268  HardwareIds->MaximumLength = HardwareIds->Length + sizeof(UNICODE_NULL);
269  return;
270  }
271 
272  for (int i = 0; i < lengthCch; i++, curr++) {
273 
274  if (*curr == UNICODE_NULL) {
275  //
276  // We found the first string. Update size. We only want to keep the
277  // first string.
278  //
279  HardwareIds->Length = (USHORT)(i * sizeof(WCHAR));
280  HardwareIds->MaximumLength = HardwareIds->Length + sizeof(UNICODE_NULL);
281  return;
282  }
283  }
284 }
uint16_t * PWCHAR
Definition: typedefs.h:56
#define UNICODE_NULL
__wchar_t WCHAR
Definition: xmlstorage.h:180
ASSERT(Info !=NULL)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned short USHORT
Definition: pedump.c:61
#define NULL
Definition: types.h:112
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)

Referenced by LogDriverInfoStream().

◆ GetHardwareIdAndSetupclassFromRegistry()

NTSTATUS GetHardwareIdAndSetupclassFromRegistry ( _In_ FxDevice Fdo,
_Out_ PUNICODE_STRING  HwIds,
_Out_ PUNICODE_STRING  SetupClass 
)

◆ IsLoggingEnabledAndNeeded()

BOOLEAN IsLoggingEnabledAndNeeded ( _In_ PFX_DRIVER_GLOBALS  DriverGlobals)

Definition at line 109 of file fxtelemetrykm.cpp.

112 {
113  LARGE_INTEGER lastLoggedTime;
114  LARGE_INTEGER currentTime;
115  LONGLONG delta;
116 
117  // If provider is not enabled exit.
118  if (FALSE == FX_TELEMETRY_ENABLED(g_TelemetryProvider, DriverGlobals)) {
119  return FALSE;
120  }
121 
122  ASSERT(DriverGlobals->TelemetryContext);
123 
124  //
125  // If we already fired an event during PnP start we are done. This avoids
126  // repeatedly firing events during PnP rebalance.
127  //
129  &DriverGlobals->TelemetryContext->DoOnceFlagsBitmap,
130  DeviceStartEventBit) != 0) {
131  return FALSE;
132  }
133 
134  //
135  // log only if it has been MIN_HOURS_BEFORE_NEXT_LOG time since last log.
136  // We don't log every time driver loads to avoid sending too much data
137  // too many times in case of a buggy driver going through load/unload cycle
138  // or when a device is plugged in two many times.
139  //
140  lastLoggedTime.QuadPart = 0;
141  RegistryReadLastLoggedTime(DriverGlobals, &lastLoggedTime);
142 
143  if (lastLoggedTime.QuadPart == 0) {
144  //
145  // driver is loading for first time ater install so need to log
146  // event
147  //
148  return TRUE;
149  }
150 
151  Mx::MxQuerySystemTime(&currentTime);
152 
153  delta = (currentTime.QuadPart - lastLoggedTime.QuadPart);
154 
156  "lastlogged %I64x, current %I64x, delta %I64x",
157  lastLoggedTime.QuadPart, currentTime.QuadPart, delta);
158 
159  //
160  // KeQuerySystemTime returns time in 100-ns. We convert MIN_HOURS_BEFORE_NEXT_LOG
161  // to 100-nano sec unit and then compare.
162  //
163  if (delta < WDF_ABS_TIMEOUT_IN_SEC(MIN_HOURS_BEFORE_NEXT_LOG * 60 * 60)) {
164  return FALSE;
165  }
166 
167  return TRUE;
168 }
#define MIN_HOURS_BEFORE_NEXT_LOG
Definition: fxtelemetry.hpp:89
#define TRUE
Definition: types.h:120
static __inline VOID MxQuerySystemTime(_Out_ PLARGE_INTEGER CurrentTime)
Definition: mxgeneralkm.h:679
#define TRACINGDRIVER
Definition: dbgtrace.h:68
DriverGlobals
VOID RegistryReadLastLoggedTime(_In_ PFX_DRIVER_GLOBALS DriverGlobals, _Out_ PLARGE_INTEGER LastLoggedTime)
FORCEINLINE LONGLONG WDF_ABS_TIMEOUT_IN_SEC(_In_ ULONGLONG Time)
Definition: wdfcore.h:71
#define FALSE
Definition: types.h:117
#define TRACE_LEVEL_VERBOSE
Definition: storswtr.h:30
#define FX_TELEMETRY_ENABLED(TraceHandle, Globals)
Definition: fxtelemetry.hpp:45
#define InterlockedBitTestAndSet
Definition: interlocked.h:30
int64_t LONGLONG
Definition: typedefs.h:68
ASSERT(Info !=NULL)
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
LONGLONG QuadPart
Definition: typedefs.h:114

Referenced by LogDeviceStartTelemetryEvent().

◆ RegistryReadLastLoggedTime()

VOID RegistryReadLastLoggedTime ( _In_ PFX_DRIVER_GLOBALS  DriverGlobals,
_Out_ PLARGE_INTEGER  CurrentTime 
)

Definition at line 333 of file fxtelemetrykm.cpp.

337 {
338  FxAutoRegKey hKey, hWdf;
339  DECLARE_CONST_UNICODE_STRING(parametersPath, L"Parameters\\Wdf");
343 
344  ASSERT(LastLoggedTime != NULL);
345  LastLoggedTime->QuadPart = 0;
346 
347  status = FxRegKey::_OpenKey(NULL,
348  DriverGlobals->Driver->GetRegistryPathUnicodeString(),
349  &hWdf.m_Key,
350  KEY_READ);
351  if (!NT_SUCCESS(status)) {
353  "Unable to open driver's service key, status %!STATUS!", status);
354  return;
355  }
356 
357  status = FxRegKey::_OpenKey(hWdf.m_Key,
358  &parametersPath,
359  &hKey.m_Key,
360  KEY_READ);
361  if (!NT_SUCCESS(status)) {
363  "Unable to open driver's service parameters key, status %!STATUS!",
364  status);
365  return;
366  }
367 
368  value.QuadPart = 0;
369  status = FxRegKey::_QueryQuadWord(
370  hKey.m_Key, &valueName, &value);
371 
372  //
373  // Set value only on success.
374  //
375  if (NT_SUCCESS(status)) {
376  LastLoggedTime->QuadPart = value.QuadPart;
377  }
378 }
Definition: pdh_main.c:93
#define KEY_READ
Definition: nt_native.h:1023
LONG NTSTATUS
Definition: precomp.h:26
#define TRACINGDRIVER
Definition: dbgtrace.h:68
DriverGlobals
#define WDF_LAST_TELEMETRY_LOG_TIME_VALUE
Definition: fxtelemetry.hpp:92
NTSTATUS status
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define DECLARE_CONST_UNICODE_STRING(_variablename, _string)
Definition: wdfcore.h:161
static const WCHAR L[]
Definition: oid.c:1250
GLsizei const GLfloat * value
Definition: glext.h:6069
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
ASSERT(Info !=NULL)
FxAutoRegKey hKey
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
#define NULL
Definition: types.h:112
Definition: ps.c:97

Referenced by IsLoggingEnabledAndNeeded().

◆ RegistryWriteCurrentTime()

VOID RegistryWriteCurrentTime ( _In_ PFX_DRIVER_GLOBALS  DriverGlobals)

Definition at line 381 of file fxtelemetrykm.cpp.

384 {
385  FxAutoRegKey hDriver, hParameters, hWdf;
386  DECLARE_CONST_UNICODE_STRING(parametersPart, L"Parameters");
387  DECLARE_CONST_UNICODE_STRING(wdfPart, L"Wdf");
388  LARGE_INTEGER currentTime;
389 
390  //
391  // Not defined with the macro because ZwSetValue doesn't use
392  // PCUNICODE_STRING
393  //
394  UNICODE_STRING wdfTimeOfLastTelemetryLog;
396 
397  RtlInitUnicodeString(&wdfTimeOfLastTelemetryLog, WDF_LAST_TELEMETRY_LOG_TIME_VALUE);
398 
399  status = FxRegKey::_OpenKey(NULL,
400  DriverGlobals->Driver->GetRegistryPathUnicodeString(),
401  &hDriver.m_Key,
403  );
404  if (!NT_SUCCESS(status)) {
406  "Unable to open driver's service key, status %!STATUS!", status);
407  return;
408  }
409  //
410  // Key creation, unlike user mode, must happen one level at a time, since
411  // create will also open take both steps instead of trying open first
412  //
413  status = FxRegKey::_Create(hDriver.m_Key,
414  &parametersPart,
415  &hParameters.m_Key,
417  );
418  if (!NT_SUCCESS(status)) {
420  "Unable to write Parameters key, status %!STATUS!", status);
421  return;
422  }
423 
424  status = FxRegKey::_Create(hParameters.m_Key,
425  &wdfPart,
426  &hWdf.m_Key,
428  );
429  if (!NT_SUCCESS(status)) {
431  "Unable to write Parameters key, status %!STATUS!", status);
432  return;
433  }
434 
435  //
436  // Using ZwSetValueKey here to avoid having to change the implementation
437  // in FxRegKey of SetValue to a static / thiscall pair
438  //
439  currentTime.QuadPart = 0;
440  Mx::MxQuerySystemTime(&currentTime);
441 
443  &wdfTimeOfLastTelemetryLog,
444  0,
445  REG_QWORD,
446  &currentTime.QuadPart,
447  sizeof(currentTime)
448  );
449 
450  if (!NT_SUCCESS(status)) {
452  "Failed to record current time for Telemetry log, status %!STATUS!",
453  status);
454  }
455 }
#define KEY_READ
Definition: nt_native.h:1023
static __inline VOID MxQuerySystemTime(_Out_ PLARGE_INTEGER CurrentTime)
Definition: mxgeneralkm.h:679
LONG NTSTATUS
Definition: precomp.h:26
_In_ LPWSTR _In_ ULONG _In_ ULONG _In_ ULONG _Out_ DEVINFO _In_ HDEV _In_ LPWSTR _In_ HANDLE hDriver
Definition: winddi.h:3553
#define TRACINGDRIVER
Definition: dbgtrace.h:68
DriverGlobals
#define WDF_LAST_TELEMETRY_LOG_TIME_VALUE
Definition: fxtelemetry.hpp:92
NTSTATUS status
static __inline NTSTATUS MxSetValueKey(_In_ HANDLE KeyHandle, _In_ PUNICODE_STRING ValueName, _In_opt_ ULONG TitleIndex, _In_ ULONG Type, _In_opt_ PVOID Data, _In_ ULONG DataSize)
Definition: mxgeneralkm.h:688
#define KEY_WRITE
Definition: nt_native.h:1031
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define DECLARE_CONST_UNICODE_STRING(_variablename, _string)
Definition: wdfcore.h:161
static const WCHAR L[]
Definition: oid.c:1250
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
#define NULL
Definition: types.h:112
#define REG_QWORD
Definition: sdbapi.c:597
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
LONGLONG QuadPart
Definition: typedefs.h:114
Definition: ps.c:97

Referenced by LogDriverInfoStream().

Variable Documentation

◆ Globals

Definition at line 187 of file fxtelemetrykm.hpp.

◆ Info

◆ ValueName