CreateAssemblyCommand(ModuleDef newModule, AssemblyOptions options) { var module = Module.ModuleUtils.CreateModule(options.Name, Guid.NewGuid(), options.ClrVersion, ModuleKind.Dll, newModule); options.CreateAssemblyDef(module).Modules.Add(module); this.asmNodeCreator = new AssemblyTreeNodeCreator(new LoadedAssembly(MainWindow.Instance.CurrentAssemblyList, module)); }
public AssemblyOptionsVM(AssemblyOptions options, ModuleDef ownerModule, Language language) { this.ownerModule = ownerModule; this.origOptions = options; this.hashAlgorithmVM = new EnumListVM(hashAlgorithmList, (a, b) => OnPropertyChanged("AssemblyFullName")); this.contentTypeVM = new EnumListVM(contentTypeList, (a, b) => OnPropertyChanged("AssemblyFullName")); this.versionMajor = new UInt16VM(a => { HasErrorUpdated(); OnPropertyChanged("AssemblyFullName"); }) { UseDecimal = true }; this.versionMinor = new UInt16VM(a => { HasErrorUpdated(); OnPropertyChanged("AssemblyFullName"); }) { UseDecimal = true }; this.versionBuild = new UInt16VM(a => { HasErrorUpdated(); OnPropertyChanged("AssemblyFullName"); }) { UseDecimal = true }; this.versionRevision = new UInt16VM(a => { HasErrorUpdated(); OnPropertyChanged("AssemblyFullName"); }) { UseDecimal = true }; this.publicKey = new HexStringVM(a => { HasErrorUpdated(); OnPropertyChanged("AssemblyFullName"); UpdatePublicKeyFlag(); }) { UpperCaseHex = false }; this.customAttributesVM = new CustomAttributesVM(ownerModule, language); this.declSecuritiesVM = new DeclSecuritiesVM(ownerModule, language, null, null); Reinitialize(); }
static void Execute(ILSpyTreeNode[] nodes) { if (!CanExecute(nodes)) { return; } var newModule = new ModuleDefUser(); var data = new AssemblyOptionsVM(AssemblyOptions.Create("MyAssembly"), newModule, MainWindow.Instance.CurrentLanguage); data.CanShowClrVersion = true; var win = new AssemblyOptionsDlg(); win.Title = CMD_NAME; win.DataContext = data; win.Owner = MainWindow.Instance; if (win.ShowDialog() != true) { return; } var cmd = new CreateAssemblyCommand(newModule, data.CreateAssemblyOptions()); UndoCommandManager.Instance.Add(cmd); MainWindow.Instance.JumpToReference(cmd.asmNodeCreator.AssemblyTreeNode); }
static void Execute(Lazy <IUndoCommandManager> undoCommandManager, IAppWindow appWindow, IFileTreeNodeData[] nodes) { if (!CanExecute(nodes)) { return; } var newModule = new ModuleDefUser(); var data = new AssemblyOptionsVM(AssemblyOptions.Create("MyAssembly"), newModule, appWindow.LanguageManager); data.CanShowClrVersion = true; var win = new AssemblyOptionsDlg(); win.Title = dnSpy_AsmEditor_Resources.CreateAssemblyCommand2; win.DataContext = data; win.Owner = appWindow.MainWindow; if (win.ShowDialog() != true) { return; } var cmd = new CreateAssemblyCommand(undoCommandManager.Value, appWindow.FileTreeView, newModule, data.CreateAssemblyOptions()); undoCommandManager.Value.Add(cmd); appWindow.FileTabManager.FollowReference(cmd.fileNodeCreator.DnSpyFileNode); }
static void Execute(Lazy <IUndoCommandService> undoCommandService, IAppService appService, DocumentTreeNodeData[] nodes) { if (!CanExecute(nodes)) { return; } var newModule = new ModuleDefUser(); var data = new AssemblyOptionsVM(AssemblyOptions.Create("MyAssembly"), newModule, appService.DecompilerService); data.CanShowClrVersion = true; var win = new AssemblyOptionsDlg(); win.Title = dnSpy_AsmEditor_Resources.CreateAssemblyCommand2; win.DataContext = data; win.Owner = appService.MainWindow; if (win.ShowDialog() != true) { return; } var cmd = new CreateAssemblyCommand(undoCommandService.Value, appService.DocumentTreeView, newModule, data.CreateAssemblyOptions()); undoCommandService.Value.Add(cmd); appService.DocumentTabService.FollowReference(cmd.fileNodeCreator.DocumentNode); }
AssemblySettingsCommand(AssemblyTreeNode asmNode, AssemblyOptions newOptions) { this.asmNode = asmNode; this.newOptions = newOptions; this.origOptions = new AssemblyOptions(asmNode.LoadedAssembly.AssemblyDefinition); if (newOptions.Name != origOptions.Name) this.assemblyRefInfos = RefFinder.FindAssemblyRefsToThisModule(asmNode.LoadedAssembly.ModuleDefinition).Where(a => AssemblyNameComparer.NameAndPublicKeyTokenOnly.Equals(a, asmNode.LoadedAssembly.AssemblyDefinition)).Select(a => new AssemblyRefInfo(a)).ToArray(); }
AssemblySettingsCommand(AssemblyDocumentNode asmNode, AssemblyOptions newOptions) { this.asmNode = asmNode; this.newOptions = newOptions; origOptions = new AssemblyOptions(asmNode.Document.AssemblyDef); if (newOptions.Name != origOptions.Name) { assemblyRefInfos = RefFinder.FindAssemblyRefsToThisModule(asmNode.Document.ModuleDef).Where(a => AssemblyNameComparer.NameAndPublicKeyTokenOnly.Equals(a, asmNode.Document.AssemblyDef)).Select(a => new AssemblyRefInfo(a)).ToArray(); } }
AssemblyOptions CopyTo(AssemblyOptions options) { options.HashAlgorithm = (AssemblyHashAlgorithm)HashAlgorithm.SelectedItem; options.Version = new Version(VersionMajor.Value, VersionMinor.Value, VersionBuild.Value, VersionRevision.Value); options.Attributes = Flags; options.PublicKey = new PublicKey(PublicKey.Value.ToArray()); options.Name = Name; options.Culture = Culture; options.ClrVersion = (Module.ClrVersion)ClrVersion.SelectedItem; options.CustomAttributes.Clear(); options.CustomAttributes.AddRange(CustomAttributesVM.Collection.Select(a => a.CreateCustomAttributeOptions().Create())); options.DeclSecurities.Clear(); options.DeclSecurities.AddRange(DeclSecuritiesVM.Collection.Select(a => a.CreateDeclSecurityOptions().Create(ownerModule))); return(options); }
void InitializeFrom(AssemblyOptions options) { PublicKey.Value = options.PublicKey.Data; HashAlgorithm.SelectedItem = options.HashAlgorithm; VersionMajor.Value = checked ((ushort)options.Version.Major); VersionMinor.Value = checked ((ushort)options.Version.Minor); VersionBuild.Value = checked ((ushort)options.Version.Build); VersionRevision.Value = checked ((ushort)options.Version.Revision); Flags = options.Attributes; ProcessArchitecture.SelectedItem = (AsmProcArch)((uint)(options.Attributes & AssemblyAttributes.PA_Mask) >> (int)AssemblyAttributes.PA_Shift); ContentType.SelectedItem = (AsmContType)((uint)(options.Attributes & AssemblyAttributes.ContentType_Mask) >> 9); Name = options.Name; Culture = options.Culture; ClrVersion.SelectedItem = options.ClrVersion; CustomAttributesVM.InitializeFrom(options.CustomAttributes); DeclSecuritiesVM.InitializeFrom(options.DeclSecurities); }
public AssemblyOptionsVM(AssemblyOptions options, ModuleDef ownerModule, IDecompilerService decompilerService) { this.ownerModule = ownerModule; origOptions = options; hashAlgorithmVM = new EnumListVM(hashAlgorithmList, (a, b) => OnPropertyChanged(nameof(AssemblyFullName))); contentTypeVM = new EnumListVM(contentTypeList, (a, b) => OnPropertyChanged(nameof(AssemblyFullName))); VersionMajor = new UInt16VM(a => { HasErrorUpdated(); OnPropertyChanged(nameof(AssemblyFullName)); }, true); VersionMinor = new UInt16VM(a => { HasErrorUpdated(); OnPropertyChanged(nameof(AssemblyFullName)); }, true); VersionBuild = new UInt16VM(a => { HasErrorUpdated(); OnPropertyChanged(nameof(AssemblyFullName)); }, true); VersionRevision = new UInt16VM(a => { HasErrorUpdated(); OnPropertyChanged(nameof(AssemblyFullName)); }, true); PublicKey = new HexStringVM(a => { HasErrorUpdated(); OnPropertyChanged(nameof(AssemblyFullName)); UpdatePublicKeyFlag(); }) { UpperCaseHex = false }; CustomAttributesVM = new CustomAttributesVM(ownerModule, decompilerService); DeclSecuritiesVM = new DeclSecuritiesVM(ownerModule, decompilerService, null, null); Reinitialize(); }
AssemblyOptions CopyTo(AssemblyOptions options) { options.HashAlgorithm = (AssemblyHashAlgorithm)HashAlgorithm.SelectedItem; options.Version = new Version(VersionMajor.Value, VersionMinor.Value, VersionBuild.Value, VersionRevision.Value); options.Attributes = Flags; options.PublicKey = new PublicKey(PublicKey.Value.ToArray()); options.Name = Name; options.Culture = Culture; options.ClrVersion = (Module.ClrVersion)ClrVersion.SelectedItem; options.CustomAttributes.Clear(); options.CustomAttributes.AddRange(CustomAttributesVM.Collection.Select(a => a.CreateCustomAttributeOptions().Create())); options.DeclSecurities.Clear(); options.DeclSecurities.AddRange(DeclSecuritiesVM.Collection.Select(a => a.CreateDeclSecurityOptions().Create(ownerModule))); return options; }
CreateAssemblyCommand(ModuleDef newModule, AssemblyOptions options) { var module = Module.ModuleUtils.CreateModule(options.Name, Guid.NewGuid(), options.ClrVersion, ModuleKind.Dll, newModule); options.CreateAssemblyDef(module).Modules.Add(module); this.asmNodeCreator = new AssemblyTreeNodeCreator(MainWindow.Instance.DnSpyFileList.CreateDnSpyFile(module)); }
CreateAssemblyCommand(IUndoCommandManager undoCommandManager, IFileTreeView fileTreeView, ModuleDef newModule, AssemblyOptions options) { this.undoCommandManager = undoCommandManager; var module = Module.ModuleUtils.CreateModule(options.Name, Guid.NewGuid(), options.ClrVersion, ModuleKind.Dll, newModule); options.CreateAssemblyDef(module).Modules.Add(module); var file = DnSpyDotNetFile.CreateAssembly(DnSpyFileInfo.CreateFile(string.Empty), module, fileTreeView.FileManager.Settings.LoadPDBFiles); this.fileNodeCreator = RootDnSpyFileNodeCreator.CreateAssembly(fileTreeView, file); }
public AssemblyOptionsVM(AssemblyOptions options, ModuleDef ownerModule, Language language) { this.ownerModule = ownerModule; this.origOptions = options; this.hashAlgorithmVM = new EnumListVM(hashAlgorithmList, (a, b) => OnPropertyChanged("AssemblyFullName")); this.contentTypeVM = new EnumListVM(contentTypeList, (a, b) => OnPropertyChanged("AssemblyFullName")); this.versionMajor = new UInt16VM(a => { HasErrorUpdated(); OnPropertyChanged("AssemblyFullName"); }, true); this.versionMinor = new UInt16VM(a => { HasErrorUpdated(); OnPropertyChanged("AssemblyFullName"); }, true); this.versionBuild = new UInt16VM(a => { HasErrorUpdated(); OnPropertyChanged("AssemblyFullName"); }, true); this.versionRevision = new UInt16VM(a => { HasErrorUpdated(); OnPropertyChanged("AssemblyFullName"); }, true); this.publicKey = new HexStringVM(a => { HasErrorUpdated(); OnPropertyChanged("AssemblyFullName"); UpdatePublicKeyFlag(); }) { UpperCaseHex = false }; this.customAttributesVM = new CustomAttributesVM(ownerModule, language); this.declSecuritiesVM = new DeclSecuritiesVM(ownerModule, language, null, null); Reinitialize(); }
void InitializeFrom(AssemblyOptions options) { PublicKey.Value = options.PublicKey.Data; HashAlgorithm.SelectedItem = options.HashAlgorithm; VersionMajor.Value = checked((ushort)options.Version.Major); VersionMinor.Value = checked((ushort)options.Version.Minor); VersionBuild.Value = checked((ushort)options.Version.Build); VersionRevision.Value = checked((ushort)options.Version.Revision); Flags = options.Attributes; ProcessArchitecture.SelectedItem = (AsmProcArch)((uint)(options.Attributes & AssemblyAttributes.PA_Mask) >> (int)AssemblyAttributes.PA_Shift); ContentType.SelectedItem = (AsmContType)((uint)(options.Attributes & AssemblyAttributes.ContentType_Mask) >> 9); Name = options.Name; Culture = options.Culture; ClrVersion.SelectedItem = options.ClrVersion; CustomAttributesVM.InitializeFrom(options.CustomAttributes); DeclSecuritiesVM.InitializeFrom(options.DeclSecurities); }
CreateAssemblyCommand(IUndoCommandService undoCommandService, IDocumentTreeView documentTreeView, ModuleDef newModule, AssemblyOptions options) { this.undoCommandService = undoCommandService; var module = Module.ModuleUtils.CreateModule(options.Name, Guid.NewGuid(), options.ClrVersion, ModuleKind.Dll, newModule); options.CreateAssemblyDef(module).Modules.Add(module); var file = DsDotNetDocument.CreateAssembly(DsDocumentInfo.CreateDocument(string.Empty), module, true); fileNodeCreator = RootDocumentNodeCreator.CreateAssembly(documentTreeView, file); }