Example #1
0
        static unsafe uint TraceInternal(Guid guid, string xml, TraceType type)
        {
            uint result = unchecked ((uint)-1);

            if (null != Provider && Provider.ShouldTrace)
            {
                int dataLength = (xml.Length + 1) * 2 < MaxSupportedStringSize ? (xml.Length + 1) * 2 : MaxSupportedStringSize;

                Mof2Event evt = new Mof2Event();
                evt.Header.Guid          = WCFTraceGuid;
                evt.Header.Type          = (byte)type;
                evt.Header.ClientContext = 0;
                evt.Header.Flags         = WnodeFlags.WnodeFlagTracedGuid | WnodeFlags.WnodeFlagUseMofPointer;
                evt.Header.BufferSize    = (ushort)EtwStructSizes.SizeofEventHeader + 2 * (ushort)EtwStructSizes.SizeofMofField;

                evt.Mof2.Length = (uint)dataLength;


                evt.Mof1.Length = 16;
                evt.Mof1.Data   = (IntPtr)(&guid);


                fixed(char *pdata = xml)
                {
                    evt.Mof2.Data = (IntPtr)pdata;
                    if (null != Provider)
                    {
                        result = provider.Trace((MofEvent *)&evt);
                    }
                }
            }

            return(result);
        }
Example #2
0
        static unsafe uint TraceInternal(Guid guid, string xml, TraceType type)
        {
            uint result = unchecked((uint)-1);

            if (null != Provider && Provider.ShouldTrace)
            {
                int dataLength = (xml.Length + 1) * 2 < MaxSupportedStringSize ? (xml.Length + 1) * 2 : MaxSupportedStringSize;

                Mof2Event evt = new Mof2Event();
                evt.Header.Guid = WCFTraceGuid;
                evt.Header.Type = (byte)type;
                evt.Header.ClientContext = 0;
                evt.Header.Flags = WnodeFlags.WnodeFlagTracedGuid | WnodeFlags.WnodeFlagUseMofPointer;
                evt.Header.BufferSize = (ushort)EtwStructSizes.SizeofEventHeader + 2 * (ushort)EtwStructSizes.SizeofMofField;

                evt.Mof2.Length = (uint)dataLength;


                evt.Mof1.Length = 16;
                evt.Mof1.Data = (IntPtr)(&guid);


                fixed (char* pdata = xml)
                {
                    evt.Mof2.Data = (IntPtr)pdata;
                    if (null != Provider)
                    {
                        result = provider.Trace((MofEvent*)&evt);
                    }
                }
            }

            return result;
        }