Exemplo n.º 1
0
		public ModuleInfo(IServiceContainer ctx, SpanStream __stream) : base(__stream) {
			DBIReader dbi = ctx.GetService<DBIReader>();
			this.EC = dbi.EC;

			OpenModuleHandle = ReadUInt32();
			SectionContribution = new SectionContrib(this);

			Position += SectionContrib.SIZE;

			Flags = new ModuleInfoFlags(ReadUInt16());
			StreamNumber = ReadInt16();

			SymbolsSize = ReadUInt32();
			LinesSize = ReadUInt32();
			C13LinesSize = ReadUInt32();

			NumberOfFiles = ReadUInt16();
			ReadUInt16();

			FileNameOffsets = ReadUInt32();

			ECInfo = Read<ECInfo>();

			ModuleName = ReadCString();
			ObjectFileName = ReadCString();
		}
Exemplo n.º 2
0
        public TPIReader(IServiceContainer ctx, SpanStream stream) : base(stream)
        {
            this.ctx = ctx;

            Header = Read <TPIHeader>();
            if (Header.HeaderSize != Marshal.SizeOf <TPIHeader>())
            {
                throw new InvalidDataException();
            }

            if (!Enum.IsDefined(typeof(TPIVersion), Header.Version))
            {
                throw new InvalidDataException();
            }


#if false
            if (Header.Version != TPIVersion.V80)
            {
                throw new NotImplementedException($"TPI Version {Header.Version} not supported yet");
            }
#endif

            lazyLeafContainers = LazyFactory.CreateLazy(ReadTypes);
        }
Exemplo n.º 3
0
        public NameTableReader(SpanStream r)
        {
            UInt32 magic = r.ReadUInt32();

            if (magic != MAGIC)
            {
                throw new InvalidDataException($"Invalid verHdr magic 0x{magic:X}");
            }

            Version = r.ReadEnum <NameTableVersion>();
            switch (Version)
            {
            case NameTableVersion.Hash:
                hasher = HasherV1.HashData;
                break;

            case NameTableVersion.HashV2:
                hasher = HasherV2.HashData;
                break;
            }

            byte[] buf = Deserializers.ReadBuffer(r);
            rdr = new SpanStream(buf);

            Indices          = Deserializers.ReadArray <UInt32>(r);
            NumberOfElements = r.ReadUInt32();
        }
Exemplo n.º 4
0
 public SymbolDataReader(IServiceContainer ctx, SpanStream stream) : base(ctx, stream)
 {
     startOffset = stream.Position;
     Header      = ReadHeader();
     endOffset   = startOffset + sizeof(UInt16) + Header.Length;
     CheckHeader();
 }
Exemplo n.º 5
0
 public SymbolDataReader(IServiceContainer ctx, SymbolHeader header, SpanStream stream) : base(ctx, stream)
 {
     startOffset = stream.Position - Marshal.SizeOf <SymbolHeader>();
     Header      = header;
     endOffset   = startOffset + Header.Length;
     CheckHeader();
 }
Exemplo n.º 6
0
 public SymbolDataWriter(
     IServiceContainer ctx, SpanStream stream,
     SymbolType type
     ) : base(ctx, stream)
 {
     this.symbolType = type;
     Init();
 }
Exemplo n.º 7
0
        public void Commit()
        {
            st = new SpanStream((int)GetDataSize());

            st.WriteUInt32((uint)Streams.Count);
            WriteStreamSizes();
            Streams.ForEach(data => WriteStream(data));
        }
Exemplo n.º 8
0
        public SourceFileModuleReader(IServiceContainer ctx, SpanStream stream) : base(stream)
        {
            this.pdb = ctx.GetService <PDBFile>();

            // including .c file
            NumberOfFiles = ReadUInt16();

            UInt16 hdrFlags = ReadUInt16();

            switch (hdrFlags)
            {
            case 0:
            case 1:
                break;

            default:
                throw new InvalidAssumptionException("hdrFlags");
            }
            bool isRoot = (hdrFlags & 1) == 1;

            // dataOffset - startOfData = headerSize
            UInt32 dataOffset = ReadUInt32();

            UInt32[] childFileOffsets = Enumerable.Range(1, NumberOfFiles - 1)
                                        .Select(_ => ReadUInt32())
                                        .ToArray();

            UInt32 unk1 = ReadUInt32();
            UInt32 unk2 = ReadUInt32();

            if (hdrFlags == 1)
            {
                UInt32 maybeFlags = ReadUInt32();

                UInt32   numTables    = ReadUInt32();
                UInt32[] tableOffsets = Enumerable.Range(1, (int)numTables)
                                        .Select(_ => ReadUInt32())
                                        .ToArray();

                UInt32[][] unkDataPerTable = Enumerable.Range(1, (int)numTables)
                                             .Select(_ => {
                    UInt32[] data = new UInt32[2];
                    data[0]       = ReadUInt32();
                    data[1]       = ReadUInt32();
                    return(data);
                }).ToArray();
            }

            FileName = ReadCString();

            // table data follows...
            // skip it for now, and go read child headers
            Children = childFileOffsets.Select(offset => {
                return(PerformAt(offset, () => {
                    return new SourceFileModuleReader(ctx, this);
                }));
            }).ToArray();
        }
Exemplo n.º 9
0
		public ModuleListReader(IServiceContainer ctx, SpanStream __stream, uint moduleListSize) : base(__stream) {
			this.ctx = ctx;

			listStartOffset = Position;
			listSize = moduleListSize;
			listEndOffset = listStartOffset + listSize;

			lazyModules = LazyFactory.CreateLazy(ReadModules);
		}
Exemplo n.º 10
0
        public DebugReader(IServiceContainer ctx, SpanStream stream) : base(stream)
        {
            this.StreamTable = ctx.GetService <StreamTableReader>();

            for (int i = 0; i < (int)DebugType.DebugTypeMax; i++)
            {
                DebugStreams[i] = ReadInt16();
            }

            lazyFPO = LazyFactory.CreateLazy(CreateFPOReader);
        }
Exemplo n.º 11
0
		public SectionContrib40(SpanStream stream) : base(stream) {
			SectionIndex = ReadUInt16();
			ReadUInt16();

			Offset = ReadUInt32();
			Size = ReadUInt32();
			Characteristics = ReadUInt32();

			ModuleIndex = ReadUInt16();
			ReadUInt16();
		}
Exemplo n.º 12
0
        public CodeViewModuleReader(IServiceContainer ctx, ModuleInfo mod, SpanStream stream) : base(stream)
        {
            this.ctx = ctx;
            this.mod = mod;

            CodeViewSignature signature = ReadEnum <CodeViewSignature>();

            if (signature != CodeViewSignature.C13)
            {
                throw new NotImplementedException($"CodeView {signature} not supported yet");
            }

            lazySymbols = LazyFactory.CreateLazy(ReadSymbols);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Reads the pages that make up the Stream Table
        /// </summary>
        /// <returns></returns>
        public override IEnumerable <byte[]> GetPages_StreamTable()
        {
            Memory <byte> streamTableList = GetPages_StreamTableList()
                                            .SelectMany(x => x)
                                            .ToArray();

            SpanStream stream = new SpanStream(streamTableList);

            var numStreamTablePages = GetNumPages(Header.DirectorySize);

            for (int i = 0; i < numStreamTablePages; i++)
            {
                uint pageNum = stream.ReadUInt32();
                yield return(ReadPage(pageNum));
            }
        }
Exemplo n.º 14
0
        private ILeafContainer ReadTypeOld(out long dataSize)
        {
            uint hash = ReadUInt32();

            // we have no length, so we just pass all memory (after the hash)
            SpanStream     memStream = new SpanStream(Memory.Slice((int)Position));
            TypeDataReader rdr       = new TypeDataReader(ctx, memStream);

            // without a length, and with a small amount of data, we can just read this directly
            ILeafContainer leaf = rdr.ReadTypeDirect(false);

            // hash + type data
            dataSize = Position + rdr.Position;

            Position += rdr.Position;
            return(leaf);
        }
Exemplo n.º 15
0
        public SectionContribsReader(uint sectionContribsSize, SpanStream stream) : base(stream)
        {
            this.SectionContribsSize = sectionContribsSize;

            Version = ReadEnum <SCVersion>();
            switch (Version)
            {
            case SCVersion.V60:
                sectionContribsLazy = LazyFactory.CreateLazy(ReadSectionContribsV1);
                break;

            case SCVersion.New:
                sectionContribsLazy = LazyFactory.CreateLazy(ReadSectionContribsV2);
                break;

            default:
                sectionContribsLazy = LazyFactory.CreateLazy(ReadSectionContribsOld);
                break;
            }

            // after version
            StreamOffset = Position;
        }
Exemplo n.º 16
0
        public TPIReader(IServiceContainer ctx, SpanStream stream) : base(stream)
        {
            this.ctx = ctx;

            PDBFile pdb = ctx.GetService <PDBFile>();

            if (pdb.Type == PDBType.Old)
            {
                this.TypeReader = new ReadTypeDelegate(ReadTypeOld);
                JGHeaderOld oldHdr = ctx.GetService <JGHeaderOld>();
                Header = ImportJGOld(oldHdr);
            }
            else
            {
                Header = Read <TPIHeader>();
                if (Header.HeaderSize != Marshal.SizeOf <TPIHeader>())
                {
                    throw new InvalidDataException();
                }

                if (!Enum.IsDefined(typeof(TPIVersion), Header.Version))
                {
                    throw new InvalidDataException();
                }
                this.TypeReader = new ReadTypeDelegate(ReadType);
            }


#if false
            if (Header.Version != TPIVersion.V80)
            {
                throw new NotImplementedException($"TPI Version {Header.Version} not supported yet");
            }
#endif

            lazyLeafContainers = LazyFactory.CreateLazy(ReadTypes);
        }