Exemple #1
0
        public static CrashData Read(RegistryKey parentKey, string subKeyName)
        {
            CrashData result;

            using (RegistryKey registryKey = parentKey.OpenSubKey(subKeyName))
            {
                try
                {
                    DateTime dateTime = new DateTime(Util.ReadRegistryLong(registryKey, "CrashTime"));
                    object   value    = registryKey.GetValue("CrashCount");
                    if (!(value is int))
                    {
                        result = null;
                    }
                    else
                    {
                        result = new CrashData((int)value, dateTime);
                    }
                }
                catch (FormatException)
                {
                    result = null;
                }
                catch (OverflowException)
                {
                    result = null;
                }
                catch (ArgumentOutOfRangeException)
                {
                    result = null;
                }
            }
            return(result);
        }
        // Token: 0x06000359 RID: 857 RVA: 0x00010A98 File Offset: 0x0000EC98
        public PoisonControl(PoisonControlMaster master, DatabaseInfo databaseInfo, string subKeyContainerName)
        {
            this.master             = master;
            this.databaseInfo       = databaseInfo;
            this.subKeyDatabaseName = databaseInfo.Guid.ToString() + "\\" + subKeyContainerName;
            if (this.master.RegistryKey == null)
            {
                return;
            }
            ExTraceGlobals.PoisonControlTracer.TraceDebug <PoisonControl, string, string>((long)this.GetHashCode(), "{0}: Creating registry key '{1}\\{2}'", this, this.master.RegistryKey.Name, this.subKeyDatabaseName);
            this.registryKeyDatabase = this.master.RegistryKey.CreateSubKey(this.subKeyDatabaseName, RegistryKeyPermissionCheck.ReadWriteSubTree);
            DateTime utcNow = DateTime.UtcNow;

            string[] subKeyNames = this.registryKeyDatabase.GetSubKeyNames();
            foreach (string text in subKeyNames)
            {
                ExTraceGlobals.PoisonControlTracer.TraceDebug <PoisonControl, string, string>((long)this.GetHashCode(), "{0}: Opening registry key '{1}\\{2}'", this, this.registryKeyDatabase.Name, text);
                CrashData crashData = CrashData.Read(this.registryKeyDatabase, text);
                if (crashData == null)
                {
                    ExTraceGlobals.PoisonControlTracer.TraceDebug <PoisonControl, string, string>((long)this.GetHashCode(), "{0}: Discarding registry key '{1}\\{2}' because it has no useful data", this, this.registryKeyDatabase.Name, text);
                    this.RemoveSubKey(text);
                }
                else if (utcNow - crashData.Time > PoisonControl.MaximumKeyAge)
                {
                    ExTraceGlobals.PoisonControlTracer.TraceDebug((long)this.GetHashCode(), "{0}: Discarding registry key '{1}\\{2}' because it is old ({3})", new object[]
                    {
                        this,
                        this.registryKeyDatabase.Name,
                        text,
                        crashData.Time
                    });
                    this.RemoveSubKey(text);
                }
                else
                {
                    ExTraceGlobals.PoisonControlTracer.TraceDebug <PoisonControl, string, string>((long)this.GetHashCode(), "{0}: Loading registry key '{1}\\{2}'", this, this.registryKeyDatabase.Name, text);
                    this.LoadCrashData(text, crashData.Count);
                }
            }
        }
 // Token: 0x0600035D RID: 861 RVA: 0x00010CC8 File Offset: 0x0000EEC8
 protected void SaveCrashData(string subKeyName, int crashCount)
 {
     CrashData.Write(this.registryKeyDatabase, subKeyName, crashCount);
 }