Esempio n. 1
0
        public DBIReader(Context ctx, Stream stream) : base(stream)
        {
            this.ctx = ctx;
            hdr      = ReadStruct <DBIHeader>();

            if (hdr.Signature != unchecked ((uint)-1) || !Enum.IsDefined(typeof(DBIVersion), (uint)hdr.Version))
            {
                throw new InvalidDataException();
            }

            uint nStreams = ctx.StreamTableReader.NumStreams;

            if (
                hdr.GsSymbolsStreamNumber >= nStreams ||
                hdr.PsSymbolsStreamNumber >= nStreams ||
                hdr.SymbolRecordsStreamNumber >= nStreams
                )
            {
                throw new InvalidDataException();
            }

            lazyModuleContainers = new Lazy <IEnumerable <IModuleContainer> >(ReadModules);
        }
Esempio n. 2
0
        /**
         * Layout of the DBI stream
         * -> Header
         * -> ModuleList
         * -> SectionContributions
         * -> SectionMap
         * -> FileInfo
         * -> TypeServerMap
         * -> EcSubstream
         * -> DebugHeader
         **/
        public DBIReader(IServiceContainer ctx, byte[] data) : base(data)
        {
            this.ctx = ctx;
            if (Length == 0)
            {
                return;
            }

            if (Length < Marshal.SizeOf <DBIHeader>())
            {
                throw new InvalidDataException();
            }

            Header = Read <DBIHeader>();

            if (Header.Signature != unchecked ((uint)-1) || !Enum.IsDefined(typeof(DBIVersion), (uint)Header.Version))
            {
                throw new InvalidDataException();
            }

            this.StreamTable = ctx.GetService <StreamTableReader>();

            uint nStreams = StreamTable.NumStreams;

            if (
                Header.GsSymbolsStreamNumber >= nStreams ||
                Header.PsSymbolsStreamNumber >= nStreams ||
                Header.SymbolRecordsStreamNumber >= nStreams
                )
            {
                throw new InvalidDataException();
            }

            lazyModuleContainers = LazyFactory.CreateLazy(ReadModules);
            Position            += Header.ModuleListSize;

            if (Header.SectionContributionSize > 0)
            {
                SectionContribs = new SectionContribsReader(Header.SectionContributionSize, this);
            }
            Position += Header.SectionContributionSize;

            Position += Header.SectionMapSize;
            Position += Header.FileInfoSize;

            if (Header.TypeServerMapSize > 0)
            {
                TypeServerMap = new TypeServerMapReader(this);
            }
            Position += Header.TypeServerMapSize;

            if (Header.EcSubstreamSize > 0)
            {
                EC = new ECReader(this);
            }
            Position += Header.EcSubstreamSize;

            if (Header.DebugHeaderSize > 0)
            {
                DebugInfo = new DebugReader(ctx, this);
            }
        }