Esempio n. 1
0
        private void ReadSections(BufferedBinaryReader reader, int count)
        {
            var sections = new Section[count];

            for (int i = 0; i < count; i++)
            {
                var section = new Section
                {
                    Name = reader.ReadZeroTerminatedString(8)
                };

                // VirtualSize		4
                reader.Advance(4);

                section.VirtualAddress   = reader.ReadUInt32();
                section.SizeOfRawData    = reader.ReadUInt32();
                section.PointerToRawData = reader.ReadUInt32();

                // PointerToRelocations		4
                // PointerToLineNumbers		4
                // NumberOfRelocations		2
                // NumberOfLineNumbers		2
                // Characteristics			4
                reader.Advance(16);

                sections[i] = section;
            }

            Sections = sections;
        }
Esempio n. 2
0
        private void Load()
        {
            _image.Load(_reader);

            uint mdbOffset = (uint)_reader.Position;

            _reader.Position = mdbOffset;

            // Metadata Header
            // Signature
            if (_reader.ReadUInt32() != 0x424A5342)
            {
                throw new BadMetadataException("Invalid metadata header.");
            }

            // MajorVersion			2
            // MinorVersion			2
            // Reserved				4
            _reader.Advance(8);

            var runtimeVersion = _reader.ReadZeroTerminatedString(_reader.ReadInt32());

            // align for dword boundary
            _reader.Align4();

            // Flags		2
            _reader.Advance(2);

            LoadHeaps(mdbOffset);
        }