Ejemplo n.º 1
0
        public override ProjectId DecompileAssembly(LoadedAssembly assembly, ITextOutput output, DecompilationOptions options)
        {
            output.WriteLine("// " + assembly.FileName);
            output.WriteLine();
            var module   = assembly.GetPEFileAsync().GetAwaiter().GetResult();
            var metadata = module.Metadata;
            var dis      = CreateDisassembler(output, options);

            if (options.FullDecompilation && options.SaveAsProjectDirectory != null)
            {
                throw new NotSupportedException($"Language '{Name}' does not support exporting assemblies as projects!");
            }

            // don't automatically load additional assemblies when an assembly node is selected in the tree view
            dis.AssemblyResolver = module.GetAssemblyResolver(loadOnDemand: options.FullDecompilation);
            dis.DebugInfo        = module.GetDebugInfoOrNull();
            if (options.FullDecompilation)
            {
                dis.WriteAssemblyReferences(metadata);
            }
            if (metadata.IsAssembly)
            {
                dis.WriteAssemblyHeader(module);
            }
            output.WriteLine();
            dis.WriteModuleHeader(module);
            if (options.FullDecompilation)
            {
                output.WriteLine();
                output.WriteLine();
                dis.WriteModuleContents(module);
            }
            return(null);
        }