internal TraceRecord GetFirstValidTrace(FileStream fs, long fileOffset, out long foundTraceFileOffset, out long potentialNextTraceOffset, TaskInfoBase task) { foundTraceFileOffset = -1L; potentialNextTraceOffset = -1L; if (fs == null || fileOffset < 0 || fileOffset > fileLength) { return(null); } Utilities.SeekFileStreamHelper(fs, fileOffset, SeekOrigin.Begin); BinaryReader binaryReader = Utilities.CreateBinaryReaderHelper(fs); long num = fileOffset; while (true) { byte[] bytes = Utilities.ReadBytesHelper(binaryReader, 2046); int num2 = 0; int num3 = Utilities.ByteArrayIndexOf(bytes, findingBytes, num2); while (num3 != -1) { num = fileOffset + num3; Utilities.SeekFileStreamHelper(fs, num, SeekOrigin.Begin); XmlTextReader xmlTextReader = new XmlTextReader(fs, XmlNodeType.Element, null); xmlTextReader.WhitespaceHandling = WhitespaceHandling.None; try { if (xmlTextReader.Read() && xmlTextReader.Name == "E2ETraceEvent") { TraceRecord traceRecord = new TraceRecord(dataSource); traceRecord.ReadFrom(xmlTextReader, xmlUtil); foundTraceFileOffset = num; potentialNextTraceOffset = foundTraceFileOffset + findingBytes.Length; int typePositionPriority = 1024; traceRecord.TraceRecordPos = new TraceRecordPosition(this, foundTraceFileOffset, traceRecord.Time, typePositionPriority); traceRecord.TraceID = foundTraceFileOffset + filePath.GetHashCode(); return(traceRecord); } if (fs.Position >= FileSize) { return(null); } } catch (XmlException ex) { task?.SaveException(new E2EInvalidFileException(ex.Message, fs.Name, ex, num)); } catch (E2EInvalidFileException ex2) { task?.SaveException(new E2EInvalidFileException(ex2.Message, fs.Name, ex2, num)); } finally { num2 += num3 + findingBytes.Length; num3 = Utilities.ByteArrayIndexOf(bytes, findingBytes, num2); } } if (fs.Position >= FileSize) { break; } fileOffset += 2046 - findingBytes.Length - 2; Utilities.SeekFileStreamHelper(fs, fileOffset, SeekOrigin.Begin); } return(null); }