//**********************************************************************` //* This is an include file generated by Message Compiler. *` //* *` //* Copyright (c) Microsoft Corporation. All Rights Reserved. *` //**********************************************************************` #pragma once #include #include #include "evntprov.h" // // Initial Defs // #if !defined(ETW_INLINE) #define ETW_INLINE DECLSPEC_NOINLINE __inline #endif #if defined(__cplusplus) extern "C" { #endif // // Allow Diasabling of code generation // #ifndef MCGEN_DISABLE_PROVIDER_CODE_GENERATION #if !defined(McGenDebug) #define McGenDebug(a,b) #endif #if !defined(MCGEN_TRACE_CONTEXT_DEF) #define MCGEN_TRACE_CONTEXT_DEF typedef struct _MCGEN_TRACE_CONTEXT { TRACEHANDLE RegistrationHandle; TRACEHANDLE Logger; ULONGLONG MatchAnyKeyword; ULONGLONG MatchAllKeyword; ULONG Flags; ULONG IsEnabled; UCHAR Level; UCHAR Reserve; } MCGEN_TRACE_CONTEXT, *PMCGEN_TRACE_CONTEXT; #endif #if !defined(MCGEN_EVENT_ENABLED_DEF) #define MCGEN_EVENT_ENABLED_DEF FORCEINLINE BOOLEAN McGenEventEnabled( __in PMCGEN_TRACE_CONTEXT EnableInfo, __in PCEVENT_DESCRIPTOR EventDescriptor ) { // // Check if the event Level is lower than the level at which // the channel is enabled. // If the event Level is 0 or the channel is enabled at level 0, // all levels are enabled. // if ((EventDescriptor->Level <= EnableInfo->Level) || // This also covers the case of Level == 0. (EnableInfo->Level == 0)) { // // Check if Keyword is enabled // if ((EventDescriptor->Keyword == (ULONGLONG)0) || ((EventDescriptor->Keyword & EnableInfo->MatchAnyKeyword) && ((EventDescriptor->Keyword & EnableInfo->MatchAllKeyword) == EnableInfo->MatchAllKeyword))) { return TRUE; } } return FALSE; } #endif // // EnableCheckMacro // #ifndef MCGEN_ENABLE_CHECK #define MCGEN_ENABLE_CHECK(Context, Descriptor) (Context.IsEnabled && McGenEventEnabled(&Context, &Descriptor)) #endif #if !defined(MCGEN_CONTROL_CALLBACK) #define MCGEN_CONTROL_CALLBACK DECLSPEC_NOINLINE __inline VOID __stdcall McGenControlCallbackV2( __in LPCGUID SourceId, __in ULONG ControlCode, __in UCHAR Level, __in ULONGLONG MatchAnyKeyword, __in ULONGLONG MatchAllKeyword, __in_opt PEVENT_FILTER_DESCRIPTOR FilterData, __inout_opt PVOID CallbackContext ) /*++ Routine Description: This is the notification callback for Vista. Arguments: SourceId - The GUID that identifies the session that enabled the provider. ControlCode - The parameter indicates whether the provider is being enabled or disabled. Level - The level at which the event is enabled. MatchAnyKeyword - The bitmask of keywords that the provider uses to determine the category of events that it writes. MatchAllKeyword - This bitmask additionally restricts the category of events that the provider writes. FilterData - The provider-defined data. CallbackContext - The context of the callback that is defined when the provider called EtwRegister to register itself. Remarks: ETW calls this function to notify provider of enable/disable --*/ { PMCGEN_TRACE_CONTEXT Ctx = (PMCGEN_TRACE_CONTEXT)CallbackContext; #ifndef MCGEN_PRIVATE_ENABLE_CALLBACK_V2 UNREFERENCED_PARAMETER(SourceId); UNREFERENCED_PARAMETER(FilterData); #endif if (Ctx == NULL) { return; } switch (ControlCode) { case EVENT_CONTROL_CODE_ENABLE_PROVIDER: Ctx->Level = Level; Ctx->MatchAnyKeyword = MatchAnyKeyword; Ctx->MatchAllKeyword = MatchAllKeyword; Ctx->IsEnabled = EVENT_CONTROL_CODE_ENABLE_PROVIDER; break; case EVENT_CONTROL_CODE_DISABLE_PROVIDER: Ctx->IsEnabled = EVENT_CONTROL_CODE_DISABLE_PROVIDER; Ctx->Level = 0; Ctx->MatchAnyKeyword = 0; Ctx->MatchAllKeyword = 0; break; default: break; } #ifdef MCGEN_PRIVATE_ENABLE_CALLBACK_V2 // // Call user defined callback // MCGEN_PRIVATE_ENABLE_CALLBACK_V2( SourceId, ControlCode, Level, MatchAnyKeyword, MatchAllKeyword, FilterData, CallbackContext ); #endif return; } #endif #endif // MCGEN_DISABLE_PROVIDER_CODE_GENERATION //+ // Provider Chrome Event Count 1 //+ EXTERN_C __declspec(selectany) const GUID CHROME = {0xd2d578d9, 0x2936, 0x45b6, {0xa0, 0x9f, 0x30, 0xe3, 0x27, 0x15, 0xf4, 0x2d}}; // // Channel // #define CHROME_CHANNEL_SYSTEM 0x8 // // Event Descriptors // EXTERN_C __declspec(selectany) const EVENT_DESCRIPTOR ChromeEvent = {0x1, 0x0, 0x8, 0x4, 0x0, 0x0, 0x8000000000000000}; #define ChromeEvent_value 0x1 // // Note on Generate Code from Manifest Windows Vista and above // //Structures : are handled as a size and pointer pairs. The macro for the event will have an extra //parameter for the size in bytes of the structure. Make sure that your structures have no extra padding. // //Strings: There are several cases that can be described in the manifest. For array of variable length //strings, the generated code will take the count of characters for the whole array as an input parameter. // //SID No support for array of SIDs, the macro will take a pointer to the SID and use appropriate //GetLengthSid function to get the length. // // // Allow Diasabling of code generation // #ifndef MCGEN_DISABLE_PROVIDER_CODE_GENERATION // // Globals // EXTERN_C __declspec(selectany) REGHANDLE ChromeHandle = (REGHANDLE)0; EXTERN_C __declspec(selectany) MCGEN_TRACE_CONTEXT CHROME_Context = {0}; #if !defined(McGenEventRegisterUnregister) #define McGenEventRegisterUnregister DECLSPEC_NOINLINE __inline ULONG __stdcall McGenEventRegister( __in LPCGUID ProviderId, __in_opt PENABLECALLBACK EnableCallback, __in_opt PVOID CallbackContext, __inout PREGHANDLE RegHandle ) /*++ Routine Description: This function register the provider with ETW USER mode. Arguments: ProviderId - Provider Id to be register with ETW. EnableCallback - Callback to be used. CallbackContext - Context for this provider. RegHandle - Pointer to Registration handle. Remarks: If the handle != NULL will return ERROR_SUCCESS --*/ { ULONG Error; if (*RegHandle) { // // already registered // return ERROR_SUCCESS; } Error = EventRegister( ProviderId, EnableCallback, CallbackContext, RegHandle); return Error; } DECLSPEC_NOINLINE __inline ULONG __stdcall McGenEventUnregister(__inout PREGHANDLE RegHandle) /*++ Routine Description: Unregister from ETW USER mode Arguments: RegHandle this is the pointer to the provider context Remarks: If Provider has not register RegHandle = NULL, return ERROR_SUCCESS --*/ { ULONG Error; if(!(*RegHandle)) { // // Provider has not registerd // return ERROR_SUCCESS; } Error = EventUnregister(*RegHandle); *RegHandle = (REGHANDLE)0; return Error; } #endif // // Register with ETW Vista + // #ifndef EventRegisterChrome #define EventRegisterChrome() McGenEventRegister(&CHROME, McGenControlCallbackV2, &CHROME_Context, &ChromeHandle) #endif // // UnRegister with ETW // #ifndef EventUnregisterChrome #define EventUnregisterChrome() McGenEventUnregister(&ChromeHandle) #endif // // Event Macro for ChromeEvent // #define EventWriteChromeEvent(Name, Phase, Arg_Name_1, Arg_Value_1, Arg_Name_2, Arg_Value_2, Arg_Name_3, Arg_Value_3)\ MCGEN_ENABLE_CHECK(CHROME_Context, ChromeEvent) ?\ Template_ssssssss(ChromeHandle, &ChromeEvent, Name, Phase, Arg_Name_1, Arg_Value_1, Arg_Name_2, Arg_Value_2, Arg_Name_3, Arg_Value_3)\ : ERROR_SUCCESS\ #endif // MCGEN_DISABLE_PROVIDER_CODE_GENERATION // // Allow Diasabling of code generation // #ifndef MCGEN_DISABLE_PROVIDER_CODE_GENERATION // // Template Functions // // //Template from manifest : tid_chrome_event // #ifndef Template_ssssssss_def #define Template_ssssssss_def ETW_INLINE ULONG Template_ssssssss( __in REGHANDLE RegHandle, __in PCEVENT_DESCRIPTOR Descriptor, __in_opt LPCSTR Name, __in_opt LPCSTR Phase, __in_opt LPCSTR Arg_Name_1, __in_opt LPCSTR Arg_Value_1, __in_opt LPCSTR Arg_Name_2, __in_opt LPCSTR Arg_Value_2, __in_opt LPCSTR Arg_Name_3, __in_opt LPCSTR Arg_Value_3 ) { #define ARGUMENT_COUNT_ssssssss 8 EVENT_DATA_DESCRIPTOR EventData[ARGUMENT_COUNT_ssssssss]; EventDataDescCreate(&EventData[0], (Name != NULL) ? Name : "NULL", (Name != NULL) ? (ULONG)((strlen(Name) + 1) * sizeof(CHAR)) : (ULONG)sizeof("NULL")); EventDataDescCreate(&EventData[1], (Phase != NULL) ? Phase : "NULL", (Phase != NULL) ? (ULONG)((strlen(Phase) + 1) * sizeof(CHAR)) : (ULONG)sizeof("NULL")); EventDataDescCreate(&EventData[2], (Arg_Name_1 != NULL) ? Arg_Name_1 : "NULL", (Arg_Name_1 != NULL) ? (ULONG)((strlen(Arg_Name_1) + 1) * sizeof(CHAR)) : (ULONG)sizeof("NULL")); EventDataDescCreate(&EventData[3], (Arg_Value_1 != NULL) ? Arg_Value_1 : "NULL", (Arg_Value_1 != NULL) ? (ULONG)((strlen(Arg_Value_1) + 1) * sizeof(CHAR)) : (ULONG)sizeof("NULL")); EventDataDescCreate(&EventData[4], (Arg_Name_2 != NULL) ? Arg_Name_2 : "NULL", (Arg_Name_2 != NULL) ? (ULONG)((strlen(Arg_Name_2) + 1) * sizeof(CHAR)) : (ULONG)sizeof("NULL")); EventDataDescCreate(&EventData[5], (Arg_Value_2 != NULL) ? Arg_Value_2 : "NULL", (Arg_Value_2 != NULL) ? (ULONG)((strlen(Arg_Value_2) + 1) * sizeof(CHAR)) : (ULONG)sizeof("NULL")); EventDataDescCreate(&EventData[6], (Arg_Name_3 != NULL) ? Arg_Name_3 : "NULL", (Arg_Name_3 != NULL) ? (ULONG)((strlen(Arg_Name_3) + 1) * sizeof(CHAR)) : (ULONG)sizeof("NULL")); EventDataDescCreate(&EventData[7], (Arg_Value_3 != NULL) ? Arg_Value_3 : "NULL", (Arg_Value_3 != NULL) ? (ULONG)((strlen(Arg_Value_3) + 1) * sizeof(CHAR)) : (ULONG)sizeof("NULL")); return EventWrite(RegHandle, Descriptor, ARGUMENT_COUNT_ssssssss, EventData); } #endif #endif // MCGEN_DISABLE_PROVIDER_CODE_GENERATION #if defined(__cplusplus) }; #endif #define MSG_ChromeEvent_EventMessage 0x00000001L