private void mNextOpcodeButton_Click(object pSender, EventArgs pArgs) { SessionForm session = DockPanel.ActiveDocument as SessionForm; if (session == null || mOpcodeCombo.SelectedIndex == -1) { return; } Opcode search = (DockPanel.ActiveDocument as SessionForm).Opcodes[mOpcodeCombo.SelectedIndex]; int initialIndex = session.ListView.SelectedIndices.Count == 0 ? 0 : session.ListView.SelectedIndices[0] + 1; for (int index = initialIndex; index < session.ListView.Items.Count; ++index) { MaplePacket packet = session.ListView.Items[index] as MaplePacket; if (packet.Outbound == search.Outbound && packet.Opcode == search.Header) { session.ListView.SelectedIndices.Clear(); session.ListView.SelectedIndices.Add(index); packet.EnsureVisible(); session.ListView.Focus(); return; } } MessageBox.Show("No further packets found with the selected opcode.", "End Of Search", MessageBoxButtons.OK, MessageBoxIcon.Information); session.ListView.Focus(); }
private void mPrevOpcodeButton_Click(object sender, EventArgs e) { SessionForm session = DockPanel.ActiveDocument as SessionForm; if (session == null || mOpcodeCombo.SelectedIndex == -1) { return; } Pair <bool, ushort> search = (DockPanel.ActiveDocument as SessionForm).Opcodes[mOpcodeCombo.SelectedIndex]; int initialIndex = session.ListView.SelectedIndices.Count == 0 ? 0 : session.ListView.SelectedIndices[0]; for (int index = initialIndex - 1; index > 0; --index) { MaplePacket packet = session.ListView.Items[index] as MaplePacket; if (packet.Outbound == search.First && packet.Opcode == search.Second) { session.ListView.SelectedIndices.Clear(); session.ListView.SelectedIndices.Add(index); packet.EnsureVisible(); session.ListView.Focus(); return; } } MessageBox.Show("No further packets found with the selected opcode.", "End Of Search", MessageBoxButtons.OK, MessageBoxIcon.Information); session.ListView.Focus(); }
public void RefreshPackets() { Opcode search = (MainForm.SearchForm.ComboBox.SelectedIndex >= 0 ? mOpcodes[MainForm.SearchForm.ComboBox.SelectedIndex] : null); MaplePacket previous = mPacketList.SelectedItems.Count > 0 ? mPacketList.SelectedItems[0] as MaplePacket : null; mOpcodes.Clear(); mPacketList.Items.Clear(); MainForm.DataForm.HexBox.ByteProvider = null; MainForm.StructureForm.Tree.Nodes.Clear(); MainForm.PropertyForm.Properties.SelectedObject = null; if (!mViewOutboundMenu.Checked && !mViewInboundMenu.Checked) { return; } mPacketList.BeginUpdate(); for (int index = 0; index < mPackets.Count; ++index) { MaplePacket packet = mPackets[index]; if (packet.Outbound && !mViewOutboundMenu.Checked) { continue; } if (!packet.Outbound && !mViewInboundMenu.Checked) { continue; } Definition definition = Config.Instance.GetDefinition(mBuild, mLocale, packet.Outbound, packet.Opcode); packet.Name = definition == null ? "" : definition.Name; if (!mOpcodes.Exists(op => op.Outbound == packet.Outbound && op.Header == packet.Opcode)) { mOpcodes.Add(new Opcode(packet.Outbound, packet.Opcode)); } if (definition != null && !mViewIgnoredMenu.Checked && definition.Ignore) { continue; } mPacketList.Items.Add(packet); if (packet == previous) { packet.Selected = true; } } mPacketList.EndUpdate(); MainForm.SearchForm.RefreshOpcodes(true); if (previous != null) { previous.EnsureVisible(); } }
private void NextSequence() { SessionForm session = DockPanel.ActiveDocument as SessionForm; if (session == null) { return; } int initialIndex = session.ListView.SelectedIndices.Count == 0 ? 0 : session.ListView.SelectedIndices[0]; byte[] pattern = (mSequenceHex.ByteProvider as DynamicByteProvider).Bytes.ToArray(); long startIndex = MainForm.DataForm.HexBox.SelectionLength > 0 ? MainForm.DataForm.HexBox.SelectionStart : -1; for (int index = initialIndex; index < session.ListView.Items.Count; ++index) { MaplePacket packet = session.ListView.Items[index] as MaplePacket; long searchIndex = startIndex + 1; bool found = false; while (searchIndex <= packet.Buffer.Length - pattern.Length) { found = true; for (int patternIndex = 0; found && patternIndex < pattern.Length; ++patternIndex) { found = packet.Buffer[searchIndex + patternIndex] == pattern[patternIndex]; } if (found) { break; } ++searchIndex; } if (found) { session.ListView.SelectedIndices.Clear(); session.ListView.SelectedIndices.Add(index); packet.EnsureVisible(); MainForm.DataForm.HexBox.SelectionStart = searchIndex; MainForm.DataForm.HexBox.SelectionLength = pattern.Length; MainForm.DataForm.HexBox.ScrollByteIntoView(); session.ListView.Focus(); return; } startIndex = -1; } MessageBox.Show("No further sequences found.", "End Of Search", MessageBoxButtons.OK, MessageBoxIcon.Information); session.ListView.Focus(); }
private void mPacketContextIgnoreMenu_CheckedChanged(object pSender, EventArgs pArgs) { if (openingContextMenu) { return; } MaplePacket packet = mPacketList.SelectedItems[0] as MaplePacket; Definition definition = Config.Instance.GetDefinition(mBuild, mLocale, packet.Outbound, packet.Opcode); if (definition == null) { definition = new Definition(); definition.Locale = mLocale; definition.Build = mBuild; definition.Outbound = packet.Outbound; definition.Opcode = packet.Opcode; definition.Locale = mLocale; } definition.Ignore = mPacketContextIgnoreMenu.Checked; SaveDefinition(definition); int newIndex = packet.Index - 1; for (var i = packet.Index - 1; i > 0; i--) { var pack = mPacketList.Items[i] as MaplePacket; var def = Config.Instance.GetDefinition(mBuild, mLocale, pack.Outbound, pack.Opcode); if (def == definition) { newIndex--; } } RefreshPackets(); if (newIndex != 0 && mPacketList.Items[newIndex] != null) { packet = mPacketList.Items[newIndex] as MaplePacket; packet.Selected = true; packet.EnsureVisible(); } }
private void mPacketContextNameBox_KeyDown(object pSender, KeyEventArgs pArgs) { if (pArgs.Modifiers == Keys.None && pArgs.KeyCode == Keys.Enter) { MaplePacket packet = mPacketList.SelectedItems[0] as MaplePacket; Definition definition = Config.Instance.GetDefinition(mBuild, mLocale, packet.Outbound, packet.Opcode); if (definition == null) { definition = new Definition(); definition.Build = mBuild; definition.Outbound = packet.Outbound; definition.Opcode = packet.Opcode; definition.Locale = mLocale; } definition.Name = mPacketContextNameBox.Text; DefinitionsContainer.Instance.SaveDefinition(definition); pArgs.SuppressKeyPress = true; mPacketContextMenu.Close(); RefreshPackets(); packet.EnsureVisible(); } }