Пример #1
0
        private void buttonAnalyze_Click(object sender, RoutedEventArgs e)
        {
            if (
                MessageBox.Show(Application.Current.MainWindow,
                                "You must close running programs before optimizing the registry.\nPlease save your work and close any running programs now.",
                                Utils.ProductName, MessageBoxButton.OKCancel, MessageBoxImage.Information) != MessageBoxResult.OK)
            {
                return;
            }

            Wizard.IsBusy = true;

            var secureDesktop = new SecureDesktop();

            secureDesktop.Show();

            var analyzeWnd = new Analyze();

            analyzeWnd.ShowDialog();

            secureDesktop.Close();

            Wizard.IsBusy = false;

            // Check registry size before continuing
            if (HiveManager.GetNewRegistrySize() <= 0 || IsCompacted)
            {
                MessageBox.Show(Application.Current.MainWindow,
                                "It appears that the registry has already been compacted.", Utils.ProductName, MessageBoxButton.OK,
                                MessageBoxImage.Error);
                return;
            }

            _scanBase.MoveNext();
        }
Пример #2
0
        private void InitHives()
        {
            RegistryKey regKeyHives;
            var         i = 0;

            Wizard.RegistryHives = new ObservableCollection <Hive>();

            using (regKeyHives = Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Control\hivelist"))
            {
                if (regKeyHives == null)
                {
                    throw new ApplicationException("Unable to open hive list... this can be a problem!");
                }

                foreach (var valueName in regKeyHives.GetValueNames())
                {
                    Dispatcher.Invoke(new Action(() => Message.Text = $"Loading {++i}/{regKeyHives.ValueCount} Hives"));

                    // Don't touch these hives because they are critical for Windows
                    if (valueName.Contains("BCD") || valueName.Contains("HARDWARE"))
                    {
                        continue;
                    }

                    var hivePath = regKeyHives.GetValue(valueName) as string;

                    if (string.IsNullOrEmpty(hivePath))
                    {
                        continue;
                    }

                    if (hivePath[hivePath.Length - 1] == 0)
                    {
                        hivePath = hivePath.Substring(0, hivePath.Length - 1);
                    }

                    if (string.IsNullOrEmpty(valueName) || string.IsNullOrEmpty(hivePath))
                    {
                        continue;
                    }

                    var h = new Hive(valueName, hivePath);

                    if (h.IsValid)
                    {
                        Wizard.RegistryHives.Add(h);
                    }
                }
            }

            _scanBase.HivesLoaded = true;

            _scanBase.MoveNext();
        }