private void button1_Click(object sender, EventArgs e) { SDOptions _options = new SDOptions(); SDOptionsFile.TryLoadOptions(out _options); OptionsForm f = new OptionsForm(); // password required ? if(_options.PasswordRequired && _options.Password != null) { PasswordDialog dialog = new PasswordDialog(); dialog.Password = _options.Password; if(dialog.ShowDialog() != DialogResult.OK) { // invalid password or canceled by user return; } } // display options window f.StartPanel = OptionsFormStartPanel.General; f.Options = _options; if(f.ShowDialog() == DialogResult.OK) { _options = f.Options; SDOptionsFile.TrySaveOptions(_options); } }
private void StartWipe() { reportTool.Visible = false; CopyPanel.Visible = false; wipeTool.Visible = true; // load options SDOptions options = new SDOptions(); SDOptionsFile.TryLoadOptions(out options); // initialize wiping tool wipeTool.ParentControl = this; wipeTool.OnWipeStarted += EnterWipeMode; wipeTool.OnWipeStopped += ExitWipeMode; wipeTool.InitializeTool(); wipeTool.Session = session; wipeTool.Options = options; wiping = true; wipeTool.Start(); }
private void button1_Click(object sender, EventArgs e) { SDOptions options = new SDOptions(); SDOptionsFile.TryLoadOptions(out options); OptionsForm f = new OptionsForm(); f.StartPanel = OptionsFormStartPanel.Schedule; f.Options = options; if(f.ShowDialog() == DialogResult.OK) { SDOptionsFile.TrySaveOptions(options); } }
public static bool TrySaveOptions(SDOptions options) { // check if the folder exists string path = SecureDeleteLocations.CombinePath(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), SecureDeleteLocations.SecureDeleteFolder); try { if(Directory.Exists(path) == false) { Directory.CreateDirectory(path); } // set registry options Registry.SetValue(SDOptions.SecureDeleteKey, SDOptions.ShellNormalEnabled, options.ShellFileOperation, RegistryValueKind.DWord); Registry.SetValue(SDOptions.SecureDeleteKey, SDOptions.ShellMoveEnabled, options.ShellMoveOperation, RegistryValueKind.DWord); Registry.SetValue(SDOptions.SecureDeleteKey, SDOptions.ShellRecycleEnabled, options.ShellRecycleOperation, RegistryValueKind.DWord); } catch(Exception e) { Debug.ReportError("Failed to create folder {0}. Exception: {1}", path, e.Message); return false; } return SaveOptions(options, SecureDeleteLocations.CombinePath(path, SecureDeleteLocations.SecureDeleteOptionsFile)); }
private void UpdateReportInfo() { WipeReportManager man = new WipeReportManager(); man.ReportDirectory = SecureDeleteLocations.GetReportDirectory(); man.LoadReportCategories(SecureDeleteLocations.GetReportFilePath()); CategoryList.Items.Clear(); // count int categories = 0; int reports = 0; int errors = 0; int failed = 0; SDOptions options = new SDOptions(); SDOptionsFile.TryLoadOptions(out options); foreach(KeyValuePair<Guid, ReportCategory> category in man.Categories) { categories++; ListViewItem item = new ListViewItem(); string name = "Not found"; if(category.Value.Guid == WipeSession.DefaultSessionGuid) { name = "Default"; item.ImageIndex = 0; } else { if(options != null && options.SessionNames != null && options.SessionNames.ContainsKey(category.Value.Guid)) { name = options.SessionNames[category.Value.Guid]; item.ImageIndex = 1; } else { item.ImageIndex = 2; } } item.Text = name; item.SubItems.Add(category.Value.Reports.Count.ToString()); CategoryList.Items.Add(item); // count messages foreach(KeyValuePair<long, ReportInfo> report in category.Value.Reports) { reports++; errors += report.Value.ErrorCount; failed += report.Value.FailedObjectCount; } } ReportCountLabel.Text = "Reports: " + reports.ToString(); ErrorCountLabel.Text = "Errors: " + errors.ToString(); FailedCountLabel.Text = "Failed objects: " + failed.ToString(); CategoryCountLabel.Text = "Categories: " + categories.ToString(); }
public static void TryLoadOptions(out SDOptions options) { options = new SDOptions(); LoadOptions(SecureDeleteLocations.GetOptionsFilePath(), ref options); // create new options if load failed if(options == null) { options = new SDOptions(); } // create new objects if needed if(options.FilterStore == null) { options.FilterStore = new FilterStore(); } if(options.ActionStore == null) { options.ActionStore = new ActionStore(); } // create session name list if(options.SessionNames == null) { options.SessionNames = new Dictionary<Guid, string>(); } // create before/after lists if(options.BeforeWipeActions == null) { options.BeforeWipeActions = new List<IAction>(); } if(options.AfterWipeActions == null) { options.AfterWipeActions = new List<IAction>(); } // initialize the WipeMethodManager options.MethodFolder = SecureDeleteLocations.GetMethodsFolder(); options.MethodManager = new WipeMethodManager(); options.MethodManager.Folder = options.MethodFolder; if(options.MethodFolder == null || options.MethodManager.ScanFolder() == false) { Debug.ReportWarning("Failed to load wipe methods. Directory: {0}", options.MethodFolder); } if(options.WipeOptions == null) { options.WipeOptions = new WipeOptions(); } // set registry options try { Registry.SetValue(SDOptions.SecureDeleteKey, SDOptions.ShellNormalEnabled, options.ShellFileOperation, RegistryValueKind.DWord); Registry.SetValue(SDOptions.SecureDeleteKey, SDOptions.ShellMoveEnabled, options.ShellMoveOperation, RegistryValueKind.DWord); Registry.SetValue(SDOptions.SecureDeleteKey, SDOptions.ShellRecycleEnabled, options.ShellRecycleOperation, RegistryValueKind.DWord); } catch(Exception e) { Debug.ReportWarning("Error while saving registry options. Exception: {0}", e.Message); } }
public static byte[] SerializeOptions(SDOptions options) { MemoryStream stream = new MemoryStream(); try { BinaryFormatter formatter = new BinaryFormatter(); formatter.Serialize(stream, options); return stream.ToArray(); } catch(Exception e) { Debug.ReportError("Error while serializing SDOptions. Exception: {0}", e.Message); return null; } finally { if(stream != null) { stream.Close(); } } }
public static bool SaveOptions(SDOptions options, string path) { Debug.AssertNotNull(options, "Options is null"); Debug.AssertNotNull(path, "Path is null"); try { // create the store FileStore.FileStore store = new FileStore.FileStore(); store.Encrypt = _encrypt; // set encryption key if(_password != null) { SHA256Managed sha = new SHA256Managed(); store.EncryptionKey = sha.ComputeHash(Encoding.ASCII.GetBytes(_password)); store.UseDPAPI = false; } else { store.UseDPAPI = true; } // add the file FileStore.StoreFile file = store.CreateFile("options.dat"); byte[] data = SerializeOptions(options); if(data == null) { return false; } // write the file contents store.WriteFile(file, data, FileStore.StoreMode.Encrypted); return store.Save(path); } catch(Exception e) { Debug.ReportError("Error while saving options. Exception: {0}", e.Message); return false; } }
public static bool LoadOptions(string path, ref SDOptions options) { // check the parameters if(path == null) { throw new ArgumentNullException("path"); } options = null; try { // create the store FileStore.FileStore store = new FileStore.FileStore(); // set encryption key if(_password != null) { SHA256Managed sha = new SHA256Managed(); store.EncryptionKey = sha.ComputeHash(Encoding.ASCII.GetBytes(_password)); } // load store if(store.Load(path) == false) { Debug.ReportError("Error while loading store from path {0}", path); return false; } // deserialize options = DeserializeOptions(store.ReadFile("options.dat")); return options != null; } catch(Exception e) { Debug.ReportError("Error while loading session. Exception: {0}", e.Message); return false; } }
public static bool LoadDefaultOptions(string path, out SDOptions options) { // check the parameters if(path == null) { throw new ArgumentNullException("path"); } options = null; try { // deserialize options = DeserializeOptions(File.ReadAllBytes(path)); return options != null; } catch(Exception e) { Debug.ReportError("Error while loading session. Exception: {0}", e.Message); return false; } }