コード例 #1
0
        public OSHeaders(BinaryReader reader)
        {
            Start = 0;

            _stub = new DOSStub(reader);
            reader.BaseStream.Position = _stub.PEPos;

            // Read "PE\0\0" signature
            if (reader.ReadUInt32() != 0x00004550)
            {
                throw new ModException("File is not a portable executable.");
            }

            _coh = new COFFHeader(reader);

            // Compute data sections offset
            _dataSectionsOffset = reader.BaseStream.Position + _coh.OptionalHeaderSize;

            _peh = new PEHeader(reader);

            reader.BaseStream.Position = _dataSectionsOffset;

            _sech = new SectionHeader[_coh.NumberOfSections];

            for (int i = 0; i < _sech.Length; i++)
            {
                _sech[i] = new SectionHeader(reader);
            }

            Length = reader.BaseStream.Position;
        }
コード例 #2
0
ファイル: Headers.cs プロジェクト: Kinect123/ex360e
        public OSHeaders(BinaryReader reader)
        {
            Start = 0;

            _stub = new DOSStub(reader);
            reader.BaseStream.Position = _stub.PEPos;

            // Read "PE\0\0" signature
            if (reader.ReadUInt32() != 0x00004550)
            {
                throw new ModException("File is not a portable executable.");
            }

            _coh = new COFFHeader(reader);

            // Compute data sections offset
            _dataSectionsOffset = reader.BaseStream.Position + _coh.OptionalHeaderSize;

            _peh = new PEHeader(reader);

            reader.BaseStream.Position = _dataSectionsOffset;

            _sech = new SectionHeader[_coh.NumberOfSections];

            for (int i = 0; i < _sech.Length; i++)
            {
                _sech[i] = new SectionHeader(reader);
            }

            Length = reader.BaseStream.Position;
        }