Leaked source code of windows server 2003
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.

269 lines
6.8 KiB

  1. /*++ BUILD Version: 0014 // 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 = (USHORT) (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. ULONG Wow; // TRUE if the logger started under WOW64
  64. union {
  65. HANDLE LogFileHandle; // handle to logfile
  66. ULONG64 LogFileHandle64;
  67. };
  68. // data returned to caller
  69. ULONG NumberOfBuffers; // no of buffers in use
  70. ULONG FreeBuffers; // no of buffers free
  71. ULONG EventsLost; // event records lost
  72. ULONG BuffersWritten; // no of buffers written to file
  73. ULONG LogBuffersLost; // no of logfile write failures
  74. ULONG RealTimeBuffersLost; // no of rt delivery failures
  75. union {
  76. HANDLE LoggerThreadId; // thread id of Logger
  77. ULONG64 LoggerThreadId64; // thread is of Logger
  78. };
  79. union {
  80. UNICODE_STRING LogFileName; // used only in WIN64
  81. UNICODE_STRING64 LogFileName64; // Logfile name: only in WIN32
  82. };
  83. // mandatory data provided by caller
  84. union {
  85. UNICODE_STRING LoggerName; // Logger instance name in WIN64
  86. UNICODE_STRING64 LoggerName64; // Logger Instance name in WIN32
  87. };
  88. // private
  89. union {
  90. PVOID Checksum;
  91. ULONG64 Checksum64;
  92. };
  93. union {
  94. PVOID LoggerExtension;
  95. ULONG64 LoggerExtension64;
  96. };
  97. } WMI_LOGGER_INFORMATION, *PWMI_LOGGER_INFORMATION;
  98. //
  99. // structure for NTDLL tracing
  100. //
  101. typedef struct
  102. {
  103. BOOLEAN IsGet;
  104. PWMI_LOGGER_INFORMATION LoggerInfo;
  105. } WMINTDLLLOGGERINFO, *PWMINTDLLLOGGERINFO;
  106. typedef struct _TIMED_TRACE_HEADER {
  107. USHORT Size;
  108. USHORT Marker;
  109. ULONG32 EventId;
  110. union {
  111. LARGE_INTEGER TimeStamp;
  112. ULONG64 LoggerId;
  113. };
  114. } TIMED_TRACE_HEADER, *PTIMED_TRACE_HEADER;
  115. typedef enum tagWMI_CLOCK_TYPE {
  116. WMICT_DEFAULT,
  117. WMICT_SYSTEMTIME,
  118. WMICT_PERFCOUNTER,
  119. WMICT_PROCESS,
  120. WMICT_THREAD,
  121. WMICT_CPUCYCLE
  122. } WMI_CLOCK_TYPE;
  123. //
  124. // Trace Control APIs
  125. //
  126. NTKERNELAPI
  127. NTSTATUS
  128. WmiStartTrace(
  129. IN OUT PWMI_LOGGER_INFORMATION LoggerInfo
  130. );
  131. NTKERNELAPI
  132. NTSTATUS
  133. WmiQueryTrace(
  134. IN OUT PWMI_LOGGER_INFORMATION LoggerInfo
  135. );
  136. NTKERNELAPI
  137. NTSTATUS
  138. WmiStopTrace(
  139. IN PWMI_LOGGER_INFORMATION LoggerInfo
  140. );
  141. NTKERNELAPI
  142. NTSTATUS
  143. WmiUpdateTrace(
  144. IN OUT PWMI_LOGGER_INFORMATION LoggerInfo
  145. );
  146. NTKERNELAPI
  147. NTSTATUS
  148. WmiFlushTrace(
  149. IN OUT PWMI_LOGGER_INFORMATION LoggerInfo
  150. );
  151. //
  152. // Trace Provider APIs
  153. //
  154. NTKERNELAPI
  155. NTSTATUS
  156. FASTCALL
  157. WmiTraceEvent(
  158. IN PWNODE_HEADER Wnode,
  159. IN KPROCESSOR_MODE RequestorMode
  160. );
  161. NTKERNELAPI
  162. NTSTATUS
  163. FASTCALL
  164. WmiTraceFastEvent(
  165. IN PWNODE_HEADER Wnode
  166. );
  167. NTKERNELAPI
  168. LONG64
  169. FASTCALL
  170. WmiGetClock(
  171. IN WMI_CLOCK_TYPE ClockType,
  172. IN PVOID Context
  173. );
  174. NTKERNELAPI
  175. NTSTATUS
  176. FASTCALL
  177. WmiGetClockType(
  178. IN TRACEHANDLE LoggerHandle,
  179. OUT WMI_CLOCK_TYPE *ClockType
  180. );
  181. // begin_ntddk begin_wdm begin_ntifs
  182. #ifdef RUN_WPP
  183. NTKERNELAPI
  184. NTSTATUS
  185. WmiTraceMessage(
  186. IN TRACEHANDLE LoggerHandle,
  187. IN ULONG MessageFlags,
  188. IN LPGUID MessageGuid,
  189. IN USHORT MessageNumber,
  190. IN ...
  191. );
  192. NTKERNELAPI
  193. NTSTATUS
  194. WmiTraceMessageVa(
  195. IN TRACEHANDLE LoggerHandle,
  196. IN ULONG MessageFlags,
  197. IN LPGUID MessageGuid,
  198. IN USHORT MessageNumber,
  199. IN va_list MessageArgList
  200. );
  201. #endif // #ifdef RUN_WPP
  202. #ifndef TRACE_INFORMATION_CLASS_DEFINE
  203. typedef enum _TRACE_INFORMATION_CLASS {
  204. TraceIdClass,
  205. TraceHandleClass,
  206. TraceEnableFlagsClass,
  207. TraceEnableLevelClass,
  208. GlobalLoggerHandleClass,
  209. EventLoggerHandleClass,
  210. AllLoggerHandlesClass,
  211. TraceHandleByNameClass
  212. } TRACE_INFORMATION_CLASS;
  213. NTKERNELAPI
  214. NTSTATUS
  215. WmiQueryTraceInformation(
  216. IN TRACE_INFORMATION_CLASS TraceInformationClass,
  217. OUT PVOID TraceInformation,
  218. IN ULONG TraceInformationLength,
  219. OUT PULONG RequiredLength OPTIONAL,
  220. IN PVOID Buffer OPTIONAL
  221. );
  222. #define TRACE_INFORMATION_CLASS_DEFINE
  223. #endif // TRACE_INFOPRMATION_CLASS_DEFINE
  224. #endif // _WMIKM_H_