internal void Start(string newFileName) { this.Show(); Task.Factory.StartNew(() => { try { ReportProgress(0, "Preparing deobfuscation"); obfuscationFile.DeobfuscateBegin(); ReportProgress(20, "Deobfuscating"); obfuscationFile.Deobfuscate(); ReportProgress(40, "Finishing deobfuscation"); obfuscationFile.DeobfuscateEnd(); ReportProgress(60, "Renaming items"); // turn all flags on RenamerFlags flags = RenamerFlags.DontCreateNewParamDefs | RenamerFlags.DontRenameDelegateFields | RenamerFlags.RenameEvents | RenamerFlags.RenameFields | RenamerFlags.RenameGenericParams | RenamerFlags.RenameMethodArgs | RenamerFlags.RenameMethods | RenamerFlags.RenameNamespaces | RenamerFlags.RenameProperties | RenamerFlags.RenameTypes | RenamerFlags.RestoreEvents | RenamerFlags.RestoreEventsFromNames | RenamerFlags.RestoreProperties | RenamerFlags.RestorePropertiesFromNames; Renamer renamer = new Renamer(obfuscationFile.DeobfuscatorContext, new IObfuscatedFile[] { obfuscationFile }, flags); renamer.Rename(); ReportProgress(80, "Saving"); obfuscationFile.Save(); } finally { obfuscationFile.DeobfuscateCleanUp(); } }) .ContinueWith(t => { ReportProgress(100, "Done"); if (t.Status == TaskStatus.Faulted) { MessageBox.Show(t.Exception.InnerExceptions[0].Message); } else if (t.Status == TaskStatus.RanToCompletion) { ReportProgress(100, "Assembly cleaned"); if (MessageBox.Show(Application.Current.MainWindow, "Would you like to load the cleaned assembly?", string.Empty, MessageBoxButton.YesNo) == MessageBoxResult.Yes) { this.assemblyManager.LoadAssembly(newFileName); } } this.Close(); }, TaskScheduler.FromCurrentSynchronizationContext()); }
private void BackgroundWorker_DoWork(object sender, DoWorkEventArgs e) { var worker = sender as BackgroundWorker; var ofile = e.Argument as IObfuscatedFile; if (worker == null || ofile == null) return; try { worker.ReportProgress(0, "Preparing deobfuscation"); ofile.DeobfuscateBegin(); worker.ReportProgress(20, "Deobfuscating"); ofile.Deobfuscate(); worker.ReportProgress(40, "Finishing deobfuscation"); ofile.DeobfuscateEnd(); worker.ReportProgress(60, "Renaming items"); const RenamerFlags flags = RenamerFlags.RenameNamespaces | RenamerFlags.RenameTypes | RenamerFlags.RenameProperties | RenamerFlags.RenameEvents | RenamerFlags.RenameFields | RenamerFlags.RenameMethods | RenamerFlags.RenameMethodArgs | RenamerFlags.RenameGenericParams | RenamerFlags.RestorePropertiesFromNames | RenamerFlags.RestoreEventsFromNames | RenamerFlags.RestoreProperties | RenamerFlags.RestoreEvents; var renamer = new Renamer(ofile.DeobfuscatorContext, new[] {ofile}, flags); renamer.Rename(); worker.ReportProgress(80, "Saving"); ofile.Save(); worker.ReportProgress(100, "Done"); } catch (Exception ex) { worker.ReportProgress(0, ex); e.Result = ex; } finally { ofile.DeobfuscateCleanUp(); } }
void Rename(IEnumerable<IObfuscatedFile> theFiles) { if (!options.RenameSymbols) return; var renamer = new Renamer(deobfuscatorContext, theFiles, options.RenamerFlags); renamer.Rename(); }