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(); }
private FileSystemPath Deobfuscate(IObfuscatedFile obfuscatedFile, IProgressIndicator progressIndicator) { try { progressIndicator.Start(5); progressIndicator.TaskName = "Deobfuscating..."; progressIndicator.CurrentItemText = string.Format("Saving to {0}", obfuscatedFile.NewFilename); progressIndicator.Advance(1); obfuscatedFile.deobfuscateBegin(); progressIndicator.Advance(1); obfuscatedFile.deobfuscate(); progressIndicator.Advance(1); obfuscatedFile.deobfuscateEnd(); // 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; var renamer = new Renamer(obfuscatedFile.DeobfuscatorContext, new[] { obfuscatedFile }, flags); progressIndicator.Advance(1); renamer.rename(); progressIndicator.Advance(1); obfuscatedFile.save(); } finally { progressIndicator.Stop(); } return new FileSystemPath(obfuscatedFile.NewFilename); }
void rename(IEnumerable<IObfuscatedFile> theFiles) { if (!options.RenameSymbols) return; var renamer = new Renamer(theFiles) { RestorePropertiesFromNames = options.RestorePropsEvents, RestoreEventsFromNames = options.RestorePropsEvents, }; renamer.rename(); }