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)); } } } }
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)); } } }