예제 #1
0
 public static void ProcessTraces(Guid providerGuid, string sessionName, EtwTraceLevel level, long keyword)
 {
     using (var listener = new EventRealtimeListener(providerGuid, sessionName, level, keyword))
     {
         listener.ProcessTraces();
     }
 }
예제 #2
0
        private void UpdateEtwEvents()
        {
            DisposeEtwEvents();
            if (!_state.EtwStarted)
            {
                return;
            }

            foreach (EtwProvider provider in App.Current.Settings.EtwProviders)
            {
                _etwListeners.TryGetValue(provider.Guid, out EventRealtimeListener listener);
                if (listener == null)
                {
                    if (!provider.IsActive)
                    {
                        continue;
                    }

                    // this would be a serialization bug
                    if (provider.Guid == Guid.Empty)
                    {
                        continue;
                    }

                    var level = (EtwTraceLevel)provider.TraceLevel;
                    listener                   = new EventRealtimeListener(provider.Guid, provider.Guid.ToString(), level);
                    listener.Description       = provider.Description;
                    listener.StringMessageMode = provider.StringMessageMode;

                    var t = new Thread(ProcessEtwTrace);
                    t.Start(listener);

                    listener.RealtimeEvent += OnEtwListenerRealtimeEvent;
                    _etwListeners.Add(provider.Guid, listener);
                }
                else
                {
                    if (!provider.IsActive)
                    {
                        listener.RealtimeEvent -= OnEtwListenerRealtimeEvent;
                        listener.Dispose();
                        _etwListeners.Remove(provider.Guid);
                        continue;
                    }
                    else
                    {
                        listener.Description       = provider.Description;
                        listener.StringMessageMode = provider.StringMessageMode;
                    }
                }
            }
        }
예제 #3
0
        private void UpdateEtwEvents()
        {
            DisposeEtwEvents();
            if (!_settings.CaptureEtwTraces)
            {
                return;
            }

            foreach (EtwProvider provider in _settings.EtwProviders)
            {
                EventRealtimeListener listener;
                _etwListeners.TryGetValue(provider.ProviderGuid, out listener);
                if (listener == null)
                {
                    if (!provider.Active)
                    {
                        continue;
                    }

                    // this would be a serialization bug
                    if (provider.ProviderGuid == Guid.Empty)
                    {
                        continue;
                    }

                    EtwTraceLevel level = (EtwTraceLevel)provider.TraceLevel;

                    listener             = new EventRealtimeListener(provider.ProviderGuid, provider.ProviderGuid.ToString(), level);
                    listener.Description = provider.Description;

                    Thread t = new Thread(ProcessEtwTrace);
                    t.Start(listener);

                    listener.RealtimeEvent += OnEtwListenerRealtimeEvent;
                    _etwListeners.Add(provider.ProviderGuid, listener);
                }
                else
                {
                    if (!provider.Active)
                    {
                        listener.RealtimeEvent -= OnEtwListenerRealtimeEvent;
                        listener.Dispose();
                        _etwListeners.Remove(provider.ProviderGuid);
                        continue;
                    }
                }
            }
        }
예제 #4
0
        private void OnEtwListenerRealtimeEvent(object sender, RealtimeEventArgs e)
        {
            EventRealtimeListener listener = (EventRealtimeListener)sender;

            Enqueue(e.ProcessId, e.Message, listener.Description);
        }
예제 #5
0
        private void ProcessEtwTrace(object state)
        {
            EventRealtimeListener listener = (EventRealtimeListener)state;

            listener.ProcessTraces();
        }
예제 #6
0
파일: Main.cs 프로젝트: Phrohdoh/TraceSpy
        private void UpdateEtwEvents()
        {
            DisposeEtwEvents();
            if (!_settings.CaptureEtwTraces)
                return;

            foreach (EtwProvider provider in _settings.EtwProviders)
            {
                EventRealtimeListener listener;
                _etwListeners.TryGetValue(provider.ProviderGuid, out listener);
                if (listener == null)
                {
                    if (!provider.Active)
                        continue;

                    // this would be a serialization bug
                    if (provider.ProviderGuid == Guid.Empty)
                        continue;

                    EtwTraceLevel level = (EtwTraceLevel)provider.TraceLevel;

                    listener = new EventRealtimeListener(provider.ProviderGuid, provider.ProviderGuid.ToString(), level);
                    listener.Description = provider.Description;

                    Thread t = new Thread(ProcessEtwTrace);
                    t.Start(listener);

                    listener.RealtimeEvent += OnEtwListenerRealtimeEvent;
                    _etwListeners.Add(provider.ProviderGuid, listener);
                }
                else
                {
                    if (!provider.Active)
                    {
                        listener.RealtimeEvent -= OnEtwListenerRealtimeEvent;
                        listener.Dispose();
                        _etwListeners.Remove(provider.ProviderGuid);
                        continue;
                    }
                }
            }
        }