예제 #1
1
		public BaseTypeNodeImpl(ITreeNodeGroup treeNodeGroup, ITypeDefOrRef typeDefOrRef, bool isBaseType) {
			TreeNodeGroup = treeNodeGroup;
			this.isBaseType = isBaseType;
			// Keep weak refs to them so we won't prevent removed modules from being GC'd.
			weakRefTypeDefOrRef = new WeakReference(typeDefOrRef);
			weakRefResolvedTypeDef = new WeakReference(null);
		}
예제 #2
0
        ResourceElement resourceElement; // updated by the asm editor, see UpdateData()

        #endregion Fields

        #region Constructors

        protected ResourceElementNode(ITreeNodeGroup treeNodeGroup, ResourceElement resourceElement)
        {
            if (treeNodeGroup == null || resourceElement == null)
                throw new ArgumentNullException();
            this.treeNodeGroup = treeNodeGroup;
            this.resourceElement = resourceElement;
        }
예제 #3
0
 public MessageNode(ITreeNodeGroup treeNodeGroup, Guid guid, ImageReference imgRef, string msg)
 {
     this.treeNodeGroup = treeNodeGroup;
     this.guid = guid;
     this.imgRef = imgRef;
     this.msg = msg;
 }
예제 #4
0
		public DerivedTypesFinder(DocumentTreeNodeData targetNode, TypeDef type)
			: base(targetNode) {
			msgNodeGroup = targetNode.Context.DocumentTreeView.DocumentTreeNodeGroups.GetGroup(DocumentTreeNodeGroupType.MessageTreeNodeGroupDerivedTypes);
			derivedTypesGroup = targetNode.Context.DocumentTreeView.DocumentTreeNodeGroups.GetGroup(DocumentTreeNodeGroupType.DerivedTypeTreeNodeGroupDerivedTypes);
			weakModules = targetNode.Context.DocumentTreeView.DocumentService.GetDocuments().Where(a => a.ModuleDef != null).SelectMany(a => a.AssemblyDef != null ? (IEnumerable<ModuleDef>)a.AssemblyDef.Modules : new[] { a.ModuleDef }).Select(a => new WeakReference(a)).ToArray();
			this.type = type;
			Start();
		}
		public AssemblyReferenceNodeImpl(ITreeNodeGroup treeNodeGroup, ModuleDef asmRefOwnerModule, AssemblyRef assemblyRef) {
			TreeNodeGroup = treeNodeGroup;
			this.asmRefOwnerModule = new WeakReference(asmRefOwnerModule);
			// Make sure we don't hold on to the original reference since it could prevent GC of the
			// owner module.
			AssemblyRef = assemblyRef.ToAssemblyRef();
			AssemblyRef.Rid = assemblyRef.Rid;
		}
예제 #6
0
		public BamlResourceElementNode(ModuleDef module, ResourceElement resourceElement, byte[] bamlData, ITreeNodeGroup treeNodeGroup, BamlSettings bamlSettings, IXamlOutputOptionsProvider xamlOutputOptionsProvider, IDocumentWriterService documentWriterService)
			: base(treeNodeGroup, resourceElement) {
			this.module = module;
			this.bamlData = bamlData;
			this.bamlSettings = bamlSettings;
			this.xamlOutputOptionsProvider = xamlOutputOptionsProvider;
			this.documentWriterService = documentWriterService;
		}
예제 #7
0
		public IResourceElementNode Create(ModuleDef module, ResourceElement resourceElement, ITreeNodeGroup treeNodeGroup) {
			if (resourceElement.ResourceData.Code != ResourceTypeCode.ByteArray && resourceElement.ResourceData.Code != ResourceTypeCode.Stream)
				return null;

			var data = (byte[])((BuiltInResourceData)resourceElement.ResourceData).Data;

			if (!BamlReader.IsBamlHeader(new MemoryStream(data)))
				return null;

			return new BamlResourceElementNode(module, resourceElement, data, treeNodeGroup, bamlSettings);
		}
예제 #8
0
		public IResourceElementNode Create(ModuleDef module, ResourceElement resourceElement, ITreeNodeGroup treeNodeGroup) {
			if (resourceElement.ResourceData.Code != ResourceTypeCode.ByteArray && resourceElement.ResourceData.Code != ResourceTypeCode.Stream)
				return null;

			var data = (byte[])((BuiltInResourceData)resourceElement.ResourceData).Data;
			var stream = MemoryImageStream.Create(data);
			if (!CouldBeImage(resourceElement.Name, stream))
				return null;

			return new ImageResourceElementNode(treeNodeGroup, resourceElement);
		}
예제 #9
0
		public IResourceNode Create(ModuleDef module, Resource resource, ITreeNodeGroup treeNodeGroup) {
			var er = resource as EmbeddedResource;
			if (er == null)
				return null;

			er.Data.Position = 0;
			if (!CouldBeImage(er.Name, er.Data))
				return null;

			return new ImageResourceNode(treeNodeGroup, er);
		}
		public ResourceElementNode Create(ModuleDef module, ResourceElement resourceElement, ITreeNodeGroup treeNodeGroup) {
			var serializedData = resourceElement.ResourceData as BinaryResourceData;
			if (serializedData == null)
				return null;

			byte[] imageData;
			if (SerializedImageUtilities.GetImageData(module, serializedData.TypeName, serializedData.Data, out imageData))
				return new SerializedImageResourceElementNodeImpl(treeNodeGroup, resourceElement, imageData);

			return null;
		}
		public ResourceNode Create(ModuleDef module, Resource resource, ITreeNodeGroup treeNodeGroup) {
			var er = resource as EmbeddedResource;
			if (er == null)
				return null;
			er.Data.Position = 0;
			if (!ResourceReader.CouldBeResourcesFile(er.Data))
				return null;

			er.Data.Position = 0;
			return new ResourceElementSetNodeImpl(treeNodeGroup, module, er);
		}
예제 #12
0
 public IResourceElementNode Create(ModuleDef module, ResourceElement resourceElement, ITreeNodeGroup treeNodeGroup)
 {
     if (module == null || resourceElement == null || treeNodeGroup == null)
         throw new ArgumentNullException();
     foreach (var creator in creators) {
         try {
             var node = creator.Value.Create(module, resourceElement, treeNodeGroup);
             if (node != null)
                 return node;
         }
         catch {
         }
     }
     return new BuiltInResourceElementNode(treeNodeGroup, resourceElement);
 }
예제 #13
0
		public ResourceElementNode Create(ModuleDef module, ResourceElement resourceElement, ITreeNodeGroup treeNodeGroup) {
			if (module == null)
				throw new ArgumentNullException(nameof(module));
			if (resourceElement == null)
				throw new ArgumentNullException(nameof(resourceElement));
			if (treeNodeGroup == null)
				throw new ArgumentNullException(nameof(treeNodeGroup));
			foreach (var provider in resourceNodeProviders) {
				try {
					var node = provider.Value.Create(module, resourceElement, treeNodeGroup);
					if (node != null)
						return node;
				}
				catch {
				}
			}
			return new BuiltInResourceElementNodeImpl(treeNodeGroup, resourceElement);
		}
예제 #14
0
 public IResourceNode Create(ModuleDef module, Resource resource, ITreeNodeGroup treeNodeGroup)
 {
     if (module == null || resource == null || treeNodeGroup == null)
     {
         throw new ArgumentNullException();
     }
     foreach (var creator in creators)
     {
         try {
             var node = creator.Value.Create(module, resource, treeNodeGroup);
             if (node != null)
             {
                 return(node);
             }
         }
         catch {
         }
     }
     return(new UnknownResourceNode(treeNodeGroup, resource));
 }
예제 #15
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="treeNodeGroup">Treenode group</param>
 /// <param name="resource">Resource</param>
 protected UnknownResourceNode(ITreeNodeGroup treeNodeGroup, Resource resource)
     : base(treeNodeGroup, resource)
 {
 }
예제 #16
0
 public ResourceElementSetNode(ITreeNodeGroup treeNodeGroup, ModuleDef module, EmbeddedResource resource)
     : base(treeNodeGroup, resource)
 {
     this.module = module;
     this.resourceElementSet = ResourceReader.Read(module, resource.Data);
 }
예제 #17
0
 public ReferencesFolderNodeImpl(ITreeNodeGroup treeNodeGroup, ModuleDocumentNode moduleNode)
 {
     Debug.Assert(moduleNode.Document.ModuleDef != null);
     TreeNodeGroup   = treeNodeGroup;
     this.moduleNode = moduleNode;
 }
예제 #18
0
 public ImageResourceNodeImpl(ITreeNodeGroup treeNodeGroup, EmbeddedResource resource)
     : base(treeNodeGroup, resource)
 {
     imageData   = resource.CreateReader().ToArray();
     imageSource = ImageResourceUtilities.CreateImageSource(imageData);
 }
예제 #19
0
        public DocumentTreeNodeData?Create(ModuleDef module, ResourceElement resourceElement, ITreeNodeGroup treeNodeGroup)
        {
            if (resourceElement.ResourceData.Code != ResourceTypeCode.ByteArray && resourceElement.ResourceData.Code != ResourceTypeCode.Stream)
            {
                return(null);
            }

            var data   = (byte[])((BuiltInResourceData)resourceElement.ResourceData).Data;
            var reader = ByteArrayDataReaderFactory.CreateReader(data);

            if (!CouldBeImage(resourceElement.Name, ref reader))
            {
                return(null);
            }

            return(new ImageResourceElementNodeImpl(treeNodeGroup, resourceElement));
        }
예제 #20
0
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="treeNodeGroup">Treenode group</param>
		/// <param name="resourceElement">Resource element</param>
		protected ImageResourceElementNode(ITreeNodeGroup treeNodeGroup, ResourceElement resourceElement)
			: base(treeNodeGroup, resourceElement) {
		}
 public MethodReferenceNodeImpl(ITreeNodeGroup treeNodeGroup, IMethod method)
     : base(method) => TreeNodeGroup = treeNodeGroup;
예제 #22
0
 public ImageResourceNode(ITreeNodeGroup treeNodeGroup, EmbeddedResource resource)
     : base(treeNodeGroup, resource)
 {
     this.imageData = resource.GetResourceData();
     this.imageSource = ImageResourceUtils.CreateImageSource(this.imageData);
 }
예제 #23
0
 public ImageResourceElementNode(ITreeNodeGroup treeNodeGroup, ResourceElement resourceElement)
     : base(treeNodeGroup, resourceElement)
 {
     InitializeImageData();
 }
예제 #24
0
		public ResourcesFolderNodeImpl(ITreeNodeGroup treeNodeGroup, ModuleDef module) {
			TreeNodeGroup = treeNodeGroup;
			this.module = module;
		}
예제 #25
0
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="treeNodeGroup">Treenode group</param>
		/// <param name="resource">Resource</param>
		protected ResourceElementSetNode(ITreeNodeGroup treeNodeGroup, Resource resource)
			: base(treeNodeGroup, resource) {
		}
예제 #26
0
        int GetInsertIndex(TreeNodeImpl owner, TreeNodeImpl impl, ITreeNodeGroup group)
        {
            var children = owner.Children;

            // At creation time, it's most likely inserted last, so check that position first.
            if (children.Count >= 1) {
                var lastData = children[children.Count - 1].Data;
                var lastGroup = lastData.TreeNodeGroup;
                if (lastGroup != null) {
                    int x = Compare(impl.Data, lastData, group, lastGroup);
                    if (x > 0)
                        return children.Count;
                }
            }

            int lo = 0, hi = children.Count - 1;
            while (lo <= hi && hi != -1) {
                int i = (lo + hi) / 2;

                var otherData = children[i].Data;
                var otherGroup = otherData.TreeNodeGroup;
                int x;
                if (otherGroup == null)
                    x = -1;
                else
                    x = Compare(impl.Data, otherData, group, otherGroup);

                if (x == 0)
                    return i;
                if (x < 0)
                    hi = i - 1;
                else
                    lo = i + 1;
            }
            return hi + 1;
        }
예제 #27
0
 int Compare(ITreeNodeData a, ITreeNodeData b, ITreeNodeGroup ga, ITreeNodeGroup gb)
 {
     if (ga.Order < gb.Order)
         return -1;
     if (ga.Order > gb.Order)
         return 1;
     if (ga.GetType() != gb.GetType()) {
         Debug.Fail(string.Format("Two different groups have identical order: {0} vs {1}", ga.GetType(), gb.GetType()));
         return ga.GetType().GetHashCode().CompareTo(gb.GetType().GetHashCode());
     }
     return ga.Compare(a, b);
 }
예제 #28
0
		public TypeNodeImpl(ITreeNodeGroup treeNodeGroup, TypeDef type)
			: base(type) {
			TreeNodeGroup = treeNodeGroup;
		}
예제 #29
0
 public NamespaceNodeImpl(ITreeNodeGroup treeNodeGroup, string name, List <TypeDef> types)
     : base(name)
 {
     TreeNodeGroup = treeNodeGroup;
     typesToCreate = types;
 }
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="treeNodeGroup">Treenode group</param>
		/// <param name="resourceElement">Resource element</param>
		protected BuiltInResourceElementNode(ITreeNodeGroup treeNodeGroup, ResourceElement resourceElement)
			: base(treeNodeGroup, resourceElement) {
		}
예제 #31
0
 public ModuleReferenceNode(ITreeNodeGroup treeNodeGroup, ModuleRef moduleRef)
 {
     this.treeNodeGroup = treeNodeGroup;
     this.moduleRef = moduleRef;
 }
예제 #32
0
 public BaseTypeFolderNode(ITreeNodeGroup treeNodeGroup, TypeDef type)
 {
     this.treeNodeGroup = treeNodeGroup;
     this.type = type;
 }
 public TypeReferenceNodeImpl(ITreeNodeGroup treeNodeGroup, ITypeDefOrRef type, TypeRefInfo typeInfo)
     : base(type)
 {
     TreeNodeGroup = treeNodeGroup;
     this.typeInfo = typeInfo;
 }
예제 #34
0
 public DerivedTypeNode(ITreeNodeGroup treeNodeGroup, TypeDef type)
 {
     this.treeNodeGroup = treeNodeGroup;
     this.weakRefTypeDef = new WeakReference(type);
 }
예제 #35
0
		public MessageNodeImpl(ITreeNodeGroup treeNodeGroup, Guid guid, ImageReference imgRef, string msg) {
			TreeNodeGroup = treeNodeGroup;
			Guid = guid;
			this.imgRef = imgRef;
			Message = msg;
		}
예제 #36
0
 public ResourceElementNode Create(ModuleDef module, ResourceElement resourceElement, ITreeNodeGroup treeNodeGroup) => null;
예제 #37
0
 public ImageResourceElementNodeImpl(ITreeNodeGroup treeNodeGroup, ResourceElement resourceElement)
     : base(treeNodeGroup, resourceElement) => InitializeImageData();
예제 #38
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="treeNodeGroup">Treenode group</param>
 /// <param name="resourceElement">Resource element</param>
 protected SerializedResourceElementNode(ITreeNodeGroup treeNodeGroup, ResourceElement resourceElement)
     : base(treeNodeGroup, resourceElement) => Debug.Assert(resourceElement.ResourceData is BinaryResourceData);
예제 #39
0
파일: EventNode.cs 프로젝트: net10010/dnSpy
 public EventNode(ITreeNodeGroup treeNodeGroup, EventDef @event)
 {
     this.TreeNodeGroup = treeNodeGroup;
     this.EventDef      = @event;
 }
예제 #40
0
 public PropertyNodeImpl(ITreeNodeGroup treeNodeGroup, PropertyDef property)
     : base(property) => TreeNodeGroup = treeNodeGroup;
예제 #41
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="treeNodeGroup">Treenode group</param>
 /// <param name="resource">Resource</param>
 protected ResourceNode(ITreeNodeGroup treeNodeGroup, Resource resource)
 {
     this.treeNodeGroup = treeNodeGroup ?? throw new ArgumentNullException(nameof(treeNodeGroup));
     Resource           = resource ?? throw new ArgumentNullException(nameof(resource));
 }
예제 #42
0
		public ModuleReferenceNodeImpl(ITreeNodeGroup treeNodeGroup, ModuleRef moduleRef)
			: base(moduleRef) {
			TreeNodeGroup = treeNodeGroup;
		}
예제 #43
0
 public ResourceElementNode Create(ModuleDef module, ResourceElement resourceElement, ITreeNodeGroup treeNodeGroup)
 {
     if (module == null)
     {
         throw new ArgumentNullException(nameof(module));
     }
     if (resourceElement == null)
     {
         throw new ArgumentNullException(nameof(resourceElement));
     }
     if (treeNodeGroup == null)
     {
         throw new ArgumentNullException(nameof(treeNodeGroup));
     }
     foreach (var provider in resourceNodeProviders)
     {
         try {
             var node = provider.Value.Create(module, resourceElement, treeNodeGroup);
             if (node != null)
             {
                 return(node);
             }
         }
         catch {
         }
     }
     return(new BuiltInResourceElementNodeImpl(treeNodeGroup, resourceElement));
 }
예제 #44
0
        public ResourceElementNode Create(ModuleDef module, ResourceElement resourceElement, ITreeNodeGroup treeNodeGroup)
        {
            var serializedData = resourceElement.ResourceData as BinaryResourceData;

            if (serializedData == null)
            {
                return(null);
            }

            byte[] imageData;
            if (SerializedImageUtilities.GetImageData(module, serializedData.TypeName, serializedData.Data, out imageData))
            {
                return(new SerializedImageResourceElementNodeImpl(treeNodeGroup, resourceElement, imageData));
            }

            return(null);
        }
예제 #45
0
 public DerivedTypesFolderNodeImpl(ITreeNodeGroup treeNodeGroup, TypeDef type)
 {
     TreeNodeGroup = treeNodeGroup;
     this.type     = type;
 }
예제 #46
0
 public IResourceElementNode Create(ModuleDef module, ResourceElement resourceElement, ITreeNodeGroup treeNodeGroup)
 {
     return null;
 }
예제 #47
0
 public TypeNodeImpl(ITreeNodeGroup treeNodeGroup, TypeDef type)
     : base(type)
 {
     this.TreeNodeGroup = treeNodeGroup;
 }
예제 #48
0
 public MethodNode(ITreeNodeGroup treeNodeGroup, MethodDef methodDef)
 {
     this.TreeNodeGroup = treeNodeGroup;
     this.MethodDef     = methodDef;
 }
예제 #49
0
 public ResourceNode Create(ModuleDef module, Resource resource, ITreeNodeGroup treeNodeGroup) => null;
예제 #50
0
 public PropertyNode(ITreeNodeGroup treeNodeGroup, PropertyDef property)
 {
     this.treeNodeGroup = treeNodeGroup;
     this.property = property;
 }
예제 #51
0
 public SerializedImageResourceElementNodeImpl(ITreeNodeGroup treeNodeGroup, ResourceElement resourceElement, byte[] imageData)
     : base(treeNodeGroup, resourceElement)
 {
     InitializeImageData(imageData);
 }
예제 #52
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="treeNodeGroup">Treenode group</param>
 /// <param name="resourceElement">Resource element</param>
 protected BuiltInResourceElementNode(ITreeNodeGroup treeNodeGroup, ResourceElement resourceElement)
     : base(treeNodeGroup, resourceElement)
 {
 }
예제 #53
0
 public ResourceElementSetNodeImpl(ITreeNodeGroup treeNodeGroup, ModuleDef module, EmbeddedResource resource)
     : base(treeNodeGroup, resource)
 {
     this.module        = module;
     resourceElementSet = ResourceReader.Read(module, resource.GetReader());
 }
예제 #54
0
        public DocumentTreeNodeData?Create(ModuleDef module, ResourceElement resourceElement, ITreeNodeGroup treeNodeGroup)
        {
            var serializedData = resourceElement.ResourceData as BinaryResourceData;

            if (serializedData is null)
            {
                return(null);
            }

            if (SerializedImageListStreamerUtilities.GetImageData(module, serializedData.TypeName, serializedData.Data, out var imageData))
            {
                return(new SerializedImageListStreamerResourceElementNodeImpl(treeNodeGroup, resourceElement, imageData));
            }

            return(null);
        }
예제 #55
0
 public MethodNodeImpl(ITreeNodeGroup treeNodeGroup, MethodDef methodDef)
     : base(methodDef) => TreeNodeGroup = treeNodeGroup;
예제 #56
0
 public ImageResourceNode(ITreeNodeGroup treeNodeGroup, EmbeddedResource resource)
     : base(treeNodeGroup, resource)
 {
     this.imageData   = resource.GetResourceData();
     this.imageSource = ImageResourceUtils.CreateImageSource(this.imageData);
 }
예제 #57
0
 public UnknownResourceNodeImpl(ITreeNodeGroup treeNodeGroup, Resource resource)
     : base(treeNodeGroup, resource)
 {
 }
예제 #58
0
        public IResourceElementNode Create(ModuleDef module, ResourceElement resourceElement, ITreeNodeGroup treeNodeGroup)
        {
            if (resourceElement.ResourceData.Code != ResourceTypeCode.ByteArray && resourceElement.ResourceData.Code != ResourceTypeCode.Stream)
            {
                return(null);
            }

            var data   = (byte[])((BuiltInResourceData)resourceElement.ResourceData).Data;
            var stream = MemoryImageStream.Create(data);

            if (!CouldBeImage(resourceElement.Name, stream))
            {
                return(null);
            }

            return(new ImageResourceElementNode(treeNodeGroup, resourceElement));
        }
예제 #59
0
 public DerivedTypeNodeImpl(ITreeNodeGroup treeNodeGroup, TypeDef type)
 {
     this.TreeNodeGroup  = treeNodeGroup;
     this.weakRefTypeDef = new WeakReference(type);
 }
예제 #60
0
 public BaseTypeFolderNode(ITreeNodeGroup treeNodeGroup, TypeDef type)
 {
     this.TreeNodeGroup = treeNodeGroup;
     this.type          = type;
 }