private void AddToList(AssemblyList list, string FullName) { AssemblyNameInfo reference = new AssemblyNameInfo(FullName); string file = GacInterop.FindAssemblyInNetGac(reference); if (file != null) list.OpenAssembly(file); }
public bool CreateList(AssemblyList list) { if (!AssemblyLists.Contains(list.ListName)) { AssemblyLists.Add(list.ListName); SaveList(list); return true; } return false; }
public LoadedAssembly(AssemblyList assemblyList, string fileName, Stream stream = null) { if (assemblyList == null) throw new ArgumentNullException("assemblyList"); if (fileName == null) throw new ArgumentNullException("fileName"); this.assemblyList = assemblyList; this.fileName = fileName; this.assemblyTask = Task.Factory.StartNew<ModuleDefinition>(LoadAssembly, stream); // requires that this.fileName is set this.shortName = Path.GetFileNameWithoutExtension(fileName); }
/// <summary> /// Saves the specifies assembly list into the config file. /// </summary> public static void SaveList(AssemblyList list) { ILSpySettings.Update( delegate (XElement root) { XElement doc = root.Element("AssemblyLists"); if (doc == null) { doc = new XElement("AssemblyLists"); root.Add(doc); } XElement listElement = doc.Elements("List").FirstOrDefault(e => (string)e.Attribute("name") == list.ListName); if (listElement != null) listElement.ReplaceWith(list.SaveAsXml()); else doc.Add(list.SaveAsXml()); }); }
/// <summary> /// Constructor to create modules present in multi-module assemblies /// </summary> /// <param name="assemblyList"></param> /// <param name="module"></param> public LoadedAssembly(AssemblyList assemblyList, ModuleDef module) { if (assemblyList == null) throw new ArgumentNullException("assemblyList"); if (module == null) throw new ArgumentNullException("module"); this.assemblyList = assemblyList; this.fileName = module.Location ?? string.Empty; this.assemblyTask = Task.Factory.StartNew<ModuleDef>(() => LoadModule(module)); this.shortName = GetShortName(fileName); if (string.IsNullOrEmpty(this.shortName)) this.shortName = module.Name; // Make sure IsLoaded is set to true if (ModuleDefinition != null) { } }
public MemberPickerVM(Language language, ITreeViewNodeFilter filter, IEnumerable<LoadedAssembly> assemblies) { this.Language = language; this.ShowInternalApi = true; this.filter = filter; this.origFilter = filter; assemblyList = new AssemblyList("Member Picker List", false); foreach (var asm in assemblies) assemblyList.ForceAddAssemblyToList(asm, true, false, -1, false); this.assemblyListTreeNode = new AssemblyListTreeNode(assemblyList); this.assemblyListTreeNode.DisableDrop = true; if (assemblyListTreeNode.Children.Count > 0) SelectedItem = assemblyListTreeNode.Children[0]; // Make sure we don't hook this event before the assembly list node because we depend // on the new asm node being present when we restart the search. assemblyList.CollectionChanged += (s, e) => RestartSearch(); CreateNewFilterSettings(); }
void MainWindow_Loaded(object sender, RoutedEventArgs e) { ILSpySettings spySettings = this.spySettings; this.spySettings = null; // Load AssemblyList only in Loaded event so that WPF is initialized before we start the CPU-heavy stuff. // This makes the UI come up a bit faster. this.assemblyList = assemblyListManager.LoadList(spySettings, sessionSettings.ActiveAssemblyList); ShowAssemblyList(this.assemblyList); string[] args = Environment.GetCommandLineArgs(); for (int i = 1; i < args.Length; i++) { assemblyList.OpenAssembly(args[i]); } if (assemblyList.GetAssemblies().Length == 0) LoadInitialAssemblies(); SharpTreeNode node = FindNodeByPath(sessionSettings.ActiveTreeViewPath, true); if (node != null) { SelectNode(node); // only if not showing the about page, perform the update check: ShowMessageIfUpdatesAvailableAsync(spySettings); } else { AboutPage.Display(decompilerTextView); } }
void MainWindow_Loaded(object sender, RoutedEventArgs e) { this.Opacity = 0; ILSpySettings spySettings = this.spySettings; this.spySettings = null; // Load AssemblyList only in Loaded event so that WPF is initialized before we start the CPU-heavy stuff. // This makes the UI come up a bit faster. this.assemblyList = assemblyListManager.LoadList(spySettings, sessionSettings.ActiveAssemblyList); HandleCommandLineArguments(App.CommandLineArguments); if (assemblyList.GetAssemblies().Length == 0 && assemblyList.ListName == AssemblyListManager.DefaultListName) { LoadInitialAssemblies(); } ShowAssemblyList(this.assemblyList); HandleCommandLineArgumentsAfterShowList(App.CommandLineArguments); if (App.CommandLineArguments.NavigateTo == null) { SharpTreeNode node = FindNodeByPath(sessionSettings.ActiveTreeViewPath, true); if (node != null) { SelectNode(node); // only if not showing the about page, perform the update check: ShowMessageIfUpdatesAvailableAsync(spySettings); } else { AboutPage.Display(decompilerTextView); } } searchBox.DataContext = SearchPane.Instance; // setting the opacity to 0 and then using this code to set it back to 1 is kind of a hack to get // around a problem where the window doesn't render properly when using the shell integration library // but it works, and it looks nice Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => this.Opacity = 1)); }
public void ResetCurrentAssembly() { assemblyList = new AssemblyList(string.Empty); }
void MainWindow_Loaded(object sender, RoutedEventArgs e) { ILSpySettings spySettings = this.spySettings; this.spySettings = null; // Load AssemblyList only in Loaded event so that WPF is initialized before we start the CPU-heavy stuff. // This makes the UI come up a bit faster. this.assemblyList = assemblyListManager.LoadList(spySettings, sessionSettings.ActiveAssemblyList); HandleCommandLineArguments(App.CommandLineArguments); ShowAssemblyList(this.assemblyList); HandleCommandLineArgumentsAfterShowList(App.CommandLineArguments); if (App.CommandLineArguments.NavigateTo == null && App.CommandLineArguments.AssembliesToLoad.Count != 1) { SharpTreeNode node = FindNodeByPath(sessionSettings.ActiveTreeViewPath, true); if (node != null) { SelectNode(node); // only if not showing the about page, perform the update check: ShowMessageIfUpdatesAvailableAsync(spySettings); } else { AboutPage.Display(decompilerTextView); } } NavigationCommands.Search.InputGestures.Add(new KeyGesture(Key.E, ModifierKeys.Control)); AvalonEditTextOutput output = new AvalonEditTextOutput(); if (FormatExceptions(App.StartupExceptions.ToArray(), output)) decompilerTextView.ShowText(output); }
void MainWindow_Loaded(object sender, RoutedEventArgs e) { ILSpySettings spySettings = this.spySettings; this.spySettings = null; // Load AssemblyList only in Loaded event so that WPF is initialized before we start the CPU-heavy stuff. // This makes the UI come up a bit faster. this.assemblyList = assemblyListManager.LoadList(spySettings, sessionSettings.ActiveAssemblyList); HandleCommandLineArguments(App.CommandLineArguments); if (assemblyList.GetAssemblies().Length == 0 && assemblyList.ListName == AssemblyListManager.DefaultListName) { LoadInitialAssemblies(); } ShowAssemblyList(this.assemblyList); HandleCommandLineArgumentsAfterShowList(App.CommandLineArguments); if (App.CommandLineArguments.NavigateTo == null) { SharpTreeNode node = FindNodeByPath(sessionSettings.ActiveTreeViewPath, true); if (node != null) { SelectNode(node); // only if not showing the about page, perform the update check: ShowMessageIfUpdatesAvailableAsync(spySettings); } else { AboutPage.Display(decompilerTextView); } } //Fires the OnLoaded notification to the plugins foreach (var x in applicationLifeCycleInterceptors) x.Value.OnLoaded(); }
private void CreateDefaultAssemblyLists() { if (!manager.AssemblyLists.Contains(DotNet4List)) { AssemblyList dotnet4 = new AssemblyList(DotNet4List); AddToList(dotnet4, "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"); AddToList(dotnet4, "System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"); AddToList(dotnet4, "System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"); AddToList(dotnet4, "System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"); AddToList(dotnet4, "System.Data.DataSetExtensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"); AddToList(dotnet4, "System.Xaml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"); AddToList(dotnet4, "System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"); AddToList(dotnet4, "System.Xml.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"); AddToList(dotnet4, "Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"); AddToList(dotnet4, "PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"); AddToList(dotnet4, "PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"); AddToList(dotnet4, "WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"); if (dotnet4.Count_NoLock > 0) { manager.CreateList(dotnet4); } } if (!manager.AssemblyLists.Contains(DotNet35List)) { AssemblyList dotnet35 = new AssemblyList(DotNet35List); AddToList(dotnet35, "mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"); AddToList(dotnet35, "System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"); AddToList(dotnet35, "System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"); AddToList(dotnet35, "System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"); AddToList(dotnet35, "System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"); AddToList(dotnet35, "System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"); AddToList(dotnet35, "System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"); AddToList(dotnet35, "PresentationCore, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"); AddToList(dotnet35, "PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"); AddToList(dotnet35, "WindowsBase, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"); if (dotnet35.Count_NoLock > 0) { manager.CreateList(dotnet35); } } if (!manager.AssemblyLists.Contains(ASPDotNetMVC3List)) { AssemblyList mvc = new AssemblyList(ASPDotNetMVC3List); AddToList(mvc, "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"); AddToList(mvc, "System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"); AddToList(mvc, "System.ComponentModel.DataAnnotations, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"); AddToList(mvc, "System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"); AddToList(mvc, "System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"); AddToList(mvc, "System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"); AddToList(mvc, "System.Data.DataSetExtensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"); AddToList(mvc, "System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"); AddToList(mvc, "System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"); AddToList(mvc, "System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"); AddToList(mvc, "System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"); AddToList(mvc, "System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"); AddToList(mvc, "System.Web.ApplicationServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"); AddToList(mvc, "System.Web.DynamicData, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"); AddToList(mvc, "System.Web.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"); AddToList(mvc, "System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"); AddToList(mvc, "System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"); AddToList(mvc, "System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"); AddToList(mvc, "System.Web.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"); AddToList(mvc, "System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"); AddToList(mvc, "System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"); AddToList(mvc, "System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"); AddToList(mvc, "System.Xml.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"); AddToList(mvc, "Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"); if (mvc.Count_NoLock > 0) { manager.CreateList(mvc); } } }
void ShowAssemblyList(AssemblyList assemblyList) { this.assemblyList = assemblyList; assemblyListTreeNode = new AssemblyListTreeNode(assemblyList); assemblyListTreeNode.FilterSettings = sessionSettings.FilterSettings.Clone(); assemblyListTreeNode.Select = SelectNode; treeView.Root = assemblyListTreeNode; if (assemblyList.ListName == AssemblyListManager.DefaultListName) this.Title = "ILSpy"; else this.Title = "ILSpy - " + assemblyList.ListName; }
public LoadedAssembly(AssemblyList assemblyList, string fileName) { if (assemblyList == null) throw new ArgumentNullException("assemblyList"); if (fileName == null) throw new ArgumentNullException("fileName"); this.assemblyList = assemblyList; this.fileName = fileName; this.assemblyTask = Task.Factory.StartNew<ModuleDef>(LoadAssembly, null); // requires that this.fileName is set this.shortName = GetShortName(fileName); }
public DecrementAssemblyLoadDisableCount(AssemblyList assemblyList) { this.assemblyList = assemblyList; }
void MainWindow_Loaded(object sender, RoutedEventArgs e) { ILSpySettings spySettings = this.spySettings; this.spySettings = null; // Load AssemblyList only in Loaded event so that WPF is initialized before we start the CPU-heavy stuff. // This makes the UI come up a bit faster. this.assemblyList = assemblyListManager.LoadList(spySettings, sessionSettings.ActiveAssemblyList); HandleCommandLineArguments(App.CommandLineArguments); if (assemblyList.GetAssemblies().Length == 0 && assemblyList.ListName == AssemblyListManager.DefaultListName) { LoadInitialAssemblies(); } ShowAssemblyList(this.assemblyList); HandleCommandLineArgumentsAfterShowList(App.CommandLineArguments); if (App.CommandLineArguments.NavigateTo == null && App.CommandLineArguments.AssembliesToLoad.Count != 1) { SharpTreeNode node = null; if (sessionSettings.ActiveTreeViewPath != null) { node = FindNodeByPath(sessionSettings.ActiveTreeViewPath, true); if (node == this.assemblyListTreeNode & sessionSettings.ActiveAutoLoadedAssembly != null) { this.assemblyList.OpenAssembly(sessionSettings.ActiveAutoLoadedAssembly, true); node = FindNodeByPath(sessionSettings.ActiveTreeViewPath, true); } } if (node != null) { SelectNode(node); // only if not showing the about page, perform the update check: ShowMessageIfUpdatesAvailableAsync(spySettings); } else { AboutPage.Display(decompilerTextView); } } AvalonEditTextOutput output = new AvalonEditTextOutput(); if (FormatExceptions(App.StartupExceptions.ToArray(), output)) decompilerTextView.ShowText(output); }
void LoadingHandler(int i) { switch (i) { case 0: this.CommandBindings.Add(new CommandBinding(ILSpyTreeNode.TreeNodeActivatedEvent, TreeNodeActivatedExecuted)); ContextMenuProvider.Add(treeView); ILSpySettings spySettings = this.spySettings; this.spySettings = null; this.assemblyList = assemblyListManager.LoadList(spySettings, sessionSettings.ActiveAssemblyList); break; case 1: HandleCommandLineArguments(App.CommandLineArguments); if (assemblyList.GetAssemblies().Length == 0 && assemblyList.ListName == AssemblyListManager.DefaultListName) { LoadInitialAssemblies(); } ShowAssemblyListDontAskUser(this.assemblyList); break; case 2: HandleCommandLineArgumentsAfterShowList(App.CommandLineArguments); if (App.CommandLineArguments.NavigateTo == null && App.CommandLineArguments.AssembliesToLoad.Count != 1) { if (ICSharpCode.ILSpy.Options.DisplaySettingsPanel.CurrentDisplaySettings.RestoreTabsAtStartup) { RestoreTabGroups(sessionSettings.SavedTabGroupsState); if (!sessionSettings.TabsFound) AboutPage.Display(SafeActiveTextView); } else { AboutPage.Display(SafeActiveTextView); } } break; case 3: AvalonEditTextOutput output = new AvalonEditTextOutput(); if (FormatExceptions(App.StartupExceptions.ToArray(), output)) SafeActiveTextView.ShowText(output); if (topPane.Content == null) { var pane = GetPane(topPane, sessionSettings.TopPaneSettings.Name); if (pane != null) ShowInTopPane(pane.PaneTitle, pane); } if (bottomPane.Content == null) { var pane = GetPane(bottomPane, sessionSettings.BottomPaneSettings.Name); if (pane != null) ShowInBottomPane(pane.PaneTitle, pane); } break; case 4: foreach (var plugin in plugins) plugin.OnLoaded(); var list = callWhenLoaded; callWhenLoaded = null; foreach (var func in list) func(); break; case 5: this.IsEnabled = true; // Make sure that when no tabs are created that we have focus. If we don't do this we // can't press Ctrl+K and open the asm search. this.Focus(); // Sometimes we get keyboard focus when it's better that the text editor gets the focus instead this.GotKeyboardFocus += MainWindow_GotKeyboardFocus; loadingControl.Visibility = Visibility.Collapsed; mainGrid.Visibility = Visibility.Visible; // In case a plugin has added their own bindings UninstallTabCommandBindings(ActiveTabState); InstallTabCommandBindings(ActiveTabState); // Flickering workaround fix. Could reproduce it when using VMWare + WinXP loadingProgressBar.IsIndeterminate = false; return; default: return; } StartLoadingHandler(i + 1); }
public static void Main (string[] args) { string appPath = null; string slnName = null; string libPath = null; string expOpt = null; string outLanguageType = LAN_TYPE_CSHARP; DecompilerSettings ds = new DecompilerSettings (); ds.AnonymousMethods = true; ds.AsyncAwait = true; ds.YieldReturn = true; string onlyDecomileClassName = null; List<string> onlyDecompilingFileNameList = new List<string> (); //parsing args foreach (string x in args) { if (x.StartsWith ("-")) { switch (x) { case "-n": case "-l": case "-t": case "-C": case "-D": expOpt = x; continue; default: if (x.StartsWith ("-")) { if (x.Length < 2) { Console.WriteLine (" Unexpected options " + x); showUsage (); return; } for (int i = 0; i < x.Length; i++) { if (!praseDecompileSetting (x [i], ds)) { Console.WriteLine (" Unexpected options " + x); showUsage (); return; } } continue; } break; } } else if (expOpt != null) { switch (expOpt) { case "-n": slnName = x; expOpt = null; break; case "-l": libPath = x; expOpt = null; break; case "-t": if (x != LAN_TYPE_CSHARP && x != LAN_TYPE_IL) { Console.WriteLine (" Unexpected Output language type: " + x); showUsage (); return; } outLanguageType = x; expOpt = null; break; case "-C": onlyDecomileClassName = x; expOpt = null; break; case "-D": onlyDecompilingFileNameList.Add (x); break; default: showUsage (); expOpt = null; return; } } else { if (appPath == null) { appPath = x; continue; } else { Console.WriteLine (" Unexpected options " + x); showUsage (); return; } } } if (appPath == null) { Console.WriteLine ("directory/to/all/your/dll missing"); showUsage (); return; } if (slnName == null && outLanguageType==LAN_TYPE_CSHARP) { Console.WriteLine ("Solution Name missing"); showUsage (); return; } Console.WriteLine ("Decompiling all dll in " + appPath); Console.WriteLine ("Please wait..."); DirectoryInfo di = new DirectoryInfo(appPath); appPath = di.FullName; FileInfo[] dllFileInfoList = di.GetFiles("*.dll"); FileInfo[] exeFileInfoList = di.GetFiles ("*.exe"); AssemblyList asmlist = new AssemblyList ("mylistname"); foreach (var dllfile in dllFileInfoList) { bool bDecompile = isDecompilingFile (dllfile.FullName, onlyDecompilingFileNameList); asmlist.OpenAssembly (dllfile.FullName,!bDecompile); } foreach (var dllfile in exeFileInfoList) { bool bDecompile = isDecompilingFile (dllfile.FullName, onlyDecompilingFileNameList); asmlist.OpenAssembly (dllfile.FullName,!bDecompile); } if (libPath != null) { di = new DirectoryInfo(libPath); libPath = di.FullName; dllFileInfoList = di.GetFiles("*.dll"); foreach (var dllfile in dllFileInfoList) { asmlist.OpenAssembly (dllfile.FullName,true); } } StringBuilder projSln = new StringBuilder (); projSln.Append ("Microsoft Visual Studio Solution File, Format Version 11.00\n# Visual Studio 2010\n"); StringBuilder globSec = new StringBuilder (); Guid slnProjGuid = Guid.NewGuid(); int num = 0; LoadedAssembly [] ls = asmlist.GetAssemblies (); var decompilationOptions = new DecompilationOptions (); decompilationOptions.FullDecompilation = true; decompilationOptions.assenmlyList = asmlist; decompilationOptions.DecompilerSettings = ds; decompilationOptions.IncludedClassName = onlyDecomileClassName; if(outLanguageType==LAN_TYPE_CSHARP) { foreach (LoadedAssembly asm in ls) { if (asm.IsAutoLoaded) continue; string projectPath = appPath + "/"+ asm.ShortName; if(!Directory.Exists(projectPath)) { Directory.CreateDirectory (projectPath); } string projectFileName = projectPath + "/" + asm.ShortName + ".csproj"; asm.ProjectGuid = Guid.NewGuid(); asm.ProjectFileName = projectFileName; } } foreach (LoadedAssembly asm in ls) { num++; Console.WriteLine(asm.FileName + " " + num+"/"+ls.Length); if (asm.IsAutoLoaded) continue; if(outLanguageType==LAN_TYPE_CSHARP) { var csharpLanguage = new CSharpLanguage (); var textOutput = new PlainTextOutput (); decompilationOptions.SaveAsProjectDirectory = appPath + "/"+ asm.ShortName; csharpLanguage.DecompileAssembly (asm, textOutput, decompilationOptions); File.WriteAllText (asm.ProjectFileName, textOutput.ToString ()); Guid createdProjGuid = asm.ProjectGuid; projSln.Append(" Project(\"{"); projSln.Append (slnProjGuid.ToString()); projSln.Append ("}\") = \""); projSln.Append (asm.ShortName); projSln.Append ("\", \""); projSln.Append (asm.ShortName+"/"+ asm.ShortName + ".csproj"); projSln.Append ("\", \"{"); projSln.Append (createdProjGuid.ToString()); projSln.Append ("}\"\n"); projSln.Append("EndProject\n"); globSec.Append (" {"+createdProjGuid.ToString()+"}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\n"); globSec.Append (" {"+createdProjGuid.ToString()+"}.Debug|Any CPU.Build.0 = Debug|Any CPU\n"); globSec.Append (" {"+createdProjGuid.ToString()+"}.Release|Any CPU.ActiveCfg = Release|Any CPU\n"); globSec.Append (" {"+createdProjGuid.ToString()+"}.Release|Any CPU.Build.0 = Release|Any CPU\n"); } else { var ilLanguage = new ILLanguage(true); var textOutput = new PlainTextOutput (); ilLanguage.DecompileAssembly (asm, textOutput, decompilationOptions); string ilFileName = appPath + "/"+ asm.ShortName+".il"; File.WriteAllText(ilFileName,textOutput.ToString()); } } if (outLanguageType == LAN_TYPE_CSHARP) { projSln.Append ("Global\n"); projSln.Append ("GlobalSection(SolutionConfigurationPlatforms) = preSolution\n"); projSln.Append ("\t\t\t\tDebug|Any CPU = Debug|Any CPU\n"); projSln.Append ("\t\t\t\tRelease|Any CPU = Release|Any CPU\n"); projSln.Append ("EndGlobalSection\n"); projSln.Append ("GlobalSection(ProjectConfigurationPlatforms) = postSolution\n"); projSln.Append (globSec.ToString ()); projSln.Append ("EndGlobalSection\n"); projSln.Append ("GlobalSection(MonoDevelopProperties) = preSolution\n"); projSln.Append ("\nEndGlobalSection\n"); projSln.Append ("EndGlobal\n\t\t"); string slnFileName = appPath + "/" + slnName + ".sln"; File.WriteAllText (slnFileName, projSln.ToString ()); } }
public PEFile ResolveAssembly(AssemblyList context) { return(context.FindAssembly(Module)?.GetPEFileOrNull()); }
static void DumpNetModule(ProjectInfo info, List<ProjectInfo> projectFiles) { var fileName = info.AssemblyFileName; if (string.IsNullOrEmpty(fileName)) throw new Exception(".NET module filename is empty or null"); var asmList = new AssemblyList("dnspc.exe", false); asmList.UseGAC = !noGac; asmList.AddSearchPath(Path.GetDirectoryName(fileName)); foreach (var path in asmPaths) asmList.AddSearchPath(path); var lasm = new LoadedAssembly(asmList, fileName); var opts = new DecompilationOptions { FullDecompilation = true, CancellationToken = new CancellationToken(), }; TextWriter writer = null; try { var lang = GetLanguage(); if (useStdout) writer = System.Console.Out; else { var baseDir = GetProjectDir(lang, fileName); Directory.CreateDirectory(baseDir); writer = new StreamWriter(info.ProjectFileName, false, Encoding.UTF8); opts.SaveAsProjectDirectory = baseDir; opts.DontReferenceStdLib = noCorlibRef; opts.ProjectFiles = projectFiles; opts.ProjectGuid = info.ProjectGuid; opts.DontShowCreateMethodBodyExceptions = dontMaskErr; Console.WriteLine("Saving {0} to {1}", fileName, baseDir); } lang.DecompileAssembly(lasm, new PlainTextOutput(writer), opts); } finally { if (!useStdout && writer != null) writer.Dispose(); } }
void ShowAssemblyListDontAskUser(AssemblyList assemblyList) { // Clear the cache since the keys contain tree nodes which get recreated now. The keys // will never match again so shouldn't be in the cache. DecompileCache.Instance.ClearAll(); UndoCommandManager.Instance.Clear(); foreach (var tabManager in tabGroupsManager.AllTabGroups.ToArray()) tabManager.RemoveAllTabStates(); this.assemblyList = assemblyList; // Make sure memory usage doesn't increase out of control. This method allocates lots of // new stuff, but the GC doesn't bother to reclaim that memory for a long time. GC.Collect(); GC.WaitForPendingFinalizers(); assemblyList.CollectionChanged += assemblyList_Assemblies_CollectionChanged; assemblyListTreeNode = new AssemblyListTreeNode(assemblyList); // Make sure CurrentAssemblyListChanged() is called after the treenodes have been created assemblyList.CollectionChanged += assemblyList_Assemblies_CollectionChanged2; assemblyListTreeNode.FilterSettings = sessionSettings.FilterSettings.Clone(); assemblyListTreeNode.Select = SelectNode; assemblyListTreeNode.OwnerTreeView = treeView; treeView.Root = assemblyListTreeNode; UpdateTitle(); }
private void AddToList(AssemblyList list, string FullName) { AssemblyNameReference reference = AssemblyNameReference.Parse(FullName); string file = GacInterop.FindAssemblyInNetGacOrWinMetadata(reference); if (file != null) list.OpenAssembly(file); }
void ShowAssemblyList(AssemblyList assemblyList) { history.Clear(); this.assemblyList = assemblyList; assemblyList.assemblies.CollectionChanged += assemblyList_Assemblies_CollectionChanged; assemblyListTreeNode = new AssemblyListTreeNode(assemblyList); assemblyListTreeNode.FilterSettings = sessionSettings.FilterSettings.Clone(); assemblyListTreeNode.Select = SelectNode; treeView.Root = assemblyListTreeNode; if (assemblyList.ListName == AssemblyListManager.DefaultListName) this.Title = "ILSpy"; else this.Title = "ILSpy - " + assemblyList.ListName; }
public static IDisposable DisableAssemblyLoad(AssemblyList assemblyList) { assemblyLoadDisableCount++; return(new DecrementAssemblyLoadDisableCount(assemblyList)); }