Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

168 lines
5.2 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 2000-2001 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // SWTracing.h
  7. //
  8. // Description:
  9. // Software tracing header.
  10. //
  11. // Maintained By:
  12. // Galen Barbee (GalenB) 05-DEC-2000
  13. //
  14. //////////////////////////////////////////////////////////////////////////////
  15. #pragma once
  16. //
  17. // KB: DEBUG_SUPPORT_NT4 DavidP 05-OCT-2000
  18. // Turn this on to support only functionality available in NT4.
  19. // This will turn off WMI support.
  20. //
  21. // #define DEBUG_SUPPORT_NT4
  22. #if defined( DEBUG_SUPPORT_NT4 )
  23. #if defined( DEBUG_SW_TRACING_ENABLED )
  24. #undef DEBUG_SW_TRACING_ENABLED
  25. #endif
  26. #else
  27. #define DEBUG_SW_TRACING_ENABLED
  28. #endif
  29. #if defined( DEBUG_SW_TRACING_ENABLED )
  30. //
  31. // WMI tracing needs these defined
  32. //
  33. #pragma warning( push )
  34. #pragma warning( disable : 4201 )
  35. #include <wmistr.h>
  36. #pragma warning( pop )
  37. #pragma warning( push )
  38. #pragma warning( disable : 4201 )
  39. #pragma warning( disable : 4096 )
  40. #include <evntrace.h>
  41. #pragma warning( pop )
  42. #endif // DEBUG_SW_TRACING_ENABLED
  43. #if defined( DEBUG_SW_TRACING_ENABLED )
  44. //
  45. // Enable WMI
  46. //
  47. #define TraceInitializeProcess( _rg, _sizeof ) \
  48. WMIInitializeTracing( _rg, _sizeof );
  49. #define TraceTerminateProcess( _rg, _sizeof ) \
  50. WMITerminateTracing( _rg, _sizeof );
  51. #else // DEBUG_SW_TRACING_ENABLED
  52. #define TraceInitializeProcess( ) 1 ? (void)0 : (void)__noop
  53. #define TraceTerminateProcess( ) 1 ? (void)0 : (void)__noop
  54. #endif // DEBUG_SW_TRACING_ENABLED
  55. #if defined( DEBUG_SW_TRACING_ENABLED )
  56. //****************************************************************************
  57. //
  58. // WMI Tracing stuctures and prototypes
  59. //
  60. //****************************************************************************
  61. typedef struct
  62. {
  63. DWORD dwFlags; // Flags to be set
  64. LPCTSTR pszName; // Usefull description of the level
  65. } DEBUG_MAP_LEVEL_TO_FLAGS;
  66. typedef struct
  67. {
  68. LPCTSTR pszName; // Usefull description of the flag
  69. } DEBUG_MAP_FLAGS_TO_COMMENTS;
  70. typedef struct
  71. {
  72. LPCGUID guidControl; // Control guid to register
  73. LPCTSTR pszName; // Internal associative name
  74. DWORD dwSizeOfTraceList; // Count of the guids in pTraceList
  75. const TRACE_GUID_REGISTRATION * pTraceList; // List of the of Tracing guids to register
  76. BYTE bSizeOfLevelList; // Count of the level<->flags
  77. const DEBUG_MAP_LEVEL_TO_FLAGS * pMapLevelToFlags; // List of level->flags mapping. NULL if no mapping.
  78. const DEBUG_MAP_FLAGS_TO_COMMENTS * pMapFlagsToComments; // List of descriptions describing the flag bits. NULL if no mapping.
  79. // Controlled by WMI tracing - these should be NULL/ZERO to start.
  80. DWORD dwFlags; // Log flags
  81. BYTE bLevel; // Log level
  82. TRACEHANDLE hTrace; // Active logger handle
  83. // From here down is initialized by InitializeWMITracing
  84. TRACEHANDLE hRegistration; // Return control handle
  85. } DEBUG_WMI_CONTROL_GUIDS;
  86. void
  87. WMIInitializeTracing(
  88. DEBUG_WMI_CONTROL_GUIDS dwcgControlListIn[],
  89. int nCountOfControlGuidsIn
  90. );
  91. void
  92. WMITerminateTracing(
  93. DEBUG_WMI_CONTROL_GUIDS dwcgControlListIn[],
  94. int nCountOfControlGuidsIn
  95. );
  96. void
  97. __cdecl
  98. WMIMessageByFlags(
  99. DEBUG_WMI_CONTROL_GUIDS * pEntryIn,
  100. const DWORD dwFlagsIn,
  101. LPCWSTR pszFormatIn,
  102. ...
  103. );
  104. void
  105. __cdecl
  106. WMIMessageByLevel(
  107. DEBUG_WMI_CONTROL_GUIDS * pEntryIn,
  108. const BYTE bLogLevelIn,
  109. LPCWSTR pszFormatIn,
  110. ...
  111. );
  112. void
  113. __cdecl
  114. WMIMessageByFlagsAndLevel(
  115. DEBUG_WMI_CONTROL_GUIDS * pEntryIn,
  116. const DWORD dwFlagsIn,
  117. const BYTE bLogLevelIn,
  118. LPCWSTR pszFormatIn,
  119. ...
  120. );
  121. //
  122. // Sample WMI message macros
  123. //
  124. // Typically you will want a particular level to map to a set of flags. This
  125. // way as you increase the level, you activate more and more messages.
  126. //
  127. // To be versatile, there there types of filtering. Choose the one that suits
  128. // the situation that you supports your logging needs. Remember that depending
  129. // on the use, you might need to specify additional parameters.
  130. //
  131. // These macros on x86 turn into 2 ops ( cmp and jnz ) in the regular code path
  132. // thereby lessening the impact of keeping the macros enabled in RETAIL. Since
  133. // other platforms were not available while developing these macros, you should
  134. // wrap the definitions in protecting against other architectures.
  135. //
  136. // #if defined( _X86_ )
  137. // #define WMIMsg ( g_pTraceGuidControl[0].dwFlags == 0 ) ? (void)0 : WMIMessageByFlags
  138. // #define WMIMsg ( g_pTraceGuidControl[0].dwFlags == 0 ) ? (void)0 : WMIMessageByLevel
  139. // #define WMIMsg ( g_pTraceGuidControl[0].dwFlags == 0 ) ? (void)0 : WMIMessageByFlagsAndLevel
  140. // #else // not X86
  141. // #define WMIMsg 1 ? (void)0 : (void)
  142. // #endif // defined( _X86_ )
  143. //
  144. //
  145. #endif // DEBUG_SW_TRACING_ENABLED