/// <summary> /// Reads a single fixed version info structure from an input stream. /// </summary> /// <param name="reader">The input stream.</param> /// <returns>The read structure.</returns> public static FixedVersionInfo FromReader(ref BinaryStreamReader reader) { var result = new FixedVersionInfo(); result.UpdateOffsets(reader.Offset, reader.Rva); uint signature = reader.ReadUInt32(); if (signature != Signature) { throw new FormatException($"Input stream does not point to a valid FixedVersionInfo structure."); } uint structVersion = reader.ReadUInt32(); result.FileVersion = ReadVersion(ref reader); result.ProductVersion = ReadVersion(ref reader); result.FileFlagsMask = (FileFlags)reader.ReadUInt32(); result.FileFlags = (FileFlags)reader.ReadUInt32(); result.FileOS = (FileOS)reader.ReadUInt32(); result.FileType = (FileType)reader.ReadUInt32(); result.FileSubType = (FileSubType)reader.ReadUInt32(); result.FileDate = reader.ReadUInt64(); return(result); }
/// <summary> /// Reads a version resource from an input stream. /// </summary> /// <param name="reader">The input stream.</param> /// <returns>The parsed version resource.</returns> /// <exception cref="FormatException"> /// Occurs when the input stream does not point to a valid version resource. /// </exception> public static VersionInfoResource FromReader(IBinaryStreamReader reader) { uint start = reader.FileOffset; // Read header. var header = VersionTableEntryHeader.FromReader(reader); if (header.Key != VsVersionInfoKey) { throw new FormatException($"Input stream does not point to a {VsVersionInfoKey} entry."); } var result = new VersionInfoResource(); // Read fixed version info. reader.Align(4); result.FixedVersionInfo = FixedVersionInfo.FromReader(reader); // Read children. while (reader.FileOffset - start < header.Length) { reader.Align(4); result.AddEntry(ReadNextEntry(reader)); } return(result); }