public void ParseFiestaPacket(FiestaPacket pPacket) { mTree.Nodes.Clear(); mSubNodes.Clear(); pPacket.Rewind(); string scriptPath = "Scripts" + Path.DirectorySeparatorChar + pPacket.Build.ToString() + Path.DirectorySeparatorChar + (pPacket.Outbound ? "Outbound" : "Inbound") + Path.DirectorySeparatorChar + "0x" + pPacket.Opcode.ToString("X4") + ".txt"; string commonPath = "Scripts" + Path.DirectorySeparatorChar + pPacket.Build.ToString() + Path.DirectorySeparatorChar + "Common.txt"; if (File.Exists(scriptPath)) { mParsing = pPacket; try { StringBuilder scriptCode = new StringBuilder(); scriptCode.Append(File.ReadAllText(scriptPath)); if (File.Exists(commonPath)) scriptCode.Append(File.ReadAllText(commonPath)); Script script = Script.Compile(scriptCode.ToString()); script.Context.SetItem("ScriptAPI", new ScriptAPI(this)); script.Execute(); } catch (Exception exc) { OutputForm output = new OutputForm("Script Error"); output.Append(exc.ToString()); output.Show(DockPanel, new Rectangle(MainForm.Location, new Size(400, 400))); } mParsing = null; } if (pPacket.Remaining > 0) mTree.Nodes.Add(new StructureNode("Undefined", pPacket.InnerBuffer, pPacket.Cursor, pPacket.Remaining)); }
public ScriptForm(string pPath, FiestaPacket pPacket) { mPath = pPath; mPacket = pPacket; InitializeComponent(); Text = "Script 0x" + pPacket.Opcode.ToString("X4") + ", " + (pPacket.Outbound ? "Outbound" : "Inbound"); }
public void OpenReadOnly(string pFilename) { mFileSaveMenu.Enabled = false; mTerminated = true; using (FileStream stream = new FileStream(pFilename, FileMode.Open, FileAccess.Read)) { BinaryReader reader = new BinaryReader(stream); mBuild = reader.ReadUInt16(); mLocalPort = reader.ReadUInt16(); while (stream.Position < stream.Length) { long timestamp = reader.ReadInt64(); ushort size = reader.ReadUInt16(); ushort opcode = reader.ReadUInt16(); bool outbound = (size & 0x8000) != 0; size = (ushort)(size & 0x7FFF); byte[] buffer = reader.ReadBytes(size); int Type = opcode >> 10; int Header = opcode & 1023; Definition definition = Config.Instance.Definitions.Find(d => d.Build == mBuild && d.Outbound == outbound && d.Opcode == opcode); FiestaPacket packet = new FiestaPacket(new DateTime(timestamp), outbound, opcode,Type,Header, definition == null ? "" : definition.Name, buffer); mPackets.Add(packet); if (!mOpcodes.Exists(kv => kv.Item1 == packet.Outbound && kv.Item2 == packet.Opcode)) mOpcodes.Add(new Tuple<bool, ushort>(packet.Outbound, packet.Opcode)); if (definition != null && definition.Ignore) continue; mPacketList.Items.Add(packet); } if (mPacketList.Items.Count > 0) mPacketList.EnsureVisible(0); } Text = string.Format("Port {0} (ReadOnly)", mLocalPort); }