Пример #1
0
        private void saveButton_Click(object sender, EventArgs e)
        {
            if (_data == null)
            {
                return;
            }

            var file = RegFile.Open(_data);

            if (file == null)
            {
                MessageBox.Show(@"Error saving file!");
                return;
            }

            var fileDialog = new SaveFileDialog
            {
                Filter           = @"All files (*.*)|*.*",
                FileName         = file.File.Split('/')[3],
                RestoreDirectory = true
            };

            if (fileDialog.ShowDialog() == DialogResult.OK)
            {
                using (var fs = File.Open(fileDialog.FileName, FileMode.Create))
                {
                    fs.Write(_data, 0, _data.Length);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// TODO: Method too long, unify and outsource some code
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OpenFileButton_Click(object sender, EventArgs e)
        {
            var fileDialog = new OpenFileDialog
            {
                Filter           = @"|*.*||system.idx;system.dat;system.eap;system.rec",
                RestoreDirectory = true
            };

            if (fileDialog.ShowDialog() == DialogResult.OK)
            {
                _data = File.ReadAllBytes(fileDialog.FileName);

                var file = RegFile.Open(_data);

                if (file == null)
                {
                    MessageBox.Show("Invalid registry file!\nOpen system.idx or system.dat or system.eap or system.rec !");
                    return;
                }

                if (file.Storage == "regcont_eap.db")
                {
                    _registry = new ObfuscatedContainerReader(_data, false);
                }
                else if (file.Storage == "regi.recover")
                {
                    _registry = new ObfuscatedContainerReader(_data, true);
                }
                else
                {
                    if (file.Storage == "regcont.db")
                    {
                        var idx = _data;

                        fileDialog = new OpenFileDialog
                        {
                            Filter           = @"|system.dat||*.*",
                            RestoreDirectory = true
                        };

                        if (fileDialog.ShowDialog() == DialogResult.OK)
                        {
                            _data = File.ReadAllBytes(fileDialog.FileName);

                            file = RegFile.Open(_data);

                            if (file == null || file.Storage != "regdatahdd.db")
                            {
                                MessageBox.Show(@"Invalid system.dat !");
                                return;
                            }

                            _registry = new DataContainerReader(_data, idx);
                        }
                    }
                    else if (file.Storage == "regdatahdd.db")
                    {
                        fileDialog = new OpenFileDialog
                        {
                            Filter           = @"|system.idx||*.*",
                            RestoreDirectory = true
                        };

                        if (fileDialog.ShowDialog() == DialogResult.OK)
                        {
                            var idx = File.ReadAllBytes(fileDialog.FileName);

                            file = Preferences.RegFiles.Find(x => x.Size == idx.Length);

                            if (file == null || file.Storage != "regcont.db")
                            {
                                MessageBox.Show(@"Invalid system.idx !");
                                return;
                            }

                            _registry = new DataContainerReader(_data, idx);
                        }
                    }
                }

                listView.Clear();

                var header = new ColumnHeader {
                    Width = listView.Width
                };
                listView.Columns.Add(header);
                listView.View        = View.Details;
                listView.HeaderStyle = ColumnHeaderStyle.None;

                _registry.Entries.ForEach(x => listView.Items.Add(x.Category));
            }
        }