示例#1
0
        public virtual void DecompileAssembly(LoadedAssembly assembly, ITextOutput output, DecompilationOptions options)
        {
            WriteCommentLine(output, assembly.FileName);
            var asm = assembly.GetAssemblyDefinitionOrNull();

            if (asm != null)
            {
                var name = asm.Name;
                if (name.IsWindowsRuntime)
                {
                    WriteCommentLine(output, name.Name + " [WinRT]");
                }
                else
                {
                    WriteCommentLine(output, name.FullName);
                }
            }
            else
            {
                WriteCommentLine(output, assembly.GetModuleDefinitionAsync().Result.Name);
            }
        }
示例#2
0
 public ILSpyWholeProjectDecompiler(LoadedAssembly assembly, DecompilationOptions options)
 {
     this.assembly = assembly;
     this.options  = options;
     base.Settings = options.DecompilerSettings;
 }
示例#3
0
 public MyUniversalResolver(LoadedAssembly assembly)
     : base(assembly.FileName, false)
 {
 }
示例#4
0
        LoadedAssembly LookupReferencedAssemblyInternal(AssemblyNameReference fullName, bool isWinRT)
        {
            string GetName(AssemblyNameReference name) => isWinRT ? name.Name : name.FullName;

            string         file;
            LoadedAssembly asm;

            lock (loadingAssemblies) {
                foreach (LoadedAssembly loaded in assemblyList.GetAssemblies())
                {
                    var asmDef = loaded.GetAssemblyDefinitionOrNull();
                    if (asmDef != null && GetName(fullName).Equals(GetName(asmDef.Name), StringComparison.OrdinalIgnoreCase))
                    {
                        LoadedAssemblyReferencesInfo.AddMessageOnce(fullName.ToString(), MessageKind.Info, "Success - Found in Assembly List");
                        return(loaded);
                    }
                }

                if (isWinRT)
                {
                    file = Path.Combine(Environment.SystemDirectory, "WinMetadata", fullName.Name + ".winmd");
                }
                else
                {
                    var resolver = new MyUniversalResolver(this)
                    {
                        TargetFramework = GetTargetFrameworkIdAsync().Result
                    };
                    file = resolver.FindAssemblyFile(fullName);
                }

                foreach (LoadedAssembly loaded in assemblyList.GetAssemblies())
                {
                    if (loaded.FileName.Equals(file, StringComparison.OrdinalIgnoreCase))
                    {
                        return(loaded);
                    }
                }

                if (file != null && loadingAssemblies.TryGetValue(file, out asm))
                {
                    return(asm);
                }

                if (assemblyLoadDisableCount > 0)
                {
                    return(null);
                }

                if (file != null)
                {
                    LoadedAssemblyReferencesInfo.AddMessage(fullName.ToString(), MessageKind.Info, "Success - Loading from: " + file);
                    asm = new LoadedAssembly(assemblyList, file)
                    {
                        IsAutoLoaded = true
                    };
                }
                else
                {
                    LoadedAssemblyReferencesInfo.AddMessageOnce(fullName.ToString(), MessageKind.Error, "Could not find reference: " + fullName);
                    return(null);
                }
                loadingAssemblies.Add(file, asm);
            }
            Dispatcher.UIThread.InvokeAsync((Action) delegate() {
                lock (assemblyList.assemblies) {
                    assemblyList.assemblies.Add(asm);
                }
                lock (loadingAssemblies) {
                    loadingAssemblies.Remove(file);
                }
            });
            return(asm);
        }
示例#5
0
 public MyAssemblyResolver(LoadedAssembly parent)
 {
     this.parent = parent;
 }