Пример #1
0
		public override IEnumerable<TreeNodeData> CreateChildren() {
			Debug.Assert(TreeNode.Children.Count == 0 && weakDocListener == null);
			if (weakDocListener != null)
				yield break;

			var buffer = hexDocMgr.GetOrCreate(peImage);
			if (buffer == null)
				yield break;

			weakDocListener = new WeakDocumentListener(this, buffer);

			yield return new ImageDosHeaderNode(buffer, peImage.ImageDosHeader);
			yield return new ImageFileHeaderNode(buffer, peImage.ImageNTHeaders.FileHeader);
			if (peImage.ImageNTHeaders.OptionalHeader is ImageOptionalHeader32)
				yield return new ImageOptionalHeader32Node(buffer, (ImageOptionalHeader32)peImage.ImageNTHeaders.OptionalHeader);
			else
				yield return new ImageOptionalHeader64Node(buffer, (ImageOptionalHeader64)peImage.ImageNTHeaders.OptionalHeader);
			for (int i = 0; i < peImage.ImageSectionHeaders.Count; i++)
				yield return new ImageSectionHeaderNode(buffer, peImage.ImageSectionHeaders[i], i);
			var cor20Hdr = ImageCor20HeaderNode.Create(buffer, peImage);
			if (cor20Hdr != null)
				yield return cor20Hdr;
			if (module != null) {
				var md = module.MetaData;
				yield return new StorageSignatureNode(buffer, md.MetaDataHeader);
				yield return new StorageHeaderNode(buffer, md.MetaDataHeader);
				var knownStreams = new List<DotNetStream> {
					md.StringsStream,
					md.USStream,
					md.BlobStream,
					md.GuidStream,
					md.TablesStream,
				};
				if (md.IsCompressed) {
					foreach (var stream in md.AllStreams) {
						if (stream.Name == "#!")
							knownStreams.Add(stream);
					}
				}
				for (int i = 0; i < md.MetaDataHeader.StreamHeaders.Count; i++) {
					var sh = md.MetaDataHeader.StreamHeaders[i];
					var knownStream = knownStreams.FirstOrDefault(a => a.StreamHeader == sh);
					yield return new StorageStreamNode(buffer, sh, i, knownStream, md);
				}
			}
		}
Пример #2
0
		protected override void LoadChildren() {
			Debug.Assert(Children.Count == 0 && weakDocListener == null);
			if (weakDocListener != null)
				return;

			var doc = HexDocumentManager.Instance.GetOrCreate(peImage);
			if (doc == null)
				return;

			weakDocListener = new WeakDocumentListener(this, doc);

			Children.Add(new ImageDosHeaderTreeNode(doc, peImage.ImageDosHeader));
			Children.Add(new ImageFileHeaderTreeNode(doc, peImage.ImageNTHeaders.FileHeader));
			if (peImage.ImageNTHeaders.OptionalHeader is ImageOptionalHeader32)
				Children.Add(new ImageOptionalHeader32TreeNode(doc, (ImageOptionalHeader32)peImage.ImageNTHeaders.OptionalHeader));
			else
				Children.Add(new ImageOptionalHeader64TreeNode(doc, (ImageOptionalHeader64)peImage.ImageNTHeaders.OptionalHeader));
			for (int i = 0; i < peImage.ImageSectionHeaders.Count; i++)
				Children.Add(new ImageSectionHeaderTreeNode(doc, peImage.ImageSectionHeaders[i], i));
			var cor20Hdr = ImageCor20HeaderTreeNode.Create(doc, peImage);
			if (cor20Hdr != null)
				Children.Add(cor20Hdr);
			if (module != null) {
				var md = module.MetaData;
				Children.Add(new StorageSignatureTreeNode(doc, md.MetaDataHeader));
				Children.Add(new StorageHeaderTreeNode(doc, md.MetaDataHeader));
				var knownStreams = new List<DotNetStream> {
					md.StringsStream,
					md.USStream,
					md.BlobStream,
					md.GuidStream,
					md.TablesStream,
				};
				if (md.IsCompressed) {
					foreach (var stream in md.AllStreams) {
						if (stream.Name == "#!")
							knownStreams.Add(stream);
					}
				}
				for (int i = 0; i < md.MetaDataHeader.StreamHeaders.Count; i++) {
					var sh = md.MetaDataHeader.StreamHeaders[i];
					var knownStream = knownStreams.FirstOrDefault(a => a.StreamHeader == sh);
					Children.Add(new StorageStreamTreeNode(doc, sh, i, knownStream, md));
				}
			}
		}
Пример #3
0
        public override IEnumerable <TreeNodeData> CreateChildren()
        {
            Debug.Assert(TreeNode.Children.Count == 0 && weakDocListener is null);
            if (!(weakDocListener is null))
            {
                yield break;
            }

            var file = createBufferFile();

            if (file is null)
            {
                yield break;
            }
            var peStructureProvider = peStructureProviderFactory.TryGetProvider(file);

            if (peStructureProvider is null)
            {
                yield break;
            }

            weakDocListener = new WeakDocumentListener(this, file.Buffer);

            yield return(new ImageDosHeaderNode(peStructureProvider.ImageDosHeader));

            yield return(new ImageFileHeaderNode(peStructureProvider.ImageFileHeader));

            if (peStructureProvider.ImageOptionalHeader is ImageOptionalHeader32VM)
            {
                yield return(new ImageOptionalHeader32Node((ImageOptionalHeader32VM)peStructureProvider.ImageOptionalHeader));
            }
            else
            {
                yield return(new ImageOptionalHeader64Node((ImageOptionalHeader64VM)peStructureProvider.ImageOptionalHeader));
            }
            for (int i = 0; i < peStructureProvider.Sections.Length; i++)
            {
                yield return(new ImageSectionHeaderNode(peStructureProvider.Sections[i], i));
            }
            var cor20Hdr = ImageCor20HeaderNode.Create(peStructureProvider.ImageCor20Header);

            if (!(cor20Hdr is null))
            {
                yield return(cor20Hdr);
            }
            if (!(cor20Hdr is null) && !(peStructureProvider.StorageSignature is null))
            {
                yield return(new StorageSignatureNode(peStructureProvider.StorageSignature));

                yield return(new StorageHeaderNode(peStructureProvider.StorageHeader !));

                foreach (var storageStream in peStructureProvider.StorageStreams)
                {
                    if (storageStream.HeapKind == DotNetHeapKind.Tables)
                    {
                        yield return(new TablesStorageStreamNode(storageStream, peStructureProvider.TablesStream !));
                    }
                    else
                    {
                        yield return(new StorageStreamNode(storageStream));
                    }
                }
            }
        }
Пример #4
0
        public override IEnumerable <TreeNodeData> CreateChildren()
        {
            Debug.Assert(TreeNode.Children.Count == 0 && weakDocListener == null);
            if (weakDocListener != null)
            {
                yield break;
            }

            var buffer = hexDocMgr.GetOrCreate(peImage);

            if (buffer == null)
            {
                yield break;
            }

            weakDocListener = new WeakDocumentListener(this, buffer);

            yield return(new ImageDosHeaderNode(buffer, peImage.ImageDosHeader));

            yield return(new ImageFileHeaderNode(buffer, peImage.ImageNTHeaders.FileHeader));

            if (peImage.ImageNTHeaders.OptionalHeader is ImageOptionalHeader32)
            {
                yield return(new ImageOptionalHeader32Node(buffer, (ImageOptionalHeader32)peImage.ImageNTHeaders.OptionalHeader));
            }
            else
            {
                yield return(new ImageOptionalHeader64Node(buffer, (ImageOptionalHeader64)peImage.ImageNTHeaders.OptionalHeader));
            }
            for (int i = 0; i < peImage.ImageSectionHeaders.Count; i++)
            {
                yield return(new ImageSectionHeaderNode(buffer, peImage.ImageSectionHeaders[i], i));
            }
            var cor20Hdr = ImageCor20HeaderNode.Create(buffer, peImage);

            if (cor20Hdr != null)
            {
                yield return(cor20Hdr);
            }
            if (module != null)
            {
                var md = module.MetaData;
                yield return(new StorageSignatureNode(buffer, md.MetaDataHeader));

                yield return(new StorageHeaderNode(buffer, md.MetaDataHeader));

                var knownStreams = new List <DotNetStream> {
                    md.StringsStream,
                    md.USStream,
                    md.BlobStream,
                    md.GuidStream,
                    md.TablesStream,
                };
                if (md.IsCompressed)
                {
                    foreach (var stream in md.AllStreams)
                    {
                        if (stream.Name == "#!")
                        {
                            knownStreams.Add(stream);
                        }
                    }
                }
                for (int i = 0; i < md.MetaDataHeader.StreamHeaders.Count; i++)
                {
                    var sh          = md.MetaDataHeader.StreamHeaders[i];
                    var knownStream = knownStreams.FirstOrDefault(a => a.StreamHeader == sh);
                    yield return(new StorageStreamNode(buffer, sh, i, knownStream, md));
                }
            }
        }
Пример #5
0
        protected override void LoadChildren()
        {
            Debug.Assert(Children.Count == 0 && weakDocListener == null);
            if (weakDocListener != null)
            {
                return;
            }

            var doc = HexDocumentManager.Instance.GetOrCreate(peImage);

            if (doc == null)
            {
                return;
            }

            weakDocListener = new WeakDocumentListener(this, doc);

            Children.Add(new ImageDosHeaderTreeNode(doc, peImage.ImageDosHeader));
            Children.Add(new ImageFileHeaderTreeNode(doc, peImage.ImageNTHeaders.FileHeader));
            if (peImage.ImageNTHeaders.OptionalHeader is ImageOptionalHeader32)
            {
                Children.Add(new ImageOptionalHeader32TreeNode(doc, (ImageOptionalHeader32)peImage.ImageNTHeaders.OptionalHeader));
            }
            else
            {
                Children.Add(new ImageOptionalHeader64TreeNode(doc, (ImageOptionalHeader64)peImage.ImageNTHeaders.OptionalHeader));
            }
            for (int i = 0; i < peImage.ImageSectionHeaders.Count; i++)
            {
                Children.Add(new ImageSectionHeaderTreeNode(doc, peImage.ImageSectionHeaders[i], i));
            }
            var cor20Hdr = ImageCor20HeaderTreeNode.Create(doc, peImage);

            if (cor20Hdr != null)
            {
                Children.Add(cor20Hdr);
            }
            if (module != null)
            {
                var md = module.MetaData;
                Children.Add(new StorageSignatureTreeNode(doc, md.MetaDataHeader));
                Children.Add(new StorageHeaderTreeNode(doc, md.MetaDataHeader));
                var knownStreams = new List <DotNetStream> {
                    md.StringsStream,
                    md.USStream,
                    md.BlobStream,
                    md.GuidStream,
                    md.TablesStream,
                };
                if (md.IsCompressed)
                {
                    foreach (var stream in md.AllStreams)
                    {
                        if (stream.Name == "#!")
                        {
                            knownStreams.Add(stream);
                        }
                    }
                }
                for (int i = 0; i < md.MetaDataHeader.StreamHeaders.Count; i++)
                {
                    var sh          = md.MetaDataHeader.StreamHeaders[i];
                    var knownStream = knownStreams.FirstOrDefault(a => a.StreamHeader == sh);
                    Children.Add(new StorageStreamTreeNode(doc, sh, i, knownStream, md));
                }
            }
        }