Exemplo n.º 1
0
        public override void DecompileMethod(IMethod method, ITextOutput output, DecompilationOptions options)
        {
            PEFile module = method.ParentModule.PEFile;
            ReadyToRunReaderCacheEntry cacheEntry = GetReader(module.GetLoadedAssembly(), module);

            if (cacheEntry.readyToRunReader == null)
            {
                WriteCommentLine(output, cacheEntry.failureReason);
            }
            else
            {
                ReadyToRunReader reader = cacheEntry.readyToRunReader;
                int bitness             = -1;
                if (reader.Machine == Machine.Amd64)
                {
                    bitness = 64;
                }
                else
                {
                    Debug.Assert(reader.Machine == Machine.I386);
                    bitness = 32;
                }
                if (cacheEntry.methodMap == null)
                {
                    cacheEntry.methodMap = reader.Methods.ToList()
                                           .GroupBy(m => m.MethodHandle)
                                           .ToDictionary(g => g.Key, g => g.ToArray());
                }
                bool showMetadataTokens         = ILSpy.Options.DisplaySettingsPanel.CurrentDisplaySettings.ShowMetadataTokens;
                bool showMetadataTokensInBase10 = ILSpy.Options.DisplaySettingsPanel.CurrentDisplaySettings.ShowMetadataTokensInBase10;
#if STRESS
                ITextOutput originalOutput = output;
                output = new DummyOutput();
                {
                    foreach (var readyToRunMethod in reader.Methods)
                    {
#else
                if (cacheEntry.methodMap.TryGetValue(method.MetadataToken, out var methods))
                {
                    foreach (var readyToRunMethod in methods)
                    {
#endif
                        foreach (RuntimeFunction runtimeFunction in readyToRunMethod.RuntimeFunctions)
                        {
                            new ReadyToRunDisassembler(output, reader, runtimeFunction).Disassemble(method.ParentModule.PEFile, bitness, (ulong)runtimeFunction.StartAddress, showMetadataTokens, showMetadataTokensInBase10);
                        }
                    }
                }
#if STRESS
                output = originalOutput;
                output.WriteLine("Passed");
#endif
            }
        }
Exemplo n.º 2
0
 public override int get_KeyOutputObject(out IVsOutput2 ppKeyOutput)
 {
     ppKeyOutput = new DummyOutput();
     return VSConstants.S_OK;
 }
 public override int get_KeyOutputObject(out IVsOutput2 ppKeyOutput)
 {
     ppKeyOutput = new DummyOutput();
     return(VSConstants.S_OK);
 }