public STDFRecord ReadRecord()
        {
            ushort num = 0;
            byte num2 = 0;
            byte num3 = 0;
            long position = 0L;
            STDFRecord record = null;
            if (this.Mode == STDFFileMode.Write)
            {
                throw new Exception("Cannot read from a file opened for write");
            }
            position = this.br.BaseStream.Position;
            this.BeginningOfBadRecord = position;
            if (this.Processor == BYTE_ORIENTATION.UNKNOWN)
            {
                this.Processor = this.DetermineProcessorType(this.br);
            }
            if ((position + 4L) > this.FileLength)
            {
                return null;
            }
            num = this.br.ReadUInt16();
            num2 = this.br.ReadByte();
            num3 = this.br.ReadByte();
            if (this.Processor != BYTE_ORIENTATION.IBMPC)
            {
                uint num5 = Convert.ToUInt32(num);
                num5 = ((num5 >> 8) | (num5 << 8)) & 0xffff;
                num = Convert.ToUInt16(num5);
            }
            if ((position + num) >= this.FileLength)
            {
                throw new Exception("File not long enough, Probable File Corruption at offset:" + this.br.BaseStream.Position.ToString());
            }
            int num6 = (num3 << 8) + num2;
            switch (num6)
            {
                case 0xa14:
                    record = new BPSRecord();
                    break;

                case 0xa32:
                    record = new GDRRecord();
                    break;

                case 0xa00:
                    record = new FARRecord();
                    break;

                case 0xa01:
                    record = new MIRRecord();
                    break;

                case 0xa02:
                    record = new WIRRecord();
                    break;

                case 0xa05:
                    record = new PIRRecord();
                    break;

                case 0xa0f:
                    record = new PTRRecord();
                    break;

                case 0x1400:
                    record = new ATRRecord();
                    break;

                case 0x1401:
                    record = new MRRRecord();
                    break;

                case 0x1402:
                    record = new WRRRecord();
                    break;

                case 0x1405:
                    record = new PRRRecord();
                    break;

                case 0xf0f:
                    record = new MPRRecord();
                    break;

                case 0x1e01:
                    record = new PCRRecord();
                    break;

                case 0x1e02:
                    record = new WCRRecord();
                    break;

                case 0x1414:
                    record = new EPSRecord();
                    break;

                case 0x140f:
                    record = new FTRRecord();
                    break;

                case 0x2801:
                    record = new HBRRecord();
                    break;

                case 0x3201:
                    record = new SBRRecord();
                    break;

                case 0x1e0a:
                    record = new TSRRecord();
                    break;

                case 0x1e32:
                    record = new DTRRecord();
                    break;

                case 0x3c01:
                    record = new PMRRecord();
                    break;

                case 0x3e01:
                    record = new PGRRecord();
                    break;

                case 0x3f01:
                    record = new PLRRecord();
                    break;

                case 0x4601:
                    record = new RDRRecord();
                    break;

                case 0x5001:
                    record = new SDRRecord();
                    break;

                default:
                {
                    StringBuilder builder = new StringBuilder(0x800);
                    builder.AppendFormat("Corrupt stdf file encountered {0}\n", this.FileProcessing);
                    builder.AppendFormat("\tLast Known Good Position 0x{0:X}\n", this.LastGoodFilePosition);
                    builder.AppendFormat("\tLast Known Good Record {0)\n", this.LastGoodSTDFRecord.ToString());
                    builder.AppendFormat("\tBeginning of Bad Record 0x{0:X}\n", this.BeginningOfBadRecord);
                    break;
                }
            }
            record.REC_LEN = num;
            record.RemainingBytes = num;
            record.RecordNumber = this.RecordCount += 1L;
            record.RECORD_TYPE = (STDFRecordType) num6;
            record.Processor = this.Processor;
            record.FilePos = position;
            record.Read(this.br);
            this.br.BaseStream.Position = (record.FilePos + record.REC_LEN) + 4L;
            this.LastGoodFilePosition = position;
            this.LastGoodSTDFRecord = record.RECORD_TYPE;
            if (this.FileLength > 0L)
            {
                this.Percent = (Convert.ToDouble(position) / Convert.ToDouble(this.FileLength)) * 100.0;
                return record;
            }
            this.Percent = 0.0;
            return record;
        }
Beispiel #2
0
        public STDFRecord ReadRecord()
        {
            ushort     num      = 0;
            byte       num2     = 0;
            byte       num3     = 0;
            long       position = 0L;
            STDFRecord record   = null;

            if (this.Mode == STDFFileMode.Write)
            {
                throw new Exception("Cannot read from a file opened for write");
            }
            position = this.br.BaseStream.Position;
            this.BeginningOfBadRecord = position;
            if (this.Processor == BYTE_ORIENTATION.UNKNOWN)
            {
                this.Processor = this.DetermineProcessorType(this.br);
            }
            if ((position + 4L) > this.FileLength)
            {
                return(null);
            }
            num  = this.br.ReadUInt16();
            num2 = this.br.ReadByte();
            num3 = this.br.ReadByte();
            if (this.Processor != BYTE_ORIENTATION.IBMPC)
            {
                uint num5 = Convert.ToUInt32(num);
                num5 = ((num5 >> 8) | (num5 << 8)) & 0xffff;
                num  = Convert.ToUInt16(num5);
            }
            if ((position + num) >= this.FileLength)
            {
                throw new Exception("File not long enough, Probable File Corruption at offset:" + this.br.BaseStream.Position.ToString());
            }
            int num6 = (num3 << 8) + num2;

            switch (num6)
            {
            case 0xa14:
                record = new BPSRecord();
                break;

            case 0xa32:
                record = new GDRRecord();
                break;

            case 0xa00:
                record = new FARRecord();
                break;

            case 0xa01:
                record = new MIRRecord();
                break;

            case 0xa02:
                record = new WIRRecord();
                break;

            case 0xa05:
                record = new PIRRecord();
                break;

            case 0xa0f:
                record = new PTRRecord();
                break;

            case 0x1400:
                record = new ATRRecord();
                break;

            case 0x1401:
                record = new MRRRecord();
                break;

            case 0x1402:
                record = new WRRRecord();
                break;

            case 0x1405:
                record = new PRRRecord();
                break;

            case 0xf0f:
                record = new MPRRecord();
                break;

            case 0x1e01:
                record = new PCRRecord();
                break;

            case 0x1e02:
                record = new WCRRecord();
                break;

            case 0x1414:
                record = new EPSRecord();
                break;

            case 0x140f:
                record = new FTRRecord();
                break;

            case 0x2801:
                record = new HBRRecord();
                break;

            case 0x3201:
                record = new SBRRecord();
                break;

            case 0x1e0a:
                record = new TSRRecord();
                break;

            case 0x1e32:
                record = new DTRRecord();
                break;

            case 0x3c01:
                record = new PMRRecord();
                break;

            case 0x3e01:
                record = new PGRRecord();
                break;

            case 0x3f01:
                record = new PLRRecord();
                break;

            case 0x4601:
                record = new RDRRecord();
                break;

            case 0x5001:
                record = new SDRRecord();
                break;

            default:
            {
                StringBuilder builder = new StringBuilder(0x800);
                builder.AppendFormat("Corrupt stdf file encountered {0}\n", this.FileProcessing);
                builder.AppendFormat("\tLast Known Good Position 0x{0:X}\n", this.LastGoodFilePosition);
                builder.AppendFormat("\tLast Known Good Record {0)\n", this.LastGoodSTDFRecord.ToString());
                builder.AppendFormat("\tBeginning of Bad Record 0x{0:X}\n", this.BeginningOfBadRecord);
                break;
            }
            }
            record.REC_LEN        = num;
            record.RemainingBytes = num;
            record.RecordNumber   = this.RecordCount += 1L;
            record.RECORD_TYPE    = (STDFRecordType)num6;
            record.Processor      = this.Processor;
            record.FilePos        = position;
            record.Read(this.br);
            this.br.BaseStream.Position = (record.FilePos + record.REC_LEN) + 4L;
            this.LastGoodFilePosition   = position;
            this.LastGoodSTDFRecord     = record.RECORD_TYPE;
            if (this.FileLength > 0L)
            {
                this.Percent = (Convert.ToDouble(position) / Convert.ToDouble(this.FileLength)) * 100.0;
                return(record);
            }
            this.Percent = 0.0;
            return(record);
        }