/// <summary> /// Gets the File Version Information that is stored as a resource in the PE file. (This is what the /// version tab a file's property page is populated with). /// </summary> public FileVersionInfo GetFileVersionInfo() { ResourceNode resources = GetResources(); ResourceNode versionNode = ResourceNode.GetChild(ResourceNode.GetChild(resources, "Version"), "1"); if (versionNode == null) { return(null); } if (!versionNode.IsLeaf && versionNode.Children.Count == 1) { versionNode = versionNode.Children[0]; } PEBuffer buff = AllocBuff(); byte * bytes = versionNode.FetchData(0, versionNode.DataLength, buff); FileVersionInfo ret = new FileVersionInfo(bytes, versionNode.DataLength); FreeBuff(buff); return(ret); }
static public ResourceNode GetChild(ResourceNode node, string name) { if (node == null) return null; foreach (var child in node.Children) if (child.Name == name) return child; return null; }
// TODO make public? internal ResourceNode GetResources() { if (Header.ResourceDirectory.VirtualAddress == 0 || Header.ResourceDirectory.Size < sizeof(IMAGE_RESOURCE_DIRECTORY)) return null; var ret = new ResourceNode("", Header.FileOffsetOfResources, this, false, true); return ret; }