예제 #1
0
        public static bool WriteBinary(TraceType traceType, Guid component, int traceTag, byte[] message, out int maxBytes)
        {
            maxBytes = 0;
            int num = message.Length;

            if (traceTag > 255)
            {
                throw new ArgumentException("Maximum allowed tag-value is 255 for binary traces", "traceTag");
            }
            if (num > 8064)
            {
                maxBytes = 8064;
                return(false);
            }
            GCHandle?gchandle = null;
            uint     num2     = 0U;

            try
            {
                DiagnosticsNativeMethods.BinaryEventTrace binaryEventTrace = new DiagnosticsNativeMethods.BinaryEventTrace(component, (byte)traceTag, message, ref gchandle);
                num2 = DiagnosticsNativeMethods.TraceEvent(ETWTrace.ComponentSession.Session.DangerousGetHandle(), ref binaryEventTrace);
            }
            finally
            {
                if (gchandle != null && gchandle.Value.IsAllocated)
                {
                    gchandle.Value.Free();
                }
            }
            return(num2 == 0U);
        }
 internal static extern uint TraceEvent([In] long sessionHandle, [In] ref DiagnosticsNativeMethods.BinaryEventTrace binaryEventTrace);