Example #1
0
		ModuleLoader(Lazy<ITheDebugger> theDebugger, IDebuggerSettings debuggerSettings, IDsDocumentService documentService, Lazy<IInMemoryModuleService> inMemoryModuleService, IModuleIdProvider moduleIdProvider) {
			this.theDebugger = theDebugger;
			this.debuggerSettings = debuggerSettings;
			this.documentService = documentService;
			this.inMemoryModuleService = inMemoryModuleService;
			this.moduleIdProvider = moduleIdProvider;
		}
Example #2
0
        public static bool IsInModifiedModule(IDsDocumentService documentService, HashSet <IDsDocument?> modules, IEnumerable <object?> references)
        {
            var checkedAsmRefs = new HashSet <IAssembly>(AssemblyNameComparer.CompareAll);

            foreach (var r in references.Distinct())
            {
                IAssembly?asmRef = null;
                if (r is IType t)
                {
                    asmRef = t.DefinitionAssembly;
                }
                if (asmRef is null && r is IMemberRef)
                {
                    var type = ((IMemberRef)r).DeclaringType;
                    if (!(type is null))
                    {
                        asmRef = type.DefinitionAssembly;
                    }
                }
                if (!(asmRef is null) && !checkedAsmRefs.Contains(asmRef))
                {
                    checkedAsmRefs.Add(asmRef);
                    var asm = documentService.FindAssembly(asmRef);
                    if (!(asm is null) && modules.Contains(asm))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
 public ScopedWhereUsedAnalyzer(IDsDocumentService documentService, EventDef eventDef, Func <TypeDef, IEnumerable <T> > typeAnalysisFunction)
     : this(documentService, eventDef.DeclaringType, typeAnalysisFunction)
 {
     // we only have to check the accessibility of the the get method
     // [CLS Rule 30: The accessibility of an event and of its accessors shall be identical.]
     memberAccessibility = GetMethodAccessibility(eventDef.AddMethod);
 }
 public ScopedWhereUsedAnalyzer(IDsDocumentService documentService, TypeDef type, Func <TypeDef, IEnumerable <T> > typeAnalysisFunction)
 {
     typeScope   = type;
     moduleScope = type.Module;
     this.typeAnalysisFunction = typeAnalysisFunction;
     this.documentService      = documentService;
 }
        public IDsDocument?Create(IDsDocumentService documentService, DsDocumentInfo documentInfo)
        {
            if (documentInfo.Type == DocumentConstants.DOCUMENTTYPE_INMEMORY)
            {
                var getFileData = documentInfo.Data as Func <(byte[]? filedata, bool isFileLayout)>;
                Debug2.Assert(getFileData is not null);
                if (getFileData is not null)
                {
                    var info = getFileData();
                    if (info.filedata is not null)
                    {
                        return(documentService.CreateDocument(documentInfo, info.filedata, documentInfo.Name, info.isFileLayout));
                    }
                }
                return(null);
            }

            var filename = GetFilename(documentInfo);

            if (filename is not null)
            {
                return(documentService.CreateDocument(documentInfo, filename));
            }
            return(null);
        }
        public ScopedWhereUsedAnalyzer(IDsDocumentService documentService, FieldDef field, Func <TypeDef, IEnumerable <T> > typeAnalysisFunction)
            : this(documentService, field.DeclaringType, typeAnalysisFunction)
        {
            switch (field.Attributes & FieldAttributes.FieldAccessMask)
            {
            case FieldAttributes.Private:
            default:
                memberAccessibility = Accessibility.Private;
                break;

            case FieldAttributes.FamANDAssem:
                memberAccessibility = Accessibility.FamilyAndInternal;
                break;

            case FieldAttributes.Assembly:
                memberAccessibility = Accessibility.Internal;
                break;

            case FieldAttributes.PrivateScope:
            case FieldAttributes.Family:
                memberAccessibility = Accessibility.Family;
                break;

            case FieldAttributes.FamORAssem:
                memberAccessibility = Accessibility.FamilyOrInternal;
                break;

            case FieldAttributes.Public:
                memberAccessibility = Accessibility.Public;
                break;
            }
        }
Example #7
0
 public DsDocumentLoader(IDsDocumentService documentService, Window ownerWindow)
 {
     this.documentService = documentService;
     this.ownerWindow     = ownerWindow;
     this.loadedDocuments = new List <IDsDocument>();
     this.hash            = new HashSet <IDsDocument>();
 }
Example #8
0
		public IDsDocumentNameKey CreateKey(IDsDocumentService documentService, DsDocumentInfo documentInfo) {
			if (documentInfo.Type == MyDsDocument.THE_GUID)
				return new FilenameKey(documentInfo.Name);  // Must match the key in MyDsDocument.Key
			// Also check for normal files
			if (documentInfo.Type == DocumentConstants.DOCUMENTTYPE_FILE && IsSupportedFile(documentInfo.Name))
				return new FilenameKey(documentInfo.Name);  // Must match the key in MyDsDocument.Key
			return null;
		}
Example #9
0
 ModuleLoader(Lazy <ITheDebugger> theDebugger, IDebuggerSettings debuggerSettings, IDsDocumentService documentService, Lazy <IInMemoryModuleService> inMemoryModuleService, IModuleIdProvider moduleIdProvider)
 {
     this.theDebugger           = theDebugger;
     this.debuggerSettings      = debuggerSettings;
     this.documentService       = documentService;
     this.inMemoryModuleService = inMemoryModuleService;
     this.moduleIdProvider      = moduleIdProvider;
 }
Example #10
0
 DbgMetadataServiceImpl(DbgModuleIdProviderService dbgModuleIdProviderService, DbgInMemoryModuleService dbgInMemoryModuleService, DsDocumentProvider dsDocumentProvider, IDsDocumentService documentService, DebuggerSettings debuggerSettings)
 {
     this.dbgModuleIdProviderService = dbgModuleIdProviderService;
     this.dbgInMemoryModuleService   = dbgInMemoryModuleService;
     this.dsDocumentProvider         = dsDocumentProvider;
     this.documentService            = documentService;
     this.debuggerSettings           = debuggerSettings;
 }
Example #11
0
 OpenListCommand(IAppWindow appWindow, IDocumentListLoader documentListLoader, DocumentListService documentListService, IMessageBoxService messageBoxService, IDsDocumentService documentService)
 {
     this.appWindow           = appWindow;
     this.documentListLoader  = documentListLoader;
     this.documentListService = documentListService;
     this.messageBoxService   = messageBoxService;
     this.documentService     = documentService;
 }
Example #12
0
 public DsDocumentLoader(IDsDocumentService documentService, Window ownerWindow, AssemblyExplorerMostRecentlyUsedList?mruList)
 {
     this.documentService = documentService;
     this.ownerWindow     = ownerWindow;
     this.mruList         = mruList;
     loadedDocuments      = new List <IDsDocument>();
     hash = new HashSet <IDsDocument>();
 }
Example #13
0
        public ScopedWhereUsedAnalyzer(IDsDocumentService documentService, PropertyDef property, Func <TypeDef, IEnumerable <T> > typeAnalysisFunction, ScopedWhereUsedAnalyzerOptions options = ScopedWhereUsedAnalyzerOptions.None)
            : this(documentService, property.DeclaringType, typeAnalysisFunction, options)
        {
            var getterAccessibility = property.GetMethod is null ? Accessibility.Private : GetMethodAccessibility(property.GetMethod, options);
            var setterAccessibility = property.SetMethod is null ? Accessibility.Private : GetMethodAccessibility(property.SetMethod, options);

            memberAccessibility = (Accessibility)Math.Max((int)getterAccessibility, (int)setterAccessibility);
        }
        public ScopedWhereUsedAnalyzer(IDsDocumentService documentService, PropertyDef property, Func <TypeDef, IEnumerable <T> > typeAnalysisFunction)
            : this(documentService, property.DeclaringType, typeAnalysisFunction)
        {
            Accessibility getterAccessibility = (property.GetMethod == null) ? Accessibility.Private : GetMethodAccessibility(property.GetMethod);
            Accessibility setterAccessibility = (property.SetMethod == null) ? Accessibility.Private : GetMethodAccessibility(property.SetMethod);

            memberAccessibility = (Accessibility)Math.Max((int)getterAccessibility, (int)setterAccessibility);
        }
Example #15
0
		public IDsDocument Create(IDsDocumentService documentService, DsDocumentInfo documentInfo) {
			if (documentInfo.Type == MyDsDocument.THE_GUID)
				return MyDsDocument.TryCreate(documentInfo.Name);
			// Also check for normal files
			if (documentInfo.Type == DocumentConstants.DOCUMENTTYPE_FILE && IsSupportedFile(documentInfo.Name))
				return MyDsDocument.TryCreate(documentInfo.Name);
			return null;
		}
Example #16
0
 public ScopedWhereUsedAnalyzer(IDsDocumentService documentService, TypeDef analyzedType, Func <TypeDef, IEnumerable <T> > typeAnalysisFunction)
 {
     this.analyzedType         = analyzedType;
     typeScope                 = analyzedType;
     this.typeAnalysisFunction = typeAnalysisFunction;
     this.documentService      = documentService;
     allModules                = new List <ModuleDef>();
 }
Example #17
0
		public IDsDocumentNameKey CreateKey(IDsDocumentService documentService, DsDocumentInfo documentInfo) {
			if (documentInfo.Type == MyDsDocument.THE_GUID)
				return new FilenameKey(documentInfo.Name);  // Must match the key in MyDsDocument.Key
			// Also check for normal files
			if (documentInfo.Type == DocumentConstants.DOCUMENTTYPE_FILE && IsSupportedFile(documentInfo.Name))
				return new FilenameKey(documentInfo.Name);  // Must match the key in MyDsDocument.Key
			return null;
		}
Example #18
0
		public IDsDocument Create(IDsDocumentService documentService, DsDocumentInfo documentInfo) {
			if (documentInfo.Type == MyDsDocument.THE_GUID)
				return MyDsDocument.TryCreate(documentInfo.Name);
			// Also check for normal files
			if (documentInfo.Type == DocumentConstants.DOCUMENTTYPE_FILE && IsSupportedFile(documentInfo.Name))
				return MyDsDocument.TryCreate(documentInfo.Name);
			return null;
		}
Example #19
0
        public ScopedWhereUsedAnalyzer(IDsDocumentService documentService, EventDef eventDef, Func <TypeDef, IEnumerable <T> > typeAnalysisFunction, ScopedWhereUsedAnalyzerOptions options = ScopedWhereUsedAnalyzerOptions.None)
            : this(documentService, eventDef.DeclaringType, typeAnalysisFunction, options)
        {
            var adderAccessibility   = eventDef.AddMethod is null ? Accessibility.Private : GetMethodAccessibility(eventDef.AddMethod, options);
            var removerAccessibility = eventDef.RemoveMethod is null ? Accessibility.Private : GetMethodAccessibility(eventDef.RemoveMethod, options);
            var invokerAccessibility = eventDef.InvokeMethod is null ? Accessibility.Private : GetMethodAccessibility(eventDef.InvokeMethod, options);

            memberAccessibility = (Accessibility)Math.Max(Math.Max((int)adderAccessibility, (int)removerAccessibility), (int)invokerAccessibility);
        }
Example #20
0
        public IDsDocument Create(IDsDocumentService documentService, DsDocumentInfo documentInfo)
        {
            var filename = GetFilename(documentInfo);

            if (filename != null)
            {
                return(documentService.CreateDocument(documentInfo, filename));
            }
            return(null);
        }
Example #21
0
 InMemoryModuleService(ITheDebugger theDebugger, IDocumentTabService documentTabService, Lazy <IMethodAnnotations> methodAnnotations, IAppWindow appWindow)
 {
     this.documentTabService = documentTabService;
     this.documentTreeView   = documentTabService.DocumentTreeView;
     this.documentService    = this.documentTreeView.DocumentService;
     this.appWindow          = appWindow;
     this.methodAnnotations  = methodAnnotations;
     this.theDebugger        = theDebugger;
     theDebugger.OnProcessStateChanged_First += TheDebugger_OnProcessStateChanged_First;
 }
		DecompileDocumentTabContentFactory(IDsDocumentService documentService, IDocumentTreeNodeDecompiler documentTreeNodeDecompiler, IDecompilerService decompilerService, IDecompilationCache decompilationCache, IMethodAnnotations methodAnnotations, IContentTypeRegistryService contentTypeRegistryService, IDocumentViewerContentFactoryProvider documentViewerContentFactoryProvider, IDocumentWriterService documentWriterService) {
			DocumentService = documentService;
			DocumentTreeNodeDecompiler = documentTreeNodeDecompiler;
			DecompilerService = decompilerService;
			DecompilationCache = decompilationCache;
			MethodAnnotations = methodAnnotations;
			ContentTypeRegistryService = contentTypeRegistryService;
			DocumentViewerContentFactoryProvider = documentViewerContentFactoryProvider;
			DocumentWriterService = documentWriterService;
		}
		InMemoryModuleService(ITheDebugger theDebugger, IDocumentTabService documentTabService, Lazy<IMethodAnnotations> methodAnnotations, IAppWindow appWindow, SimpleProcessReader simpleProcessReader) {
			this.documentTabService = documentTabService;
			documentTreeView = documentTabService.DocumentTreeView;
			documentService = documentTreeView.DocumentService;
			this.appWindow = appWindow;
			this.methodAnnotations = methodAnnotations;
			this.theDebugger = theDebugger;
			this.simpleProcessReader = simpleProcessReader;
			theDebugger.OnProcessStateChanged_First += TheDebugger_OnProcessStateChanged_First;
		}
 DecompileDocumentTabContentFactory(IDsDocumentService documentService, IDocumentTreeNodeDecompiler documentTreeNodeDecompiler, IDecompilerService decompilerService, IDecompilationCache decompilationCache, IMethodAnnotations methodAnnotations, IContentTypeRegistryService contentTypeRegistryService, IDocumentViewerContentFactoryProvider documentViewerContentFactoryProvider)
 {
     DocumentService                      = documentService;
     DocumentTreeNodeDecompiler           = documentTreeNodeDecompiler;
     DecompilerService                    = decompilerService;
     DecompilationCache                   = decompilationCache;
     MethodAnnotations                    = methodAnnotations;
     ContentTypeRegistryService           = contentTypeRegistryService;
     DocumentViewerContentFactoryProvider = documentViewerContentFactoryProvider;
 }
Example #25
0
 OpenListCommand(IAppWindow appWindow, IDocumentListLoader documentListLoader, DocumentListService documentListService, IMessageBoxService messageBoxService, IDsDocumentService documentService, IClassificationFormatMapService classificationFormatMapService, ITextElementProvider textElementProvider)
 {
     this.appWindow           = appWindow;
     this.documentListLoader  = documentListLoader;
     this.documentListService = documentListService;
     this.messageBoxService   = messageBoxService;
     this.documentService     = documentService;
     classificationFormatMap  = classificationFormatMapService.GetClassificationFormatMap(AppearanceCategoryConstants.UIMisc);
     this.textElementProvider = textElementProvider;
 }
        public IDsDocumentNameKey?CreateKey(IDsDocumentService documentService, DsDocumentInfo documentInfo)
        {
            var filename = GetFilename(documentInfo);

            if (filename is not null)
            {
                return(new FilenameKey(filename));
            }
            return(null);
        }
Example #27
0
        public DocumentTreeView(bool isGlobal, IDocumentTreeNodeFilter filter, ITreeViewService treeViewService, IDecompilerService decompilerService, IDsDocumentService documentService, IDocumentTreeViewSettings documentTreeViewSettings, IMenuService menuService, IDotNetImageService dotNetImageService, IWpfCommandService wpfCommandService, IResourceNodeFactory resourceNodeFactory, IAppSettings appSettings, [ImportMany] IEnumerable <Lazy <IDsDocumentNodeProvider, IDsDocumentNodeProviderMetadata> > dsDocumentNodeProvider, [ImportMany] IEnumerable <Lazy <IDocumentTreeNodeDataFinder, IDocumentTreeNodeDataFinderMetadata> > mefFinders, ITreeViewNodeTextElementProvider treeViewNodeTextElementProvider)
        {
            this.decompilerService        = decompilerService;
            this.documentTreeViewSettings = documentTreeViewSettings;
            this.appSettings = appSettings;

            context = new DocumentTreeNodeDataContext(this, resourceNodeFactory, filter ?? FilterNothingDocumentTreeNodeFilter.Instance, treeViewNodeTextElementProvider)
            {
                SyntaxHighlight            = documentTreeViewSettings.SyntaxHighlight,
                SingleClickExpandsChildren = documentTreeViewSettings.SingleClickExpandsTreeViewChildren,
                ShowAssemblyVersion        = documentTreeViewSettings.ShowAssemblyVersion,
                ShowAssemblyPublicKeyToken = documentTreeViewSettings.ShowAssemblyPublicKeyToken,
                ShowToken            = documentTreeViewSettings.ShowToken,
                Decompiler           = decompilerService.Decompiler,
                UseNewRenderer       = appSettings.UseNewRenderer_DocumentTreeView,
                DeserializeResources = documentTreeViewSettings.DeserializeResources,
                CanDragAndDrop       = isGlobal,
            };

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

            documentTreeNodeGroups      = new DocumentTreeNodeGroups();
            this.dsDocumentNodeProvider = dsDocumentNodeProvider.OrderBy(a => a.Metadata.Order).ToArray();
            TreeView = treeViewService.Create(new Guid(TreeViewConstants.DOCUMENT_TREEVIEW_GUID), options);
            TreeView.SelectionChanged += TreeView_SelectionChanged;
            DocumentService            = documentService;
            DotNetImageService         = dotNetImageService;
            dispatcher = Dispatcher.CurrentDispatcher;
            DocumentService.SetDispatcher(AddAction);
            documentService.CollectionChanged        += DocumentService_CollectionChanged;
            decompilerService.DecompilerChanged      += DecompilerService_DecompilerChanged;
            documentTreeViewSettings.PropertyChanged += DocumentTreeViewSettings_PropertyChanged;
            appSettings.PropertyChanged += AppSettings_PropertyChanged;

            WpfCommands = wpfCommandService.GetCommands(ControlConstants.GUID_DOCUMENT_TREEVIEW);

            if (isGlobal)
            {
                menuService.InitializeContextMenu(TreeView.UIObject, new Guid(MenuConstants.GUIDOBJ_DOCUMENTS_TREEVIEW_GUID), new GuidObjectsProvider(TreeView));
                wpfCommandService.Add(ControlConstants.GUID_DOCUMENT_TREEVIEW, TreeView.UIObject);
            }

            nodeFinders = mefFinders.OrderBy(a => a.Metadata.Order).ToArray();
            InitializeDocumentTreeNodeGroups();
        }
Example #28
0
        static bool IsInModifiedModule(IDsDocumentService documentService, HashSet <IDsDocument?> modules, Item item)
        {
            var result = item.Content;

            if (result is null && !(item.WeakContent is null))
            {
                result = (DocumentViewerContent?)item.WeakContent.Target;
            }
            var refs = result?.ReferenceCollection;

            if (refs is null)
            {
                return(false);
            }
            return(InModifiedModuleHelper.IsInModifiedModule(documentService, modules, refs.Select(a => a.Data.Reference)));
        }
Example #29
0
        internal static HashSet <string> GetFriendAssemblies(IDsDocumentService documentService, ModuleDef mod, out IDsDocument[] modules)
        {
            var asm = mod.Assembly;

            Debug.Assert(!(asm is null));
            var friendAssemblies = new HashSet <string>(StringComparer.OrdinalIgnoreCase);

            foreach (var attribute in asm.CustomAttributes.FindAll("System.Runtime.CompilerServices.InternalsVisibleToAttribute"))
            {
                if (attribute.ConstructorArguments.Count == 0)
                {
                    continue;
                }
                string assemblyName = attribute.ConstructorArguments[0].Value as UTF8String;
                if (assemblyName is null)
                {
                    continue;
                }
                assemblyName = assemblyName.Split(',')[0];
                friendAssemblies.Add(assemblyName);
            }
            modules = documentService.GetDocuments().Where(a => CanIncludeModule(mod, a.ModuleDef)).ToArray();
            foreach (var module in modules)
            {
                Debug.Assert(!(module.ModuleDef is null));
                var asm2 = module.AssemblyDef;
                if (asm2 is null)
                {
                    continue;
                }
                foreach (var attribute in asm2.CustomAttributes.FindAll("System.Runtime.CompilerServices.IgnoresAccessChecksToAttribute"))
                {
                    string assemblyName = attribute.ConstructorArguments[0].Value as UTF8String;
                    if (assemblyName is null)
                    {
                        continue;
                    }
                    assemblyName = assemblyName.Split(',')[0];
                    if (StringComparer.OrdinalIgnoreCase.Equals(asm.Name.String, assemblyName))
                    {
                        friendAssemblies.Add(asm2.Name);
                    }
                }
            }
            return(friendAssemblies);
        }
Example #30
0
 internal static void AddTypeEquivalentTypes(IDsDocumentService documentService, TypeDef analyzedType, List <TypeDef> analyzedTypes)
 {
     Debug.Assert(analyzedTypes.Count == 1 && analyzedTypes[0] == analyzedType);
     if (!TIAHelper.IsTypeDefEquivalent(analyzedType))
     {
         return;
     }
     foreach (var document in documentService.GetDocuments())
     {
         foreach (var type in GetTypeEquivalentTypes(document.AssemblyDef, document.ModuleDef, analyzedType))
         {
             if (type != analyzedType)
             {
                 analyzedTypes.Add(type);
             }
         }
     }
 }
		public DefaultDsDocumentLoader(IDsDocumentService documentService) {
			this.documentService = documentService;
		}
 public ScopedWhereUsedAnalyzer(IDsDocumentService documentService, MethodDef method, Func <TypeDef, IEnumerable <T> > typeAnalysisFunction)
     : this(documentService, method.DeclaringType, typeAnalysisFunction)
 {
     memberAccessibility = GetMethodAccessibility(method);
 }
Example #33
0
		public OpenAssembly(IDsDocumentService documentService) {
			this.documentService = documentService;
		}
Example #34
0
		OpenListCommand(IAppWindow appWindow, IDocumentListLoader documentListLoader, DocumentListService documentListService, IMessageBoxService messageBoxService, IDsDocumentService documentService, IClassificationFormatMapService classificationFormatMapService, ITextElementProvider textElementProvider) {
			this.appWindow = appWindow;
			this.documentListLoader = documentListLoader;
			this.documentListService = documentListService;
			this.messageBoxService = messageBoxService;
			this.documentService = documentService;
			classificationFormatMap = classificationFormatMapService.GetClassificationFormatMap(AppearanceCategoryConstants.UIMisc);
			this.textElementProvider = textElementProvider;
		}
Example #35
0
 DsDocumentProviderImpl(IDsDocumentService documentService) => this.documentService = documentService;
 DsDocumentServiceAppSettingsModifiedListener(IDsDocumentService documentService)
 {
     this.documentService = documentService;
 }
		public IDsDocument Create(IDsDocumentService documentService, DsDocumentInfo documentInfo) {
			var filename = GetFilename(documentInfo);
			if (filename != null)
				return documentService.CreateDocument(documentInfo, filename);
			return null;
		}
		public IDsDocumentNameKey CreateKey(IDsDocumentService documentService, DsDocumentInfo documentInfo) {
			var filename = GetFilename(documentInfo);
			if (filename != null)
				return new FilenameKey(filename);
			return null;
		}
Example #39
0
 DecompilationCache(IDsDocumentService documentService)
 {
     this.documentService = documentService;
     AddTimerWait(this);
 }
Example #40
0
 public DefaultDsDocumentLoader(IDsDocumentService documentService) => this.documentService = documentService;
Example #41
0
		public DsDocumentLoader(IDsDocumentService documentService, Window ownerWindow) {
			this.documentService = documentService;
			this.ownerWindow = ownerWindow;
			loadedDocuments = new List<IDsDocument>();
			hash = new HashSet<IDsDocument>();
		}
		DsDocumentServiceAppSettingsModifiedListener(IDsDocumentService documentService) {
			this.documentService = documentService;
		}