Exemple #1
0
        static void DoTest()
        {
            string exe = @"TestApp.dll";
            var    m   = new DotNetFile(exe);

            var decompiler = new IlDecompiler(m.EntryPoint);

            Console.WriteLine("Decompile of Main function:");
            var ilFormater   = new ILFormater(decompiler.Decompile());
            var outputString = ilFormater.Format();

            Console.WriteLine(outputString);
            Console.WriteLine("Running program:");
            DotNetClr clr = new DotNetClr(
                m,
                Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location),
                             "framework"));

            //Register our internal methods
            clr.RegisterCustomInternalMethod("TestsComplete", TestsComplete);
            clr.RegisterCustomInternalMethod("TestSuccess", TestSuccess);
            clr.RegisterCustomInternalMethod("TestFail", TestFail);

            clr.Start();
        }
Exemple #2
0
        static void Main()
        {
            //This is for debugging purposes
            bool   doil2cpu = false;
            string il2cpu   = @"C:\Users\Misha\AppData\Roaming\Cosmos User Kit\Build\IL2CPU\IL2CPU.dll";
            string exe      = doil2cpu ? il2cpu : "TestApp.dll";


            //Create a new dotnetfile with the path to the EXE
            m = new DotNetFile(exe);

            //This is not needed, but this shows the IL code of the entry point
            var decompiler = new IlDecompiler(m.EntryPoint);

            Console.WriteLine("Decompile of Main function:");
            var ilFormater   = new ILFormater(decompiler.Decompile());
            var outputString = ilFormater.Format();

            Console.WriteLine(outputString);

            //This creates an instance of a CLR, and then runs it
            Console.WriteLine("Running program:");
            clr = new DotNetClr(
                m,
                Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location),
                             "framework"));

            //Register our internal methods
            clr.RegisterCustomInternalMethod("TestsComplete", TestsComplete);
            clr.RegisterCustomInternalMethod("TestSuccess", TestSuccess);
            clr.RegisterCustomInternalMethod("TestFail", TestFail);
            clr.RegisterCustomInternalMethod("TestsRxObject", TestRxObject);

            //Put arguments in the string array
            clr.Start(new string[] { "testArg" });


            if (NumbOfFailedTests >= 1)
            {
                Environment.Exit(1);
            }
        }