private void ProcessFileForBuild(string fileName) { var records = PCapReader.LoadPcap(fileName, ref searchAborted); // Temperorary objects var allFrags = new List <FragDatListFile.FragDatInfo>(); var createObjectFrags = new List <FragDatListFile.FragDatInfo>(); foreach (var record in records) { if (searchAborted || Disposing || IsDisposed) { return; } // ******************************************************************** // ************************ Custom Search Code ************************ // ******************************************************************** foreach (BlobFrag frag in record.netPacket.fragList_) { try { if (frag.dat_.Length <= 4) { continue; } Interlocked.Increment(ref fragmentsProcessed); FragDatListFile.PacketDirection packetDirection = (record.isSend ? FragDatListFile.PacketDirection.ClientToServer : FragDatListFile.PacketDirection.ServerToClient); // Write to emperorary object allFrags.Add(new FragDatListFile.FragDatInfo(packetDirection, record.index, frag.dat_)); BinaryReader fragDataReader = new BinaryReader(new MemoryStream(frag.dat_)); var messageCode = fragDataReader.ReadUInt32(); // Write to emperorary object if (messageCode == 0xF745) // Create Object { Interlocked.Increment(ref totalHits); createObjectFrags.Add(new FragDatListFile.FragDatInfo(packetDirection, record.index, frag.dat_)); } } catch { // Do something with the exception maybe Interlocked.Increment(ref totalExceptions); } } } string outputFileName = (chkIncludeFullPathAndFileName.Checked ? fileName : (Path.GetFileName(fileName))); // ******************************************************************** // ************************* Write The Output ************************* // ******************************************************************** allFragDatFile.Write(new KeyValuePair <string, IList <FragDatListFile.FragDatInfo> >(outputFileName, allFrags)); createObjectFragDatFile.Write(new KeyValuePair <string, IList <FragDatListFile.FragDatInfo> >(outputFileName, createObjectFrags)); Interlocked.Increment(ref filesProcessed); }
private void ProcessFileForBuild(string fileName) { // NOTE: If you want to get fully constructed/merged messages instead of fragments: // Pass true below and use record.data as the full message, instead of individual record.frags var isPcapng = false; var records = PCapReader.LoadPcap(fileName, false, ref searchAborted, ref isPcapng); // Temperorary objects var allFrags = new List <FragDatListFile.FragDatInfo>(); var createObjectFrags = new List <FragDatListFile.FragDatInfo>(); foreach (var record in records) { if (searchAborted || Disposing || IsDisposed) { return; } // ******************************************************************** // ************************ Custom Search Code ************************ // ******************************************************************** foreach (BlobFrag frag in record.frags) { try { if (frag.dat_.Length <= 4) { continue; } Interlocked.Increment(ref fragmentsProcessed); FragDatListFile.PacketDirection packetDirection = (record.isSend ? FragDatListFile.PacketDirection.ClientToServer : FragDatListFile.PacketDirection.ServerToClient); // Write to emperorary object allFrags.Add(new FragDatListFile.FragDatInfo(packetDirection, record.index, frag.dat_)); //BinaryReader fragDataReader = new BinaryReader(new MemoryStream(frag.dat_)); //var messageCode = fragDataReader.ReadUInt32(); int messageCode = BitConverter.ToInt32(frag.dat_, 0); // Write to emperorary object if (messageCode == 0xF745) // Create Object { Interlocked.Increment(ref totalHits); createObjectFrags.Add(new FragDatListFile.FragDatInfo(packetDirection, record.index, frag.dat_)); } } catch { // Do something with the exception maybe Interlocked.Increment(ref totalExceptions); } } } string outputFileName = (chkIncludeFullPathAndFileName.Checked ? fileName : (Path.GetFileName(fileName))); // ******************************************************************** // ************************* Write The Output ************************* // ******************************************************************** allFragDatFile.Write(new KeyValuePair <string, IList <FragDatListFile.FragDatInfo> >(outputFileName, allFrags)); createObjectFragDatFile.Write(new KeyValuePair <string, IList <FragDatListFile.FragDatInfo> >(outputFileName, createObjectFrags)); Interlocked.Increment(ref filesProcessed); }