public void ParseMaplePacket(MaplePacket pPacket) { mTree.Nodes.Clear(); mSubNodes.Clear(); pPacket.Rewind(); string scriptPath = Application.StartupPath + Path.DirectorySeparatorChar + "Scripts" + Path.DirectorySeparatorChar + pPacket.Locale.ToString() + Path.DirectorySeparatorChar + pPacket.Build.ToString() + Path.DirectorySeparatorChar + (pPacket.Outbound ? "Outbound" : "Inbound") + Path.DirectorySeparatorChar + "0x" + pPacket.Opcode.ToString("X4") + ".txt"; string commonPath = Application.StartupPath + Path.DirectorySeparatorChar + "Scripts" + Path.DirectorySeparatorChar + pPacket.Locale.ToString() + 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.Buffer, pPacket.Cursor, pPacket.Remaining)); }
public void ParseFiestaPacket(FiestaPacket pPacket) { if (pPacket == null) { return; } mTree.Nodes.Clear(); mSubNodes.Clear(); pPacket.Rewind(); string scriptPath = "Scripts" + Path.DirectorySeparatorChar + (pPacket.Outbound ? "Outbound" : "Inbound") + Path.DirectorySeparatorChar + "0x" + pPacket.Opcode.ToString("X4") + ".txt"; string beforePath = "Scripts" + Path.DirectorySeparatorChar + "Global.txt"; string afterPath = "Scripts" + Path.DirectorySeparatorChar + "Common.txt"; if (File.Exists(scriptPath)) { mParsing = pPacket; try { StringBuilder scriptCode = new StringBuilder(); this.showTypes = false; this.showData = false; if (File.Exists(beforePath)) { scriptCode.Append(File.ReadAllText(beforePath)); } scriptCode.Append(Environment.NewLine + File.ReadAllText(scriptPath) + Environment.NewLine); if (File.Exists(afterPath)) { scriptCode.Append(File.ReadAllText(afterPath)); } 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 void ParseMaplePacket(MaplePacket pPacket) { mTree.Nodes.Clear(); mSubNodes.Clear(); pPacket.Rewind(); string scriptPath = Application.StartupPath + Path.DirectorySeparatorChar + "Scripts" + Path.DirectorySeparatorChar + pPacket.Locale.ToString() + Path.DirectorySeparatorChar + pPacket.Build.ToString() + Path.DirectorySeparatorChar + (pPacket.Outbound ? "Outbound" : "Inbound") + Path.DirectorySeparatorChar + "0x" + pPacket.Opcode.ToString("X4") + ".txt"; string commonPath = Application.StartupPath + Path.DirectorySeparatorChar + "Scripts" + Path.DirectorySeparatorChar + pPacket.Locale.ToString() + 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 void ParseMaplePacket(MaplePacket pPacket) { mTree.Nodes.Clear(); mSubNodes.Clear(); pPacket.Rewind(); var scriptPath = Helpers.GetScriptPath(pPacket.Locale, pPacket.Build, pPacket.Outbound, pPacket.Opcode); var commonPath = Helpers.GetCommonScriptPath(pPacket.Locale, pPacket.Build); 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.Buffer, pPacket.Cursor, pPacket.Remaining)); } }
private void ProcessTCPPacket(TCPPacket pTCPPacket, ref uint pSequence, Dictionary <uint, byte[]> pBuffer, FiestaStream pStream) { if (pTCPPacket.SequenceNumber > pSequence) { byte[] data; while ((data = pBuffer.GetOrDefault(pSequence, null)) != null) { pBuffer.Remove(pSequence); pStream.Append(data); pSequence += (uint)data.Length; } if (pTCPPacket.SequenceNumber > pSequence) { pBuffer[(uint)pTCPPacket.SequenceNumber] = pTCPPacket.TCPData; } } if (pTCPPacket.SequenceNumber < pSequence) { int difference = (int)(pSequence - pTCPPacket.SequenceNumber); if (difference > 0) { byte[] data = pTCPPacket.TCPData; if (data.Length > difference) { pStream.Append(data, difference, data.Length - difference); pSequence += (uint)(data.Length - difference); } } } else if (pTCPPacket.SequenceNumber == pSequence) { byte[] data = pTCPPacket.TCPData; pStream.Append(data); pSequence += (uint)data.Length; } FiestaPacket packet; bool refreshOpcodes = false; try { while ((packet = pStream.Read(DateTime.Now)) != null) { mPackets.Add(packet); Definition definition = Config.Instance.Definitions.Find(d => d.Outbound == packet.Outbound && d.Opcode == packet.Opcode); if (!mOpcodes.Exists(kv => kv.First == packet.Outbound && kv.Second == packet.Opcode)) { mOpcodes.Add(new Pair <bool, ushort>(packet.Outbound, packet.Opcode)); refreshOpcodes = true; } if (definition != null && definition.Ignore) { continue; } mPacketList.Items.Add(packet); if (mPacketList.SelectedItems.Count == 0) { packet.EnsureVisible(); } } } catch (Exception exc) { OutputForm output = new OutputForm("Packet Error"); output.Append(exc.ToString()); output.Show(DockPanel, new Rectangle(MainForm.Location, new Size(400, 400))); mTerminated = true; Text += " (T.)"; } if (DockPanel.ActiveDocument == this && refreshOpcodes) { MainForm.SearchForm.RefreshOpcodes(true); } }
public void ParseMaplePacket(MaplePacket pPacket) { mTree.Nodes.Clear(); mSubNodes.Clear(); pPacket.Rewind(); string scriptPath = Application.StartupPath + Path.DirectorySeparatorChar + "Scripts" + Path.DirectorySeparatorChar + pPacket.Locale.ToString() + Path.DirectorySeparatorChar + pPacket.Build.ToString() + Path.DirectorySeparatorChar + (pPacket.Outbound ? "发送" : "接收") + Path.DirectorySeparatorChar + "0x" + pPacket.Opcode.ToString("X4") + ".txt"; string commonPath = Application.StartupPath + Path.DirectorySeparatorChar + "Scripts" + Path.DirectorySeparatorChar + pPacket.Locale.ToString() + 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)); } // SSharp // Script script = Script.Compile(scriptCode.ToString()); // script.Context.SetItem("ScriptAPI", new ScriptAPI(this)); // script.Execute(); //Jint var engine = new Jint.Engine(); engine.SetValue("ScriptAPI", new ScriptAPI(this)); engine.SetValue("mplew", new mplew(this)); engine.Execute(scriptCode.ToString()); //var context = new NiL.JS.Core.Context(); //context.DefineVariable("ScriptAPI").Assign(NiL.JS.Core.JSValue.Marshal(new ScriptAPI(this))); //context.Eval(scriptCode.ToString()); } catch (Jint.Parser.ParserException exc) { OutputForm output = new OutputForm("Script Error"); output.Append(exc.Message); output.Show(DockPanel, new Rectangle(MainForm.Location, new Size(400, 400))); } catch (Jint.Runtime.JavaScriptException exc) { OutputForm output = new OutputForm("Script Error"); output.Append(exc.LineNumber + " : " + exc.Message); output.Show(DockPanel, new Rectangle(MainForm.Location, new Size(400, 400))); } 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.Buffer, pPacket.Cursor, pPacket.Remaining)); } }