コード例 #1
0
        public override void Read(BinaryReader r)
        {
            var sstSrcModuleBaseAddress = r.BaseStream.Position;

            // Number of source files contributing code to segments.
            var cFile = r.ReadUInt16();
            // Number of code segments receiving code from this module.
            var cSeg = r.ReadUInt16();

            baseSrcFile = new uint[cFile];
            for (int i = 0; i < cFile; i++)
            {
                baseSrcFile[i] = r.ReadUInt32();
            }

            /*
             * An array of two 32-bit offsets per segment that receives code from
             * this module. The first offset is the offset within the segment of the
             * first byte of code from this module. The second offset is the ending
             * address of the code from this module. The order of these pairs
             * corresponds to the ordering of the segments in the seg array. Zeroes
             * in these entries means that the information is not known, and the file
             * and line tables described below need to be examined to determine if
             * an address of interest is contained within the code from this module.
             */
            starts = new uint[cSeg];
            ends   = new uint[cSeg];
            for (int i = 0; i < cSeg; i++)
            {
                starts[i] = r.ReadUInt32();
                ends[i]   = r.ReadUInt32();
            }

            segmentIndices = new ushort[cSeg];
            for (int i = 0; i < cSeg; i++)
            {
                segmentIndices[i] = r.ReadUInt16();
            }

            //if (cSeg % 2==1) r.ReadUInt16();

            FileInfo = new SourceFileInformation[cFile];

            for (int i = 0; i < cFile; i++)
            {
                r.BaseStream.Position = sstSrcModuleBaseAddress + baseSrcFile[i];

                var sfi = new SourceFileInformation();

                var cSeg2 = r.ReadUInt16();
                var pad   = r.ReadUInt16();             // pad

                if (pad != 0)
                {
                    throw new Exception("Wrong pad value!");
                }

                sfi.baseSrcLn = new uint[cSeg2];

                for (int j = 0; j < cSeg2; j++)
                {
                    sfi.baseSrcLn[j] = r.ReadUInt32();
                }

                sfi.segmentStartOffsets = new uint[cSeg2];
                sfi.segmentEndOffsets   = new uint[cSeg2];
                for (int j = 0; j < cSeg2; j++)
                {
                    sfi.segmentStartOffsets[j] = r.ReadUInt32();
                    sfi.segmentEndOffsets[j]   = r.ReadUInt32();
                }

                sfi.SourceFileName = r.ReadString();


                sfi.Segments = new SourceSegmentInfo[cSeg2];
                for (int j = 0; j < cSeg2; j++)
                {
                    r.BaseStream.Position = sstSrcModuleBaseAddress + sfi.baseSrcLn[j];

                    var ssi = new SourceSegmentInfo();

                    ssi.SegmentId = r.ReadUInt16();
                    var cPair = r.ReadUInt16();

                    ssi.Offsets = new uint[cPair];
                    for (int k = 0; k < cPair; k++)
                    {
                        ssi.Offsets[k] = r.ReadUInt32();
                    }

                    ssi.Lines = new ushort[cPair];
                    for (int k = 0; k < cPair; k++)
                    {
                        ssi.Lines[k] = r.ReadUInt16();
                    }

                    sfi.Segments[j] = ssi;
                }

                FileInfo[i] = sfi;
            }
        }
コード例 #2
0
        public override void Read(BinaryReader r)
        {
            var sstSrcModuleBaseAddress = r.BaseStream.Position;

            // Number of source files contributing code to segments.
            var cFile = r.ReadUInt16();
            // Number of code segments receiving code from this module.
            var cSeg = r.ReadUInt16();

            baseSrcFile = new uint[cFile];
            for (int i = 0; i < cFile; i++)
                baseSrcFile[i] = r.ReadUInt32();

            /*
             * An array of two 32-bit offsets per segment that receives code from
             * this module. The first offset is the offset within the segment of the
             * first byte of code from this module. The second offset is the ending
             * address of the code from this module. The order of these pairs
             * corresponds to the ordering of the segments in the seg array. Zeroes
             * in these entries means that the information is not known, and the file
             * and line tables described below need to be examined to determine if
             * an address of interest is contained within the code from this module.
             */
            starts = new uint[cSeg];
            ends = new uint[cSeg];
            for (int i = 0; i < cSeg; i++)
            {
                starts[i] = r.ReadUInt32();
                ends[i] = r.ReadUInt32();
            }

            segmentIndices=new ushort[cSeg];
            for (int i = 0; i < cSeg; i++)
                segmentIndices[i] = r.ReadUInt16();

            //if (cSeg % 2==1) r.ReadUInt16();

            FileInfo=new SourceFileInformation[cFile];

            for (int i = 0; i < cFile; i++)
            {
                r.BaseStream.Position = sstSrcModuleBaseAddress + baseSrcFile[i];

                var sfi=new SourceFileInformation();

                var cSeg2 = r.ReadUInt16();
                var pad=r.ReadUInt16(); // pad

                if (pad != 0)
                    throw new Exception("Wrong pad value!");

                sfi.baseSrcLn = new uint[cSeg2];

                for (int j = 0; j < cSeg2; j++)
                    sfi.baseSrcLn[j] = r.ReadUInt32();

                sfi.segmentStartOffsets=new uint[cSeg2];
                sfi.segmentEndOffsets = new uint[cSeg2];
                for (int j = 0; j < cSeg2; j++)
                {
                    sfi.segmentStartOffsets[j] = r.ReadUInt32();
                    sfi.segmentEndOffsets[j] = r.ReadUInt32();
                }

                sfi.SourceFileName = r.ReadString();

                sfi.Segments = new SourceSegmentInfo[cSeg2];
                for (int j = 0; j < cSeg2; j++)
                {
                    r.BaseStream.Position = sstSrcModuleBaseAddress + sfi.baseSrcLn[j];

                    var ssi = new SourceSegmentInfo();

                    ssi.SegmentId = r.ReadUInt16();
                    var cPair = r.ReadUInt16();

                    ssi.Offsets = new uint[cPair];
                    for (int k = 0; k < cPair; k++)
                        ssi.Offsets[k] = r.ReadUInt32();

                    ssi.Lines = new ushort[cPair];
                    for (int k = 0; k < cPair; k++)
                        ssi.Lines[k] = r.ReadUInt16();

                    sfi.Segments[j] = ssi;
                }

                FileInfo[i] = sfi;
            }
        }