Beispiel #1
0
        internal static StringTable ReadStringTable(this PeReader reader)
        {
            var orgPos = reader.GetPosition();

            var table = new StringTable();

            reader.ReadFileInfo(table, 8);

            table.LanguageCode = ulong.Parse(table.Key, NumberStyles.HexNumber);

            // Read children (Strings, as sz key/value pairs)
            var children = new Dictionary <string, string>();

            while (reader.GetPosition() < orgPos + table.Length)
            {
                var child = reader.ReadStringTableString();
                children.Add(child.key, child.value);
            }
            table.Values = children.ToImmutableDictionary();

            // Undocumented
            reader.ReadPadding();

            return(table);
        }
Beispiel #2
0
        internal static void ReadFileInfo(this PeReader reader, FileInfo info, int keyLen)
        {
            info.Position = reader.GetPosition();

            info.Length      = reader.ReadUInt16();
            info.ValueLength = reader.ReadUInt16();
            info.Type        = reader.ReadUInt16();
            info.Key         = reader.ReadStringZ(keyLen);
            info.Padding1    = reader.ReadPadding();
        }
Beispiel #3
0
        internal static (string key, string value) ReadStringTableString(this PeReader reader)
        {
            var entry = new StringTable.String();

            // Undocumented - StringTable entries are 32-bit aligned
            reader.ReadPadding();
            reader.ReadFileInfo(entry);

            return(entry.Key, reader.ReadStringZ());
        }