EditCodeVMCreator(IRawModuleBytesProvider rawModuleBytesProvider, IOpenFromGAC openFromGAC, IDocumentTreeView documentTreeView, IDecompilerService decompilerService, [ImportMany] IEnumerable<ILanguageCompilerProvider> languageCompilerProviders) { this.rawModuleBytesProvider = rawModuleBytesProvider; this.openFromGAC = openFromGAC; openAssembly = new OpenAssembly(documentTreeView.DocumentService); this.decompilerService = decompilerService; this.languageCompilerProviders = languageCompilerProviders.OrderBy(a => a.Order).ToArray(); }
public MemberPickerDlg(IDocumentTreeView globalDocumentTreeView, IDocumentTreeView newDocumentTreeView) { InitializeComponent(); DataContextChanged += (s, e) => { var data = DataContext as MemberPickerVM; if (data != null) { data.OpenAssembly = new OpenAssembly(globalDocumentTreeView.DocumentService); data.PropertyChanged += MemberPickerVM_PropertyChanged; } }; var treeView = newDocumentTreeView.TreeView.UIObject; cpTreeView.Content = treeView; Validation.SetErrorTemplate(treeView, (ControlTemplate)FindResource("noRedBorderOnValidationError")); treeView.AllowDrop = false; treeView.BorderThickness = new Thickness(1); var binding = new Binding { ValidatesOnDataErrors = true, ValidatesOnExceptions = true, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged, Path = new PropertyPath(nameof(MemberPickerVM.SelectedItem)), Mode = BindingMode.TwoWay, }; treeView.SetBinding(Selector.SelectedItemProperty, binding); var cmd = new RelayCommand(a => { searchTextBox.SelectAll(); searchTextBox.Focus(); }); InputBindings.Add(new KeyBinding(cmd, Key.E, ModifierKeys.Control)); InputBindings.Add(new KeyBinding(cmd, Key.F, ModifierKeys.Control)); }
DocumentTabReferenceResult Create(AddressReference addrRef, IDocumentTreeView documentTreeView) { var content = hexViewDocumentTabContentCreator.Value.TryCreate(addrRef.Filename); if (content == null) return null; var fileOffset = GetFileOffset(addrRef, documentTreeView); return new DocumentTabReferenceResult(content, null, e => CreateHandler(e, content, fileOffset, addrRef)); }
public DocumentTreeNodeDataContext(IDocumentTreeView documentTreeView, IResourceNodeFactory resourceNodeFactory, IDocumentTreeNodeFilter filter, ITreeViewNodeTextElementProvider treeViewNodeTextElementProvider) { DocumentTreeView = documentTreeView; ResourceNodeFactory = resourceNodeFactory; Filter = filter; TreeViewNodeTextElementProvider = treeViewNodeTextElementProvider; FilterVersion = 1; CanDragAndDrop = true; }
ExportProjectCommand(IAppWindow appWindow, IDocumentTreeView documentTreeView, IDecompilerService decompilerService, IDocumentTreeViewSettings documentTreeViewSettings, IExportToProjectSettings exportToProjectSettings, [ImportMany] IEnumerable<Lazy<IBamlDecompiler>> bamlDecompilers, [ImportMany] IEnumerable<Lazy<IXamlOutputOptionsProvider>> xamlOutputOptionsProviders) { this.appWindow = appWindow; this.documentTreeView = documentTreeView; this.decompilerService = decompilerService; this.documentTreeViewSettings = documentTreeViewSettings; this.exportToProjectSettings = exportToProjectSettings; bamlDecompiler = bamlDecompilers.FirstOrDefault(); xamlOutputOptionsProvider = xamlOutputOptionsProviders.FirstOrDefault(); }
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; }
public IDocumentSearcher Create(DocumentSearcherOptions options, IDocumentTreeView documentTreeView) { if (options == null) throw new ArgumentNullException(nameof(options)); if (documentTreeView == null) throw new ArgumentNullException(nameof(documentTreeView)); var searchResultContext = new SearchResultContext(classificationFormatMap, textElementProvider) { SyntaxHighlight = true, Decompiler = decompilerService.Decompiler, }; return new DocumentSearcher(options, documentTreeView, dotNetImageService, searchResultContext); }
internal static MetaDataTableRecordNode FindNode(IDocumentTreeView documentTreeView, TokenReference tokRef) { if (tokRef == null) return null; var modNode = documentTreeView.FindNode(tokRef.ModuleDef); if (modNode == null) return null; modNode.TreeNode.EnsureChildrenLoaded(); var peNode = (PENode)modNode.TreeNode.DataChildren.FirstOrDefault(a => a is PENode); return peNode?.FindTokenNode(tokRef.Token); }
internal static IDsDocument[] OpenDocuments(IDocumentTreeView documentTreeView, Window ownerWindow, IEnumerable<string> filenames, bool selectDocument = true) { var documentLoader = new DsDocumentLoader(documentTreeView.DocumentService, ownerWindow); var loadedDocuments = documentLoader.Load(filenames.Select(a => new DocumentToLoad(DsDocumentInfo.CreateDocument(a)))); var document = loadedDocuments.Length == 0 ? null : loadedDocuments[loadedDocuments.Length - 1]; if (selectDocument && document != null) { Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { var node = documentTreeView.FindNode(document); if (node != null) documentTreeView.TreeView.SelectItems(new[] { node }); })); } return loadedDocuments; }
public DsDocumentNode Create(IDocumentTreeView documentTreeView, DsDocumentNode owner, IDsDocument document) { var dnDocument = document as IDsDotNetDocument; if (dnDocument != null) { Debug.Assert(document.ModuleDef != null); if (document.AssemblyDef == null || owner != null) return new ModuleDocumentNodeImpl(dnDocument); return new AssemblyDocumentNodeImpl(dnDocument); } Debug.Assert(document.AssemblyDef == null && document.ModuleDef == null); if (document.PEImage != null) return new PEDocumentNodeImpl(document); return null; }
public AddUpdatedNodesHelper(Lazy<IMethodAnnotations> methodAnnotations, Lazy<IResourceNodeFactory> resourceNodeFactory, IDocumentTreeView documentTreeView, ModuleDocumentNode modNode, ModuleImporter importer) { this.modNode = modNode; var dict = new Dictionary<string, List<TypeDef>>(StringComparer.Ordinal); foreach (var t in importer.NewNonNestedTypes) { List<TypeDef> list; var ns = (t.TargetType.Namespace ?? UTF8String.Empty).String; if (!dict.TryGetValue(ns, out list)) dict[ns] = list = new List<TypeDef>(); list.Add(t.TargetType); } newTypeNodeCreators = dict.Values.Select(a => new TypeNodeCreator(modNode, a)).ToArray(); existingTypeNodeUpdaters = importer.MergedNonNestedTypes.Select(a => new ExistingTypeNodeUpdater(methodAnnotations, modNode, a)).ToArray(); if (!importer.MergedNonNestedTypes.All(a => a.TargetType.Module == modNode.Document.ModuleDef)) throw new InvalidOperationException(); newAssemblyDeclSecurities = importer.NewAssemblyDeclSecurities; newAssemblyCustomAttributes = importer.NewAssemblyCustomAttributes; newModuleCustomAttributes = importer.NewModuleCustomAttributes; if (newAssemblyDeclSecurities != null) origAssemblyDeclSecurities = modNode.Document.AssemblyDef?.DeclSecurities.ToArray(); if (newAssemblyCustomAttributes != null) origAssemblyCustomAttributes = modNode.Document.AssemblyDef?.CustomAttributes.ToArray(); if (newModuleCustomAttributes != null) origModuleCustomAttributes = modNode.Document.ModuleDef.CustomAttributes.ToArray(); if (importer.NewResources.Length != 0) { var module = modNode.Document.ModuleDef; var rsrcListNode = GetResourceListTreeNode(modNode); Debug.Assert(rsrcListNode != null); if (rsrcListNode != null) { var newNodes = new ResourceNode[importer.NewResources.Length]; var treeNodeGroup = documentTreeView.DocumentTreeNodeGroups.GetGroup(DocumentTreeNodeGroupType.ResourceTreeNodeGroup); for (int i = 0; i < newNodes.Length; i++) newNodes[i] = (ResourceNode)documentTreeView.TreeView.Create(resourceNodeFactory.Value.Create(module, importer.NewResources[i], treeNodeGroup)).Data; resourceNodeCreator = new ResourceNodeCreator(rsrcListNode, newNodes); } } }
AppService(IAppWindow appWindow, IDocumentTabService documentTabService, IDocumentTreeView documentTreeView, IDecompilerService decompilerService) { AppWindow = appWindow; DocumentTabService = documentTabService; DocumentTreeView = documentTreeView; DecompilerService = decompilerService; }
public DsDocumentNode Create(IDocumentTreeView documentTreeView, DsDocumentNode owner, IDsDocument document) { var myDocument = document as MyDsDocument; if (myDocument != null) return new MyDsDocumentNode(myDocument); return null; }
OpenFileInit(IDocumentTreeView documentTreeView, IAppWindow appWindow) { this.documentTreeView = documentTreeView; this.appWindow = appWindow; appWindow.MainWindowCommands.Add(ApplicationCommands.Open, (s, e) => { Open(); e.Handled = true; }, (s, e) => e.CanExecute = true); }
public static RootDocumentNodeCreator CreateAssembly(IDocumentTreeView documentTreeView, IDsDotNetDocument asm) => new RootDocumentNodeCreator(documentTreeView, documentTreeView.CreateAssembly(asm), false);
RootDocumentNodeCreator(IDocumentTreeView documentTreeView, DsDocumentNode fileNode, bool restoreIndex) { this.documentTreeView = documentTreeView; documentNode = fileNode; this.restoreIndex = restoreIndex; }
CodeCommand(Lazy<IUndoCommandService> undoCommandService, IDocumentTreeView documentTreeView) : base(documentTreeView) { this.undoCommandService = undoCommandService; }
HexAddressReferenceFileTabContentCreator(Lazy<IHexViewDocumentTabContentCreator> hexViewDocumentTabContentCreator, IDocumentTreeView documentTreeView) { this.hexViewDocumentTabContentCreator = hexViewDocumentTabContentCreator; }
public static RootDocumentNodeCreator CreateModule(IDocumentTreeView documentTreeView, IDsDotNetDocument asm) => new RootDocumentNodeCreator(documentTreeView, documentTreeView.CreateModule(asm), false);
HexAddressReferenceFileTabContentCreator(Lazy <IHexViewDocumentTabContentCreator> hexViewDocumentTabContentCreator, IDocumentTreeView documentTreeView) => this.hexViewDocumentTabContentCreator = hexViewDocumentTabContentCreator;
AddUpdatedNodesHelperProvider(Lazy<IMethodAnnotations> methodAnnotations, Lazy<IResourceNodeFactory> resourceNodeFactory, IDocumentTreeView documentTreeView) { this.methodAnnotations = methodAnnotations; this.resourceNodeFactory = resourceNodeFactory; this.documentTreeView = documentTreeView; }
AddUpdatedNodesHelperProvider(Lazy <IMethodAnnotations> methodAnnotations, Lazy <IResourceNodeFactory> resourceNodeFactory, IDocumentTreeView documentTreeView) { this.methodAnnotations = methodAnnotations; this.resourceNodeFactory = resourceNodeFactory; this.documentTreeView = documentTreeView; }
public AddUpdatedNodesHelper(Lazy <IMethodAnnotations> methodAnnotations, Lazy <IResourceNodeFactory> resourceNodeFactory, IDocumentTreeView documentTreeView, ModuleDocumentNode modNode, ModuleImporter importer) { asmNode = modNode.TreeNode.Parent?.Data as AssemblyDocumentNode; this.modNode = modNode; var dict = new Dictionary <string, List <TypeDef> >(StringComparer.Ordinal); foreach (var t in importer.NewNonNestedTypes) { var ns = (t.TargetType !.Namespace ?? UTF8String.Empty).String; if (!dict.TryGetValue(ns, out var list)) { dict[ns] = list = new List <TypeDef>(); } list.Add(t.TargetType); } newTypeNodeCreators = dict.Values.Select(a => new TypeNodeCreator(modNode, a)).ToArray(); existingTypeNodeUpdaters = importer.MergedNonNestedTypes.Select(a => new ExistingTypeNodeUpdater(methodAnnotations, modNode, a)).ToArray(); if (!importer.MergedNonNestedTypes.All(a => a.TargetType !.Module == modNode.Document.ModuleDef)) { throw new InvalidOperationException(); } newAssemblyDeclSecurities = importer.NewAssemblyDeclSecurities; newAssemblyCustomAttributes = importer.NewAssemblyCustomAttributes; newModuleCustomAttributes = importer.NewModuleCustomAttributes; newExportedTypes = importer.NewExportedTypes; newAssemblyVersion = importer.NewAssemblyVersion; if (!(newAssemblyDeclSecurities is null)) { origAssemblyDeclSecurities = modNode.Document.AssemblyDef?.DeclSecurities.ToArray(); } if (!(newAssemblyCustomAttributes is null)) { origAssemblyCustomAttributes = modNode.Document.AssemblyDef?.CustomAttributes.ToArray(); } if (!(newModuleCustomAttributes is null)) { origModuleCustomAttributes = modNode.Document.ModuleDef !.CustomAttributes.ToArray(); } if (!(newExportedTypes is null)) { origExportedTypes = modNode.Document.ModuleDef !.ExportedTypes.ToArray(); } if (!(newAssemblyVersion is null)) { origAssemblyVersion = modNode.Document.AssemblyDef?.Version; } if (importer.NewResources !.Length != 0) { var module = modNode.Document.ModuleDef !; var rsrcListNode = GetResourceListTreeNode(modNode); Debug2.Assert(!(rsrcListNode is null)); if (!(rsrcListNode is null)) { var newNodes = new NodeAndResource[importer.NewResources.Length]; var treeNodeGroup = documentTreeView.DocumentTreeNodeGroups.GetGroup(DocumentTreeNodeGroupType.ResourceTreeNodeGroup); for (int i = 0; i < newNodes.Length; i++) { var resource = importer.NewResources[i]; var node = (DocumentTreeNodeData)documentTreeView.TreeView.Create(resourceNodeFactory.Value.Create(module, resource, treeNodeGroup)).Data; newNodes[i] = new NodeAndResource(node); } resourceNodeCreator = new ResourceNodeCreator(rsrcListNode, newNodes); } } }
IEnumerable<object> GetNodes(GetNodesContext ctx, IDocumentTreeView documentTreeView) { var list = new List<DocumentTreeNodeData>(); var root = documentTreeView.TreeView.Root; var findCtx = new FindNodeContext(); foreach (var path in Paths) { foreach (var o in path.FindNode(findCtx, root)) yield return o; if (findCtx.Node == null) yield break; list.Add(findCtx.Node); } ctx.Nodes = list.ToArray(); }
public MemberPickerVM(IDocumentSearcherProvider fileSearcherProvider, IDocumentTreeView documentTreeView, IDecompilerService decompilerService, IDocumentTreeNodeFilter filter, string title, IEnumerable<IDsDocument> assemblies) { Title = title; this.fileSearcherProvider = fileSearcherProvider; this.decompilerService = decompilerService; this.documentTreeView = documentTreeView; decompiler = decompilerService.Decompiler; this.filter = filter; delayedSearch = new DelayedAction(DEFAULT_DELAY_SEARCH_MS, DelayStartSearch); SearchResults = new ObservableCollection<ISearchResult>(); searchResultsCollectionView = (ListCollectionView)CollectionViewSource.GetDefaultView(SearchResults); searchResultsCollectionView.CustomSort = new SearchResult_Comparer(); foreach (var file in assemblies) documentTreeView.DocumentService.ForceAdd(file, false, null); documentTreeView.DocumentService.CollectionChanged += (s, e) => Restart(); CaseSensitive = false; MatchWholeWords = false; MatchAnySearchTerm = false; RefreshTreeView(); }
public SearchControlVM(IDocumentSearcherProvider fileSearcherProvider, IDocumentTreeView documentTreeView, ISearchSettings searchSettings) { this.fileSearcherProvider = fileSearcherProvider; this.documentTreeView = documentTreeView; SearchSettings = searchSettings; searchSettings.PropertyChanged += SearchSettings_PropertyChanged; delayedSearch = new DelayedAction(DEFAULT_DELAY_SEARCH_MS, DelayStartSearch); SearchTypeVMs = new ObservableCollection<SearchTypeVM>(); SearchResults = new ObservableCollection<ISearchResult>(); searchResultsCollectionView = (ListCollectionView)CollectionViewSource.GetDefaultView(SearchResults); searchResultsCollectionView.CustomSort = new SearchResult_Comparer(); SearchLocationVM = new EnumListVM(searchLocationList, (a, b) => Restart()); SearchLocationVM.SelectedItem = SearchLocation.AllFiles; Add(SearchType.AssemblyDef, dnSpy_Resources.SearchWindow_Assembly, DsImages.Assembly, null, VisibleMembersFlags.AssemblyDef); Add(SearchType.ModuleDef, dnSpy_Resources.SearchWindow_Module, DsImages.ModulePublic, null, VisibleMembersFlags.ModuleDef); Add(SearchType.Namespace, dnSpy_Resources.SearchWindow_Namespace, DsImages.Namespace, null, VisibleMembersFlags.Namespace); Add(SearchType.TypeDef, dnSpy_Resources.SearchWindow_Type, DsImages.ClassPublic, dnSpy_Resources.SearchWindow_Type_Key, VisibleMembersFlags.TypeDef); Add(SearchType.FieldDef, dnSpy_Resources.SearchWindow_Field, DsImages.FieldPublic, dnSpy_Resources.SearchWindow_Field_Key, VisibleMembersFlags.FieldDef); Add(SearchType.MethodDef, dnSpy_Resources.SearchWindow_Method, DsImages.MethodPublic, dnSpy_Resources.SearchWindow_Method_Key, VisibleMembersFlags.MethodDef); Add(SearchType.PropertyDef, dnSpy_Resources.SearchWindow_Property, DsImages.Property, dnSpy_Resources.SearchWindow_Property_Key, VisibleMembersFlags.PropertyDef); Add(SearchType.EventDef, dnSpy_Resources.SearchWindow_Event, DsImages.EventPublic, dnSpy_Resources.SearchWindow_Event_Key, VisibleMembersFlags.EventDef); Add(SearchType.ParamDef, dnSpy_Resources.SearchWindow_Parameter, DsImages.Parameter, dnSpy_Resources.SearchWindow_Parameter_Key, VisibleMembersFlags.ParamDef); Add(SearchType.Local, dnSpy_Resources.SearchWindow_Local, DsImages.LocalVariable, dnSpy_Resources.SearchWindow_Local_Key, VisibleMembersFlags.Local); Add(SearchType.ParamLocal, dnSpy_Resources.SearchWindow_ParameterLocal, DsImages.LocalVariable, dnSpy_Resources.SearchWindow_ParameterLocal_Key, VisibleMembersFlags.ParamDef | VisibleMembersFlags.Local); Add(SearchType.AssemblyRef, dnSpy_Resources.SearchWindow_AssemblyRef, DsImages.Reference, null, VisibleMembersFlags.AssemblyRef); Add(SearchType.ModuleRef, dnSpy_Resources.SearchWindow_ModuleRef, DsImages.Reference, null, VisibleMembersFlags.ModuleRef); Add(SearchType.Resource, dnSpy_Resources.SearchWindow_Resource, DsImages.Dialog, dnSpy_Resources.SearchWindow_Resource_Key, VisibleMembersFlags.Resource | VisibleMembersFlags.ResourceElement); Add(SearchType.GenericTypeDef, dnSpy_Resources.SearchWindow_Generic, DsImages.Template, null, VisibleMembersFlags.GenericTypeDef); Add(SearchType.NonGenericTypeDef, dnSpy_Resources.SearchWindow_NonGeneric, DsImages.ClassPublic, null, VisibleMembersFlags.NonGenericTypeDef); Add(SearchType.EnumTypeDef, dnSpy_Resources.SearchWindow_Enum, DsImages.EnumerationPublic, null, VisibleMembersFlags.EnumTypeDef); Add(SearchType.InterfaceTypeDef, dnSpy_Resources.SearchWindow_Interface, DsImages.InterfacePublic, null, VisibleMembersFlags.InterfaceTypeDef); Add(SearchType.ClassTypeDef, dnSpy_Resources.SearchWindow_Class, DsImages.ClassPublic, null, VisibleMembersFlags.ClassTypeDef); Add(SearchType.StructTypeDef, dnSpy_Resources.SearchWindow_Struct, DsImages.StructurePublic, null, VisibleMembersFlags.StructTypeDef); Add(SearchType.DelegateTypeDef, dnSpy_Resources.SearchWindow_Delegate, DsImages.DelegatePublic, null, VisibleMembersFlags.DelegateTypeDef); Add(SearchType.Member, dnSpy_Resources.SearchWindow_Member, DsImages.Property, dnSpy_Resources.SearchWindow_Member_Key, VisibleMembersFlags.MethodDef | VisibleMembersFlags.FieldDef | VisibleMembersFlags.PropertyDef | VisibleMembersFlags.EventDef); Add(SearchType.Any, dnSpy_Resources.SearchWindow_AllAbove, DsImages.ClassPublic, dnSpy_Resources.SearchWindow_AllAbove_Key, VisibleMembersFlags.TreeViewAll | VisibleMembersFlags.ParamDef | VisibleMembersFlags.Local); Add(SearchType.Literal, dnSpy_Resources.SearchWindow_Literal, DsImages.ConstantPublic, dnSpy_Resources.SearchWindow_Literal_Key, VisibleMembersFlags.MethodBody | VisibleMembersFlags.FieldDef | VisibleMembersFlags.ParamDef | VisibleMembersFlags.PropertyDef | VisibleMembersFlags.Resource | VisibleMembersFlags.ResourceElement | VisibleMembersFlags.Attributes); SelectedSearchTypeVM = SearchTypeVMs.First(a => a.SearchType == SearchType.Any); }
CodeCommand(Lazy <IUndoCommandService> undoCommandService, IDocumentTreeView documentTreeView) : base(documentTreeView) => this.undoCommandService = undoCommandService;
public RootDocumentNodeCreator(IDocumentTreeView documentTreeView, DsDocumentNode asmNode) : this(documentTreeView, asmNode, true) { }
RemoveAssemblyCommand(IDocumentTreeView documentTreeView, DsDocumentNode[] asmNodes) { savedStates = new RootDocumentNodeCreator[asmNodes.Length]; for (int i = 0; i < savedStates.Length; i++) savedStates[i] = new RootDocumentNodeCreator(documentTreeView, asmNodes[i]); }
CloseOldInMemoryModulesCommand(IDocumentTreeView documentTreeView, Lazy<IUndoCommandService> undoCommandService, Lazy<IDocumentSaver> documentSaver, IAppService appService) { this.documentTreeView = documentTreeView; this.undoCommandService = undoCommandService; this.documentSaver = documentSaver; this.appService = appService; }
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); }
SortAssembliesCtxMenuCommand(IDocumentTreeView documentTreeView) { this.documentTreeView = documentTreeView; }
public AddUpdatedNodesHelper(Lazy <IMethodAnnotations> methodAnnotations, Lazy <IResourceNodeFactory> resourceNodeFactory, IDocumentTreeView documentTreeView, ModuleDocumentNode modNode, ModuleImporter importer) { this.modNode = modNode; var dict = new Dictionary <string, List <TypeDef> >(StringComparer.Ordinal); foreach (var t in importer.NewNonNestedTypes) { List <TypeDef> list; var ns = (t.TargetType.Namespace ?? UTF8String.Empty).String; if (!dict.TryGetValue(ns, out list)) { dict[ns] = list = new List <TypeDef>(); } list.Add(t.TargetType); } this.newTypeNodeCreators = dict.Values.Select(a => new TypeNodeCreator(modNode, a)).ToArray(); this.existingTypeNodeUpdaters = importer.MergedNonNestedTypes.Select(a => new ExistingTypeNodeUpdater(methodAnnotations, modNode, a)).ToArray(); if (!importer.MergedNonNestedTypes.All(a => a.TargetType.Module == modNode.Document.ModuleDef)) { throw new InvalidOperationException(); } this.newAssemblyCustomAttributes = importer.NewAssemblyCustomAttributes; this.newModuleCustomAttributes = importer.NewModuleCustomAttributes; if (newAssemblyCustomAttributes != null) { origAssemblyCustomAttributes = modNode.Document.AssemblyDef?.CustomAttributes.ToArray(); } if (newModuleCustomAttributes != null) { origModuleCustomAttributes = modNode.Document.ModuleDef.CustomAttributes.ToArray(); } if (importer.NewResources.Length != 0) { var module = modNode.Document.ModuleDef; var rsrcListNode = GetResourceListTreeNode(modNode); Debug.Assert(rsrcListNode != null); if (rsrcListNode != null) { var newNodes = new ResourceNode[importer.NewResources.Length]; var treeNodeGroup = documentTreeView.DocumentTreeNodeGroups.GetGroup(DocumentTreeNodeGroupType.ResourceTreeNodeGroup); for (int i = 0; i < newNodes.Length; i++) { newNodes[i] = (ResourceNode)documentTreeView.TreeView.Create(resourceNodeFactory.Value.Create(module, importer.NewResources[i], treeNodeGroup)).Data; } resourceNodeCreator = new ResourceNodeCreator(rsrcListNode, newNodes); } } }
HexPosition? GetFileOffset(AddressReference addrRef, IDocumentTreeView documentTreeView) { if (!addrRef.IsRVA) return addrRef.Address; if (string.IsNullOrEmpty(addrRef.Filename)) return null; var file = documentTreeView.GetAllCreatedDocumentNodes().FirstOrDefault(a => StringComparer.OrdinalIgnoreCase.Equals(a.Document.Filename, addrRef.Filename)); if (file == null) return null; var pe = file.Document.PEImage; if (pe == null) return null; return (ulong)pe.ToFileOffset((RVA)addrRef.Address); }
MmapDisabler(IDocumentTreeView documentTreeView, Lazy<IUndoCommandService> undoCommandService) { this.documentTreeView = documentTreeView; this.undoCommandService = undoCommandService; }
public DocumentTreeNodeData FindNode(IDocumentTreeView documentTreeView, object @ref) => FindNode(documentTreeView, @ref as TokenReference);