private void listener_MessageElementsReceived(AgentListener.MessageQueueElement[] elements) { if (InvokeRequired) { Invoke(receivedHandler, new object[] { elements }); return; } foreach (AgentListener.MessageQueueElement el in elements) { if (el.msg_type == MessageType.MESSAGE_TYPE_MESSAGE) { msgCount++; msgBytes += (uint) el.message.Length; } else { pktCount++; pktBytes += el.len; } } msgCountLabel.Text = Convert.ToString(msgCount); msgBytesLabel.Text = Convert.ToString(msgBytes); pktCountLabel.Text = Convert.ToString(pktCount); pktBytesLabel.Text = Convert.ToString(pktBytes); }
public CaptureForm(AgentListener listener, AgentListener.SoftwallRule[] rules) { InitializeComponent(); this.listener = listener; msgCount = msgBytes = 0; pktCount = pktBytes = 0; receivedHandler = new AgentListener.ElementsReceivedHandler(listener_MessageElementsReceived); listener.MessageElementsReceived += receivedHandler; listener.Start(rules); }
public MainForm() { InitializeComponent(); config = ConfigManager.GetContext("MainForm"); colorPool = new ColorPool(); listener = new AgentListener(); receivedHandler = new AgentListener.ElementsReceivedHandler(listener_ElementsReceived); listener.MessageElementsReceived += receivedHandler; stoppedHandler = new AgentListener.StoppedHandler(listener_Stopped); listener.Stopped += stoppedHandler; tblMessages = dataSet.Tables["messages"]; debugForm = new DebugForm(); injectForm = new InjectForm(); swForm = new SoftwallForm(); packetParser = new PacketParser(debugForm); packetParser.PacketDescriptionReceived += new PacketParser.PacketDescriptionReceivedHandler(packetParser_PacketDescriptionReceived); dumpDisplayMode = DisplayMode.HEX; findTypeComboBox.SelectedIndex = 0; ClearState(); LoadSettings(); ApplyFilters(); }
private void listener_ElementsReceived(AgentListener.MessageQueueElement[] elements) { if (InvokeRequired) { Invoke(receivedHandler, new object[] { elements }); return; } object source = dataGridView.DataSource; dataGridView.DataSource = null; dataSet.Tables[0].BeginLoadData(); foreach (AgentListener.MessageQueueElement msg in elements) { DataTable tbl = dataSet.Tables["messages"]; DataRow row = tbl.NewRow(); row.BeginEdit(); /* Common stuff */ row["Timestamp"] = new DateTime(msg.time.wYear, msg.time.wMonth, msg.time.wDay, msg.time.wHour, msg.time.wMinute, msg.time.wSecond, msg.time.wMilliseconds, DateTimeKind.Local); row["ProcessName"] = msg.process_name; row["ProcessId"] = msg.process_id; row["ThreadId"] = msg.thread_id; row["FunctionName"] = msg.function_name; row["Backtrace"] = msg.backtrace; UInt32 returnAddress = 0; string callerModName = ""; if (msg.backtrace.Length > 0) { string[] tokens = msg.backtrace.Split(new char[] { '\n' }, 2); if (tokens.Length >= 1) { string line = tokens[0]; string[] lineTokens = line.Split(new string[] { "::" }, 2, StringSplitOptions.None); if (lineTokens.Length == 2) { returnAddress = Convert.ToUInt32(lineTokens[1].Substring(2), 16); callerModName = lineTokens[0]; } } } row["ReturnAddress"] = returnAddress; row["CallerModuleName"] = callerModName; row["ResourceId"] = msg.resource_id; row["MsgType"] = msg.msg_type; row["MsgContext"] = msg.context; row["Domain"] = msg.domain; row["Severity"] = msg.severity; row["Message"] = msg.message; if (msg.context == MessageContext.MESSAGE_CTX_ACTIVESYNC_DEVICE) deviceLabel = msg.message; else if (msg.context == MessageContext.MESSAGE_CTX_ACTIVESYNC_STATUS) statusLabel = msg.message; else if (msg.context == MessageContext.MESSAGE_CTX_ACTIVESYNC_SUBSTATUS) subStatusLabel = msg.message; else if (msg.context == MessageContext.MESSAGE_CTX_ACTIVESYNC_WZ_STATUS) wizStatusLabel = msg.message; row["Direction"] = msg.direction; row["LocalAddress"] = msg.local_address; row["LocalPort"] = msg.local_port; row["PeerAddress"] = msg.peer_address; row["PeerPort"] = msg.peer_port; byte[] data = new byte[msg.len]; Array.Copy(msg.buf, data, data.Length); row["Data"] = data; row["AS_Device"] = deviceLabel; row["AS_Status"] = statusLabel; row["AS_SubStatus"] = subStatusLabel; row["AS_WizStatus"] = wizStatusLabel; row.EndEdit(); tbl.Rows.Add(row); } dataSet.Tables[0].EndLoadData(); dataGridView.DataSource = source; }