home *** CD-ROM | disk | FTP | other *** search
/ PC Format (South-Africa) 2001 June / PCFJune.iso / Xenon / C++ / FreeCommandLineTools.exe / Include / evntrace.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-01-31  |  25.4 KB  |  862 lines

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