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.

1014 lines
28 KiB

  1. /*++
  2. Copyright (c) 1997-2000 Microsoft Corporation
  3. Module Name:
  4. EvnTrace.h
  5. Abstract:
  6. Public headers for event tracing control applications,
  7. consumers and providers
  8. --*/
  9. #ifndef _EVNTRACE_
  10. #define _EVNTRACE_
  11. #if defined(_WINNT_) || defined(WINNT)
  12. #ifndef WMIAPI
  13. #ifndef MIDL_PASS
  14. #ifdef _WMI_SOURCE_
  15. #define WMIAPI __stdcall
  16. #else
  17. #define WMIAPI DECLSPEC_IMPORT __stdcall
  18. #endif // _WMI_SOURCE
  19. #endif // MIDL_PASS
  20. #endif // WMIAPI
  21. #include <guiddef.h>
  22. //
  23. // EventTraceGuid is used to identify a event tracing session
  24. //
  25. DEFINE_GUID ( /* 68fdd900-4a3e-11d1-84f4-0000f80464e3 */
  26. EventTraceGuid,
  27. 0x68fdd900,
  28. 0x4a3e,
  29. 0x11d1,
  30. 0x84, 0xf4, 0x00, 0x00, 0xf8, 0x04, 0x64, 0xe3
  31. );
  32. //
  33. // SystemTraceControlGuid. Used to specify event tracing for kernel
  34. //
  35. DEFINE_GUID ( /* 9e814aad-3204-11d2-9a82-006008a86939 */
  36. SystemTraceControlGuid,
  37. 0x9e814aad,
  38. 0x3204,
  39. 0x11d2,
  40. 0x9a, 0x82, 0x00, 0x60, 0x08, 0xa8, 0x69, 0x39
  41. );
  42. //
  43. //EventTraceConfigGuid. Used to report hardware configuration records
  44. //
  45. DEFINE_GUID ( /* 01853a65-418f-4f36-aefc-dc0f1d2fd235 */
  46. EventTraceConfigGuid,
  47. 0x01853a65,
  48. 0x418f,
  49. 0x4f36,
  50. 0xae, 0xfc, 0xdc, 0x0f, 0x1d, 0x2f, 0xd2, 0x35
  51. );
  52. #define MAX_MOF_FIELDS 16 // Limit of USE_MOF_PTR fields
  53. typedef ULONG64 TRACEHANDLE, *PTRACEHANDLE;
  54. typedef struct _TRACE_ENABLE_CONTEXT {
  55. USHORT LoggerId; // Actual Id of the logger
  56. UCHAR Level; // Enable level passed by control caller
  57. UCHAR InternalFlag; // Reserved
  58. ULONG EnableFlags; // Enable flags passed by control caller
  59. } TRACE_ENABLE_CONTEXT, *PTRACE_ENABLE_CONTEXT;
  60. //
  61. // predefined generic event types (0x00 to 0x09 reserved).
  62. //
  63. #define EVENT_TRACE_TYPE_INFO 0x00 // Info or point event
  64. #define EVENT_TRACE_TYPE_START 0x01 // Start event
  65. #define EVENT_TRACE_TYPE_END 0x02 // End event
  66. #define EVENT_TRACE_TYPE_DC_START 0x03 // Collection start marker
  67. #define EVENT_TRACE_TYPE_DC_END 0x04 // Collection end marker
  68. #define EVENT_TRACE_TYPE_EXTENSION 0x05 // Extension/continuation
  69. #define EVENT_TRACE_TYPE_REPLY 0x06 // Reply event
  70. #define EVENT_TRACE_TYPE_DEQUEUE 0x07 // De-queue event
  71. #define EVENT_TRACE_TYPE_CHECKPOINT 0x08 // Generic checkpoint event
  72. #define EVENT_TRACE_TYPE_RESERVED9 0x09
  73. //
  74. // Event types for Process & Threads
  75. //
  76. #define EVENT_TRACE_TYPE_LOAD 0x0A // Load image
  77. //
  78. // Event types for IO subsystem
  79. //
  80. #define EVENT_TRACE_TYPE_IO_READ 0x0A
  81. #define EVENT_TRACE_TYPE_IO_WRITE 0x0B
  82. //
  83. // Event types for Memory subsystem
  84. //
  85. #define EVENT_TRACE_TYPE_MM_TF 0x0A // Transition fault
  86. #define EVENT_TRACE_TYPE_MM_DZF 0x0B // Demand Zero fault
  87. #define EVENT_TRACE_TYPE_MM_COW 0x0C // Copy on Write
  88. #define EVENT_TRACE_TYPE_MM_GPF 0x0D // Guard Page fault
  89. #define EVENT_TRACE_TYPE_MM_HPF 0x0E // Hard page fault
  90. //
  91. // Event types for Network subsystem, all protocols
  92. //
  93. #define EVENT_TRACE_TYPE_SEND 0x0A // Send
  94. #define EVENT_TRACE_TYPE_RECEIVE 0x0B // Receive
  95. #define EVENT_TRACE_TYPE_CONNECT 0x0C // Connect
  96. #define EVENT_TRACE_TYPE_DISCONNECT 0x0D // Disconnect
  97. #define EVENT_TRACE_TYPE_RETRANSMIT 0x0E // ReTransmit
  98. #define EVENT_TRACE_TYPE_ACCEPT 0x0F // Accept
  99. //
  100. // Event Types for the Header (to handle internal event headers)
  101. //
  102. #define EVENT_TRACE_TYPE_GUIDMAP 0x0A
  103. #define EVENT_TRACE_TYPE_CONFIG 0x0B
  104. #define EVENT_TRACE_TYPE_SIDINFO 0x0C
  105. #define EVENT_TRACE_TYPE_SECURITY 0x0D
  106. //
  107. // Event types for Registry subsystem
  108. //
  109. #define EVENT_TRACE_TYPE_REGCREATE 0x0A // NtCreateKey
  110. #define EVENT_TRACE_TYPE_REGOPEN 0x0B // NtOpenKey
  111. #define EVENT_TRACE_TYPE_REGDELETE 0x0C // NtDeleteKey
  112. #define EVENT_TRACE_TYPE_REGQUERY 0x0D // NtQueryKey
  113. #define EVENT_TRACE_TYPE_REGSETVALUE 0x0E // NtSetValueKey
  114. #define EVENT_TRACE_TYPE_REGDELETEVALUE 0x0F // NtDeleteValueKey
  115. #define EVENT_TRACE_TYPE_REGQUERYVALUE 0x10 // NtQueryValueKey
  116. #define EVENT_TRACE_TYPE_REGENUMERATEKEY 0x11 // NtEnumerateKey
  117. #define EVENT_TRACE_TYPE_REGENUMERATEVALUEKEY 0x12 // NtEnumerateValueKey
  118. #define EVENT_TRACE_TYPE_REGQUERYMULTIPLEVALUE 0x13 // NtQueryMultipleValueKey
  119. #define EVENT_TRACE_TYPE_REGSETINFORMATION 0x14 // NtSetInformationKey
  120. #define EVENT_TRACE_TYPE_REGFLUSH 0x15 // NtFlushKey
  121. #define EVENT_TRACE_TYPE_REGKCBDMP 0x16 // KcbDump/create
  122. //
  123. // Event types for hardware configuration records
  124. //
  125. #define EVENT_TRACE_TYPE_CONFIG_CPU 0x0A // CPU Configuration
  126. #define EVENT_TRACE_TYPE_CONFIG_PHYSICALDISK 0x0B // Physical Disk Configuration
  127. #define EVENT_TRACE_TYPE_CONFIG_LOGICALDISK 0x0C // Logical Disk Configuration
  128. #define EVENT_TRACE_TYPE_CONFIG_NIC 0x0D // NIC Configuration
  129. #define EVENT_TRACE_TYPE_CONFIG_VIDEO 0x0E // Video Adapter Configuration
  130. //
  131. // Enable flags for SystemControlGuid only
  132. //
  133. #define EVENT_TRACE_FLAG_PROCESS 0x00000001 // process start & end
  134. #define EVENT_TRACE_FLAG_THREAD 0x00000002 // thread start & end
  135. #define EVENT_TRACE_FLAG_IMAGE_LOAD 0x00000004 // image load
  136. #define EVENT_TRACE_FLAG_DISK_IO 0x00000100 // physical disk IO
  137. #define EVENT_TRACE_FLAG_DISK_FILE_IO 0x00000200 // requires disk IO
  138. #define EVENT_TRACE_FLAG_MEMORY_PAGE_FAULTS 0x00001000 // all page faults
  139. #define EVENT_TRACE_FLAG_MEMORY_HARD_FAULTS 0x00002000 // hard faults only
  140. #define EVENT_TRACE_FLAG_NETWORK_TCPIP 0x00010000 // tcpip send & receive
  141. #define EVENT_TRACE_FLAG_REGISTRY 0x00020000 // registry calls
  142. #define EVENT_TRACE_FLAG_DBGPRINT 0x00040000 // DbgPrint(ex) Calls
  143. //
  144. // Pre-defined Enable flags for everybody else
  145. //
  146. #define EVENT_TRACE_FLAG_EXTENSION 0x80000000 // indicates more flags
  147. #define EVENT_TRACE_FLAG_FORWARD_WMI 0x40000000 // Can forward to WMI
  148. #define EVENT_TRACE_FLAG_ENABLE_RESERVE 0x20000000 // Reserved
  149. //
  150. // Logger Mode flags
  151. //
  152. #define EVENT_TRACE_FILE_MODE_NONE 0x00000000 // logfile is off
  153. #define EVENT_TRACE_FILE_MODE_SEQUENTIAL 0x00000001 // log sequentially
  154. #define EVENT_TRACE_FILE_MODE_CIRCULAR 0x00000002 // log in circular manner
  155. #define EVENT_TRACE_FILE_MODE_APPEND 0x00000004 // append sequential log
  156. #define EVENT_TRACE_FILE_MODE_NEWFILE 0x00000008 // auto-switch log file
  157. #define EVENT_TRACE_REAL_TIME_MODE 0x00000100 // real time mode on
  158. #define EVENT_TRACE_DELAY_OPEN_FILE_MODE 0x00000200 // delay opening file
  159. #define EVENT_TRACE_BUFFERING_MODE 0x00000400 // buffering mode only
  160. #define EVENT_TRACE_PRIVATE_LOGGER_MODE 0x00000800 // Process Private Logger
  161. #define EVENT_TRACE_ADD_HEADER_MODE 0x00001000 // Add a logfile header
  162. #define EVENT_TRACE_USE_GLOBAL_SEQUENCE 0x00004000 // Use global sequence no.
  163. #define EVENT_TRACE_USE_LOCAL_SEQUENCE 0x00008000 // Use local sequence no.
  164. //
  165. // internal control codes used.
  166. //
  167. #define EVENT_TRACE_CONTROL_QUERY 0
  168. #define EVENT_TRACE_CONTROL_STOP 1
  169. #define EVENT_TRACE_CONTROL_UPDATE 2
  170. #define EVENT_TRACE_CONTROL_FLUSH 3 // Flushes all the buffers
  171. //
  172. // Flags used by WMI Trace Message
  173. // Note that the order or value of these flags should NOT be changed as they are processed
  174. // in this order.
  175. //
  176. #define TRACE_MESSAGE_SEQUENCE 1 // Message should include a sequence number
  177. #define TRACE_MESSAGE_GUID 2 // Message includes a GUID
  178. #define TRACE_MESSAGE_COMPONENTID 4 // Message has no GUID, Component ID instead
  179. #define TRACE_MESSAGE_TIMESTAMP 8 // Message includes a timestamp
  180. #define TRACE_MESSAGE_PERFORMANCE_TIMESTAMP 16 // Timestamp is the Performance Counter not the system clock
  181. #define TRACE_MESSAGE_SYSTEMINFO 32 // Message includes system information TID,PID
  182. #define TRACE_MESSAGE_FLAG_MASK 0xFFFF // Only the lower 16 bits of flags are placed in the message
  183. // those above 16 bits are reserved for local processing
  184. #pragma warning (disable:4201)
  185. //
  186. // Trace header for all (except kernel) events. This is used to overlay
  187. // to bottom part of WNODE_HEADER to conserve space.
  188. //
  189. typedef struct _EVENT_TRACE_HEADER { // overlays WNODE_HEADER
  190. USHORT Size; // Size of entire record
  191. UCHAR HeaderType; // Header type - internal use only
  192. UCHAR MarkerFlags; // Marker - internal use only
  193. union {
  194. ULONG Version;
  195. struct {
  196. UCHAR Type; // event type
  197. UCHAR Level; // trace instrumentation level
  198. USHORT Version; // version of trace record
  199. } Class;
  200. };
  201. ULONG ThreadId; // Thread Id
  202. ULONG ProcessId; // Process Id
  203. LARGE_INTEGER TimeStamp; // time when event happens
  204. union {
  205. GUID Guid; // Guid that identifies event
  206. ULONGLONG GuidPtr; // use with WNODE_FLAG_USE_GUID_PTR
  207. };
  208. union {
  209. struct {
  210. ULONG ClientContext; // Reserved
  211. ULONG Flags; // Flags for header
  212. };
  213. struct {
  214. ULONG KernelTime; // Kernel Mode CPU ticks
  215. ULONG UserTime; // User mode CPU ticks
  216. };
  217. ULONG64 ProcessorTime; // Processor Clock
  218. };
  219. } EVENT_TRACE_HEADER, *PEVENT_TRACE_HEADER;
  220. //
  221. // This header is used to trace and track transaction co-relations
  222. //
  223. typedef struct _EVENT_INSTANCE_HEADER {
  224. USHORT Size;
  225. UCHAR HeaderType;
  226. UCHAR MarkerFlags;
  227. union {
  228. ULONG Version;
  229. struct {
  230. UCHAR Type;
  231. UCHAR Level;
  232. USHORT Version;
  233. } Class;
  234. };
  235. ULONG ThreadId;
  236. ULONG ProcessId;
  237. LARGE_INTEGER TimeStamp;
  238. ULONGLONG RegHandle;
  239. ULONG InstanceId;
  240. ULONG ParentInstanceId;
  241. union {
  242. struct {
  243. ULONG ClientContext; // Reserved
  244. ULONG Flags; // Flags for header
  245. };
  246. struct {
  247. ULONG KernelTime; // Kernel Mode CPU ticks
  248. ULONG UserTime; // User mode CPU ticks
  249. };
  250. ULONG64 ProcessorTime; // Processor Clock
  251. };
  252. ULONGLONG ParentRegHandle;
  253. } EVENT_INSTANCE_HEADER, *PEVENT_INSTANCE_HEADER;
  254. //
  255. // Following are structures and macros for use with USE_MOF_PTR
  256. //
  257. #define DEFINE_TRACE_MOF_FIELD(MOF, ptr, length, type) \
  258. (MOF)->DataPtr = (ULONG64) ptr; \
  259. (MOF)->Length = (ULONG) length; \
  260. (MOF)->DataType = (ULONG) type;
  261. typedef struct _MOF_FIELD {
  262. ULONG64 DataPtr; // Pointer to the field. Up to 64-bits only
  263. ULONG Length; // Length of the MOF field
  264. ULONG DataType; // Type of data
  265. } MOF_FIELD, *PMOF_FIELD;
  266. #if !defined(_NTDDK_) || defined(_WMIKM_)
  267. //
  268. // This is the header for every logfile. The memory for LoggerName
  269. // and LogFileName must be contiguous adjacent to this structure
  270. // Allows both user-mode and kernel-mode to understand the header
  271. //
  272. typedef struct _TRACE_LOGFILE_HEADER {
  273. ULONG BufferSize; // Logger buffer size in Kbytes
  274. union {
  275. ULONG Version; // Logger version
  276. struct {
  277. UCHAR MajorVersion;
  278. UCHAR MinorVersion;
  279. UCHAR SubVersion;
  280. UCHAR SubMinorVersion;
  281. } VersionDetail;
  282. };
  283. ULONG ProviderVersion; // defaults to NT version
  284. ULONG NumberOfProcessors; // Number of Processors
  285. LARGE_INTEGER EndTime; // Time when logger stops
  286. ULONG TimerResolution; // assumes timer is constant!!!
  287. ULONG MaximumFileSize; // Maximum in Mbytes
  288. ULONG LogFileMode; // specify logfile mode
  289. ULONG BuffersWritten; // used to file start of Circular File
  290. union {
  291. GUID LogInstanceGuid; // For RealTime Buffer Delivery
  292. struct {
  293. ULONG StartBuffers; // Count of buffers written at start.
  294. ULONG PointerSize; // Size of pointer type in bits
  295. ULONG EventsLost; // Events losts during log session
  296. ULONG Reserved32; // Reserved 32bits
  297. };
  298. };
  299. #if defined(_WMIKM_)
  300. PWCHAR LoggerName;
  301. PWCHAR LogFileName;
  302. RTL_TIME_ZONE_INFORMATION TimeZone;
  303. #else
  304. LPWSTR LoggerName;
  305. LPWSTR LogFileName;
  306. TIME_ZONE_INFORMATION TimeZone;
  307. #endif
  308. LARGE_INTEGER BootTime;
  309. LARGE_INTEGER PerfFreq; // Reserved
  310. LARGE_INTEGER StartTime; // Reserved
  311. ULONG ReservedFlags; // Reserved
  312. ULONG BuffersLost;
  313. } TRACE_LOGFILE_HEADER, *PTRACE_LOGFILE_HEADER;
  314. #endif // !_NTDDK_ || _WMIKM_
  315. //
  316. // Instance Information to track parent child relationship of Instances.
  317. //
  318. typedef struct EVENT_INSTANCE_INFO {
  319. HANDLE RegHandle;
  320. ULONG InstanceId;
  321. } EVENT_INSTANCE_INFO, *PEVENT_INSTANCE_INFO;
  322. #if !defined(_WMIKM_) && !defined(_NTDDK_)
  323. //
  324. // Structures that have UNICODE and ANSI versions are defined here
  325. //
  326. //
  327. // Logger configuration and running statistics. This structure is used
  328. // by user-mode callers, such as PDH library
  329. //
  330. typedef struct _EVENT_TRACE_PROPERTIES {
  331. WNODE_HEADER Wnode;
  332. //
  333. // data provided by caller
  334. ULONG BufferSize; // buffer size for logging (kbytes)
  335. ULONG MinimumBuffers; // minimum to preallocate
  336. ULONG MaximumBuffers; // maximum buffers allowed
  337. ULONG MaximumFileSize; // maximum logfile size (in MBytes)
  338. ULONG LogFileMode; // sequential, circular
  339. ULONG FlushTimer; // buffer flush timer, in seconds
  340. ULONG EnableFlags; // trace enable flags
  341. LONG AgeLimit; // age decay time, in minutes
  342. // data returned to caller
  343. ULONG NumberOfBuffers; // no of buffers in use
  344. ULONG FreeBuffers; // no of buffers free
  345. ULONG EventsLost; // event records lost
  346. ULONG BuffersWritten; // no of buffers written to file
  347. ULONG LogBuffersLost; // no of logfile write failures
  348. ULONG RealTimeBuffersLost; // no of rt delivery failures
  349. HANDLE LoggerThreadId; // thread id of Logger
  350. ULONG LogFileNameOffset; // Offset to LogFileName
  351. ULONG LoggerNameOffset; // Offset to LoggerName
  352. } EVENT_TRACE_PROPERTIES, *PEVENT_TRACE_PROPERTIES;
  353. // NOTE:
  354. // If AgeLimit is 0, default is used
  355. // If AgeLimit is < 0, buffer aging is turned off
  356. typedef struct _TRACE_GUID_PROPERTIES {
  357. GUID Guid;
  358. ULONG GuidType;
  359. ULONG LoggerId;
  360. ULONG EnableLevel;
  361. ULONG EnableFlags;
  362. BOOLEAN IsEnable;
  363. } TRACE_GUID_PROPERTIES, *PTRACE_GUID_PROPERTIES;
  364. //
  365. // Data Provider structures
  366. //
  367. // Used by RegisterTraceGuids()
  368. typedef struct _TRACE_GUID_REGISTRATION {
  369. LPCGUID Guid; // Guid of data block being registered or updated.
  370. HANDLE RegHandle; // Guid Registration Handle is returned.
  371. } TRACE_GUID_REGISTRATION, *PTRACE_GUID_REGISTRATION;
  372. //
  373. // Data consumer structures
  374. //
  375. // An EVENT_TRACE consists of a fixed header (EVENT_TRACE_HEADER) and
  376. // optionally a variable portion pointed to by MofData. The datablock
  377. // layout of the variable portion is unknown to the Logger and must
  378. // be obtained from WBEM CIMOM database.
  379. //
  380. typedef struct _EVENT_TRACE {
  381. EVENT_TRACE_HEADER Header; // Event trace header
  382. ULONG InstanceId; // Instance Id of this event
  383. ULONG ParentInstanceId; // Parent Instance Id.
  384. GUID ParentGuid; // Parent Guid;
  385. PVOID MofData; // Pointer to Variable Data
  386. ULONG MofLength; // Variable Datablock Length
  387. ULONG ClientContext; // Reserved
  388. } EVENT_TRACE, *PEVENT_TRACE;
  389. typedef struct _EVENT_TRACE_LOGFILEW
  390. EVENT_TRACE_LOGFILEW, *PEVENT_TRACE_LOGFILEW;
  391. typedef struct _EVENT_TRACE_LOGFILEA
  392. EVENT_TRACE_LOGFILEA, *PEVENT_TRACE_LOGFILEA;
  393. typedef ULONG (WINAPI * PEVENT_TRACE_BUFFER_CALLBACKW)
  394. (PEVENT_TRACE_LOGFILEW Logfile);
  395. typedef ULONG (WINAPI * PEVENT_TRACE_BUFFER_CALLBACKA)
  396. (PEVENT_TRACE_LOGFILEA Logfile);
  397. typedef VOID (WINAPI *PEVENT_CALLBACK)( PEVENT_TRACE pEvent );
  398. //
  399. // Prototype for service request callback. Data providers register with WMI
  400. // by passing a service request callback function that is called for all
  401. // wmi requests.
  402. typedef ULONG (
  403. #ifndef MIDL_PASS
  404. WINAPI
  405. #endif
  406. *WMIDPREQUEST)(
  407. IN WMIDPREQUESTCODE RequestCode,
  408. IN PVOID RequestContext,
  409. IN OUT ULONG *BufferSize,
  410. IN OUT PVOID Buffer
  411. );
  412. struct _EVENT_TRACE_LOGFILEW {
  413. LPWSTR LogFileName; // Logfile Name
  414. LPWSTR LoggerName; // LoggerName
  415. LONGLONG CurrentTime; // timestamp of last event
  416. ULONG BuffersRead; // buffers read to date
  417. ULONG LogFileMode; // Mode of the logfile
  418. EVENT_TRACE CurrentEvent; // Current Event from this stream.
  419. TRACE_LOGFILE_HEADER LogfileHeader; // logfile header structure
  420. PEVENT_TRACE_BUFFER_CALLBACKW // callback before each buffer
  421. BufferCallback; // is read
  422. //
  423. // following variables are filled for BufferCallback.
  424. //
  425. ULONG BufferSize;
  426. ULONG Filled;
  427. ULONG EventsLost;
  428. //
  429. // following needs to be propaged to each buffer
  430. //
  431. PEVENT_CALLBACK EventCallback; // callback for every event
  432. ULONG IsKernelTrace; // TRUE for kernel logfile
  433. PVOID Context; // reserved for internal use
  434. };
  435. struct _EVENT_TRACE_LOGFILEA {
  436. LPSTR LogFileName; // Logfile Name
  437. LPSTR LoggerName; // LoggerName
  438. LONGLONG CurrentTime; // timestamp of last event
  439. ULONG BuffersRead; // buffers read to date
  440. ULONG LogFileMode; // LogFile Mode.
  441. EVENT_TRACE CurrentEvent; // Current Event from this stream
  442. TRACE_LOGFILE_HEADER LogfileHeader; // logfile header structure
  443. PEVENT_TRACE_BUFFER_CALLBACKA // callback before each buffer
  444. BufferCallback; // is read
  445. //
  446. // following variables are filled for BufferCallback.
  447. //
  448. ULONG BufferSize;
  449. ULONG Filled;
  450. ULONG EventsLost;
  451. //
  452. // following needs to be propaged to each buffer
  453. //
  454. PEVENT_CALLBACK EventCallback; // callback for every event
  455. ULONG IsKernelTrace; // TRUE for kernel logfile
  456. PVOID Context; // reserved for internal use
  457. };
  458. //
  459. // Define generic structures
  460. //
  461. #if defined(_UNICODE) || defined(UNICODE)
  462. #define PEVENT_TRACE_BUFFER_CALLBACK PEVENT_TRACE_BUFFER_CALLBACKW
  463. #define EVENT_TRACE_LOGFILE EVENT_TRACE_LOGFILEW
  464. #define PEVENT_TRACE_LOGFILE PEVENT_TRACE_LOGFILEW
  465. #else
  466. #define PEVENT_TRACE_BUFFER_CALLBACK PEVENT_TRACE_BUFFER_CALLBACKA
  467. #define EVENT_TRACE_LOGFILE EVENT_TRACE_LOGFILEA
  468. #define PEVENT_TRACE_LOGFILE PEVENT_TRACE_LOGFILEA
  469. #endif
  470. #pragma warning (default:4201)
  471. #ifdef __cplusplus
  472. extern "C" {
  473. #endif
  474. //
  475. // Logger control APIs
  476. //
  477. //
  478. // Use the routine below to start an event trace session
  479. //
  480. // ULONG
  481. // StartTrace(
  482. // OUT PTRACEHANDLE TraceHandle,
  483. // IN LPTSTR InstanceName,
  484. // IN OUT PEVENT_TRACE_PROPERTIES Properties
  485. // );
  486. EXTERN_C
  487. ULONG
  488. WMIAPI
  489. StartTraceW(
  490. OUT PTRACEHANDLE TraceHandle,
  491. IN LPCWSTR InstanceName,
  492. IN OUT PEVENT_TRACE_PROPERTIES Properties
  493. );
  494. EXTERN_C
  495. ULONG
  496. WMIAPI
  497. StartTraceA(
  498. OUT PTRACEHANDLE TraceHandle,
  499. IN LPCSTR InstanceName,
  500. IN OUT PEVENT_TRACE_PROPERTIES Properties
  501. );
  502. //
  503. // Use the routine below to stop an event trace session
  504. //
  505. //
  506. // ULONG
  507. // StopTrace(
  508. // IN TRACEHANDLE TraceHandle,
  509. // IN LPTSTR InstanceName,
  510. // IN OUT PEVENT_TRACE_PROPERTIES Properties
  511. // );
  512. EXTERN_C
  513. ULONG
  514. WMIAPI
  515. StopTraceW(
  516. IN TRACEHANDLE TraceHandle,
  517. IN LPCWSTR InstanceName,
  518. IN OUT PEVENT_TRACE_PROPERTIES Properties
  519. );
  520. EXTERN_C
  521. ULONG
  522. WMIAPI
  523. StopTraceA(
  524. IN TRACEHANDLE TraceHandle,
  525. IN LPCSTR InstanceName,
  526. IN OUT PEVENT_TRACE_PROPERTIES Properties
  527. );
  528. //
  529. // Use the routine below to query the properties of an event trace session
  530. //
  531. // ULONG
  532. // QueryTrace(
  533. // IN TRACEHANDLE TraceHandle,
  534. // IN LPTSTR InstanceName,
  535. // IN OUT PEVENT_TRACE_PROPERTIES Properties
  536. // );
  537. EXTERN_C
  538. ULONG
  539. WMIAPI
  540. QueryTraceW(
  541. IN TRACEHANDLE TraceHandle,
  542. IN LPCWSTR InstanceName,
  543. IN OUT PEVENT_TRACE_PROPERTIES Properties
  544. );
  545. EXTERN_C
  546. ULONG
  547. WMIAPI
  548. QueryTraceA(
  549. IN TRACEHANDLE TraceHandle,
  550. IN LPCSTR InstanceName,
  551. IN OUT PEVENT_TRACE_PROPERTIES Properties
  552. );
  553. //
  554. // Use the routine below to update certain properties of an event trace session
  555. //
  556. // ULONG
  557. // UpdateTrace(
  558. // IN (PTRACEHANDLE TraceHandle,
  559. // IN LPTSTR InstanceName,
  560. // IN OUT PEVENT_TRACE_PROPERTIES Properties
  561. // );
  562. EXTERN_C
  563. ULONG
  564. WMIAPI
  565. UpdateTraceW(
  566. IN TRACEHANDLE TraceHandle,
  567. IN LPCWSTR InstanceName,
  568. IN OUT PEVENT_TRACE_PROPERTIES Properties
  569. );
  570. EXTERN_C
  571. ULONG
  572. WMIAPI
  573. UpdateTraceA(
  574. IN TRACEHANDLE TraceHandle,
  575. IN LPCSTR InstanceName,
  576. IN OUT PEVENT_TRACE_PROPERTIES Properties
  577. );
  578. //
  579. // Use the routine below to request that all active buffers an event trace
  580. // session be "flushed", or written out.
  581. //
  582. // ULONG
  583. // FlushTrace(
  584. // IN TRACEHANDLE TraceHandle,
  585. // IN LPTSTR InstanceName,
  586. // IN OUT PEVENT_TRACE_PROPERTIES Properties
  587. // );
  588. EXTERN_C
  589. ULONG
  590. WMIAPI
  591. FlushTraceW(
  592. IN TRACEHANDLE TraceHandle,
  593. IN LPCWSTR InstanceName,
  594. IN OUT PEVENT_TRACE_PROPERTIES Properties
  595. );
  596. EXTERN_C
  597. ULONG
  598. WMIAPI
  599. FlushTraceA(
  600. IN TRACEHANDLE TraceHandle,
  601. IN LPCSTR InstanceName,
  602. IN OUT PEVENT_TRACE_PROPERTIES Properties
  603. );
  604. //
  605. // Generic trace control routine
  606. //
  607. EXTERN_C
  608. ULONG
  609. WMIAPI
  610. ControlTraceW(
  611. IN TRACEHANDLE TraceHandle,
  612. IN LPCWSTR InstanceName,
  613. IN OUT PEVENT_TRACE_PROPERTIES Properties,
  614. IN ULONG ControlCode
  615. );
  616. EXTERN_C
  617. ULONG
  618. WMIAPI
  619. ControlTraceA(
  620. IN TRACEHANDLE TraceHandle,
  621. IN LPCSTR InstanceName,
  622. IN OUT PEVENT_TRACE_PROPERTIES Properties,
  623. IN ULONG ControlCode
  624. );
  625. //
  626. // ULONG
  627. // QueryAllTraces(
  628. // OUT PEVENT_TRACE_PROPERTIES *PropertyArray,
  629. // IN ULONG PropertyArrayCount,
  630. // OUT PULONG LoggerCount
  631. // );
  632. //
  633. EXTERN_C
  634. ULONG
  635. WMIAPI
  636. QueryAllTracesW(
  637. OUT PEVENT_TRACE_PROPERTIES *PropertyArray,
  638. IN ULONG PropertyArrayCount,
  639. OUT PULONG LoggerCount
  640. );
  641. EXTERN_C
  642. ULONG
  643. WMIAPI
  644. QueryAllTracesA(
  645. OUT PEVENT_TRACE_PROPERTIES *PropertyArray,
  646. IN ULONG PropertyArrayCount,
  647. OUT PULONG LoggerCount
  648. );
  649. //
  650. // Data Provider APIs
  651. //
  652. EXTERN_C
  653. ULONG
  654. WMIAPI
  655. CreateTraceInstanceId(
  656. IN HANDLE RegHandle,
  657. IN OUT PEVENT_INSTANCE_INFO pInstInfo
  658. );
  659. EXTERN_C
  660. ULONG
  661. WMIAPI
  662. EnableTrace(
  663. IN ULONG Enable,
  664. IN ULONG EnableFlag,
  665. IN ULONG EnableLevel,
  666. IN LPCGUID ControlGuid,
  667. IN TRACEHANDLE TraceHandle
  668. );
  669. //
  670. // Use the routine below to generate and record an event trace
  671. //
  672. EXTERN_C
  673. ULONG
  674. WMIAPI
  675. TraceEvent(
  676. IN TRACEHANDLE TraceHandle,
  677. IN PEVENT_TRACE_HEADER EventTrace
  678. );
  679. EXTERN_C
  680. ULONG
  681. WMIAPI
  682. TraceEventInstance(
  683. IN TRACEHANDLE TraceHandle,
  684. IN PEVENT_INSTANCE_HEADER EventTrace,
  685. IN PEVENT_INSTANCE_INFO pInstInfo,
  686. IN PEVENT_INSTANCE_INFO pParentInstInfo
  687. );
  688. //
  689. // Use the routine below to register a guid for tracing
  690. //
  691. //
  692. // ULONG
  693. // RegisterTraceGuids(
  694. // IN WMIDPREQUEST RequestAddress,
  695. // IN PVOID RequestContext,
  696. // IN LPCGUID ControlGuid,
  697. // IN ULONG GuidCount,
  698. // IN PTRACE_GUID_REGISTRATION TraceGuidReg,
  699. // IN LPCTSTR MofImagePath,
  700. // IN LPCTSTR MofResourceName,
  701. // OUT PTRACEHANDLE RegistrationHandle
  702. // );
  703. //
  704. EXTERN_C
  705. ULONG
  706. WMIAPI
  707. RegisterTraceGuidsW(
  708. IN WMIDPREQUEST RequestAddress,
  709. IN PVOID RequestContext,
  710. IN LPCGUID ControlGuid,
  711. IN ULONG GuidCount,
  712. IN PTRACE_GUID_REGISTRATION TraceGuidReg,
  713. IN LPCWSTR MofImagePath,
  714. IN LPCWSTR MofResourceName,
  715. OUT PTRACEHANDLE RegistrationHandle
  716. );
  717. EXTERN_C
  718. ULONG
  719. WMIAPI
  720. RegisterTraceGuidsA(
  721. IN WMIDPREQUEST RequestAddress,
  722. IN PVOID RequestContext,
  723. IN LPCGUID ControlGuid,
  724. IN ULONG GuidCount,
  725. IN PTRACE_GUID_REGISTRATION TraceGuidReg,
  726. IN LPCSTR MofImagePath,
  727. IN LPCSTR MofResourceName,
  728. OUT PTRACEHANDLE RegistrationHandle
  729. );
  730. EXTERN_C
  731. ULONG
  732. WMIAPI
  733. EnumerateTraceGuids(
  734. IN OUT PTRACE_GUID_PROPERTIES *GuidPropertiesArray,
  735. IN ULONG PropertyArrayCount,
  736. OUT PULONG GuidCount
  737. );
  738. EXTERN_C
  739. ULONG
  740. WMIAPI
  741. UnregisterTraceGuids(
  742. IN TRACEHANDLE RegistrationHandle
  743. );
  744. EXTERN_C
  745. TRACEHANDLE
  746. WMIAPI
  747. GetTraceLoggerHandle(
  748. IN PVOID Buffer
  749. );
  750. EXTERN_C
  751. UCHAR
  752. WMIAPI
  753. GetTraceEnableLevel(
  754. IN TRACEHANDLE TraceHandle
  755. );
  756. EXTERN_C
  757. ULONG
  758. WMIAPI
  759. GetTraceEnableFlags(
  760. IN TRACEHANDLE TraceHandle
  761. );
  762. //
  763. // Data Consumer APIs and structures start here
  764. //
  765. //
  766. // TRACEHANDLE
  767. // OpenTrace(
  768. // IN OUT PEVENT_TRACE_LOGFILE Logfile
  769. // );
  770. //
  771. EXTERN_C
  772. TRACEHANDLE
  773. WMIAPI
  774. OpenTraceA(
  775. IN OUT PEVENT_TRACE_LOGFILEA Logfile
  776. );
  777. EXTERN_C
  778. TRACEHANDLE
  779. WMIAPI
  780. OpenTraceW(
  781. IN OUT PEVENT_TRACE_LOGFILEW Logfile
  782. );
  783. EXTERN_C
  784. ULONG
  785. WMIAPI
  786. ProcessTrace(
  787. IN PTRACEHANDLE HandleArray,
  788. IN ULONG HandleCount,
  789. IN LPFILETIME StartTime,
  790. IN LPFILETIME EndTime
  791. );
  792. EXTERN_C
  793. ULONG
  794. WMIAPI
  795. CloseTrace(
  796. IN TRACEHANDLE TraceHandle
  797. );
  798. EXTERN_C
  799. ULONG
  800. WMIAPI
  801. SetTraceCallback(
  802. IN LPCGUID pGuid,
  803. IN PEVENT_CALLBACK EventCallback
  804. );
  805. EXTERN_C
  806. ULONG
  807. WMIAPI
  808. RemoveTraceCallback (
  809. IN LPCGUID pGuid
  810. );
  811. // The routines for tracing Messages follow
  812. //
  813. EXTERN_C
  814. ULONG
  815. __cdecl
  816. TraceMessage(
  817. IN TRACEHANDLE LoggerHandle,
  818. IN ULONG MessageFlags,
  819. IN LPGUID MessageGuid,
  820. IN USHORT MessageNumber,
  821. ...
  822. );
  823. EXTERN_C
  824. ULONG
  825. TraceMessageVa(
  826. IN TRACEHANDLE LoggerHandle,
  827. IN ULONG MessageFlags,
  828. IN LPGUID MessageGuid,
  829. IN USHORT MessageNumber,
  830. IN va_list MessageArgList
  831. );
  832. #ifdef __cplusplus
  833. } // extern "C"
  834. #endif
  835. //
  836. //
  837. // Define the encoding independent routines
  838. //
  839. #if defined(UNICODE) || defined(_UNICODE)
  840. #define RegisterTraceGuids RegisterTraceGuidsW
  841. #define StartTrace StartTraceW
  842. #define ControlTrace ControlTraceW
  843. #define StopTrace StopTraceW
  844. #define QueryTrace QueryTraceW
  845. #define UpdateTrace UpdateTraceW
  846. #define FlushTrace FlushTraceW
  847. #define QueryAllTraces QueryAllTracesW
  848. #define OpenTrace OpenTraceW
  849. #else
  850. #define RegisterTraceGuids RegisterTraceGuidsA
  851. #define StartTrace StartTraceA
  852. #define ControlTrace ControlTraceA
  853. #define StopTrace StopTraceA
  854. #define QueryTrace QueryTraceA
  855. #define UpdateTrace UpdateTraceA
  856. #define FlushTrace FlushTraceA
  857. #define QueryAllTraces QueryAllTracesA
  858. #define OpenTrace OpenTraceA
  859. #endif // UNICODE
  860. #endif /* _WMIKM_ && _NTDDK_ */
  861. #endif // WINNT
  862. #endif /* _EVNTRACE_ */