示例#1
0
        /// <summary>
        /// Reads a single VarFileInfo structure from the provided input stream.
        /// </summary>
        /// <param name="startOffset">The offset of the consumed header.</param>
        /// <param name="header">The header.</param>
        /// <param name="reader">The input stream.</param>
        /// <returns>The read structure.</returns>
        /// <remarks>
        /// This function assumes the provided header was already consumed.
        /// </remarks>
        public static VarFileInfo FromReader(ulong startOffset, VersionTableEntryHeader header, ref BinaryStreamReader reader)
        {
            var result = new VarFileInfo();

            while (reader.Offset - startOffset < header.Length)
            {
                result.Tables.Add(VarTable.FromReader(ref reader));
            }

            return(result);
        }
示例#2
0
        /// <summary>
        /// Reads a single Var table at the provided input stream.
        /// </summary>
        /// <param name="reader">The input stream.</param>
        /// <returns>The var table.</returns>
        /// <exception cref="FormatException">
        /// Occurs when the input stream does not point to a valid Var table structure.
        /// </exception>
        public static VarTable FromReader(ref BinaryStreamReader reader)
        {
            var header = VersionTableEntryHeader.FromReader(ref reader);

            if (header.Key != TranslationKey)
            {
                throw new FormatException($"Expected a Var structure but got a {header.Key} structure.");
            }

            reader.Align(4);

            var result = new VarTable();

            ulong start = reader.Offset;

            while (reader.Offset - start < header.ValueLength)
            {
                result.Values.Add(reader.ReadUInt32());
            }

            return(result);
        }