コード例 #1
0
        public override void MoveFirst(bool autoMove = true)
        {
            BadRegKeyArray.Clear();
            Scan.EnabledScanners.Clear();

            base.MoveFirst(autoMove);
        }
コード例 #2
0
        public override bool OnUnloaded(bool forceExit)
        {
            bool exit;

            var scan = CurrentControl as Scan;

            if (scan != null)
            {
                exit = forceExit ||
                       MessageBox.Show("Would you like to cancel the scan that's in progress?", Utils.ProductName,
                                       MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes;

                if (!exit)
                {
                    return(false);
                }

                scan.AbortScanThread();
                BadRegKeyArray.Clear();
                Scan.EnabledScanners.Clear();

                return(true);
            }

            var results = CurrentControl as Results;

            if (results == null)
            {
                return(true);
            }

            if (!forceExit && ((Results)CurrentControl).FixProblemsRunning)
            {
                return(false);
            }

            exit = forceExit ||
                   MessageBox.Show("Would you like to cancel?", Utils.ProductName, MessageBoxButton.YesNo,
                                   MessageBoxImage.Question) == MessageBoxResult.Yes;

            if (!exit)
            {
                return(false);
            }

            // Forced to exit -> abort fix task
            ((Results)CurrentControl).CancelFixIfRunning();

            BadRegKeyArray.Clear();
            Scan.EnabledScanners.Clear();

            return(true);
        }
コード例 #3
0
        /// <summary>
        ///     <para>Stores an invalid registry key to array list</para>
        ///     <para>Use IsOnIgnoreList to check for ignored registry keys and paths</para>
        /// </summary>
        /// <param name="problem">Reason its invalid</param>
        /// <param name="regPath">The path to registry key (including registry hive)</param>
        /// <param name="valueName">Value name (See remarks)</param>
        /// <remarks>Set value name to null/empty for no value name or (default) to use default value</remarks>
        /// <returns>True if it was added. Otherwise, false.</returns>
        internal static bool StoreInvalidKey(string problem, string regPath, string valueName)
        {
            string baseKey, subKey;

            // Check for null parameters
            if (string.IsNullOrEmpty(problem) || string.IsNullOrEmpty(regPath))
            {
                return(false);
            }

            // Make sure registry key isnt already in array
            if (BadRegKeyArray.Contains(regPath, valueName))
            {
                return(false);
            }

            // Make sure registry key exists
            if (!Utils.RegKeyExists(regPath))
            {
                return(false);
            }

            // Parse registry key to base and subkey
            if (!Utils.ParseRegKeyPath(regPath, out baseKey, out subKey))
            {
                return(false);
            }

            // Check for ignored registry path
            if (IsOnIgnoreList(regPath))
            {
                return(false);
            }

            using (var regKey = Utils.RegOpenKey(regPath, false))
            {
                // Can we get write access?
                if (regKey == null)
                {
                    return(false);
                }

                // Can we delete it?
                if (!ScanFunctions.CanDeleteKey(regKey))
                {
                    return(false);
                }
            }

            // If value name is specified, see if it exists
            if (!string.IsNullOrEmpty(valueName))
            {
                if (!ScanFunctions.ValueNameExists(baseKey, subKey, valueName))
                {
                    return(false);
                }
            }

            var severity = 1;

            if (problem == Strings.InvalidFile)
            {
                severity = 5;
            }
            else if (problem == Strings.InvalidFileExt)
            {
                severity = 2;
            }
            else if (problem == Strings.InvalidInprocServer)
            {
                severity = 4;
            }
            else if (problem == Strings.InvalidInprocServer32)
            {
                severity = 4;
            }
            else if (problem == Strings.InvalidProgIDFileExt)
            {
                severity = 3;
            }
            else if (problem == Strings.InvalidRegKey)
            {
                severity = 2;
            }
            else if (problem == Strings.InvalidToolbar)
            {
                severity = 4;
            }
            else if (problem == Strings.MissingAppID)
            {
                severity = 5;
            }
            else if (problem == Strings.MissingCLSID)
            {
                severity = 5;
            }
            else if (problem == Strings.MissingProgID)
            {
                severity = 5;
            }
            else if (problem == Strings.NoRegKey)
            {
                severity = 1;
            }
            else if (problem == Strings.ObsoleteRegKey)
            {
                severity = 1;
            }

            BadRegKeyArray.Add(new BadRegistryKey(CurrentScannerName, problem, baseKey, subKey, valueName, severity));

            Report.WriteLine(!string.IsNullOrEmpty(valueName)
                ? $"Bad Registry Value Found! Problem: \"{problem}\" Path: \"{regPath}\" Value Name: \"{valueName}\""
                : $"Bad Registry Key Found! Problem: \"{problem}\" Path: \"{regPath}\"");

            return(true);
        }
コード例 #4
0
        /// <summary>
        ///     Go back to the scan control
        /// </summary>
        public void Rescan()
        {
            BadRegKeyArray.Clear();

            SetCurrentControl(1);
        }