Exemple #1
0
 private unsafe void EtwEnableCallBack([In] ref Guid sourceId, [In] int controlCode, [In] byte setLevel, [In] long anyKeyword, [In] long allKeyword, [In] UnsafeNativeMethods.ManifestEtw.EVENT_FILTER_DESCRIPTOR *filterData, [In] void *callbackContext)
 {
     try
     {
         ControllerCommand            command   = ControllerCommand.Update;
         IDictionary <string, string> arguments = (IDictionary <string, string>)null;
         bool flag1 = false;
         if (controlCode == 1)
         {
             this.m_enabled        = true;
             this.m_level          = setLevel;
             this.m_anyKeywordMask = anyKeyword;
             this.m_allKeywordMask = allKeyword;
             List <Tuple <EventProvider.SessionInfo, bool> > sessions = this.GetSessions();
             foreach (Tuple <EventProvider.SessionInfo, bool> tuple in sessions)
             {
                 int  num1         = tuple.Item1.sessionIdBit;
                 int  etwSessionId = tuple.Item1.etwSessionId;
                 bool flag2        = tuple.Item2;
                 flag1     = true;
                 arguments = (IDictionary <string, string>)null;
                 if (sessions.Count > 1)
                 {
                     filterData = (UnsafeNativeMethods.ManifestEtw.EVENT_FILTER_DESCRIPTOR *)null;
                 }
                 byte[] data;
                 int    dataStart;
                 if (flag2 && this.GetDataFromController(etwSessionId, filterData, out command, out data, out dataStart))
                 {
                     arguments = (IDictionary <string, string>) new Dictionary <string, string>(4);
                     int null1;
                     for (; dataStart < data.Length; dataStart = null1 + 1)
                     {
                         int null2 = EventProvider.FindNull(data, dataStart);
                         int num2  = null2 + 1;
                         null1 = EventProvider.FindNull(data, num2);
                         if (null1 < data.Length)
                         {
                             string string1 = Encoding.UTF8.GetString(data, dataStart, null2 - dataStart);
                             string string2 = Encoding.UTF8.GetString(data, num2, null1 - num2);
                             arguments[string1] = string2;
                         }
                     }
                 }
                 this.OnControllerCommand(command, arguments, flag2 ? num1 : -num1, etwSessionId);
             }
         }
         else if (controlCode == 0)
         {
             this.m_enabled        = false;
             this.m_level          = (byte)0;
             this.m_anyKeywordMask = 0L;
             this.m_allKeywordMask = 0L;
             this.m_liveSessions   = (List <EventProvider.SessionInfo>)null;
         }
         else
         {
             if (controlCode != 2)
             {
                 return;
             }
             command = ControllerCommand.SendManifest;
         }
         if (flag1)
         {
             return;
         }
         this.OnControllerCommand(command, arguments, 0, 0);
     }
     catch (Exception ex)
     {
     }
 }
        private unsafe void EtwEnableCallBack([In] ref Guid sourceId, [In] int controlCode, [In] byte setLevel, [In] long anyKeyword, [In] long allKeyword, [In] UnsafeNativeMethods.ManifestEtw.EVENT_FILTER_DESCRIPTOR *filterData, [In] void *callbackContext)
        {
            try
            {
                ControllerCommand            command    = ControllerCommand.Update;
                IDictionary <string, string> dictionary = null;
                bool flag = false;
                if (controlCode == 1)
                {
                    this.m_enabled        = true;
                    this.m_level          = setLevel;
                    this.m_anyKeywordMask = anyKeyword;
                    this.m_allKeywordMask = allKeyword;
                    List <Tuple <EventProvider.SessionInfo, bool> > sessions = this.GetSessions();
                    using (List <Tuple <EventProvider.SessionInfo, bool> > .Enumerator enumerator = sessions.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            Tuple <EventProvider.SessionInfo, bool> tuple = enumerator.Current;
                            int  sessionIdBit = tuple.Item1.sessionIdBit;
                            int  etwSessionId = tuple.Item1.etwSessionId;
                            bool item         = tuple.Item2;
                            flag       = true;
                            dictionary = null;
                            if (sessions.Count > 1)
                            {
                                filterData = null;
                            }
                            byte[] array;
                            int    i;
                            if (item && this.GetDataFromController(etwSessionId, filterData, out command, out array, out i))
                            {
                                dictionary = new Dictionary <string, string>(4);
                                while (i < array.Length)
                                {
                                    int num  = EventProvider.FindNull(array, i);
                                    int num2 = num + 1;
                                    int num3 = EventProvider.FindNull(array, num2);
                                    if (num3 < array.Length)
                                    {
                                        string @string = Encoding.UTF8.GetString(array, i, num - i);
                                        string string2 = Encoding.UTF8.GetString(array, num2, num3 - num2);
                                        dictionary[@string] = string2;
                                    }
                                    i = num3 + 1;
                                }
                            }
                            this.OnControllerCommand(command, dictionary, item ? sessionIdBit : (-sessionIdBit), etwSessionId);
                        }
                        goto IL_162;
                    }
                }
                if (controlCode == 0)
                {
                    this.m_enabled        = false;
                    this.m_level          = 0;
                    this.m_anyKeywordMask = 0L;
                    this.m_allKeywordMask = 0L;
                    this.m_liveSessions   = null;
                }
                else
                {
                    if (controlCode != 2)
                    {
                        return;
                    }
                    command = ControllerCommand.SendManifest;
                }
IL_162:
                if (!flag)
                {
                    this.OnControllerCommand(command, dictionary, 0, 0);
                }
            }
            catch (Exception)
            {
            }
        }