public static StringTableSection ReadFrom(EndianAwareBinaryReader reader) { var list = new List <string>(); reader.ReadByte(); var sb = new StringBuilder(); while (true) { var b = reader.ReadByte(); if (b == 0) { if (sb.Length == 0) { // no more strings break; } list.Add(sb.ToString()); sb.Clear(); continue; } sb.Append((char)b); } return(new StringTableSection(list.ToArray())); }
public static SectionHeaderEntry64 ReadFrom(EndianAwareBinaryReader reader) { var name = reader.ReadUInt32(); var type = (SectionType)reader.ReadUInt32(); var flags = (SectionAttribute)reader.ReadUInt64(); var addr = reader.ReadUInt64(); var offset = reader.ReadUInt64(); var sectionSize = reader.ReadUInt64(); var link = reader.ReadInt32(); var info = reader.ReadInt32(); var addrAlign = reader.ReadUInt64(); var entrySize = reader.ReadUInt64(); return(new SectionHeaderEntry64(name, type, flags, addr, offset, sectionSize, link, info, addrAlign, entrySize)); }
/// <summary> /// Reads elf header /// </summary> /// <param name="reader">The reader.</param> public static ElfHeader64 ReadFrom64(EndianAwareBinaryReader reader) { var Type = (FileType)reader.ReadUInt16(); var Machine = (MachineType)reader.ReadUInt16(); var Version = (Version)reader.ReadUInt32(); var EntryAddress = reader.ReadUInt64(); var ProgramHeaderOffset = reader.ReadUInt64(); var SectionHeaderOffset = reader.ReadUInt64(); var Flags = reader.ReadUInt32(); var ElfHeaderSize = reader.ReadUInt16(); var ProgramHeaderEntrySize = reader.ReadUInt16(); var ProgramHeaderCount = reader.ReadUInt16(); var SectionHeaderEntrySize = reader.ReadUInt16(); var SectionHeaderCount = reader.ReadUInt16(); var SectionHeaderStringIndex = reader.ReadUInt16(); return(new ElfHeader64(Type, Machine, Version, EntryAddress, ProgramHeaderOffset, ProgramHeaderCount, SectionHeaderOffset, SectionHeaderCount, Flags, SectionHeaderStringIndex)); }