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.

268 lines
6.4 KiB

  1. /*++ BUILD Version: 0013 // Increment this if a change has global effects
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. wmikm.h
  5. Abstract:
  6. This module defines the WMI types, constants, and functions that are
  7. exposed to internal device drivers.
  8. Revision History:
  9. --*/
  10. #ifndef _WMIKM_H_
  11. #define _WMIKM_H_
  12. #include <evntrace.h>
  13. #include <wmistr.h>
  14. #define IRP_MN_SET_TRACE_NOTIFY 0x0A
  15. //
  16. // The following is set for a KM provider who is considered private to
  17. // kernel tracing
  18. //
  19. #define WMIREG_FLAG_TRACE_PROVIDER 0x00010000
  20. //
  21. // The following mask is to extract the trace callout class
  22. //
  23. #define WMIREG_FLAG_TRACE_NOTIFY_MASK 0x00F00000
  24. //
  25. // We use 4 bits for the trace callout classes.
  26. //
  27. #define WMIREG_NOTIFY_DISK_IO 1 << 20
  28. #define WMIREG_NOTIFY_TDI_IO 2 << 20
  29. //
  30. // Public routines to break down the Loggerhandle
  31. //
  32. #define KERNEL_LOGGER_ID 0xFFFF // USHORT only
  33. typedef struct _TRACE_ENABLE_CONTEXT {
  34. USHORT LoggerId; // Actual Id of the logger
  35. UCHAR Level; // Enable level passed by control caller
  36. UCHAR InternalFlag; // Reserved
  37. ULONG EnableFlags; // Enable flags passed by control caller
  38. } TRACE_ENABLE_CONTEXT, *PTRACE_ENABLE_CONTEXT;
  39. #define WmiGetLoggerId(LoggerContext) \
  40. (((PTRACE_ENABLE_CONTEXT) (&LoggerContext))->LoggerId == \
  41. (USHORT)KERNEL_LOGGER_ID) ? \
  42. KERNEL_LOGGER_ID : \
  43. ((PTRACE_ENABLE_CONTEXT) (&LoggerContext))->LoggerId
  44. #define WmiGetLoggerEnableFlags(LoggerContext) \
  45. ((PTRACE_ENABLE_CONTEXT) (&LoggerContext))->EnableFlags
  46. #define WmiGetLoggerEnableLevel(LoggerContext) \
  47. ((PTRACE_ENABLE_CONTEXT) (&LoggerContext))->Level
  48. #define WmiSetLoggerId(Id, Context) \
  49. (((PTRACE_ENABLE_CONTEXT)Context)->LoggerId = (Id ? \
  50. (USHORT)Id: (USHORT)KERNEL_LOGGER_ID));
  51. typedef struct _WMI_LOGGER_INFORMATION {
  52. WNODE_HEADER Wnode; // Had to do this since wmium.h comes later
  53. //
  54. // data provider by caller
  55. ULONG BufferSize; // buffer size for logging (in kbytes)
  56. ULONG MinimumBuffers; // minimum to preallocate
  57. ULONG MaximumBuffers; // maximum buffers allowed
  58. ULONG MaximumFileSize; // maximum logfile size (in MBytes)
  59. ULONG LogFileMode; // sequential, circular
  60. ULONG FlushTimer; // buffer flush timer, in seconds
  61. ULONG EnableFlags; // trace enable flags
  62. LONG AgeLimit; // aging decay time, in minutes
  63. union {
  64. HANDLE LogFileHandle; // handle to logfile
  65. ULONG64 LogFileHandle64;
  66. };
  67. // data returned to caller
  68. ULONG NumberOfBuffers; // no of buffers in use
  69. ULONG FreeBuffers; // no of buffers free
  70. ULONG EventsLost; // event records lost
  71. ULONG BuffersWritten; // no of buffers written to file
  72. ULONG LogBuffersLost; // no of logfile write failures
  73. ULONG RealTimeBuffersLost; // no of rt delivery failures
  74. union {
  75. HANDLE LoggerThreadId; // thread id of Logger
  76. ULONG64 LoggerThreadId64; // thread is of Logger
  77. };
  78. union {
  79. UNICODE_STRING LogFileName; // used only in WIN64
  80. UNICODE_STRING64 LogFileName64; // Logfile name: only in WIN32
  81. };
  82. // mandatory data provided by caller
  83. union {
  84. UNICODE_STRING LoggerName; // Logger instance name in WIN64
  85. UNICODE_STRING64 LoggerName64; // Logger Instance name in WIN32
  86. };
  87. // private
  88. union {
  89. PVOID Checksum;
  90. ULONG64 Checksum64;
  91. };
  92. union {
  93. PVOID LoggerExtension;
  94. ULONG64 LoggerExtension64;
  95. };
  96. } WMI_LOGGER_INFORMATION, *PWMI_LOGGER_INFORMATION;
  97. //
  98. // structure for NTDLL tracing
  99. //
  100. typedef struct
  101. {
  102. BOOLEAN IsGet;
  103. PWMI_LOGGER_INFORMATION LoggerInfo;
  104. } WMINTDLLLOGGERINFO, *PWMINTDLLLOGGERINFO;
  105. typedef struct _TIMED_TRACE_HEADER {
  106. USHORT Size;
  107. USHORT Marker;
  108. ULONG32 EventId;
  109. union {
  110. LARGE_INTEGER TimeStamp;
  111. ULONG64 LoggerId;
  112. };
  113. } TIMED_TRACE_HEADER, *PTIMED_TRACE_HEADER;
  114. typedef enum tagWMI_CLOCK_TYPE {
  115. WMICT_DEFAULT,
  116. WMICT_SYSTEMTIME,
  117. WMICT_PERFCOUNTER,
  118. WMICT_PROCESS,
  119. WMICT_THREAD,
  120. WMICT_CPUCYCLE
  121. } WMI_CLOCK_TYPE;
  122. //
  123. // Trace Control APIs
  124. //
  125. NTKERNELAPI
  126. NTSTATUS
  127. WmiStartTrace(
  128. IN OUT PWMI_LOGGER_INFORMATION LoggerInfo
  129. );
  130. NTKERNELAPI
  131. NTSTATUS
  132. WmiQueryTrace(
  133. IN OUT PWMI_LOGGER_INFORMATION LoggerInfo
  134. );
  135. NTKERNELAPI
  136. NTSTATUS
  137. WmiStopTrace(
  138. IN PWMI_LOGGER_INFORMATION LoggerInfo
  139. );
  140. NTKERNELAPI
  141. NTSTATUS
  142. WmiUpdateTrace(
  143. IN OUT PWMI_LOGGER_INFORMATION LoggerInfo
  144. );
  145. NTKERNELAPI
  146. NTSTATUS
  147. WmiFlushTrace(
  148. IN OUT PWMI_LOGGER_INFORMATION LoggerInfo
  149. );
  150. //
  151. // Trace Provider APIs
  152. //
  153. NTKERNELAPI
  154. NTSTATUS
  155. FASTCALL
  156. WmiTraceEvent(
  157. IN PWNODE_HEADER Wnode,
  158. IN KPROCESSOR_MODE RequestorMode
  159. );
  160. NTKERNELAPI
  161. NTSTATUS
  162. FASTCALL
  163. WmiTraceFastEvent(
  164. IN PWNODE_HEADER Wnode
  165. );
  166. NTKERNELAPI
  167. LONG64
  168. FASTCALL
  169. WmiGetClock(
  170. IN WMI_CLOCK_TYPE ClockType,
  171. IN PVOID Context
  172. );
  173. NTKERNELAPI
  174. NTSTATUS
  175. FASTCALL
  176. WmiGetClockType(
  177. IN TRACEHANDLE LoggerHandle,
  178. OUT WMI_CLOCK_TYPE *ClockType
  179. );
  180. // begin_ntddk begin_wdm
  181. #ifdef RUN_WPP
  182. NTKERNELAPI
  183. NTSTATUS
  184. WmiTraceMessage(
  185. IN TRACEHANDLE LoggerHandle,
  186. IN ULONG MessageFlags,
  187. IN LPGUID MessageGuid,
  188. IN USHORT MessageNumber,
  189. IN ...
  190. );
  191. NTKERNELAPI
  192. NTSTATUS
  193. WmiTraceMessageVa(
  194. IN TRACEHANDLE LoggerHandle,
  195. IN ULONG MessageFlags,
  196. IN LPGUID MessageGuid,
  197. IN USHORT MessageNumber,
  198. IN va_list MessageArgList
  199. );
  200. #endif // #ifdef RUN_WPP
  201. #ifndef TRACE_INFORMATION_CLASS_DEFINE
  202. typedef enum _TRACE_INFORMATION_CLASS {
  203. TraceIdClass,
  204. TraceHandleClass,
  205. TraceEnableFlagsClass,
  206. TraceEnableLevelClass,
  207. GlobalLoggerHandleClass,
  208. EventLoggerHandleClass,
  209. AllLoggerHandlesClass,
  210. TraceHandleByNameClass
  211. } TRACE_INFORMATION_CLASS;
  212. NTKERNELAPI
  213. NTSTATUS
  214. WmiQueryTraceInformation(
  215. IN TRACE_INFORMATION_CLASS TraceInformationClass,
  216. OUT PVOID TraceInformation,
  217. IN ULONG TraceInformationLength,
  218. OUT PULONG RequiredLength OPTIONAL,
  219. IN PVOID Buffer OPTIONAL
  220. );
  221. #define TRACE_INFORMATION_CLASS_DEFINE
  222. #endif // TRACE_INFOPRMATION_CLASS_DEFINE
  223. #endif // _WMIKM_H_