コード例 #1
0
 FileSearcherProvider(IFileTreeView fileTreeView, IImageManager imageManager, IDotNetImageManager dotNetImageManager, IDecompilerManager decompilerManager)
 {
     this.fileTreeView       = fileTreeView;
     this.imageManager       = imageManager;
     this.dotNetImageManager = dotNetImageManager;
     this.decompilerManager  = decompilerManager;
 }
コード例 #2
0
ファイル: MarshalTypeVM.cs プロジェクト: zhangguanjiong/dnSpy
        static TypeSigCreatorVM CreateTypeSigCreatorVM(ModuleDef ownerModule, IDecompilerManager decompilerManager, TypeDef ownerType, MethodDef ownerMethod, bool allowNullTypeSig, PropertyChangedEventHandler handler)
        {
            var typeSigCreatorOptions = new TypeSigCreatorOptions(ownerModule, decompilerManager)
            {
                IsLocal = false,
                CanAddGenericTypeVar   = true,
                CanAddGenericMethodVar = false,
                OwnerType          = ownerType,
                OwnerMethod        = ownerMethod,
                NullTypeSigAllowed = allowNullTypeSig,
            };

            if (ownerType != null && ownerType.GenericParameters.Count == 0)
            {
                typeSigCreatorOptions.CanAddGenericTypeVar = false;
            }
            if (ownerMethod != null && ownerMethod.GenericParameters.Count > 0)
            {
                typeSigCreatorOptions.CanAddGenericMethodVar = true;
            }
            var typeSigCreator = new TypeSigCreatorVM(typeSigCreatorOptions);

            typeSigCreator.PropertyChanged += handler;
            return(typeSigCreator);
        }
コード例 #3
0
        public PropertyOptionsVM(PropertyDefOptions options, ModuleDef ownerModule, IDecompilerManager decompilerManager, TypeDef ownerType)
        {
            this.ownerModule = ownerModule;
            this.origOptions = options;

            var typeSigCreatorOptions = new TypeSigCreatorOptions(ownerModule, decompilerManager)
            {
                IsLocal = false,
                CanAddGenericTypeVar   = true,
                CanAddGenericMethodVar = true,
                OwnerType = ownerType,
            };

            if (ownerType != null && ownerType.GenericParameters.Count == 0)
            {
                typeSigCreatorOptions.CanAddGenericTypeVar = false;
            }
            var methodSigCreatorOptions = new MethodSigCreatorOptions(typeSigCreatorOptions);

            methodSigCreatorOptions.IsPropertySig = true;
            this.MethodSigCreator = new MethodSigCreatorVM(methodSigCreatorOptions);
            this.MethodSigCreator.PropertyChanged += methodSigCreator_PropertyChanged;
            this.MethodSigCreator.ParametersCreateTypeSigArray.PropertyChanged           += methodSigCreator_PropertyChanged;
            this.MethodSigCreator.ParametersCreateTypeSigArray.TypeSigCreator.CanAddFnPtr = false;
            this.GetMethodsVM                = new MethodDefsVM(ownerModule, decompilerManager);
            this.SetMethodsVM                = new MethodDefsVM(ownerModule, decompilerManager);
            this.OtherMethodsVM              = new MethodDefsVM(ownerModule, decompilerManager);
            this.CustomAttributesVM          = new CustomAttributesVM(ownerModule, decompilerManager);
            this.ConstantVM                  = new ConstantVM(ownerModule, options.Constant == null ? null : options.Constant.Value, dnSpy_AsmEditor_Resources.Property_DefaultValue);
            this.ConstantVM.PropertyChanged += constantVM_PropertyChanged;

            ConstantVM.IsEnabled = HasDefault;
            Reinitialize();
        }
コード例 #4
0
        public EventOptionsVM(EventDefOptions options, ModuleDef ownerModule, IDecompilerManager decompilerManager, TypeDef ownerType)
        {
            this.ownerModule = ownerModule;
            var typeSigCreatorOptions = new TypeSigCreatorOptions(ownerModule, decompilerManager)
            {
                IsLocal = false,
                CanAddGenericTypeVar   = true,
                CanAddGenericMethodVar = true,
                OwnerType = ownerType,
            };

            if (ownerType != null && ownerType.GenericParameters.Count == 0)
            {
                typeSigCreatorOptions.CanAddGenericTypeVar = false;
            }
            this.TypeSigCreator = new TypeSigCreatorVM(typeSigCreatorOptions);
            this.TypeSigCreator.PropertyChanged += typeSigCreator_PropertyChanged;

            this.CustomAttributesVM = new CustomAttributesVM(ownerModule, decompilerManager);
            this.OtherMethodsVM     = new MethodDefsVM(ownerModule, decompilerManager);

            this.origOptions = options;

            this.TypeSigCreator.CanAddFnPtr = false;
            Reinitialize();
        }
コード例 #5
0
        public MemberPickerVM(IFileSearcherProvider fileSearcherProvider, IFileTreeView fileTreeView, IDecompilerManager decompilerManager, IFileTreeNodeFilter filter, string title, IEnumerable <IDnSpyFile> assemblies)
        {
            this.Title = title;
            this.fileSearcherProvider = fileSearcherProvider;
            this.decompilerManager    = decompilerManager;
            this.fileTreeView         = fileTreeView;
            this.decompiler           = decompilerManager.Decompiler;
            this.filter        = filter;
            this.delayedSearch = new DelayedAction(DEFAULT_DELAY_SEARCH_MS, DelayStartSearch);
            this.SearchResults = new ObservableCollection <ISearchResult>();
            this.searchResultsCollectionView            = (ListCollectionView)CollectionViewSource.GetDefaultView(SearchResults);
            this.searchResultsCollectionView.CustomSort = new SearchResult_Comparer();

            foreach (var file in assemblies)
            {
                fileTreeView.FileManager.ForceAdd(file, false, null);
            }

            fileTreeView.FileManager.CollectionChanged += (s, e) => Restart();

            this.CaseSensitive      = false;
            this.MatchWholeWords    = false;
            this.MatchAnySearchTerm = false;
            RefreshTreeView();
        }
コード例 #6
0
ファイル: BreakpointsVM.cs プロジェクト: zhangguanjiong/dnSpy
 BreakpointsVM(IDecompilerManager decompilerManager, IImageManager imageManager, IThemeManager themeManager, IDebuggerSettings debuggerSettings, ITheDebugger theDebugger, IBreakpointManager breakpointManager, IBreakpointSettings breakpointSettings, Lazy <IModuleLoader> moduleLoader, IInMemoryModuleManager inMemoryModuleManager)
 {
     this.breakpointContext = new BreakpointContext(imageManager, moduleLoader)
     {
         Decompiler         = decompilerManager.Decompiler,
         SyntaxHighlight    = debuggerSettings.SyntaxHighlightBreakpoints,
         UseHexadecimal     = debuggerSettings.UseHexadecimal,
         ShowTokens         = breakpointSettings.ShowTokens,
         ShowModuleNames    = breakpointSettings.ShowModuleNames,
         ShowParameterTypes = breakpointSettings.ShowParameterTypes,
         ShowParameterNames = breakpointSettings.ShowParameterNames,
         ShowOwnerTypes     = breakpointSettings.ShowOwnerTypes,
         ShowReturnTypes    = breakpointSettings.ShowReturnTypes,
         ShowNamespaces     = breakpointSettings.ShowNamespaces,
         ShowTypeKeywords   = breakpointSettings.ShowTypeKeywords,
     };
     this.breakpointManager                      = breakpointManager;
     this.theDebugger                            = theDebugger;
     this.breakpointList                         = new ObservableCollection <BreakpointVM>();
     breakpointSettings.PropertyChanged         += BreakpointSettings_PropertyChanged;
     breakpointManager.BreakpointsAdded         += BreakpointManager_BreakpointsAdded;
     breakpointManager.BreakpointsRemoved       += BreakpointManager_BreakpointsRemoved;
     debuggerSettings.PropertyChanged           += DebuggerSettings_PropertyChanged;
     theDebugger.OnProcessStateChanged          += TheDebugger_OnProcessStateChanged;
     themeManager.ThemeChanged                  += ThemeManager_ThemeChanged;
     decompilerManager.DecompilerChanged        += DecompilerManager_DecompilerChanged;
     inMemoryModuleManager.DynamicModulesLoaded += InMemoryModuleManager_DynamicModulesLoaded;
     foreach (var bp in breakpointManager.GetBreakpoints())
     {
         AddBreakpoint(bp);
     }
 }
コード例 #7
0
        public GenericParamVM(GenericParamOptions options, ModuleDef ownerModule, IDecompilerManager decompilerManager, TypeDef ownerType, MethodDef ownerMethod)
        {
            this.ownerModule          = ownerModule;
            this.origOptions          = options;
            this.Number               = new UInt16VM(a => { OnPropertyChanged(nameof(FullName)); HasErrorUpdated(); });
            this.TypeDefOrRefAndCAsVM = new TypeDefOrRefAndCAsVM <GenericParamConstraint>(dnSpy_AsmEditor_Resources.EditGenericParameterConstraint, dnSpy_AsmEditor_Resources.CreateGenericParameterConstraint, ownerModule, decompilerManager, ownerType, ownerMethod);
            this.CustomAttributesVM   = new CustomAttributesVM(ownerModule, decompilerManager);
            this.GPVarianceVM         = new EnumListVM(EnumVM.Create(typeof(GPVariance)));

            var typeSigCreatorOptions = new TypeSigCreatorOptions(ownerModule, decompilerManager)
            {
                IsLocal = false,
                CanAddGenericTypeVar   = true,
                CanAddGenericMethodVar = false,
                OwnerType   = ownerType,
                OwnerMethod = ownerMethod,
            };

            if (ownerType != null && ownerType.GenericParameters.Count == 0)
            {
                typeSigCreatorOptions.CanAddGenericTypeVar = false;
            }
            if (ownerMethod != null && ownerMethod.GenericParameters.Count > 0)
            {
                typeSigCreatorOptions.CanAddGenericMethodVar = true;
            }
            this.TypeSigCreator = new TypeSigCreatorVM(typeSigCreatorOptions);

            Reinitialize();
        }
コード例 #8
0
 EditCodeVMCreator(IImageManager imageManager, IOpenFromGAC openFromGAC, IFileTreeView fileTreeView, IDecompilerManager decompilerManager, [ImportMany] IEnumerable <ILanguageCompilerProvider> languageCompilerProviders)
 {
     this.imageManager              = imageManager;
     this.openFromGAC               = openFromGAC;
     this.openAssembly              = new OpenAssembly(fileTreeView.FileManager);
     this.decompilerManager         = decompilerManager;
     this.languageCompilerProviders = languageCompilerProviders.OrderBy(a => a.Order).ToArray();
 }
コード例 #9
0
ファイル: SaveCommands.cs プロジェクト: zhangguanjiong/dnSpy
 ExportProjectCommand(IAppWindow appWindow, IFileTreeView fileTreeView, IDecompilerManager decompilerManager, IFileTreeViewSettings fileTreeViewSettings, IExportToProjectSettings exportToProjectSettings, [ImportMany] IEnumerable <Lazy <IBamlDecompiler> > bamlDecompilers)
 {
     this.appWindow               = appWindow;
     this.fileTreeView            = fileTreeView;
     this.decompilerManager       = decompilerManager;
     this.fileTreeViewSettings    = fileTreeViewSettings;
     this.exportToProjectSettings = exportToProjectSettings;
     this.bamlDecompiler          = bamlDecompilers.FirstOrDefault();
 }
コード例 #10
0
        public FileTreeView(bool isGlobal, IFileTreeNodeFilter filter, IThemeManager themeManager, ITreeViewManager treeViewManager, IDecompilerManager decompilerManager, IFileManager fileManager, IFileTreeViewSettings fileTreeViewSettings, IMenuManager menuManager, IDotNetImageManager dotNetImageManager, IWpfCommandManager wpfCommandManager, IResourceNodeFactory resourceNodeFactory, IAppSettings appSettings, [ImportMany] IEnumerable <Lazy <IDnSpyFileNodeProvider, IDnSpyFileNodeProviderMetadata> > dnSpyFileNodeProviders, [ImportMany] IEnumerable <Lazy <IFileTreeNodeDataFinder, IFileTreeNodeDataFinderMetadata> > mefFinders)
        {
            this.decompilerManager    = decompilerManager;
            this.themeManager         = themeManager;
            this.fileTreeViewSettings = fileTreeViewSettings;
            this.appSettings          = appSettings;

            this.context = new FileTreeNodeDataContext(this, resourceNodeFactory, filter ?? FilterNothingFileTreeNodeFilter.Instance)
            {
                SyntaxHighlight            = fileTreeViewSettings.SyntaxHighlight,
                SingleClickExpandsChildren = fileTreeViewSettings.SingleClickExpandsTreeViewChildren,
                ShowAssemblyVersion        = fileTreeViewSettings.ShowAssemblyVersion,
                ShowAssemblyPublicKeyToken = fileTreeViewSettings.ShowAssemblyPublicKeyToken,
                ShowToken            = fileTreeViewSettings.ShowToken,
                Decompiler           = decompilerManager.Decompiler,
                UseNewRenderer       = appSettings.UseNewRenderer_FileTreeView,
                DeserializeResources = fileTreeViewSettings.DeserializeResources,
                CanDragAndDrop       = isGlobal,
            };

            var options = new TreeViewOptions {
                AllowDrop          = true,
                IsVirtualizing     = true,
                VirtualizationMode = VirtualizationMode.Recycling,
                TreeViewListener   = this,
                RootNode           = new RootNode {
                    DropNodes = OnDropNodes,
                    DropFiles = OnDropFiles,
                },
            };

            this.fileTreeNodeGroups     = new FileTreeNodeGroups();
            this.dnSpyFileNodeProviders = dnSpyFileNodeProviders.OrderBy(a => a.Metadata.Order).ToArray();
            this.TreeView = treeViewManager.Create(new Guid(TVConstants.FILE_TREEVIEW_GUID), options);
            this.TreeView.SelectionChanged += TreeView_SelectionChanged;
            this.FileManager        = fileManager;
            this.DotNetImageManager = dotNetImageManager;
            this.dispatcher         = Dispatcher.CurrentDispatcher;
            this.FileManager.SetDispatcher(AddAction);
            fileManager.CollectionChanged        += FileManager_CollectionChanged;
            decompilerManager.DecompilerChanged  += DecompilerManager_DecompilerChanged;
            themeManager.ThemeChanged            += ThemeManager_ThemeChanged;
            fileTreeViewSettings.PropertyChanged += FileTreeViewSettings_PropertyChanged;
            appSettings.PropertyChanged          += AppSettings_PropertyChanged;

            this.WpfCommands = wpfCommandManager.GetCommands(ControlConstants.GUID_FILE_TREEVIEW);

            if (isGlobal)
            {
                menuManager.InitializeContextMenu((FrameworkElement)this.TreeView.UIObject, new Guid(MenuConstants.GUIDOBJ_FILES_TREEVIEW_GUID), new GuidObjectsProvider(this.TreeView));
                wpfCommandManager.Add(ControlConstants.GUID_FILE_TREEVIEW, (UIElement)TreeView.UIObject);
            }

            this.nodeFinders = mefFinders.OrderBy(a => a.Metadata.Order).ToArray();
            InitializeFileTreeNodeGroups();
        }
コード例 #11
0
        public TypeOptionsVM(TypeDefOptions options, ModuleDef ownerModule, IDecompilerManager decompilerManager, TypeDef ownerType)
        {
            this.ownerModule = ownerModule;
            var typeSigCreatorOptions = new TypeSigCreatorOptions(ownerModule, decompilerManager)
            {
                IsLocal = false,
                CanAddGenericTypeVar   = true,
                CanAddGenericMethodVar = false,
                OwnerType = ownerType,
            };

            if (ownerType != null && ownerType.GenericParameters.Count == 0)
            {
                typeSigCreatorOptions.CanAddGenericTypeVar = false;
            }
            this.TypeSigCreator = new TypeSigCreatorVM(typeSigCreatorOptions);
            this.TypeSigCreator.PropertyChanged += typeSigCreator_PropertyChanged;

            this.CustomAttributesVM = new CustomAttributesVM(ownerModule, decompilerManager, ownerType, null);
            this.DeclSecuritiesVM   = new DeclSecuritiesVM(ownerModule, decompilerManager, ownerType, null);
            this.GenericParamsVM    = new GenericParamsVM(ownerModule, decompilerManager, ownerType, null);
            this.InterfaceImplsVM   = new TypeDefOrRefAndCAsVM <InterfaceImpl>(dnSpy_AsmEditor_Resources.EditInterfaceImpl, dnSpy_AsmEditor_Resources.CreateInterfaceImpl, ownerModule, decompilerManager, ownerType, null);

            this.origOptions   = options;
            this.IsNestedType  = (options.Attributes & TypeAttributes.VisibilityMask) > TypeAttributes.Public;
            this.TypeKind      = new EnumListVM(typeKindList, (a, b) => OnTypeKindChanged());
            this.TypeLayout    = new EnumListVM(typeLayoutList, (a, b) => InitializeTypeKind());
            this.TypeSemantics = new EnumListVM(typeSemanticsList, (a, b) => InitializeTypeKind());
            this.PackingSize   = new NullableUInt16VM(a => HasErrorUpdated());
            this.ClassSize     = new NullableUInt32VM(a => HasErrorUpdated());

            Types.TypeVisibility start, end;
            if (!IsNestedType)
            {
                start = Types.TypeVisibility.NotPublic;
                end   = Types.TypeVisibility.Public;
            }
            else
            {
                start = Types.TypeVisibility.NestedPublic;
                end   = Types.TypeVisibility.NestedFamORAssem;
            }
            for (var t = Types.TypeVisibility.NotPublic; t <= Types.TypeVisibility.NestedFamORAssem; t++)
            {
                if (t < start || t > end)
                {
                    TypeVisibility.Items.RemoveAt(TypeVisibility.GetIndex(t));
                }
            }

            InitializeTypeKind();
            this.TypeSigCreator.CanAddFnPtr = false;
            Reinitialize();
        }
コード例 #12
0
        public SecurityAttributeVM(SecurityAttribute sa, ModuleDef ownerModule, IDecompilerManager decompilerManager, TypeDef ownerType, MethodDef ownerMethod)
        {
            this.origSa             = sa;
            this.ownerModule        = ownerModule;
            this.CANamedArgumentsVM = new CANamedArgumentsVM(ownerModule, decompilerManager, ownerType, ownerMethod, a => {
                // The named args blob length must also be at most 0x1FFFFFFF bytes but we can't verify it here
                return(a.Collection.Count < ModelUtils.COMPRESSED_UINT32_MAX);
            });
            CANamedArgumentsVM.Collection.CollectionChanged += Args_CollectionChanged;

            Reinitialize();
        }
コード例 #13
0
        public MethodBodyVM(MethodBodyOptions options, ModuleDef ownerModule, IDecompilerManager decompilerManager, TypeDef ownerType, MethodDef ownerMethod)
        {
            this.origOptions = options;

            this.NativeMethodBodyVM             = new MethodBody.NativeMethodBodyVM(options.NativeMethodBodyOptions, false);
            NativeMethodBodyVM.PropertyChanged += (s, e) => HasErrorUpdated();
            this.CilBodyVM             = new MethodBody.CilBodyVM(options.CilBodyOptions, ownerModule, decompilerManager, ownerType, ownerMethod, false);
            CilBodyVM.PropertyChanged += (s, e) => HasErrorUpdated();
            this.MethodBodyTypeVM      = new EnumListVM(methodBodyTypeList, (a, b) => OnMethodBodyTypeChanged());

            Reinitialize();
        }
コード例 #14
0
        public CustomAttributeVM(CustomAttributeOptions options, ModuleDef ownerModule, IDecompilerManager decompilerManager, TypeDef ownerType, MethodDef ownerMethod)
        {
            this.origOptions       = options;
            this.ownerModule       = ownerModule;
            this.decompilerManager = decompilerManager;
            this.ownerType         = ownerType;
            this.ownerMethod       = ownerMethod;

            this.RawData            = new HexStringVM(a => HasErrorUpdated());
            this.CANamedArgumentsVM = new CANamedArgumentsVM(ownerModule, decompilerManager, ownerType, ownerMethod, a => !IsRawData && a.Collection.Count < ushort.MaxValue);
            ConstructorArguments.CollectionChanged          += Args_CollectionChanged;
            CANamedArgumentsVM.Collection.CollectionChanged += Args_CollectionChanged;

            Reinitialize();
        }
コード例 #15
0
ファイル: ParamDefVM.cs プロジェクト: zhangguanjiong/dnSpy
        public ParamDefVM(ParamDefOptions options, ModuleDef ownerModule, IDecompilerManager decompilerManager, TypeDef ownerType, MethodDef ownerMethod)
        {
            this.ownerModule               = ownerModule;
            this.origOptions               = options;
            this.Sequence                  = new UInt16VM(a => { OnPropertyChanged(nameof(FullName)); HasErrorUpdated(); });
            this.CustomAttributesVM        = new CustomAttributesVM(ownerModule, decompilerManager);
            this.ConstantVM                = new ConstantVM(ownerModule, options.Constant?.Value, dnSpy_AsmEditor_Resources.Parameter_DefaultValueInfo);
            ConstantVM.PropertyChanged    += constantVM_PropertyChanged;
            this.MarshalTypeVM             = new MarshalTypeVM(ownerModule, decompilerManager, ownerType != null ? ownerType : ownerMethod?.DeclaringType, ownerMethod);
            MarshalTypeVM.PropertyChanged += marshalTypeVM_PropertyChanged;

            ConstantVM.IsEnabled    = HasDefault;
            MarshalTypeVM.IsEnabled = HasFieldMarshal;
            Reinitialize();
        }
コード例 #16
0
 FileTreeViewProvider(IThemeManager themeManager, ITreeViewManager treeViewManager, IDecompilerManager decompilerManager, IFileManagerProvider fileManagerProvider, IFileTreeViewSettings fileTreeViewSettings, IMenuManager menuManager, IDotNetImageManager dotNetImageManager, IWpfCommandManager wpfCommandManager, IResourceNodeFactory resourceNodeFactory, IAppSettings appSettings, [ImportMany] IEnumerable <Lazy <IDnSpyFileNodeProvider, IDnSpyFileNodeProviderMetadata> > dnSpyFileNodeProviders, [ImportMany] IEnumerable <Lazy <IFileTreeNodeDataFinder, IFileTreeNodeDataFinderMetadata> > mefFinders)
 {
     this.themeManager           = themeManager;
     this.treeViewManager        = treeViewManager;
     this.decompilerManager      = decompilerManager;
     this.fileManagerProvider    = fileManagerProvider;
     this.fileTreeViewSettings   = fileTreeViewSettings;
     this.menuManager            = menuManager;
     this.dotNetImageManager     = dotNetImageManager;
     this.wpfCommandManager      = wpfCommandManager;
     this.resourceNodeFactory    = resourceNodeFactory;
     this.appSettings            = appSettings;
     this.dnSpyFileNodeProviders = dnSpyFileNodeProviders.ToArray();
     this.mefFinders             = mefFinders.ToArray();
 }
コード例 #17
0
 public ExportToProjectVM(IPickDirectory pickDirectory, IDecompilerManager decompilerManager, IExportTask exportTask, bool canDecompileBaml)
 {
     this.pickDirectory                 = pickDirectory;
     this.decompilerManager             = decompilerManager;
     this.exportTask                    = exportTask;
     this.canDecompileBaml              = canDecompileBaml;
     this.unpackResources               = true;
     this.createResX                    = true;
     this.decompileXaml                 = canDecompileBaml;
     this.createSolution                = true;
     this.ProjectVersionVM.SelectedItem = ProjectVersion.VS2010;
     this.decompiler                    = decompilerManager.AllDecompilers.FirstOrDefault(a => a.ProjectFileExtension != null);
     this.isIndeterminate               = false;
     this.ProjectGuid                   = new NullableGuidVM(Guid.NewGuid(), a => HasErrorUpdated());
 }
コード例 #18
0
 public DeclSecurityVM(DeclSecurityOptions options, ModuleDef ownerModule, IDecompilerManager decompilerManager, TypeDef ownerType, MethodDef ownerMethod)
 {
     this.ownerModule                    = ownerModule;
     this.decompilerManager              = decompilerManager;
     this.ownerType                      = ownerType;
     this.ownerMethod                    = ownerMethod;
     this.origOptions                    = options;
     this.CustomAttributesVM             = new CustomAttributesVM(ownerModule, decompilerManager);
     CustomAttributesVM.PropertyChanged += CustomAttributesVM_PropertyChanged;
     this.DeclSecVerEnumList             = new EnumListVM(declSecVerList, (a, b) => OnDeclSecVerChanged());
     this.SecurityActionEnumList         = new EnumListVM(secActList, (a, b) => OnSecurityActionChanged());
     this.SecurityAttributesVM           = new SecurityAttributesVM(ownerModule, decompilerManager, ownerType, ownerMethod);
     this.SecurityAttributesVM.Collection.CollectionChanged += SecurityAttributesVM_CollectionChanged;
     Reinitialize();
 }
コード例 #19
0
ファイル: SearchManager.cs プロジェクト: zhangguanjiong/dnSpy
        SearchManager(IImageManager imageManager, IDecompilerManager decompilerManager, IThemeManager themeManager, ISearchSettings searchSettings, IFileSearcherProvider fileSearcherProvider, IMenuManager menuManager, IWpfCommandManager wpfCommandManager, IFileTabManager fileTabManager)
        {
            this.fileTabManager = fileTabManager;
            this.searchControl  = new SearchControl();
            this.vmSearch       = new SearchControlVM(imageManager, fileSearcherProvider, fileTabManager.FileTreeView, searchSettings)
            {
                Decompiler     = decompilerManager.Decompiler,
                BackgroundType = BackgroundType.Search,
            };
            this.searchControl.DataContext = this.vmSearch;

            menuManager.InitializeContextMenu(this.searchControl.ListBox, MenuConstants.GUIDOBJ_SEARCH_GUID, new GuidObjectsProvider());
            wpfCommandManager.Add(ControlConstants.GUID_SEARCH_CONTROL, this.searchControl);
            wpfCommandManager.Add(ControlConstants.GUID_SEARCH_LISTBOX, this.searchControl.ListBox);
            decompilerManager.DecompilerChanged += DecompilerManager_DecompilerChanged;
            themeManager.ThemeChanged           += ThemeManager_ThemeChanged;
            searchSettings.PropertyChanged      += SearchSettings_PropertyChanged;
            fileTabManager.FileTreeView.FileManager.CollectionChanged += FileManager_CollectionChanged;

            this.searchControl.SearchListBoxDoubleClick += (s, e) => FollowSelectedReference();
            var cmds    = wpfCommandManager.GetCommands(ControlConstants.GUID_SEARCH_LISTBOX);
            var command = new RelayCommand(a => FollowSelectedReference());

            cmds.Add(command, ModifierKeys.None, Key.Enter);
            cmds.Add(command, ModifierKeys.Control, Key.Enter);
            cmds.Add(command, ModifierKeys.Shift, Key.Enter);

            Add(SearchType.TypeDef, Key.T);
            Add(SearchType.FieldDef, Key.F);
            Add(SearchType.MethodDef, Key.M);
            Add(SearchType.PropertyDef, Key.P);
            Add(SearchType.EventDef, Key.E);
            Add(SearchType.ParamDef, Key.J);
            Add(SearchType.Local, Key.I);
            Add(SearchType.ParamLocal, Key.N);
            Add(SearchType.Resource, Key.R);
            Add(SearchType.Member, Key.U);
            Add(SearchType.Any, Key.B);
            Add(SearchType.Literal, Key.L);

            Add(SearchLocation.AllFiles, Key.G);
            Add(SearchLocation.SelectedFiles, Key.S);
            Add(SearchLocation.AllFilesInSameDir, Key.D);
            Add(SearchLocation.SelectedType, Key.Q);
        }
コード例 #20
0
 public AssemblyOptionsVM(AssemblyOptions options, ModuleDef ownerModule, IDecompilerManager decompilerManager)
 {
     this.ownerModule     = ownerModule;
     this.origOptions     = options;
     this.hashAlgorithmVM = new EnumListVM(hashAlgorithmList, (a, b) => OnPropertyChanged(nameof(AssemblyFullName)));
     this.contentTypeVM   = new EnumListVM(contentTypeList, (a, b) => OnPropertyChanged(nameof(AssemblyFullName)));
     this.VersionMajor    = new UInt16VM(a => { HasErrorUpdated(); OnPropertyChanged(nameof(AssemblyFullName)); }, true);
     this.VersionMinor    = new UInt16VM(a => { HasErrorUpdated(); OnPropertyChanged(nameof(AssemblyFullName)); }, true);
     this.VersionBuild    = new UInt16VM(a => { HasErrorUpdated(); OnPropertyChanged(nameof(AssemblyFullName)); }, true);
     this.VersionRevision = new UInt16VM(a => { HasErrorUpdated(); OnPropertyChanged(nameof(AssemblyFullName)); }, true);
     this.PublicKey       = new HexStringVM(a => { HasErrorUpdated(); OnPropertyChanged(nameof(AssemblyFullName)); UpdatePublicKeyFlag(); })
     {
         UpperCaseHex = false
     };
     this.CustomAttributesVM = new CustomAttributesVM(ownerModule, decompilerManager);
     this.DeclSecuritiesVM   = new DeclSecuritiesVM(ownerModule, decompilerManager, null, null);
     Reinitialize();
 }
コード例 #21
0
 LanguageComboBoxToolbarCommand(IDecompilerManager decompilerManager)
 {
     this.decompilerManager = decompilerManager;
     this.infos             = decompilerManager.AllDecompilers.OrderBy(a => a.OrderUI).Select(a => new LanguageInfo {
         Decompiler = a
     }).ToList();
     UpdateSelectedItem();
     this.comboBox = new ComboBox {
         DisplayMemberPath = "Name",
         Width             = 90,
         ItemsSource       = infos,
     };
     this.comboBox.SetBinding(Selector.SelectedItemProperty, new Binding(nameof(SelectedItem))
     {
         Source = this,
     });
     decompilerManager.DecompilerChanged += DecompilerManager_DecompilerChanged;
 }
コード例 #22
0
ファイル: MarshalTypeVM.cs プロジェクト: zhangguanjiong/dnSpy
 public MarshalTypeVM(ModuleDef ownerModule, IDecompilerManager decompilerManager, TypeDef ownerType, MethodDef ownerMethod)
 {
     this.NativeType = new EnumListVM(nativeTypeList, (a, b) => { OnNativeTypeChanged(); TypeStringUpdated(); });
     FixNativeTypeEnum(this.NativeType, false);
     this.RawMarshalType_Data              = new HexStringVM(a => { HasErrorUpdated(); TypeStringUpdated(); });
     this.FixedSysStringMarshalType_Size   = new NullableCompressedUInt32(a => { HasErrorUpdated(); TypeStringUpdated(); });
     this.SafeArrayMarshalType_VariantType = new EnumListVM(variantTypeList, (a, b) => { OnSafeArrayMarshalTypeIsEnabledChanged(); TypeStringUpdated(); });
     this.SafeArrayMarshalType_UserDefinedSubType_TypeSigCreator = CreateTypeSigCreatorVM(ownerModule, decompilerManager, ownerType, ownerMethod, true, safeArrayMarshalType_userDefinedSubType_typeSigCreator_PropertyChanged);
     this.FixedArrayMarshalType_Size       = new NullableCompressedUInt32(a => { OnFixedArrayMarshalTypeIsEnabledChanged(); TypeStringUpdated(); });
     this.FixedArrayMarshalType_NativeType = new EnumListVM(nativeTypeList, (a, b) => { OnFixedArrayMarshalTypeIsEnabledChanged(); TypeStringUpdated(); });
     FixNativeTypeEnum(FixedArrayMarshalType_NativeType, true);
     this.ArrayMarshalType_NativeType = new EnumListVM(nativeTypeList, (a, b) => { OnArrayMarshalTypeIsEnabledChanged(); TypeStringUpdated(); });
     FixNativeTypeEnum(ArrayMarshalType_NativeType, true);
     this.ArrayMarshalType_ParamNum = new NullableCompressedUInt32(a => { OnArrayMarshalTypeIsEnabledChanged(); TypeStringUpdated(); });
     this.ArrayMarshalType_NumElems = new NullableCompressedUInt32(a => { OnArrayMarshalTypeIsEnabledChanged(); TypeStringUpdated(); });
     this.ArrayMarshalType_Flags    = new NullableCompressedUInt32(a => { OnArrayMarshalTypeIsEnabledChanged(); TypeStringUpdated(); });
     this.CustomMarshalType_CustMarshaler_TypeSigCreator = CreateTypeSigCreatorVM(ownerModule, decompilerManager, ownerType, ownerMethod, true, customMarshalType_custMarshaler_typeSigCreator_PropertyChanged);
     this.InterfaceMarshalType_IidParamIndex             = new NullableCompressedUInt32(a => { HasErrorUpdated(); TypeStringUpdated(); });
 }
コード例 #23
0
 AppWindow(IThemeManager themeManager, IImageManager imageManager, IAppSettings appSettings, ISettingsManager settingsManager, IFileTabManager fileTabManager, AppToolBar appToolBar, MainWindowControl mainWindowControl, IWpfCommandManager wpfCommandManager, IDecompilerManager decompilerManager)
 {
     this.assemblyInformationalVersion = CalculateAssemblyInformationalVersion(GetType().Assembly);
     this.uiSettings = new UISettings(settingsManager);
     this.uiSettings.Read();
     this.appSettings           = appSettings;
     this.stackedContent        = new StackedContent <IStackedContentChild>(margin: new Thickness(6));
     this.themeManager          = themeManager;
     themeManager.ThemeChanged += ThemeManager_ThemeChanged;
     this.imageManager          = imageManager;
     this.fileTabManager        = fileTabManager;
     this.statusBar             = new AppStatusBar();
     this.appToolBar            = appToolBar;
     this.mainWindowControl     = mainWindowControl;
     this.wpfCommandManager     = wpfCommandManager;
     this.decompilerManager     = decompilerManager;
     this.mainWindowCommands    = wpfCommandManager.GetCommands(ControlConstants.GUID_MAINWINDOW);
     this.mainWindowClosing     = new WeakEventList <CancelEventArgs>();
     this.mainWindowClosed      = new WeakEventList <EventArgs>();
 }
コード例 #24
0
        public MethodOptionsVM(MethodDefOptions options, ModuleDef ownerModule, IDecompilerManager decompilerManager, TypeDef ownerType, MethodDef ownerMethod)
        {
            this.ownerModule = ownerModule;
            var typeSigCreatorOptions = new TypeSigCreatorOptions(ownerModule, decompilerManager)
            {
                IsLocal = false,
                CanAddGenericTypeVar   = true,
                CanAddGenericMethodVar = ownerMethod == null || ownerMethod.GenericParameters.Count > 0,
                OwnerType   = ownerType,
                OwnerMethod = ownerMethod,
            };

            if (ownerType != null && ownerType.GenericParameters.Count == 0)
            {
                typeSigCreatorOptions.CanAddGenericTypeVar = false;
            }

            var methodSigCreatorOptions = new MethodSigCreatorOptions(typeSigCreatorOptions);

            methodSigCreatorOptions.IsPropertySig = false;
            this.MethodSigCreator = new MethodSigCreatorVM(methodSigCreatorOptions);
            this.MethodSigCreator.PropertyChanged += methodSigCreator_PropertyChanged;
            this.MethodSigCreator.ParametersCreateTypeSigArray.PropertyChanged += methodSigCreator_PropertyChanged;
            this.MethodSigCreator.ParametersCreateTypeSigArray.TypeSigCreator.ShowTypeFullName = true;
            this.MethodSigCreator.ParametersCreateTypeSigArray.TypeSigCreator.CanAddFnPtr      = false;

            this.CustomAttributesVM = new CustomAttributesVM(ownerModule, decompilerManager, ownerType, ownerMethod);
            this.DeclSecuritiesVM   = new DeclSecuritiesVM(ownerModule, decompilerManager, ownerType, ownerMethod);
            this.ParamDefsVM        = new ParamDefsVM(ownerModule, decompilerManager, ownerType, ownerMethod);
            this.GenericParamsVM    = new GenericParamsVM(ownerModule, decompilerManager, ownerType, ownerMethod);
            this.MethodOverridesVM  = new MethodOverridesVM(ownerModule, decompilerManager, ownerType, ownerMethod);

            this.origOptions = options;

            this.ImplMapVM             = new ImplMapVM(ownerModule);
            ImplMapVM.PropertyChanged += implMapVM_PropertyChanged;

            ImplMapVM.IsEnabled = PinvokeImpl;
            Reinitialize();
        }
コード例 #25
0
 public ModuleOptionsVM(ModuleDef module, ModuleOptions options, IDecompilerManager decompilerManager)
 {
     this.module      = module;
     this.options     = new ModuleOptions();
     this.origOptions = options;
     ModuleKind       = new EnumListVM(SaveModule.SaveModuleOptionsVM.moduleKindList, (a, b) => {
         Characteristics = SaveModule.CharacteristicsHelper.GetCharacteristics(Characteristics, (dnlib.DotNet.ModuleKind)ModuleKind.SelectedItem);
     });
     this.Machine = new EnumListVM(SaveModule.PEHeadersOptionsVM.machineList, (a, b) => {
         Characteristics = SaveModule.CharacteristicsHelper.GetCharacteristics(Characteristics, (dnlib.PE.Machine)Machine.SelectedItem);
     });
     Mvid       = new NullableGuidVM(a => HasErrorUpdated());
     EncId      = new NullableGuidVM(a => HasErrorUpdated());
     EncBaseId  = new NullableGuidVM(a => HasErrorUpdated());
     ClrVersion = new EnumListVM(NetModuleOptionsVM.clrVersionList, (a, b) => OnClrVersionChanged());
     ClrVersion.Items.Add(new EnumVM(Module.ClrVersion.Unknown, dnSpy_AsmEditor_Resources.Unknown));
     ClrVersion.SelectedItem   = Module.ClrVersion.Unknown;
     Cor20HeaderRuntimeVersion = new NullableUInt32VM(a => { HasErrorUpdated(); UpdateClrVersion(); });
     TablesHeaderVersion       = new NullableUInt16VM(a => { HasErrorUpdated(); UpdateClrVersion(); });
     NativeEntryPointRva       = new UInt32VM(a => HasErrorUpdated());
     CustomAttributesVM        = new CustomAttributesVM(module, decompilerManager);
     Reinitialize();
 }
コード例 #26
0
        public FieldOptionsVM(FieldDefOptions options, ModuleDef ownerModule, IDecompilerManager decompilerManager, TypeDef ownerType)
        {
            this.ownerModule = ownerModule;
            var typeSigCreatorOptions = new TypeSigCreatorOptions(ownerModule, decompilerManager)
            {
                IsLocal = false,
                CanAddGenericTypeVar   = true,
                CanAddGenericMethodVar = false,
                OwnerType = ownerType,
            };

            if (ownerType != null && ownerType.GenericParameters.Count == 0)
            {
                typeSigCreatorOptions.CanAddGenericTypeVar = false;
            }
            this.TypeSigCreator             = new TypeSigCreatorVM(typeSigCreatorOptions);
            TypeSigCreator.PropertyChanged += typeSigCreator_PropertyChanged;

            this.CustomAttributesVM = new CustomAttributesVM(ownerModule, decompilerManager);
            this.origOptions        = options;

            this.ConstantVM                = new ConstantVM(ownerModule, options.Constant?.Value, dnSpy_AsmEditor_Resources.Field_DefaultValueInfo);
            ConstantVM.PropertyChanged    += constantVM_PropertyChanged;
            this.MarshalTypeVM             = new MarshalTypeVM(ownerModule, decompilerManager, ownerType, null);
            MarshalTypeVM.PropertyChanged += marshalTypeVM_PropertyChanged;
            this.FieldOffset               = new NullableUInt32VM(a => HasErrorUpdated());
            this.InitialValue              = new HexStringVM(a => HasErrorUpdated());
            this.RVA                   = new UInt32VM(a => HasErrorUpdated());
            this.ImplMapVM             = new ImplMapVM(ownerModule);
            ImplMapVM.PropertyChanged += implMapVM_PropertyChanged;

            this.TypeSigCreator.CanAddFnPtr = false;
            ConstantVM.IsEnabled            = HasDefault;
            MarshalTypeVM.IsEnabled         = HasFieldMarshal;
            ImplMapVM.IsEnabled             = PinvokeImpl;
            Reinitialize();
        }
コード例 #27
0
ファイル: Commands.cs プロジェクト: zhangguanjiong/dnSpy
        AnalyzeCommandLoader(IMainToolWindowManager mainToolWindowManager, IWpfCommandManager wpfCommandManager, IFileTabManager fileTabManager, Lazy <IAnalyzerManager> analyzerManager, IDecompilerManager decompilerManager)
        {
            this.mainToolWindowManager = mainToolWindowManager;
            this.fileTabManager        = fileTabManager;
            this.analyzerManager       = analyzerManager;
            this.decompilerManager     = decompilerManager;

            var cmds = wpfCommandManager.GetCommands(ControlConstants.GUID_DOCUMENTVIEWER_UICONTEXT);

            cmds.Add(AnalyzeRoutedCommand, TextEditor_Executed, TextEditor_CanExecute, ModifierKeys.Control, Key.R);
            cmds.Add(AnalyzeRoutedCommand, ShowAnalyzerExecuted, ShowAnalyzerCanExecute, ModifierKeys.Control, Key.R);

            cmds = wpfCommandManager.GetCommands(ControlConstants.GUID_FILE_TREEVIEW);
            cmds.Add(AnalyzeRoutedCommand, FileTreeView_Executed, FileTreeView_CanExecute, ModifierKeys.Control, Key.R);
            cmds.Add(AnalyzeRoutedCommand, ShowAnalyzerExecuted, ShowAnalyzerCanExecute, ModifierKeys.Control, Key.R);

            cmds = wpfCommandManager.GetCommands(ControlConstants.GUID_ANALYZER_TREEVIEW);
            cmds.Add(AnalyzeRoutedCommand, AnalyzerTreeView_Executed, AnalyzerTreeView_CanExecute, ModifierKeys.Control, Key.R);
            cmds.Add(AnalyzeRoutedCommand, ShowAnalyzerExecuted, ShowAnalyzerCanExecute, ModifierKeys.Control, Key.R);

            cmds = wpfCommandManager.GetCommands(ControlConstants.GUID_SEARCH_LISTBOX);
            cmds.Add(AnalyzeRoutedCommand, SearchListBox_Executed, SearchListBox_CanExecute, ModifierKeys.Control, Key.R);
            cmds.Add(AnalyzeRoutedCommand, ShowAnalyzerExecuted, ShowAnalyzerCanExecute, ModifierKeys.Control, Key.R);
        }
コード例 #28
0
        public CilBodyVM(CilBodyOptions options, ModuleDef ownerModule, IDecompilerManager decompilerManager, TypeDef ownerType, MethodDef ownerMethod, bool initialize)
        {
            this.OwnerModule = ownerModule;
            this.ownerMethod = ownerMethod;
            this.origOptions = options;

            TypeSigCreatorOptions = new TypeSigCreatorOptions(ownerModule, decompilerManager)
            {
                CanAddGenericTypeVar   = ownerType.HasGenericParameters,
                CanAddGenericMethodVar = ownerMethod.MethodSig.GetGenParamCount() > 0,
                OwnerType   = ownerType,
                OwnerMethod = ownerMethod,
            };

            this.LocalsListVM                                  = new LocalsIndexObservableCollection(this, () => new LocalVM(TypeSigCreatorOptions, new LocalOptions(new Local(ownerModule.CorLibTypes.Int32))));
            this.InstructionsListVM                            = new IndexObservableCollection <InstructionVM>(() => CreateInstructionVM());
            this.ExceptionHandlersListVM                       = new IndexObservableCollection <ExceptionHandlerVM>(() => new ExceptionHandlerVM(TypeSigCreatorOptions, new ExceptionHandlerOptions()));
            this.LocalsListVM.UpdateIndexesDelegate            = LocalsUpdateIndexes;
            this.InstructionsListVM.UpdateIndexesDelegate      = InstructionsUpdateIndexes;
            this.ExceptionHandlersListVM.UpdateIndexesDelegate = ExceptionHandlersUpdateIndexes;
            this.InstructionsListVM.CollectionChanged         += InstructionsListVM_CollectionChanged;
            this.LocalsListVM.CollectionChanged               += LocalsListVM_CollectionChanged;
            this.ExceptionHandlersListVM.CollectionChanged    += ExceptionHandlersListVM_CollectionChanged;
            this.MaxStack         = new UInt16VM(a => CallHasErrorUpdated());
            this.LocalVarSigTok   = new UInt32VM(a => CallHasErrorUpdated());
            this.HeaderSize       = new ByteVM(a => CallHasErrorUpdated());
            this.HeaderRVA        = new UInt32VM(a => CallHasErrorUpdated());
            this.HeaderFileOffset = new UInt64VM(a => CallHasErrorUpdated());
            this.RVA        = new UInt32VM(a => CallHasErrorUpdated());
            this.FileOffset = new UInt64VM(a => CallHasErrorUpdated());

            if (initialize)
            {
                Reinitialize();
            }
        }
コード例 #29
0
        public TypeDefOrRefAndCAVM(TypeDefOrRefAndCAOptions options, ModuleDef ownerModule, IDecompilerManager decompilerManager, TypeDef ownerType, MethodDef ownerMethod)
        {
            this.origOptions = options;

            var typeSigCreatorOptions = new TypeSigCreatorOptions(ownerModule, decompilerManager)
            {
                IsLocal = false,
                CanAddGenericTypeVar   = true,
                CanAddGenericMethodVar = false,
                OwnerType   = ownerType,
                OwnerMethod = ownerMethod,
            };

            if (ownerType != null && ownerType.GenericParameters.Count == 0)
            {
                typeSigCreatorOptions.CanAddGenericTypeVar = false;
            }
            if (ownerMethod != null && ownerMethod.GenericParameters.Count > 0)
            {
                typeSigCreatorOptions.CanAddGenericMethodVar = true;
            }

            this.TypeSigCreator             = new TypeSigCreatorVM(typeSigCreatorOptions);
            TypeSigCreator.PropertyChanged += TypeSigCreator_PropertyChanged;
            this.CustomAttributesVM         = new CustomAttributesVM(ownerModule, decompilerManager);

            Reinitialize();
        }
コード例 #30
0
 public MethodOverridesVM(ModuleDef ownerModule, IDecompilerManager decompilerManager, TypeDef ownerType, MethodDef ownerMethod)
     : base(dnSpy_AsmEditor_Resources.EditMethodOverride, dnSpy_AsmEditor_Resources.CreateMethodOverride, ownerModule, decompilerManager, ownerType, ownerMethod)
 {
 }