private async void ButtonStart_Click(object sender, EventArgs e) { this.tabViewSwitcher.SelectedIndex = 1; var assemblyLoader = new MonoCecilAssemblyLoader(assemblyFolder); var assemblies = assemblyLoader.LoadDomainAssemblies(options); var asmGraphAnalyzer = new MonoCecilAssemblyGraphAnalyzer(assemblies, new TypeDefinitionUtility()); var pathFinder = new DepthFirstCodePathFinder(asmGraphAnalyzer); var limit = this.checkLimitPathDepth.Checked ? (int)this.numericDepthLImit.Value : -1; try { await pathFinder.ConstructPartialPaths(start, end, source.Token); this.labelSearchStatus.Text = "Constructing the result tree from the partial paths..."; var pathEnumerable = pathFinder.ConstructFullPaths(start, end, source.Token, limit); var paths = await Task.Run(() => pathEnumerable.ToList(), source.Token); var viewer = new ResultsViewerLanding(paths, start, end); viewer.Show(); } catch (OperationCanceledException ex) { AppLogger.Current.Error(ex, "Path finding operation was cancelled!"); MessageBox.Show("The search was cancelled.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } Close(); }
/// <summary> /// Entry point for console Code Path Finder /// </summary> static void Main(string[] args) { AppLogger.RegisterLogger(new ConsoleLogger()); var assemblyLoader = new MonoCecilAssemblyLoader(DefaultAsmPath); var assemblies = assemblyLoader.LoadDomainAssemblies(options); var startMethod = assemblyLoader.LoadMethods( "WanderingWiFi.AirWatch.DeviceServices.Handlers.SecureChannelEndPointHandler.ProcessRequest") .First(); var endMethod = assemblyLoader.LoadMethods( "WanderingWiFi.AirWatch.Entity.Certificate.CertificateLoad._GenerateCertificate") .First(); var asmGraphAnalyzer = new MonoCecilAssemblyGraphAnalyzer(assemblies, new TypeDefinitionUtility()); var pathFinder = new DepthFirstCodePathFinder(asmGraphAnalyzer); var allPaths = pathFinder.EnumeratePathsBetweenMethods(startMethod, endMethod, default(CancellationToken)).Result; var batchSize = 10000; using (var fs = new FileStream(@"D:\results.txt", FileMode.Create, FileAccess.ReadWrite)) using (var writer = new StreamWriter(fs)) { var batch = new List <CodePath>(); foreach (var path in allPaths) { batch.Add(path); if (batch.Count == batchSize) { foreach (var printPath in batch) { writer.WriteLine(printPath); } batch.Clear(); writer.Flush(); } } foreach (var printPath in batch) { writer.WriteLine(printPath); } Console.ReadKey(); } }