public void UnRegister()
 {
     lock (EventProviderStreamsLock)
     {
         if (s_Streams != null)
         {
             if (this == s_Streams)
             {
                 s_Streams = this.m_Next;
             }
             else
             {
                 EventProviderDataStream stream = s_Streams;
                 while (true)
                 {
                     EventProviderDataStream next = stream.m_Next;
                     if (next == null)
                     {
                         break;
                     }
                     if (next == this)
                     {
                         stream.m_Next = next.m_Next;
                         this.RemoveStreamFromProviders(next);
                         break;
                     }
                     stream = next;
                 }
             }
         }
     }
 }
 internal EventProviderDataStream(Action <EventWrittenEventArgs> callBack, EventProviderDataStream next, bool[] eventEnabled, EventProviderDataStream masterStream)
 {
     this.m_Callback     = callBack;
     this.m_Next         = next;
     this.m_EventEnabled = eventEnabled;
     this.m_MasterStream = masterStream;
 }
 private void RemoveStreamFromProviders(EventProviderDataStream streamToRemove)
 {
     foreach (WeakReference reference in s_providers)
     {
         EventProviderBase target = reference.Target as EventProviderBase;
         if (target != null)
         {
             if (target.m_OutputStreams.m_MasterStream == streamToRemove)
             {
                 target.m_OutputStreams = target.m_OutputStreams.m_Next;
             }
             else
             {
                 EventProviderDataStream outputStreams = target.m_OutputStreams;
                 while (true)
                 {
                     EventProviderDataStream next = outputStreams.m_Next;
                     if (next == null)
                     {
                         break;
                     }
                     if (next.m_MasterStream == streamToRemove)
                     {
                         outputStreams.m_Next = next.m_Next;
                         break;
                     }
                     outputStreams = next;
                 }
             }
         }
     }
 }
Example #4
0
 protected void SetEnabled(EventProviderDataStream outputStream, int eventId, bool value)
 {
     if (outputStream == null)
     {
         this.m_eventData[eventId].EnabledForETW = value;
     }
     else
     {
         outputStream.m_EventEnabled[eventId] = value;
         if (value)
         {
             this.m_providerEnabled = true;
             this.m_eventData[eventId].EnabledForAnyStream = true;
         }
         else
         {
             this.m_eventData[eventId].EnabledForAnyStream = false;
             for (EventProviderDataStream stream = this.m_OutputStreams; stream != null; stream = stream.m_Next)
             {
                 if (stream.m_EventEnabled[eventId])
                 {
                     this.m_eventData[eventId].EnabledForAnyStream = true;
                     return;
                 }
             }
         }
     }
 }
Example #5
0
 protected EventProviderBase(System.Guid providerGuid, string providerName)
 {
     if (providerName == null)
     {
         providerName = base.GetType().Name;
     }
     this.m_name     = providerName;
     this.m_guid     = providerGuid;
     this.m_provider = new OverideEventProvider(this);
     try
     {
         this.m_provider.Register(providerGuid);
     }
     catch (ArgumentException)
     {
         this.m_provider = null;
     }
     if (this.m_providerEnabled && !this.m_ETWManifestSent)
     {
         this.SendManifest(this.m_rawManifest, null);
         this.m_ETWManifestSent = true;
     }
     this.m_completelyInited = true;
     EventProviderDataStream.AddProvider(this);
 }
 internal EventProviderDataStream(Action<EventWrittenEventArgs> callBack, EventProviderDataStream next, bool[] eventEnabled, EventProviderDataStream masterStream)
 {
     this.m_Callback = callBack;
     this.m_Next = next;
     this.m_EventEnabled = eventEnabled;
     this.m_MasterStream = masterStream;
 }
Example #7
0
        private unsafe bool SendManifest(byte[] rawManifest, EventProviderDataStream outputStream)
        {
            fixed(byte *numRef = rawManifest)
            {
                EventDescriptorInternal eventDescriptor = new EventDescriptorInternal(0xfffe, 1, 0, 0, 0xfe, 0, -1L);
                ManifestEnvelope        envelope        = new ManifestEnvelope {
                    Format       = ManifestEnvelope.ManifestFormats.SimpleXmlFormat,
                    MajorVersion = 1,
                    MinorVersion = 0,
                    Magic        = 0x5b
                };
                int length = rawManifest.Length;

                envelope.TotalChunks = (ushort)((length + 0xfeff) / 0xff00);
                envelope.ChunkNumber = 0;
                EventProvider.EventData *dataPtr = (EventProvider.EventData *) stackalloc byte[(((IntPtr)2) * sizeof(EventProvider.EventData))];
                dataPtr->Ptr        = (ulong)((IntPtr) & envelope);
                dataPtr->Size       = (uint)sizeof(ManifestEnvelope);
                dataPtr->Reserved   = 0;
                dataPtr[1].Ptr      = (ulong)numRef;
                dataPtr[1].Reserved = 0;
                bool flag = true;

                while (length > 0)
                {
                    dataPtr[1].Size = (uint)Math.Min(length, 0xff00);
                    if (((outputStream == null) && (this.m_provider != null)) && !this.m_provider.WriteEvent(ref eventDescriptor, 2, (IntPtr)dataPtr))
                    {
                        flag = false;
                    }
                    if (outputStream != null)
                    {
                        byte[] destination = null;
                        byte[] buffer2     = null;
                        if (destination == null)
                        {
                            destination = new byte[dataPtr->Size];
                            buffer2     = new byte[dataPtr[1].Size];
                        }
                        Marshal.Copy((IntPtr)dataPtr->Ptr, destination, 0, (int)dataPtr->Size);
                        Marshal.Copy((IntPtr)dataPtr[1].Ptr, buffer2, 0, (int)dataPtr[1].Size);
                        this.m_eventCallbackArgs.EventId = eventDescriptor.EventId;
                        this.m_eventCallbackArgs.Payload = new object[] { destination, buffer2 };
                        outputStream.m_Callback(this.m_eventCallbackArgs);
                    }
                    length -= 0xff00;
                    envelope.ChunkNumber = (ushort)(envelope.ChunkNumber + 1);
                }
                return(flag);
            }
        }
Example #8
0
 private void WriteToAllStreams(int eventId, params object[] args)
 {
     this.m_eventCallbackArgs.EventId = eventId;
     this.m_eventCallbackArgs.Payload = args;
     for (EventProviderDataStream stream = this.m_OutputStreams; stream != null; stream = stream.m_Next)
     {
         if (stream.m_EventEnabled[eventId])
         {
             stream.m_Callback(this.m_eventCallbackArgs);
         }
     }
     if (this.m_eventData[eventId].CaptureStack)
     {
         this.CaptureStack();
     }
 }
 public static EventProviderDataStream Register(Action <EventWrittenEventArgs> callBack)
 {
     lock (EventProviderStreamsLock)
     {
         EventProviderDataStream masterStream = new EventProviderDataStream(callBack, s_Streams, null, null);
         s_Streams = masterStream;
         foreach (WeakReference reference in s_providers)
         {
             EventProviderBase target = reference.Target as EventProviderBase;
             if (target != null)
             {
                 target.m_OutputStreams = new EventProviderDataStream(callBack, target.m_OutputStreams, new bool[target.EventIdLimit], masterStream);
             }
         }
         return(masterStream);
     }
 }
 internal static void AddProvider(EventProviderBase newProvider)
 {
     lock (EventProviderStreamsLock)
     {
         if (s_providers == null)
         {
             s_providers = new List <WeakReference>(2);
         }
         int count = -1;
         if ((s_providers.Count % 0x40) == 0x3f)
         {
             for (int i = 0; i < s_providers.Count; i++)
             {
                 WeakReference reference = s_providers[i];
                 if (!reference.IsAlive)
                 {
                     count            = i;
                     reference.Target = newProvider;
                     break;
                 }
             }
         }
         if (count < 0)
         {
             count = s_providers.Count;
             s_providers.Add(new WeakReference(newProvider));
         }
         newProvider.m_id = count;
         for (EventProviderDataStream stream = s_Streams; stream != null; stream = stream.m_Next)
         {
             newProvider.m_OutputStreams = new EventProviderDataStream(stream.m_Callback, newProvider.m_OutputStreams, new bool[newProvider.EventIdLimit], stream);
         }
         EventHandler <EventProviderCreatedEventArgs> handler = s_EventProviderCreated;
         if (handler != null)
         {
             EventProviderCreatedEventArgs e = new EventProviderCreatedEventArgs {
                 Provider = newProvider
             };
             handler(null, e);
         }
     }
 }
Example #11
0
 protected virtual void OnControllerCommand(EventProviderDataStream outputStream, ControllerCommand command, IDictionary <string, string> arguments)
 {
 }
Example #12
0
 protected bool IsEnabled(EventProviderDataStream outputStream, int eventId)
 {
     return(outputStream.m_EventEnabled[eventId]);
 }
 protected void SetEnabled(EventProviderDataStream outputStream, int eventId, bool value)
 {
     if (outputStream == null)
     {
         this.m_eventData[eventId].EnabledForETW = value;
     }
     else
     {
         outputStream.m_EventEnabled[eventId] = value;
         if (value)
         {
             this.m_providerEnabled = true;
             this.m_eventData[eventId].EnabledForAnyStream = true;
         }
         else
         {
             this.m_eventData[eventId].EnabledForAnyStream = false;
             for (EventProviderDataStream stream = this.m_OutputStreams; stream != null; stream = stream.m_Next)
             {
                 if (stream.m_EventEnabled[eventId])
                 {
                     this.m_eventData[eventId].EnabledForAnyStream = true;
                     return;
                 }
             }
         }
     }
 }
Example #14
0
            protected override void OnControllerCommand(ControllerCommand command, IDictionary <string, string> arguments)
            {
                EventProviderDataStream outputStream = null;

                this.m_eventProviderBase.SendCommand(outputStream, base.IsEnabled(), base.Level, base.MatchAnyKeyword, command, arguments);
            }
Example #15
0
        private unsafe bool SendManifest(byte[] rawManifest, EventProviderDataStream outputStream) 
        { 
            fixed (byte* dataPtr = rawManifest)
            { 
                EventDescriptorInternal manifestDescr = new EventDescriptorInternal(0xFFFE, 1, 0, 0, 0xFE, 0, -1);
                ManifestEnvelope envelope = new ManifestEnvelope();

                envelope.Format = ManifestEnvelope.ManifestFormats.SimpleXmlFormat; 
                envelope.MajorVersion = 1;
                envelope.MinorVersion = 0; 
                envelope.Magic = 0x5B;              // An unusual number that can be checked for consistancy. 
                int dataLeft = rawManifest.Length;
                envelope.TotalChunks = (ushort)((dataLeft + (ManifestEnvelope.MaxChunkSize - 1)) / ManifestEnvelope.MaxChunkSize); 
                envelope.ChunkNumber = 0;

                EventProvider.EventData* dataDescrs = stackalloc EventProvider.EventData[2];
                dataDescrs[0].Ptr = (ulong)&envelope; 
                dataDescrs[0].Size = (uint)sizeof(ManifestEnvelope);
                dataDescrs[0].Reserved = 0; 
 
                dataDescrs[1].Ptr = (ulong)dataPtr;
                dataDescrs[1].Reserved = 0; 

                bool success = true;
                while (dataLeft > 0)
                { 
                    dataDescrs[1].Size = (uint)Math.Min(dataLeft, ManifestEnvelope.MaxChunkSize);
#if ETW_SUPPORTED 
                    if (outputStream == null && m_provider != null && !m_provider.WriteEvent(ref manifestDescr, 2, (IntPtr)dataDescrs)) 
                        success = false;
#endif 
                    if (outputStream != null)
                    {
                        byte[] envelopeBlob = null;
                        byte[] manifestBlob = null; 
                        if (envelopeBlob == null)
                        { 
                            envelopeBlob = new byte[dataDescrs[0].Size]; 
                            manifestBlob = new byte[dataDescrs[1].Size];
                        } 
                        System.Runtime.InteropServices.Marshal.Copy((IntPtr)dataDescrs[0].Ptr, envelopeBlob, 0, (int)dataDescrs[0].Size);
                        System.Runtime.InteropServices.Marshal.Copy((IntPtr)dataDescrs[1].Ptr, manifestBlob, 0, (int)dataDescrs[1].Size);

                        m_eventCallbackArgs.EventId = manifestDescr.EventId; 
                        m_eventCallbackArgs.Payload = new object[] { envelopeBlob, manifestBlob };
                        outputStream.m_Callback(m_eventCallbackArgs); 
                    } 

                    dataLeft -= ManifestEnvelope.MaxChunkSize; 
                    envelope.ChunkNumber++;
                }
                return success;
            } 
        }
Example #16
0
        internal void SendCommand(EventProviderDataStream outputStream, bool enable, EventLevel level, EventKeywords matchAnyKeyword, ControllerCommand command, IDictionary<string, string> commandArguments) 
        {
            InsureInitialized();
            if (m_OutputStreams != null && m_eventCallbackArgs == null)
                m_eventCallbackArgs = new EventWrittenEventArgs(this); 

            m_providerEnabled = enable; 
            m_level = level; 
            m_matchAnyKeyword = matchAnyKeyword;
 
            // Find the per-Provider stream cooresponding to registered outputStream
            EventProviderDataStream providerOutputStream = m_OutputStreams;
            if (providerOutputStream != null)
            { 
                for (; ; )
                { 
                    if (providerOutputStream == null) 
                        throw new ArgumentException("outputStream not found");
                    if (providerOutputStream.m_MasterStream == outputStream) 
                        break;
                    providerOutputStream = providerOutputStream.m_Next;
                }
            } 

            if (enable) 
            { 
                // Send the manifest if the stream once per stream
                if (providerOutputStream != null) 
                {
                    if (!providerOutputStream.m_ManifestSent)
                    {
                        providerOutputStream.m_ManifestSent = true; 
                        SendManifest(m_rawManifest, providerOutputStream);
                    } 
                } 
                else
                { 
                    // providerOutputStream == null means this is the ETW manifest
                    // If we are not completely initalized we can't send the manifest because WriteEvent
                    // will fail (handle was not returned from OS API).  We will try again after the
                    // constuctor completes. 
                    if (!m_ETWManifestSent && m_completelyInited)
                    { 
                        m_ETWManifestSent = true; 
                        SendManifest(m_rawManifest, providerOutputStream);
                    } 
                }
            }
            else
            {   // 
                if (providerOutputStream != null)
                    providerOutputStream.m_ManifestSent = false; 
                else 
                    m_ETWManifestSent = false;
            } 

            // Set it up using the 'standard' filtering bitfields
            for (int i = 0; i < m_eventData.Length; i++)
                SetEnabled(providerOutputStream, i, IsEnabledDefault(i, level, matchAnyKeyword)); 

            if (commandArguments == null) 
                commandArguments = new Dictionary<string, string>(); 

            // Allow subclasses to fiddle with it from there. 
            OnControllerCommand(providerOutputStream, command, commandArguments);

        }
 private void RemoveStreamFromProviders(EventProviderDataStream streamToRemove)
 {
     foreach (WeakReference reference in s_providers)
     {
         EventProviderBase target = reference.Target as EventProviderBase;
         if (target != null)
         {
             if (target.m_OutputStreams.m_MasterStream == streamToRemove)
             {
                 target.m_OutputStreams = target.m_OutputStreams.m_Next;
             }
             else
             {
                 EventProviderDataStream outputStreams = target.m_OutputStreams;
                 while (true)
                 {
                     EventProviderDataStream next = outputStreams.m_Next;
                     if (next == null)
                     {
                         break;
                     }
                     if (next.m_MasterStream == streamToRemove)
                     {
                         outputStreams.m_Next = next.m_Next;
                         break;
                     }
                     outputStreams = next;
                 }
             }
         }
     }
 }
Example #18
0
 protected void SetEnabled(EventProviderDataStream outputStream, int eventId, bool value)
 {
     if (outputStream == null)
     { 
         Contract.Assert(m_providerEnabled || !value, "m_providerEnabled || !value");
         m_eventData[eventId].EnabledForETW = value; 
     } 
     else
     { 
         outputStream.m_EventEnabled[eventId] = value;
         if (value)
         {
             m_providerEnabled = true; 
             m_eventData[eventId].EnabledForAnyStream = true;
         } 
         else 
         {
             m_eventData[eventId].EnabledForAnyStream = false; 
             for (EventProviderDataStream stream = m_OutputStreams; stream != null; stream = stream.m_Next)
                 if (stream.m_EventEnabled[eventId])
                 {
                     m_eventData[eventId].EnabledForAnyStream = true; 
                     break;
                 } 
         } 
     }
 } 
Example #19
0
 /// <summary> 
 /// This method is called when the provider is updated by the controller.
 /// </summary> 
 protected virtual void OnControllerCommand(EventProviderDataStream outputStream, ControllerCommand command, IDictionary<string, string> arguments) { }
 private unsafe bool SendManifest(byte[] rawManifest, EventProviderDataStream outputStream)
 {
     fixed (byte* numRef = rawManifest)
     {
         EventDescriptorInternal eventDescriptor = new EventDescriptorInternal(0xfffe, 1, 0, 0, 0xfe, 0, -1L);
         ManifestEnvelope envelope = new ManifestEnvelope {
             Format = ManifestEnvelope.ManifestFormats.SimpleXmlFormat,
             MajorVersion = 1,
             MinorVersion = 0,
             Magic = 0x5b
         };
         int length = rawManifest.Length;
         envelope.TotalChunks = (ushort) ((length + 0xfeff) / 0xff00);
         envelope.ChunkNumber = 0;
         EventProvider.EventData* dataPtr = (EventProvider.EventData*) stackalloc byte[(((IntPtr) 2) * sizeof(EventProvider.EventData))];
         dataPtr->Ptr = (ulong) ((IntPtr) &envelope);
         dataPtr->Size = (uint) sizeof(ManifestEnvelope);
         dataPtr->Reserved = 0;
         dataPtr[1].Ptr = (ulong) numRef;
         dataPtr[1].Reserved = 0;
         bool flag = true;
         while (length > 0)
         {
             dataPtr[1].Size = (uint) Math.Min(length, 0xff00);
             if (((outputStream == null) && (this.m_provider != null)) && !this.m_provider.WriteEvent(ref eventDescriptor, 2, (IntPtr) dataPtr))
             {
                 flag = false;
             }
             if (outputStream != null)
             {
                 byte[] destination = null;
                 byte[] buffer2 = null;
                 if (destination == null)
                 {
                     destination = new byte[dataPtr->Size];
                     buffer2 = new byte[dataPtr[1].Size];
                 }
                 Marshal.Copy((IntPtr) dataPtr->Ptr, destination, 0, (int) dataPtr->Size);
                 Marshal.Copy((IntPtr) dataPtr[1].Ptr, buffer2, 0, (int) dataPtr[1].Size);
                 this.m_eventCallbackArgs.EventId = eventDescriptor.EventId;
                 this.m_eventCallbackArgs.Payload = new object[] { destination, buffer2 };
                 outputStream.m_Callback(this.m_eventCallbackArgs);
             }
             length -= 0xff00;
             envelope.ChunkNumber = (ushort) (envelope.ChunkNumber + 1);
         }
         return flag;
     }
 }
 public void UnRegister()
 {
     lock (EventProviderStreamsLock)
     {
         if (s_Streams != null)
         {
             if (this == s_Streams)
             {
                 s_Streams = this.m_Next;
             }
             else
             {
                 EventProviderDataStream stream = s_Streams;
                 while (true)
                 {
                     EventProviderDataStream next = stream.m_Next;
                     if (next == null)
                     {
                         break;
                     }
                     if (next == this)
                     {
                         stream.m_Next = next.m_Next;
                         this.RemoveStreamFromProviders(next);
                         break;
                     }
                     stream = next;
                 }
             }
         }
     }
 }
Example #22
0
        internal void SendCommand(EventProviderDataStream outputStream, bool enable, EventLevel level, EventKeywords matchAnyKeyword, ControllerCommand command, IDictionary <string, string> commandArguments)
        {
            this.InsureInitialized();
            if ((this.m_OutputStreams != null) && (this.m_eventCallbackArgs == null))
            {
                this.m_eventCallbackArgs = new EventWrittenEventArgs(this);
            }
            this.m_providerEnabled = enable;
            this.m_level           = level;
            this.m_matchAnyKeyword = matchAnyKeyword;
            EventProviderDataStream outputStreams = this.m_OutputStreams;

            if (outputStreams == null)
            {
                goto Label_0062;
            }
Label_0042:
            if (outputStreams == null)
            {
                throw new ArgumentException("outputStream not found");
            }
            if (outputStreams.m_MasterStream != outputStream)
            {
                outputStreams = outputStreams.m_Next;
                goto Label_0042;
            }
Label_0062:
            if (enable)
            {
                if (outputStreams != null)
                {
                    if (!outputStreams.m_ManifestSent)
                    {
                        outputStreams.m_ManifestSent = true;
                        this.SendManifest(this.m_rawManifest, outputStreams);
                    }
                }
                else if (!this.m_ETWManifestSent && this.m_completelyInited)
                {
                    this.m_ETWManifestSent = true;
                    this.SendManifest(this.m_rawManifest, outputStreams);
                }
            }
            else if (outputStreams != null)
            {
                outputStreams.m_ManifestSent = false;
            }
            else
            {
                this.m_ETWManifestSent = false;
            }
            for (int i = 0; i < this.m_eventData.Length; i++)
            {
                this.SetEnabled(outputStreams, i, this.IsEnabledDefault(i, level, matchAnyKeyword));
            }
            if (commandArguments == null)
            {
                commandArguments = new Dictionary <string, string>();
            }
            this.OnControllerCommand(outputStreams, command, commandArguments);
        }
Example #23
0
 protected bool IsEnabled(EventProviderDataStream outputStream, int eventId)
 {
     return outputStream.m_EventEnabled[eventId]; 
 }
Example #24
0
        public static EventProviderDataStream Register(Action<EventWrittenEventArgs> callBack)
        { 
            lock (EventProviderStreamsLock)
            { 
                // Add the outputStream to the global list of EventProviderDataStreams. 
                EventProviderDataStream ret = new EventProviderDataStream(callBack, s_Streams, null, null);
                s_Streams = ret; 

                // Add the outputStream  to each existing EventProvider.
                foreach (WeakReference providerRef in s_providers)
                { 
                    EventProviderBase providerBase = providerRef.Target as EventProviderBase;
                    if (providerBase != null) 
                        providerBase.m_OutputStreams = new EventProviderDataStream(callBack, providerBase.m_OutputStreams, new bool[providerBase.EventIdLimit], ret); 
                }
 
                return ret;
            }
        }
 public static EventProviderDataStream Register(Action<EventWrittenEventArgs> callBack)
 {
     lock (EventProviderStreamsLock)
     {
         EventProviderDataStream masterStream = new EventProviderDataStream(callBack, s_Streams, null, null);
         s_Streams = masterStream;
         foreach (WeakReference reference in s_providers)
         {
             EventProviderBase target = reference.Target as EventProviderBase;
             if (target != null)
             {
                 target.m_OutputStreams = new EventProviderDataStream(callBack, target.m_OutputStreams, new bool[target.EventIdLimit], masterStream);
             }
         }
         return masterStream;
     }
 }
Example #26
0
 private void RemoveStreamFromProviders(EventProviderDataStream streamToRemove)
 { 
     // Foreach existing Provider
     foreach (WeakReference providerRef in s_providers) 
     { 
         EventProviderBase providerBase = providerRef.Target as EventProviderBase;
         if (providerBase != null) 
         {
             // Is the first output outputStream the outputStream we are removing?
             if (providerBase.m_OutputStreams.m_MasterStream == streamToRemove)
                 providerBase.m_OutputStreams = providerBase.m_OutputStreams.m_Next; 
             else
             { 
                 // Remove 'streamToRemove' from the providerBase.m_OutputStreams linked list. 
                 EventProviderDataStream prev = providerBase.m_OutputStreams;
                 for (; ; ) 
                 {
                     EventProviderDataStream cur = prev.m_Next;
                     if (cur == null)
                     { 
                         Contract.Assert(false, "Provider did not have a registers EventProviderDataStream!");
                         break; 
                     } 
                     if (cur.m_MasterStream == streamToRemove)
                     { 
                         prev.m_Next = cur.m_Next;       // Remove entry.
                         break;
                     }
                     prev = cur; 
                 }
             } 
         } 
     }
 } 
 internal void SendCommand(EventProviderDataStream outputStream, bool enable, EventLevel level, EventKeywords matchAnyKeyword, ControllerCommand command, IDictionary<string, string> commandArguments)
 {
     this.InsureInitialized();
     if ((this.m_OutputStreams != null) && (this.m_eventCallbackArgs == null))
     {
         this.m_eventCallbackArgs = new EventWrittenEventArgs(this);
     }
     this.m_providerEnabled = enable;
     this.m_level = level;
     this.m_matchAnyKeyword = matchAnyKeyword;
     EventProviderDataStream outputStreams = this.m_OutputStreams;
     if (outputStreams == null)
     {
         goto Label_0062;
     }
 Label_0042:
     if (outputStreams == null)
     {
         throw new ArgumentException("outputStream not found");
     }
     if (outputStreams.m_MasterStream != outputStream)
     {
         outputStreams = outputStreams.m_Next;
         goto Label_0042;
     }
 Label_0062:
     if (enable)
     {
         if (outputStreams != null)
         {
             if (!outputStreams.m_ManifestSent)
             {
                 outputStreams.m_ManifestSent = true;
                 this.SendManifest(this.m_rawManifest, outputStreams);
             }
         }
         else if (!this.m_ETWManifestSent && this.m_completelyInited)
         {
             this.m_ETWManifestSent = true;
             this.SendManifest(this.m_rawManifest, outputStreams);
         }
     }
     else if (outputStreams != null)
     {
         outputStreams.m_ManifestSent = false;
     }
     else
     {
         this.m_ETWManifestSent = false;
     }
     for (int i = 0; i < this.m_eventData.Length; i++)
     {
         this.SetEnabled(outputStreams, i, this.IsEnabledDefault(i, level, matchAnyKeyword));
     }
     if (commandArguments == null)
     {
         commandArguments = new Dictionary<string, string>();
     }
     this.OnControllerCommand(outputStreams, command, commandArguments);
 }