コード例 #1
0
ファイル: Program.cs プロジェクト: ciscprocess/CodePathFinder
        static void Main()
        {
            AppLogger.RegisterLogger(
                new NLogLogger(
                    NLog.LogManager.GetCurrentClassLogger()
                    ));

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new LandingPage());
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: ciscprocess/CodePathFinder
        /// <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();
                }
        }