예제 #1
0
        public PUBDEFRecord(RecordReader reader, RecordContext context)
            : base(reader, context)
        {
            int baseGroupIndex = reader.ReadIndex();

            if (baseGroupIndex > context.Groups.Count)
            {
                throw new InvalidDataException("GroupIndex is out of range.");
            }
            if (baseGroupIndex > 0)
            {
                this.BaseGroup = context.Groups[baseGroupIndex - 1];
            }

            int baseSegmentIndex = reader.ReadIndex();

            if (baseSegmentIndex > context.Segments.Count)
            {
                throw new InvalidDataException("SegmentIndex is out of range.");
            }
            if (baseSegmentIndex == 0)
            {
                this.BaseFrame = reader.ReadUInt16();
            }
            else
            {
                this.BaseSegment = context.Segments[baseSegmentIndex - 1];
            }

            int startIndex = context.PublicNames.Count;

            while (!reader.IsEOF)
            {
                PublicNameDefinition def = new PublicNameDefinition();
                def.DefinedBy   = reader.RecordNumber;
                def.BaseGroup   = BaseGroup;
                def.BaseSegment = BaseSegment;
                def.BaseFrame   = BaseFrame;
                def.Name        = reader.ReadPrefixedString();
                def.Offset      = (int)reader.ReadUInt16Or32();
                def.TypeIndex   = reader.ReadIndex();
                context.PublicNames.Add(def);
            }
            int endIndex = context.PublicNames.Count;

            this.Definitions = context.PublicNames.Slice(
                startIndex, endIndex - startIndex);
        }
예제 #2
0
        public SEGDEFRecord(RecordReader reader, RecordContext context)
            : base(reader, context)
        {
            SegmentDefinition def = new SegmentDefinition();

            // Read the record.
            byte acbp = reader.ReadByte();
            def.Alignment = GetAlignment(acbp);
            def.Combination = GetCombination(acbp);
            def.IsUse32 = GetUse32(acbp);

            if (def.Alignment == SegmentAlignment.Absolute)
            {
                def.Frame = reader.ReadUInt16();
                def.Offset = reader.ReadByte();
            }

            UInt32 storedLength=reader.ReadUInt16Or32();
            def.Length = GetLength(acbp, storedLength, reader.RecordNumber);

            UInt16 segmentNameIndex = reader.ReadIndex();
            if (segmentNameIndex > context.Names.Count)
                throw new InvalidDataException("SegmentNameIndex is out of range.");
            if (segmentNameIndex > 0)
                def.SegmentName = context.Names[segmentNameIndex - 1];

            UInt16 classNameIndex = reader.ReadIndex();
            if (classNameIndex > context.Names.Count)
                throw new InvalidDataException("ClassNameIndex is out of range.");
            if (classNameIndex > 0)
                def.ClassName = context.Names[classNameIndex - 1];

            UInt16 overlayNameIndex = reader.ReadIndex();
            if (overlayNameIndex > context.Names.Count)
                throw new InvalidDataException("OverlayNameIndex is out of range.");
            if (overlayNameIndex > 0)
                def.OverlayName = context.Names[overlayNameIndex - 1];

            def.Data = new byte[def.Length];
            //def.Fixups = new List<FixupDefinition>();

            this.Definition = def;
            context.Segments.Add(def);
        }
예제 #3
0
        private static UInt32 ReadEncodedInteger(RecordReader reader)
        {
            byte b = reader.ReadByte();

            if (b == 0x81)
            {
                return(reader.ReadUInt16());
            }
            else if (b == 0x84)
            {
                return(reader.ReadUInt24());
            }
            else if (b == 0x88)
            {
                return(reader.ReadUInt32());
            }
            else
            {
                return(b);
            }
        }
예제 #4
0
        public SEGDEFRecord(RecordReader reader, RecordContext context)
            : base(reader, context)
        {
            SegmentDefinition def = new SegmentDefinition();

            // Read the record.
            byte acbp = reader.ReadByte();

            def.Alignment   = GetAlignment(acbp);
            def.Combination = GetCombination(acbp);
            def.IsUse32     = GetUse32(acbp);

            if (def.Alignment == SegmentAlignment.Absolute)
            {
                def.Frame  = reader.ReadUInt16();
                def.Offset = reader.ReadByte();
            }

            UInt32 storedLength = reader.ReadUInt16Or32();

            def.Length = GetLength(acbp, storedLength, reader.RecordNumber);

            UInt16 segmentNameIndex = reader.ReadIndex();

            if (segmentNameIndex > context.Names.Count)
            {
                throw new InvalidDataException("SegmentNameIndex is out of range.");
            }
            if (segmentNameIndex > 0)
            {
                def.SegmentName = context.Names[segmentNameIndex - 1];
            }

            UInt16 classNameIndex = reader.ReadIndex();

            if (classNameIndex > context.Names.Count)
            {
                throw new InvalidDataException("ClassNameIndex is out of range.");
            }
            if (classNameIndex > 0)
            {
                def.ClassName = context.Names[classNameIndex - 1];
            }

            UInt16 overlayNameIndex = reader.ReadIndex();

            if (overlayNameIndex > context.Names.Count)
            {
                throw new InvalidDataException("OverlayNameIndex is out of range.");
            }
            if (overlayNameIndex > 0)
            {
                def.OverlayName = context.Names[overlayNameIndex - 1];
            }

            def.Data = new byte[def.Length];
            //def.Fixups = new List<FixupDefinition>();

            this.Definition = def;
            context.Segments.Add(def);
        }
예제 #5
0
        public PUBDEFRecord(RecordReader reader, RecordContext context)
            : base(reader, context)
        {
            int baseGroupIndex = reader.ReadIndex();
            if (baseGroupIndex > context.Groups.Count)
                throw new InvalidDataException("GroupIndex is out of range.");
            if (baseGroupIndex > 0)
                this.BaseGroup = context.Groups[baseGroupIndex - 1];

            int baseSegmentIndex = reader.ReadIndex();
            if (baseSegmentIndex > context.Segments.Count)
                throw new InvalidDataException("SegmentIndex is out of range.");
            if (baseSegmentIndex == 0)
                this.BaseFrame = reader.ReadUInt16();
            else
                this.BaseSegment = context.Segments[baseSegmentIndex - 1];

            int startIndex = context.PublicNames.Count;
            while (!reader.IsEOF)
            {
                PublicNameDefinition def = new PublicNameDefinition();
                def.DefinedBy = reader.RecordNumber;
                def.BaseGroup = BaseGroup;
                def.BaseSegment = BaseSegment;
                def.BaseFrame = BaseFrame;
                def.Name = reader.ReadPrefixedString();
                def.Offset = (int)reader.ReadUInt16Or32();
                def.TypeIndex = reader.ReadIndex();
                context.PublicNames.Add(def);
            }
            int endIndex = context.PublicNames.Count;
            this.Definitions = context.PublicNames.Slice(
                startIndex, endIndex - startIndex);
        }
예제 #6
0
 private static UInt32 ReadEncodedInteger(RecordReader reader)
 {
     byte b = reader.ReadByte();
     if (b == 0x81)
         return reader.ReadUInt16();
     else if (b == 0x84)
         return reader.ReadUInt24();
     else if (b == 0x88)
         return reader.ReadUInt32();
     else
         return b;
 }