public int Read(BinaryReader br, out STDFRecordType recType) { byte num = br.ReadByte(); int num3 = (br.ReadByte() << 8) + num; recType = (STDFRecordType) num3; return 2; }
public int Read(BinaryReader br, out STDFRecordType recType) { byte num = br.ReadByte(); int num3 = (br.ReadByte() << 8) + num; recType = (STDFRecordType)num3; return(2); }
public STDFRecordIndex(STDFRecordType rType, ushort rLength, long fPosition, uint rNumber, STDFRecordKeys rKey) { this.RecordType = rType; this.RecordLength = rLength; this.FilePosition = fPosition; this.RecordNumber = rNumber; this.Key = rKey; }
public int MakeIndex() { int capacity = 0x3d0900; ushort num2 = 0; byte num3 = 0; STDFRecordType nAN = STDFRecordType.NAN; long fPosition = 0L; long length = 0L; uint num7 = 1; this.Logger("Indexing File:{0}{1}{0}", new object[] { Environment.NewLine, this.FileProcessing.ToString() }); if (this.Mode != STDFFileMode.Read) { throw new Exception("Cannot index a file opened for write."); } long position = this.br.BaseStream.Position; this.br.BaseStream.Position = 0L; length = this.br.BaseStream.Length; if (this.Processor == BYTE_ORIENTATION.UNKNOWN) { this.Processor = this.DetermineProcessorType(this.br); } this.RecIndexList = new List <STDFRecordIndex>(capacity); do { fPosition = this.br.BaseStream.Position; num2 = this.br.ReadUInt16(); if (this.Processor != BYTE_ORIENTATION.IBMPC) { uint num9 = Convert.ToUInt32(num2); num9 = ((num9 >> 8) | (num9 << 8)) & 0xffff; num2 = Convert.ToUInt16(num9); } num3 = this.br.ReadByte(); nAN = (STDFRecordType)((this.br.ReadByte() << 8) + num3); this.RecIndexList.Add(new STDFRecordIndex(nAN, num2, fPosition, num7++, RecordLookup(nAN))); this.br.ReadBytes(num2); }while (this.br.BaseStream.Position < length); this.br.BaseStream.Position = position; this.RecIndex = 0; return(0); }
public STDFRecord(STDFRecordType type) { this.RECORD_TYPE = type; }
public static STDFRecordKeys RecordLookup(STDFRecordType rt) { if (rt == STDFRecordType.PTR) { return(STDFRecordKeys.PTR); } if (rt == STDFRecordType.PIR) { return(STDFRecordKeys.PIR); } if (rt == STDFRecordType.PRR) { return(STDFRecordKeys.PRR); } if (rt == STDFRecordType.PMR) { return(STDFRecordKeys.PMR); } if (rt == STDFRecordType.PGR) { return(STDFRecordKeys.PGR); } if (rt == STDFRecordType.RDR) { return(STDFRecordKeys.RDR); } if (rt == STDFRecordType.TSR) { return(STDFRecordKeys.TSR); } if (rt == STDFRecordType.BPS) { return(STDFRecordKeys.BPS); } if (rt == STDFRecordType.SDR) { return(STDFRecordKeys.SDR); } if (rt == STDFRecordType.SBR) { return(STDFRecordKeys.SBR); } if (rt == STDFRecordType.HBR) { return(STDFRecordKeys.HBR); } if (rt == STDFRecordType.PLR) { return(STDFRecordKeys.PLR); } if (rt == STDFRecordType.PCR) { return(STDFRecordKeys.PCR); } if (rt == STDFRecordType.ATR) { return(STDFRecordKeys.ATR); } if (rt == STDFRecordType.FTR) { return(STDFRecordKeys.FTR); } if (rt == STDFRecordType.MPR) { return(STDFRecordKeys.MPR); } if (rt == STDFRecordType.WRR) { return(STDFRecordKeys.WRR); } if (rt == STDFRecordType.WCR) { return(STDFRecordKeys.WCR); } if (rt == STDFRecordType.WIR) { return(STDFRecordKeys.WIR); } if (rt == STDFRecordType.MIR) { return(STDFRecordKeys.MIR); } if (rt == STDFRecordType.MRR) { return(STDFRecordKeys.MRR); } if (rt == STDFRecordType.FAR) { return(STDFRecordKeys.FAR); } if (rt == STDFRecordType.GDR) { return(STDFRecordKeys.GDR); } if (rt == STDFRecordType.DTR) { return(STDFRecordKeys.DTR); } if (rt == STDFRecordType.GDR) { return(STDFRecordKeys.GDR); } if (rt == STDFRecordType.EPS) { return(STDFRecordKeys.EPS); } return(STDFRecordKeys.NAN); }
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); }
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; }
public static STDFRecordKeys RecordLookup(STDFRecordType rt) { if (rt == STDFRecordType.PTR) { return STDFRecordKeys.PTR; } if (rt == STDFRecordType.PIR) { return STDFRecordKeys.PIR; } if (rt == STDFRecordType.PRR) { return STDFRecordKeys.PRR; } if (rt == STDFRecordType.PMR) { return STDFRecordKeys.PMR; } if (rt == STDFRecordType.PGR) { return STDFRecordKeys.PGR; } if (rt == STDFRecordType.RDR) { return STDFRecordKeys.RDR; } if (rt == STDFRecordType.TSR) { return STDFRecordKeys.TSR; } if (rt == STDFRecordType.BPS) { return STDFRecordKeys.BPS; } if (rt == STDFRecordType.SDR) { return STDFRecordKeys.SDR; } if (rt == STDFRecordType.SBR) { return STDFRecordKeys.SBR; } if (rt == STDFRecordType.HBR) { return STDFRecordKeys.HBR; } if (rt == STDFRecordType.PLR) { return STDFRecordKeys.PLR; } if (rt == STDFRecordType.PCR) { return STDFRecordKeys.PCR; } if (rt == STDFRecordType.ATR) { return STDFRecordKeys.ATR; } if (rt == STDFRecordType.FTR) { return STDFRecordKeys.FTR; } if (rt == STDFRecordType.MPR) { return STDFRecordKeys.MPR; } if (rt == STDFRecordType.WRR) { return STDFRecordKeys.WRR; } if (rt == STDFRecordType.WCR) { return STDFRecordKeys.WCR; } if (rt == STDFRecordType.WIR) { return STDFRecordKeys.WIR; } if (rt == STDFRecordType.MIR) { return STDFRecordKeys.MIR; } if (rt == STDFRecordType.MRR) { return STDFRecordKeys.MRR; } if (rt == STDFRecordType.FAR) { return STDFRecordKeys.FAR; } if (rt == STDFRecordType.GDR) { return STDFRecordKeys.GDR; } if (rt == STDFRecordType.DTR) { return STDFRecordKeys.DTR; } if (rt == STDFRecordType.GDR) { return STDFRecordKeys.GDR; } if (rt == STDFRecordType.EPS) { return STDFRecordKeys.EPS; } return STDFRecordKeys.NAN; }