Пример #1
0
        private static int Run(Options options)
        {
            string             listing  = null;
            long               elapsed  = 0;
            Disassembler       ds       = new Disassembler();
            DisassemblyOptions settings = DisassemblyOptions.None;

            if (options.ShowNames)
            {
                settings |= DisassemblyOptions.ShowNames;
            }
            if (options.ShowTypes)
            {
                settings |= DisassemblyOptions.ShowTypes;
            }

            if (options.DebugMode)
            {
                byte[] bytes = File.ReadAllBytes(options.InputFile);
                using (MemoryStream stream = new MemoryStream(bytes))
                {
                    // idle run just to compile code
                    Module.ReadFrom(stream);

                    Stopwatch stopwatch = new Stopwatch();
                    for (int i = 0; i < 5; i++)
                    {
                        stream.Position = 0;
                        stopwatch.Start();
                        Module module = Module.ReadFrom(stream);
                        listing = ds.Disassemble(module, settings);
                        stopwatch.Stop();

                        elapsed = stopwatch.ElapsedMilliseconds;
                        Console.WriteLine($"{i + 1}) Time elapsed {elapsed}ms");
                        stopwatch.Reset();
                    }
                    Console.WriteLine();
                }
            }
            else
            {
                using (FileStream stream = File.OpenRead(options.InputFile))
                {
                    Module module = Module.ReadFrom(stream);
                    listing = ds.Disassemble(module, settings);
                }
            }

            Console.WriteLine(listing);
            return(0);
        }
Пример #2
0
        static int Run(Options options)
        {
            var module = Module.ReadFrom(System.IO.File.OpenRead(options.InputFile));
            var ds     = new Disassembler();

            var settings = DisassemblyOptions.None;

            if (options.ShowNames)
            {
                settings |= DisassemblyOptions.ShowNames;
            }

            if (options.ShowTypes)
            {
                settings |= DisassemblyOptions.ShowTypes;
            }

            Console.Write(ds.Disassemble(module, settings));

            return(0);
        }