private void SaveLog() { if (!NeedToSave) { return; } NeedToSave = false; if (AnalysisType == AnalysisTypeEnum.Unknown) { return; } if (AnalysisType == AnalysisTypeEnum.LogFile) { MessageBox.Show("Saving saved log is retarded"); return; } var header = new LogHeader { Region = Version.ToString() }; PacketLogWriter writer = new PacketLogWriter(string.Format("{0}.TeraLog", DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss_" + Version, CultureInfo.InvariantCulture)), header); foreach (var message in OpcodeFinder.Instance.AllPackets) { writer.Append(message.Value); } writer.Dispose(); MessageBox.Show("Saved"); }
private void messageReceived(Message message) { try { //Message does not contain our length, add it to see the full packet byte[] data = new byte[message.Data.Count]; Array.Copy(message.Data.Array, 0, data, 2, message.Data.Count - 2); data[0] = (byte)(((short)message.Data.Count) & 255); data[1] = (byte)(((short)message.Data.Count) >> 8); if (message.Direction == MessageDirection.ClientToServer) { Packet_old tmpPacket = new Packet_old(Direction.CS, message.OpCode, data, false); mainWindow.pp.AppendPacket(tmpPacket); } else { Packet_old tmpPacket = new Packet_old(Direction.SC, message.OpCode, data, false); mainWindow.pp.AppendPacket(tmpPacket); } if (logWriter != null) { logWriter.Append(message); } } catch (Exception ex) { mainWindow.SetText("device_OnPacketArrival failure. \n Message:" + ex); } }
void teraSniffer_MessageReceived(Message message) { InvokeAction(() => { var mes = _messageFactory.Create(message); var cVersion = mes as C_CHECK_VERSION; if (cVersion != null) { _opCodeNamer = new OpCodeNamer(Path.Combine(_basicTeraData.ResourceDirectory, $"opcodes/{cVersion.Versions[0]}.txt")); } Write(string.Format("{0} {1}({2}) {3}", message.Direction == MessageDirection.ClientToServer ? ">" : "<", GetOpcodeName(message.OpCode), message.OpCode, message.Data.Count)); _logWriter.Append(message); if (message.Direction == MessageDirection.ClientToServer) { _clientMessages++; } else { _serverMessages++; } MessageCount.Text = string.Format("Client {0} Server {1}", _clientMessages, _serverMessages); }); }
private void SaveToTmpFile(string version, Queue <Message> packetsCopyStorage, string filename) { var header = new LogHeader { Region = version }; PacketLogWriter writer = new PacketLogWriter(filename, header); foreach (var message in packetsCopyStorage) { ParsedMessage parsedMessage = PacketProcessor.Instance.MessageFactory.Create(message); parsedMessage = WipeoutSensitiveData(parsedMessage); writer.Append(message); } writer.Dispose(); }
void teraSniffer_MessageReceived(Message message) { InvokeAction(() => { Write(string.Format("{0} {1}({2}) {3}", message.Direction == MessageDirection.ClientToServer ? ">" : "<", GetOpcodeName(message.OpCode), message.OpCode, message.Data.Count)); _logWriter.Append(message); if (message.Direction == MessageDirection.ClientToServer) { _clientMessages++; } else { _serverMessages++; } MessageCount.Text = string.Format("Client {0} Server {1}", _clientMessages, _serverMessages); }); }
public override void Process(RawMessage raw) { m_Writer.Append(raw); }