예제 #1
0
        public static int Main(string[] args)
        {
#if DEBUG
            var tempPath  = ConfigurationManager.AppSettings["WorkingDir"];
            var graphPath = @"C:\Users\lean\Desktop\EPAs";
            if (!Directory.Exists(graphPath))
            {
                Directory.CreateDirectory(graphPath);
            }

            var examplesPath = Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, @"..\..\..\Examples\obj\Debug\Decl\Examples.dll"));

            args = new[]
            {
                "-i", examplesPath,
                "-g", graphPath,
                "--tmp", tempPath,
                "-t", "Examples.Door",
                "-b", "Corral",
                "--ga",
                "-o", @"C:\Users\lean\Desktop\EPAs\strengthenedAssembly.dll",
            };
#endif
            var options = new Options();
            if (!Parser.Default.ParseArgumentsStrict(args, options))
            {
                throw new FormatException("Args parsing error!");
            }

            System.Console.WriteLine(options.InputAssembly);

            var decompiler    = new CciAssemblyPersister();
            var inputAssembly = decompiler.Load(options.InputAssembly, null);
            var typeToAnalyze = inputAssembly.Types().First(t => t.Name.Equals(options.TypeToAnalyze));

            var analysisResult = GenerateEpa(inputAssembly, typeToAnalyze, options);

            System.Console.WriteLine(analysisResult.ToString());

            var epa = analysisResult.Epa;

            SaveEpasAsImages(epa, new DirectoryInfo(options.GraphDirectory));

            if (options.XML)
            {
                SaveEpasAsXml(epa, new DirectoryInfo(options.GraphDirectory));
            }

            if (options.GenerateStrengthenedAssembly)
            {
                var strengthenedAssembly = GenerateStrengthenedAssembly(epa, inputAssembly) as CciAssembly;
                decompiler.Save(strengthenedAssembly, options.OutputAssembly);
            }

            System.Console.WriteLine("Done!");
            System.Console.ReadLine();
            return(0);
        }
예제 #2
0
        private static void Main(string[] args)
        {
            var assemblyFileName = @"C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.dll";
            var assemblyWithContractsFileName = @"C:\Program Files (x86)\Microsoft\Contracts\Contracts\.NETFramework\v4.0\System.Contracts.dll";
            var outputFileName = @"C:\Users\Eddy\Documents\Tesis\temp\System.dll";

            var persister = new CciAssemblyPersister();

            Console.WriteLine("Loading input assembly...");
            Console.WriteLine("Loading contract reference assembly...");
            var assembly = persister.Load(assemblyFileName, assemblyWithContractsFileName);

            Console.WriteLine("Injecting contracts into output assembly...");
            Console.WriteLine("Saving output assembly...");
            persister.Save(assembly, outputFileName);

            Console.WriteLine("Done!");
            Console.ReadKey();
        }