| 1 |
`**********************************************************************` |
| 2 |
`* This is an include template file for the tracewpp preprocessor. *` |
| 3 |
`* *` |
| 4 |
`* Copyright (c) Microsoft Corporation. All rights reserved. *` |
| 5 |
`**********************************************************************` |
| 6 |
// template `TemplateFile` |
| 7 |
|
| 8 |
#ifdef WPP_THIS_FILE |
| 9 |
// included twice |
| 10 |
# define WPP_ALREADY_INCLUDED |
| 11 |
# undef WPP_THIS_FILE |
| 12 |
#endif // #ifdef WPP_THIS_FILE |
| 13 |
|
| 14 |
#define WPP_THIS_FILE `SourceFile.CanonicalName` |
| 15 |
|
| 16 |
#ifndef WPP_ALREADY_INCLUDED |
| 17 |
|
| 18 |
`* Dump the definitions specified via -D on the command line to WPP *` |
| 19 |
`FORALL def IN MacroDefinitions` |
| 20 |
#define `def.Name` `def.Alias` |
| 21 |
`ENDFOR` |
| 22 |
|
| 23 |
#ifdef BUILD_MINWIN |
| 24 |
#include <windowscore.h> |
| 25 |
#else |
| 26 |
#include <windows.h> |
| 27 |
#endif |
| 28 |
|
| 29 |
#include <wmistr.h> |
| 30 |
#include <evntrace.h> |
| 31 |
#ifndef WPP_TRACE_W2K_COMPATABILITY |
| 32 |
#include <sddl.h> |
| 33 |
#endif |
| 34 |
|
| 35 |
#ifdef __cplusplus |
| 36 |
extern "C" { |
| 37 |
#endif |
| 38 |
|
| 39 |
// LEGACY: This structure was used by Win2k RpcRt4 and cluster tracing |
| 40 |
|
| 41 |
typedef struct _WPP_WIN2K_CONTROL_BLOCK { |
| 42 |
TRACEHANDLE Logger; |
| 43 |
ULONG Flags; |
| 44 |
ULONG Level; |
| 45 |
LPCGUID ControlGuid; |
| 46 |
} WPP_WIN2K_CONTROL_BLOCK, *PWPP_WIN2K_CONTROL_BLOCK; |
| 47 |
|
| 48 |
#pragma warning(push) |
| 49 |
#pragma warning(disable:4201) // nonstandard extension used nameless struct/union |
| 50 |
|
| 51 |
typedef struct _WPP_TRACE_CONTROL_BLOCK |
| 52 |
{ |
| 53 |
struct _WPP_TRACE_CONTROL_BLOCK *Next; |
| 54 |
TRACEHANDLE UmRegistrationHandle; |
| 55 |
union { |
| 56 |
TRACEHANDLE Logger; |
| 57 |
PWPP_WIN2K_CONTROL_BLOCK Win2kCb; |
| 58 |
PVOID Ptr; |
| 59 |
struct _WPP_TRACE_CONTROL_BLOCK *Cb; |
| 60 |
}; |
| 61 |
|
| 62 |
UCHAR FlagsLen; |
| 63 |
UCHAR Level; |
| 64 |
USHORT Options; |
| 65 |
ULONG Flags[1]; |
| 66 |
LPCGUID ControlGuid; |
| 67 |
#if ENABLE_WPP_RECORDER |
| 68 |
PVOID AutoLogContext; |
| 69 |
USHORT AutoLogVerboseEnabled; |
| 70 |
USHORT AutoLogAttachToMiniDump; |
| 71 |
#endif |
| 72 |
} WPP_TRACE_CONTROL_BLOCK, *PWPP_TRACE_CONTROL_BLOCK; |
| 73 |
#pragma warning(pop) |
| 74 |
|
| 75 |
#ifdef WPP_USE_NTDLL_FUNCTIONS |
| 76 |
// Not supported. |
| 77 |
#include <wpp_use_ntdll_functions.h> |
| 78 |
#endif |
| 79 |
|
| 80 |
#define WPP_IsValidSid IsValidSid |
| 81 |
#define WPP_GetLengthSid GetLengthSid |
| 82 |
|
| 83 |
#ifndef WPP_TRACE |
| 84 |
#define WPP_TRACE TraceMessage |
| 85 |
#endif |
| 86 |
|
| 87 |
#ifndef WPP_UNREGISTER_TRACE_GUIDS |
| 88 |
#define WPP_UNREGISTER_TRACE_GUIDS UnregisterTraceGuids |
| 89 |
#endif |
| 90 |
|
| 91 |
|
| 92 |
#ifndef WPP_REGISTER_TRACE_GUIDS |
| 93 |
#define WPP_REGISTER_TRACE_GUIDS RegisterTraceGuids |
| 94 |
#endif |
| 95 |
|
| 96 |
|
| 97 |
#ifndef WPP_GET_TRACE_LOGGER_HANDLE |
| 98 |
#define WPP_GET_TRACE_LOGGER_HANDLE GetTraceLoggerHandle |
| 99 |
#endif |
| 100 |
|
| 101 |
#ifndef WPP_GET_TRACE_ENABLE_LEVEL |
| 102 |
#define WPP_GET_TRACE_ENABLE_LEVEL GetTraceEnableLevel |
| 103 |
#endif |
| 104 |
|
| 105 |
#ifndef WPP_GET_TRACE_ENABLE_FLAGS |
| 106 |
#define WPP_GET_TRACE_ENABLE_FLAGS GetTraceEnableFlags |
| 107 |
#endif |
| 108 |
|
| 109 |
enum { |
| 110 |
WPP_VER_WIN2K_CB_FORWARD_PTR = 0x01, |
| 111 |
WPP_VER_WHISTLER_CB_FORWARD_PTR = 0x02, |
| 112 |
WPP_VER_LH_CB_FORWARD_PTR = 0x03 |
| 113 |
}; |
| 114 |
|
| 115 |
#if ENABLE_WPP_RECORDER |
| 116 |
|
| 117 |
#ifndef WPP_RECORDER |
| 118 |
#define WPP_RECORDER WppAutoLogTrace |
| 119 |
#endif |
| 120 |
|
| 121 |
// |
| 122 |
// This setting is only applicable when IFR is enabled. |
| 123 |
// Setting this to 1 will allow a WPP trace session to |
| 124 |
// capture trace messages as usual i.e it will require the |
| 125 |
// user to provide WPP trace ENABLED and LOGGER macro. If |
| 126 |
// this is set to 0 by default the IFR trace filter also |
| 127 |
// affects which trace messages land in the WPP trace session. |
| 128 |
// |
| 129 |
#if !defined(ENABLE_WPP_TRACE_FILTERING_WITH_WPP_RECORDER) |
| 130 |
#define ENABLE_WPP_TRACE_FILTERING_WITH_WPP_RECORDER 0 |
| 131 |
#endif |
| 132 |
|
| 133 |
#if !defined(WPP_RECORDER_LEVEL_FLAGS_ARGS) |
| 134 |
#define WPP_RECORDER_LEVEL_FLAGS_ARGS(lvl, flags) WPP_CONTROL(WPP_BIT_ ## flags).AutoLogContext, lvl, WPP_BIT_ ## flags |
| 135 |
#define WPP_RECORDER_LEVEL_FLAGS_FILTER(lvl,flags) (lvl < TRACE_LEVEL_VERBOSE || WPP_CONTROL(WPP_BIT_ ## flags).AutoLogVerboseEnabled) |
| 136 |
#endif |
| 137 |
|
| 138 |
#if !defined(WPP_RECORDER_FLAGS_LEVEL_ARGS) |
| 139 |
#define WPP_RECORDER_FLAGS_LEVEL_ARGS(flags, lvl) WPP_RECORDER_LEVEL_FLAGS_ARGS(lvl, flags) |
| 140 |
#define WPP_RECORDER_FLAGS_LEVEL_FILTER(flags, lvl) WPP_RECORDER_LEVEL_FLAGS_FILTER(lvl, flags) |
| 141 |
#endif |
| 142 |
|
| 143 |
#if !defined(WPP_RECORDER_LEVEL_ARGS) |
| 144 |
#define WPP_RECORDER_LEVEL_ARGS(lvl) WPP_CONTROL(WPP_BIT_ ## lvl).AutoLogContext, 0, WPP_BIT_ ## lvl |
| 145 |
#define WPP_RECORDER_LEVEL_FILTER(lvl) (WPP_CONTROL(WPP_BIT_ ## lvl).AutoLogVerboseEnabled) |
| 146 |
#endif |
| 147 |
|
| 148 |
NTSTATUS |
| 149 |
WppAutoLogTrace( |
| 150 |
_In_ PVOID AutoLogContext, |
| 151 |
_In_ UCHAR MessageLevel, |
| 152 |
_In_ ULONG MessageFlags, |
| 153 |
_In_ LPGUID MessageGuid, |
| 154 |
_In_ USHORT MessageNumber, |
| 155 |
_In_ ... |
| 156 |
); |
| 157 |
|
| 158 |
#endif // ENABLE_WPP_RECORDER |
| 159 |
|
| 160 |
// |
| 161 |
// WPP_INIT_TRACING and WPP_CLEANUP macros are defined differently for kernel |
| 162 |
// mode and user mode. In order to support mode-agnostic WDF drivers, |
| 163 |
// WPP_INIT_TRACING and WPP_CLEANUP macros for UMDF 2.x user-mode drivers are |
| 164 |
// being updated to be same as kernel mode macros. This difference is based |
| 165 |
// upon the macro WPP_MACRO_USE_KM_VERSION_FOR_UM. |
| 166 |
// |
| 167 |
|
| 168 |
#ifdef WPP_MACRO_USE_KM_VERSION_FOR_UM |
| 169 |
|
| 170 |
VOID WppCleanupUm( VOID ); |
| 171 |
#define WPP_CLEANUP(DrvObj) WppCleanupUm() |
| 172 |
#else |
| 173 |
VOID WppCleanupUm( VOID ); |
| 174 |
#define WPP_CLEANUP() WppCleanupUm() |
| 175 |
#endif |
| 176 |
|
| 177 |
#define WppLoadTracingSupport |
| 178 |
|
| 179 |
// |
| 180 |
// For getting private callback, implement a function with the signature below. |
| 181 |
// To register the function: #define WPP_PRIVATE_ENABLE_CALLBACK MyPrivateCallback |
| 182 |
// If multiple control guids are used, be sure to compare Guid to the one of interest. |
| 183 |
// |
| 184 |
|
| 185 |
#if defined(WPP_PRIVATE_ENABLE_CALLBACK) |
| 186 |
|
| 187 |
typedef |
| 188 |
VOID |
| 189 |
(NTAPI *PFN_WPP_PRIVATE_ENABLE_CALLBACK)( |
| 190 |
_In_ LPCGUID Guid, |
| 191 |
_In_ TRACEHANDLE Logger, |
| 192 |
_In_ BOOLEAN Enable, |
| 193 |
_In_ ULONG Flags, |
| 194 |
_In_ UCHAR Level |
| 195 |
); |
| 196 |
|
| 197 |
#endif |
| 198 |
|
| 199 |
// |
| 200 |
// For generating CAPTURE_STATE callback (Win7+), implement a function with the signature |
| 201 |
// below. To register the function: #define WPP_CAPTURE_STATE_CALLBACK MyCaptureStateCallback |
| 202 |
// If multiple control guids are used, be sure to compare Guid to the one of interest. |
| 203 |
// |
| 204 |
|
| 205 |
#if defined(WPP_CAPTURE_STATE_CALLBACK) |
| 206 |
|
| 207 |
typedef |
| 208 |
VOID |
| 209 |
(NTAPI *PFN_WPP_CAPTURE_STATE_CALLBACK)( |
| 210 |
_In_ LPCGUID Guid, |
| 211 |
_In_ TRACEHANDLE Logger, |
| 212 |
_In_ ULONG Flags, |
| 213 |
_In_ UCHAR Level |
| 214 |
); |
| 215 |
|
| 216 |
#endif |
| 217 |
|
| 218 |
#ifdef __cplusplus |
| 219 |
} // extern "C" |
| 220 |
#endif |
| 221 |
|
| 222 |
#endif // #ifndef WPP_ALREADY_INCLUDED |