Пример #1
0
        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));
        }
Пример #2
0
 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();
 }
Пример #3
0
        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);
        }
Пример #4
0
        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);
        }
Пример #5
0
        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);
        }
Пример #6
0
        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();
        }
Пример #7
0
        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();
            }
        }
Пример #8
0
 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);
 }
Пример #9
0
 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);
 }
Пример #10
0
 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();
 }
Пример #11
0
 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;
 }
Пример #12
0
		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));
		}
Пример #13
0
        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);
        }
Пример #14
0
 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();
 }
Пример #15
0
 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);
 }
Пример #16
0
		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();
		}
Пример #17
0
		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);
		}
Пример #18
0
        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);
        }
Пример #19
0
		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);
		}