示例#1
0
        /// <summary>
        /// Reads the specified reader.
        /// </summary>
        /// <param name="reader">The reader.</param>
        public void Read(System.IO.BinaryReader reader)
        {
            Ident = reader.ReadBytes(16);

            // Check for magic number
            if (Ident[0] != MagicNumber[0] || Ident[1] != MagicNumber[1] || Ident[2] != MagicNumber[2] || Ident[3] != MagicNumber[3])
            {
                // Magic number not present, so it seems to be an invalid ELF file
                throw new NotSupportedException("This is not a valid ELF file");
            }

            Type                     = (Elf32FileType)reader.ReadUInt16();
            Machine                  = (Elf32MachineType)reader.ReadUInt16();
            Version                  = (Elf32Version)reader.ReadUInt32();
            EntryAddress             = reader.ReadUInt32();
            ProgramHeaderOffset      = reader.ReadUInt32();
            SectionHeaderOffset      = reader.ReadUInt32();
            Flags                    = reader.ReadUInt32();
            ElfHeaderSize            = reader.ReadUInt16();
            ProgramHeaderEntrySize   = reader.ReadUInt16();
            ProgramHeaderNumber      = reader.ReadUInt16();
            SectionHeaderEntrySize   = reader.ReadUInt16();
            SectionHeaderNumber      = reader.ReadUInt16();
            SectionHeaderStringIndex = reader.ReadUInt16();
        }
示例#2
0
        /// <summary>
        /// Reads the specified reader.
        /// </summary>
        /// <param name="reader">The reader.</param>
        public void Read(System.IO.BinaryReader reader)
        {
            Ident = reader.ReadBytes(16);

            // Check for magic number
            if (Ident[0] != MagicNumber[0] || Ident[1] != MagicNumber[1] || Ident[2] != MagicNumber[2] || Ident[3] != MagicNumber[3])
            {
                // Magic number not present, so it seems to be an invalid ELF file
                throw new NotSupportedException("This is not a valid ELF file");
            }

            Type = (Elf32FileType)reader.ReadUInt16();
            Machine = (Elf32MachineType)reader.ReadUInt16();
            Version = (Elf32Version)reader.ReadUInt32();
            EntryAddress = reader.ReadUInt32();
            ProgramHeaderOffset = reader.ReadUInt32();
            SectionHeaderOffset = reader.ReadUInt32();
            Flags = reader.ReadUInt32();
            ElfHeaderSize = reader.ReadUInt16();
            ProgramHeaderEntrySize = reader.ReadUInt16();
            ProgramHeaderNumber = reader.ReadUInt16();
            SectionHeaderEntrySize = reader.ReadUInt16();
            SectionHeaderNumber = reader.ReadUInt16();
            SectionHeaderStringIndex = reader.ReadUInt16();
        }