Ejemplo n.º 1
0
        public Session()
        {
            this.packets          = new PacketList();
            this.mouse            = new MouseHook();
            this.mouseSlim        = new MouseHookSlim();
            this.keyboard         = new KeyboardHook();
            this.keyboardSlim     = new KeyboardHookSlim();
            this.keyChar          = new KeyCharHook();
            this.stopwatch        = new Stopwatch();
            this.minWaitTime      = 1;
            this.recordMouse      = true;
            this.recordMouseUp    = true;
            this.recordKeyboard   = true;
            this.recordKeyboardUp = true;
            this.recordKeyChar    = false;
            this.mergeKeyChar     = false;
            this.excludeKeys      = false;
            this.excludedKeys     = new Keys[0];
            this.manualResetEvent = new ManualResetEvent(false);
            this.sendInput        = new SendInput();
            this.speed            = 1.0;
            this.times            = 1;
            this.minWaitTime      = 1;

            mouse.InputEvent        += system_event;
            mouseSlim.InputEvent    += system_event;
            keyboard.InputEvent     += system_event;
            keyboardSlim.InputEvent += system_event;
            keyChar.InputEvent      += system_event;
            state = SessionState.Idle;
        }
Ejemplo n.º 2
0
        private void LoadPacketCapture()
        {
            var fb         = new OpenFileDialog();
            var showResult = fb.ShowDialog();

            if (showResult == DialogResult.OK || showResult == DialogResult.Yes)
            {
                var filePath = fb.FileName;
                CurrentOutputDir = Path.Combine(TempPacketFolder, Path.GetFileNameWithoutExtension(filePath));

                Directory.CreateDirectory(CurrentOutputDir);

                if (filePath != null)
                {
                    var loader = new PcapLoader(filePath);

                    Packets.Clear();
                    Packets = loader.GetPacketBytes();

                    PacketList.Items.Clear();

                    PacketList.BeginUpdate();
                    foreach (var pct in Packets)
                    {
                        AddPacket(pct);
                    }

                    PacketList.EndUpdate();
                }
            }
        }
Ejemplo n.º 3
0
 private void AddExternal(PacketList packetType, PacketHandler handler)
 {
     if (!_externalPacketList.ContainsKey(packetType))
     {
         _externalPacketList.Add((ushort)packetType, handler);
     }
 }
Ejemplo n.º 4
0
		private static bool LoadPacketDefintions() {

			string filePath = "Config/Server/Packets.xml";
			if (File.Exists(filePath) == false) {
				ServerConsole.WriteLine(GodLesZ.Library.EConsoleColor.Error, "failed, file not found!");
				Core.Kill();
				return false;
			}

			XmlSerializer xml = new XmlSerializer(typeof(PacketList));
			using (Stream fs = File.OpenRead(filePath)) {
				mPackets = (PacketList)xml.Deserialize(fs);
			}

			// TODO: Make a defaul packet version, holding base definitions
			//		 and let them be overritten from higher versions


			// Load all types from script assemblies
			//List<Type> scriptTypes = new List<Type>();
			/*
			foreach (Assembly asm in Scripting.ScriptCompiler.Assemblies) {
				scriptTypes.AddRange(asm.GetTypes());
			}
			*/
			Assembly lookupAsm = Assembly.GetExecutingAssembly();

			// Attach all packet handlers
			foreach (PacketVersion packets in mPackets) {
				foreach (PacketDefinition p in packets.Packets) {
					string asmName = string.Format("Rovolution.Server.Network.Packets.{0}", p.HandlerType);
					/*
					foreach (Type type in scriptTypes) {
						if (type.FullName == asmName) {
							MethodInfo info = type.GetMethod(p.HandlerName, BindingFlags.Public | BindingFlags.Static);
							Delegate dele = Delegate.CreateDelegate(typeof(OnPacketReceive), info);
							PacketHandlers.Register(p.ID, p.Length, (OnPacketReceive)dele);
							
							found = true;
							break;
						}
					}
					*/
					Type t = lookupAsm.GetType(asmName);
					if (t != null) {
						MethodInfo info = t.GetMethod(p.HandlerName, BindingFlags.Public | BindingFlags.Static);
						if (info == null) {
							ServerConsole.ErrorLine("Unable to find Packet handler for definition: {0}.{1}", p.HandlerType, p.HandlerName);
							continue;
						}
						Delegate dele = Delegate.CreateDelegate(typeof(OnPacketReceive), info);
						PacketHandlers.Register(p.HandlerName, p.ID, p.Length, (OnPacketReceive)dele);
					} else {
						ServerConsole.ErrorLine("Unable to find Packet handler for definition: {0}.{1}", p.HandlerType, p.HandlerName);
					}
				}
			}

			return true;
		}
Ejemplo n.º 5
0
 public override void GetObject(PacketList packet, ref object obj)
 {
     if (packet == PacketList.PACKET_GETPLAYER)
     {
         obj = player;
     }
 }
Ejemplo n.º 6
0
 public MainControl()
 {
     InitializeComponent();
     random = new Random();
     PacketList.DoubleBuffering(true);
     initListHeader();
 }
Ejemplo n.º 7
0
        //.method hidebysig static void LoadExecutngAssembly(string[] args) cil managed
        static void LoadExecutingAssembly(string[] args)
        {
            Logger.Init();

            //Logger.Trace("TODO: REMAKE ALL CONTAINSKEY [] - TO TRYGETVALUE");

            Settings m_Current = Settings.Default;

            //--------------- Init Commons ----------------------
            LocalCommons.Main.InitializeStruct(args);

            //------------- Controllers -------------------------
            Logger.Section("Controllers");
            GameServerController.LoadAvailableGameServers();

            //--------------- MySQL ---------------------------
            Logger.Section("MySQL");

            // Database
            ArcheageDb.Init(m_Current.DataBase_Host, m_Current.DataBase_User, m_Current.DataBase_Password, m_Current.DataBase_Name, m_Current.SSL, m_Current.PersistSecurityInfo);

            Database = new LoginDb();

            // Check if there are any updates
            CheckDatabaseUpdates();

            AccountHolder.LoadAccountData();

            //----------------Network ---------------------------
            Logger.Section("Network");
            PacketList.Initialize(Program.ServerClientVersion);
            new AsyncListener(m_Current.Main_IP, m_Current.Game_Port, defined: typeof(GameConnection));         //Waiting For GameServer Connections
            new AsyncListener(m_Current.Main_IP, m_Current.ArcheAge_Port, defined: typeof(ArcheAgeConnection)); //Waiting For ArcheAge Connections
        }
Ejemplo n.º 8
0
        //.method hidebysig static void LoadExecutngAssembly(string[] args) cil managed
        static void LoadExecutingAssembly(string[] args)
        {
            Logger.Init();

            //Logger.Trace("TODO: REMAKE ALL CONTAINSKEY [] - TO TRYGETVALUE");

            Settings m_Current = Settings.Default;

            //--------------- Init Commons ----------------------
            LocalCommons.Native.Significant.Main.InitializeStruct(args);

            //------------- Controllers -------------------------
            Logger.Section("Controllers");
            GameServerController.LoadAvailableGameServers();

            //--------------- MySQL ---------------------------
            Logger.Section("MySQL");
            AccountHolder.LoadAccountData();

            //----------------Network ---------------------------
            Logger.Section("Network");
            PacketList.Initialize(Program.ServerClientVersion);
            new AsyncListener(m_Current.Main_IP, m_Current.Game_Port, defined: typeof(GameConnection));         //Waiting For Game Server Connections
            new AsyncListener(m_Current.Main_IP, m_Current.ArcheAge_Port, defined: typeof(ArcheAgeConnection)); //Waiting For ArcheAge Connections
        }
Ejemplo n.º 9
0
 public void GetObject(int senderID, int recieveID, PacketList packet, ref object obj)
 {
     foreach (Manager mn in managerList)
     {
         int bRecive = mn.managerID & recieveID;
         if (bRecive != 0)
         {
             mn.GetObject(packet, ref obj);
         }
     }
 }
Ejemplo n.º 10
0
		public bool LoadPacketDefintions(string packetsBaseNamespace, Assembly lookupAsm) {
			if (File.Exists(Filepath) == false) {
				throw new Exception("Failed to load packet definition file (file not found): " + Filepath);
			}

			var xml = new XmlSerializer(typeof(PacketList));
			using (Stream fs = File.OpenRead(Filepath)) {
				mPackets = (PacketList)xml.Deserialize(fs);
			}

			// TODO: Make a defaul packet version, holding base definitions
			//		 and let them be overritten from higher versions


			// Load all types from script assemblies
			//List<Type> scriptTypes = new List<Type>();
			/*
			foreach (Assembly asm in Scripting.ScriptCompiler.Assemblies) {
				scriptTypes.AddRange(asm.GetTypes());
			}
			*/

			// Attach all packet handlers
			foreach (PacketVersion packets in mPackets) {
				foreach (PacketDefinition p in packets.Packets) {
					string asmName = string.Format("{0}.{1}", packetsBaseNamespace, p.HandlerType);
					/*
					foreach (Type type in scriptTypes) {
						if (type.FullName == asmName) {
							MethodInfo info = type.GetMethod(p.HandlerName, BindingFlags.Public | BindingFlags.Static);
							Delegate dele = Delegate.CreateDelegate(typeof(OnPacketReceive), info);
							PacketHandlers.Register(p.ID, p.Length, (OnPacketReceive)dele);
							
							found = true;
							break;
						}
					}
					*/
					var t = lookupAsm.GetType(asmName);
					if (t == null) {
						throw new Exception("Unable to find namespace: " + asmName);
					}

					var info = t.GetMethod(p.HandlerName, BindingFlags.Public | BindingFlags.Static);
					if (info == null) {
						throw new Exception("Unable to find Packet handler for definition: " + string.Format("{0}.{1}", p.HandlerType, p.HandlerName));
					}
					var dele = Delegate.CreateDelegate(typeof (OnPacketReceive), info);
					PacketHandlers.Register(p.HandlerName, p.ID, p.Length, (OnPacketReceive)dele);
				}
			}

			return true;
		}
Ejemplo n.º 11
0
    public void postMessage(int senderID, int receiveID, PacketList packet, int iPacket, object objPacket1, object objPacket2)
    {
        Packet pk = new Packet();

        pk.senderID    = senderID;
        pk.receiveID   = receiveID;
        pk.packetID    = packet;
        pk.iMessage    = iPacket;
        pk.objMessage1 = objPacket1;
        pk.objMessage2 = objPacket2;
        packets.Add(pk);
    }
Ejemplo n.º 12
0
        void listBox1_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            PacketList        plist  = e.Source as PacketList;
            TORCapturedPacket packet = plist.Session.GetPacket(plist.SelectedIndex + 1);

            if (packet == null)
            {
                MessageBox.Show("This packet doesn't exist!");
                return;
            }
            plist.Session._uiPacketRawView.Text = Utility.HexDump(packet.Data);
        }
Ejemplo n.º 13
0
    public void delayMessage(int senderID, int receiveID, PacketList packet, int iPacket, object objPacket1, object objPacket2, float lateTime)
    {
        Packet pk = new Packet();

        pk.senderID     = senderID;
        pk.receiveID    = receiveID;
        pk.packetID     = packet;
        pk.iMessage     = iPacket;
        pk.objMessage1  = objPacket1;
        pk.objMessage2  = objPacket2;
        pk.dispatchTime = Time.time + lateTime;
        packets.Add(pk);
    }
Ejemplo n.º 14
0
        /// <summary>
        /// Client Connect
        /// </summary>
        /// <param name="pd"></param>
        /// <param name="pl"></param>
        public static void In0x00a(PacketData pd, PacketList pl)
        {
            pl.currentParsePlayerID   = pd.GetUInt32AtPos(0x04);
            pl.currentParseZone       = pd.GetUInt16AtPos(0x30);
            pl.currentParsePlayerName = pd.GetStringAtPos(0x84, 16);

            if (GameViewForm.GV != null)
            {
                var GV = GameViewForm.GV;
                GV.gbPlayer.Text    = "Player 0x" + pl.currentParsePlayerID.ToString("X8");
                GV.lPlayerName.Text = pl.currentParsePlayerName;
            }
        }
Ejemplo n.º 15
0
        public static void Message(PacketList value)
        {
            switch (value)
            {
            case PacketList.Disconnect:
                Settings.Disconnected    = true;
                EngineMessageBox.Enabled = true;
                EngineMessageBox.Show("Desconectado");
                GameServerNetwork.Instance.TCPClient.Disconnect("dc");
                if (WorldServerNetwork.Instance.TCPClient != null)
                {
                    WorldServerNetwork.Instance.TCPClient.Disconnect("dc");
                }
                break;

            case PacketList.AcceptedConnection:
                EngineMessageBox.Enabled = true;
                EngineMessageBox.Visible = false;
                break;

            case PacketList.WorldServer_Client_CharacterDeleted:
                EngineMessageBox.Enabled = true;
                EngineMessageBox.Show("Personagem deletado");
                break;

            case PacketList.Error:
                EngineMessageBox.Enabled = true;
                EngineMessageBox.Show("Ocorreu um erro");
                break;

            case PacketList.WorldServer_Client_CharNameInUse:
                EngineMessageBox.Enabled = true;
                EngineMessageBox.Show("Nome já está em uso");
                break;

            case PacketList.WorldServer_Client_CharacterCreationDisabled:
                EngineMessageBox.Enabled = true;
                EngineMessageBox.Show("Criação de personagens desativado");
                break;

            case PacketList.WorldServer_Client_CharacterDeleteDisabled:
                EngineMessageBox.Enabled = true;
                EngineMessageBox.Show("Exclusão de personagens desativado");
                break;

            case PacketList.WorldServer_Client_InvalidLevelToDelete:
                EngineMessageBox.Enabled = true;
                EngineMessageBox.Show("Limite de level para exclusão 1 ~ 50");
                break;
            }
        }
Ejemplo n.º 16
0
        private void ClearPacketListExecute()
        {
            PacketList.Clear();
            FilteredPacketList.Clear();
            StatsHandler.ResetStats();

            if (monitor != null)
            {
                StatsHandler.StopWatch.Start();
            }

            ClearSelectedPacketData();
            IsClearEnabled = false;
        }
Ejemplo n.º 17
0
        private async void Button1_Click(object sender, EventArgs e)
        {
            openFileDialog.Multiselect = false;
            openFileDialog.Filter      = "Pcap Dump|*.pcap";
            if (openFileDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            PacketList.BeginUpdate();
            await DumpManager.LoadPcap(openFileDialog.FileName, (byte[] message, DateTime time) =>
            {
                parsePacket(message, time, false, true);
            }, new Progress <float>(percent => DumpBox.Text = string.Format("Loading: {0:0.00}%", percent)));

            PacketList.EndUpdate();
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Adds newly received packet to packet lists
        /// </summary>
        /// <param name="newPacket">Packet to be added to packet lists</param>
        private void ReceiveNewPacket(IPPacket newPacket)
        {
            newPacket.PacketID = (uint)PacketList.Count + 1;

            lock (PacketList)
            {
                PacketList.Add(newPacket);
            }
            IsClearEnabled = true;

            lock (filteredPacketList)
            {
                AddToFilteredList(newPacket);
            }

            StatsHandler.UpdateStats(newPacket);
        }
Ejemplo n.º 19
0
        //.method hidebysig static void LoadExecutngAssembly(string[] args) cil managed
        static void LoadExecutingAssembly(string[] args)
        {
            Logger.Init();
            Settings m_Current = Settings.Default;

            //--------------- Init Commons ----------------------
            LocalCommons.Main.InitializeStruct(args);

            //------------- Controllers -------------------------
            //Logger.Section("Controllers");
            //GameServerController.LoadAvailableGameServers();

            //----------------Network ---------------------------
            Logger.Section("Network");
            PacketList.Initialize();
            new AsyncListener(m_Current.ArcheAgeStream_IP, m_Current.ArcheAgeStream_PORT, defined: typeof(StreamConnection)); //Waiting For ArcheAge Connections
        }
Ejemplo n.º 20
0
        private static void LoadClientPackets()
        {
            if (!File.Exists("packets\\client.json"))
            {
                return;
            }

            try
            {
                ClientMessages = JsonConvert.DeserializeObject <PacketList>(File.ReadAllText("packets\\client.json"));

                Logger.Log("PacketProcessor", "Successfully loaded {0} client packets.", Logger.LogLevel.Config, ClientMessages.Packets.Count);
            }
            catch (Exception)
            {
                Logger.Log("PacketProcessor", "Error while parsing ClientMessages.", Logger.LogLevel.Error);
            }
        }
Ejemplo n.º 21
0
        void AddToPacketList(PacketItemDetail detail)
        {
            ListViewItem item = new ListViewItem();

            item.Text = detail.parsedValues["ID"];

            for (int i = 1; i < PacketList.Columns.Count; ++i)
            {
                var key = PacketList.Columns[i].Text;
                item.SubItems.Add(detail.parsedValues.ContainsKey(key) ? detail.parsedValues[key] : "");
            }

            item.Tag = detail;
            if (detail.ipc != null)
            {
                item.BackColor = Color.AliceBlue;
            }
            PacketList.Invoke((MethodInvoker)(() => PacketList.Items.Add(item)));
        }
Ejemplo n.º 22
0
        public bool LoadPacketDefintions(string packetsBaseNamespace, Assembly lookupAsm)
        {
            if (File.Exists(Filepath) == false)
            {
                throw new Exception("Failed to load packet definition file (file not found): " + Filepath);
            }

            var xml = new XmlSerializer(typeof(PacketList));

            using (Stream fs = File.OpenRead(Filepath)) {
                mPackets = (PacketList)xml.Deserialize(fs);
            }

            // TODO: Make a defaul packet version, holding base definitions
            //		 and let them be overritten from higher versions


            // Load all types from script assemblies
            //List<Type> scriptTypes = new List<Type>();

            /*
             * foreach (Assembly asm in Scripting.ScriptCompiler.Assemblies) {
             *      scriptTypes.AddRange(asm.GetTypes());
             * }
             */

            // Attach all packet handlers
            foreach (PacketVersion packets in mPackets)
            {
                foreach (PacketDefinition p in packets.Packets)
                {
                    string asmName = string.Format("{0}.{1}", packetsBaseNamespace, p.HandlerType);

                    /*
                     * foreach (Type type in scriptTypes) {
                     *      if (type.FullName == asmName) {
                     *              MethodInfo info = type.GetMethod(p.HandlerName, BindingFlags.Public | BindingFlags.Static);
                     *              Delegate dele = Delegate.CreateDelegate(typeof(OnPacketReceive), info);
                     *              PacketHandlers.Register(p.ID, p.Length, (OnPacketReceive)dele);
                     *
                     *              found = true;
                     *              break;
                     *      }
                     * }
                     */
                    var t = lookupAsm.GetType(asmName);
                    if (t == null)
                    {
                        throw new Exception("Unable to find namespace: " + asmName);
                    }

                    var info = t.GetMethod(p.HandlerName, BindingFlags.Public | BindingFlags.Static);
                    if (info == null)
                    {
                        throw new Exception("Unable to find Packet handler for definition: " + string.Format("{0}.{1}", p.HandlerType, p.HandlerName));
                    }
                    var dele = Delegate.CreateDelegate(typeof(OnPacketReceive), info);
                    PacketHandlers.Register(p.HandlerName, p.ID, p.Length, (OnPacketReceive)dele);
                }
            }

            return(true);
        }
Ejemplo n.º 23
0
 public State(System.Net.Sockets.Socket socket, PacketList packetList)
 {
     Socket = socket; PacketList = packetList;
 }
Ejemplo n.º 24
0
        void SessionList_OnAdd(object sender, EventArgs<CaptureSession> e)
        {
            // listbox1_SelectionChanged
            //<Label Content="Raw View" FontSize="10" FontWeight="Bold" Height="28" HorizontalAlignment="Left" Margin="374,-3,0,0" Name="label2" VerticalAlignment="Top" />
            //<TextBox Height="214" HorizontalAlignment="Left" Margin="374,17,0,0" Name="textBox1" VerticalAlignment="Top" Width="849" TextWrapping="Wrap" VerticalScrollBarVisibility="Visible" AcceptsReturn="True" />

            this.Dispatcher.Invoke(new Action(() =>
                {
                    TabItem ti = new TabItem();
                    ti.Content = new Grid();
                    ti.Header = "Session " + e.Value.ID;

                    Label lbl_captured_packets = new Label()
                    {
                        Content = "Captured Packets",
                        Height = 28,
                        HorizontalAlignment = System.Windows.HorizontalAlignment.Left,
                        Margin = new Thickness(1, -3, 0, 0),
                        Name = "lbl_captured_packets_" + e.Value.ID,
                        VerticalAlignment = System.Windows.VerticalAlignment.Top,
                        FontWeight = FontWeights.Bold,
                        FontSize = 10
                    };
                    TextBox tb_raw_view = new TextBox()
                    {
                        Height = 214,
                        HorizontalAlignment = System.Windows.HorizontalAlignment.Left,
                        Margin = new Thickness(374, 17, 0, 0),
                        Name = "tb_raw_view",
                        VerticalAlignment = System.Windows.VerticalAlignment.Top,
                        Width = 849,
                        TextWrapping = TextWrapping.Wrap,
                        VerticalScrollBarVisibility = ScrollBarVisibility.Visible,
                        AcceptsReturn = true,
                        FontFamily = new FontFamily("Courier New")
                    };
                    Label lbl_raw_view = new Label()
                    {
                        Content = "Raw View",
                        FontSize = 10,
                        FontWeight = FontWeights.Bold,
                        Height = 28,
                        HorizontalAlignment = System.Windows.HorizontalAlignment.Left,
                        Margin = new Thickness(374, -3, 0, 0),
                        Name = "lbl_raw_view",
                        VerticalAlignment = System.Windows.VerticalAlignment.Top
                    };
                    PacketList packet_list = new PacketList()
                    {
                        Height = 667,
                        HorizontalAlignment = System.Windows.HorizontalAlignment.Left,
                        Margin = new Thickness(4, 17, 0, 0),
                        Name = "packet_list",
                        VerticalAlignment = System.Windows.VerticalAlignment.Top,
                        Width = 364
                    };

                    packet_list.Session = e.Value;

                    (ti.Content as Grid).Children.Add(lbl_captured_packets);
                    (ti.Content as Grid).Children.Add(packet_list);
                    (ti.Content as Grid).Children.Add(tb_raw_view);
                    (ti.Content as Grid).Children.Add(lbl_raw_view);

                    e.Value._uiPacketList = packet_list;
                    e.Value._uiPacketRawView = tb_raw_view;

                    packet_list.SelectionChanged += new SelectionChangedEventHandler(listBox1_SelectionChanged);

                    tabControl1.Items.Add(ti);
                }));
        }
        static public bool ExportPacketToCSV(PacketList PL, string TargetFileName)
        {
            if (!PL.IsPreParsed)
            {
                return(false);
            }

            List <string> FieldNames = new List <string>();

            void AddFieldName(string fName)
            {
                if (fName.StartsWith("?") || fName.StartsWith("_"))
                {
                    return;
                }
                if (!FieldNames.Contains(fName))
                {
                    FieldNames.Add(fName);
                }
            }

            int FieldIndex(string fName)
            {
                for (int i = 0; i < FieldNames.Count; i++)
                {
                    if (FieldNames[i] == fName)
                    {
                        return(i);
                    }
                }
                return(-1);
            }

            string FilteredString(string s)
            {
                string res = string.Empty;

                foreach (char c in s)
                {
                    if (((byte)c < 16) || ((byte)c > 192))
                    {
                        res += ".";
                    }
                    else
                    {
                        res += c;
                    }
                }
                return(res);
            }

            var packetCount = PL.Count();

            // Generate Table-Headers
            FieldNames.Clear();
            AddFieldName("Header-Time");
            for (int x = 0; x < packetCount; x++)
            {
                foreach (var pv in PL.GetPacket(x).PP.ParsedView)
                {
                    AddFieldName(pv.Var);
                }
            }

            if (FieldNames.Count > 100)
            {
                if (MessageBox.Show("The exported file will contain a large number of field columns (" + FieldNames.Count.ToString() + ")\r\n" +
                                    "Are you sure you want to continue ?", "Export CSV", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
                {
                    return(false);
                }
            }

            List <List <string> > csvString = new List <List <string> >();

            csvString.Add(FieldNames); // add header

            // Generate CSV data
            for (int x = 0; x < packetCount; x++)
            {
                var           thisPacket = PL.GetPacket(x);
                var           pvl        = thisPacket.PP.ParsedView;
                List <string> line       = new List <string>();
                foreach (var _ in FieldNames)
                {
                    line.Add("");
                }
                line[0] = thisPacket.TimeStamp.ToString();
                foreach (var pv in pvl)
                {
                    var fIndex = FieldIndex(pv.Var);
                    if (fIndex > 0)
                    {
                        line[fIndex] = FilteredString(pv.Data);
                    }
                }
                csvString.Add(line);
            }

            var lines = new List <string>();

            foreach (var lData in csvString)
            {
                string l = string.Empty;
                foreach (var f in lData)
                {
                    string FieldPart;
                    if (f.Contains("\"") || f.Contains(";") || f.Contains("'"))
                    {
                        FieldPart = "\"" + f.Replace("\"", "\\\"") + "\"";
                    }
                    else
                    {
                        FieldPart = f;
                    }
                    l += FieldPart + ";";
                }
                lines.Add(l);
            }
            File.WriteAllLines(TargetFileName, lines);

            return(true);
        }
Ejemplo n.º 26
0
        private static bool LoadPacketDefintions()
        {
            string filePath = "Config/Server/Packets.xml";

            if (File.Exists(filePath) == false)
            {
                ServerConsole.WriteLine(GodLesZ.Library.EConsoleColor.Error, "failed, file not found!");
                Core.Kill();
                return(false);
            }

            XmlSerializer xml = new XmlSerializer(typeof(PacketList));

            using (Stream fs = File.OpenRead(filePath)) {
                mPackets = (PacketList)xml.Deserialize(fs);
            }

            // TODO: Make a defaul packet version, holding base definitions
            //		 and let them be overritten from higher versions


            // Load all types from script assemblies
            //List<Type> scriptTypes = new List<Type>();

            /*
             * foreach (Assembly asm in Scripting.ScriptCompiler.Assemblies) {
             *      scriptTypes.AddRange(asm.GetTypes());
             * }
             */
            Assembly lookupAsm = Assembly.GetExecutingAssembly();

            // Attach all packet handlers
            foreach (PacketVersion packets in mPackets)
            {
                foreach (PacketDefinition p in packets.Packets)
                {
                    string asmName = string.Format("Rovolution.Server.Network.Packets.{0}", p.HandlerType);

                    /*
                     * foreach (Type type in scriptTypes) {
                     *      if (type.FullName == asmName) {
                     *              MethodInfo info = type.GetMethod(p.HandlerName, BindingFlags.Public | BindingFlags.Static);
                     *              Delegate dele = Delegate.CreateDelegate(typeof(OnPacketReceive), info);
                     *              PacketHandlers.Register(p.ID, p.Length, (OnPacketReceive)dele);
                     *
                     *              found = true;
                     *              break;
                     *      }
                     * }
                     */
                    Type t = lookupAsm.GetType(asmName);
                    if (t != null)
                    {
                        MethodInfo info = t.GetMethod(p.HandlerName, BindingFlags.Public | BindingFlags.Static);
                        if (info == null)
                        {
                            ServerConsole.ErrorLine("Unable to find Packet handler for definition: {0}.{1}", p.HandlerType, p.HandlerName);
                            continue;
                        }
                        Delegate dele = Delegate.CreateDelegate(typeof(OnPacketReceive), info);
                        PacketHandlers.Register(p.HandlerName, p.ID, p.Length, (OnPacketReceive)dele);
                    }
                    else
                    {
                        ServerConsole.ErrorLine("Unable to find Packet handler for definition: {0}.{1}", p.HandlerType, p.HandlerName);
                    }
                }
            }

            return(true);
        }
Ejemplo n.º 27
0
 public override void GetObject(PacketList packet, ref object obj)
 {
     throw new System.NotImplementedException();
 }
Ejemplo n.º 28
0
 /// <summary>
 /// NPC Interaction 2
 /// </summary>
 /// <param name="pd"></param>
 /// <param name="pl"></param>
 public static void In0x034(PacketData pd, PacketList pl)
 {
     pl.currentParseZone = pd.GetUInt16AtPos(0x2A);
 }
Ejemplo n.º 29
0
 public void delayMessage(int senderID, int receiveID, PacketList packet, int iPacket, object objPacket1, object objPacket2, float delayTime)
 {
     _gameModel.delayMessage(senderID, receiveID, packet, iPacket, objPacket1, objPacket2, delayTime);
 }
Ejemplo n.º 30
0
 public void PacketDropped(PacketList packetList)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 31
0
        private void FillListBox(ListBox lb, PacketList pList, UInt16 GotTolastSync = 0)
        {
            int GotoIndex = -1;

            Application.UseWaitCursor = true;
            using (LoadingForm loadform = new LoadingForm(this))
            {
                try
                {
                    Random rand = new Random();
                    if (rand.Next(100) >= 95)
                    {
                        switch (rand.Next(5))
                        {
                        case 0:
                            loadform.Text = "That's a lot of data, please wait ...";
                            break;

                        case 1:
                            loadform.Text = "Burning circles, please wait ...";
                            break;

                        case 2:
                            loadform.Text = "I'm bored, please wait ...";
                            break;

                        case 3:
                            loadform.Text = "Camping NM, please wait ...";
                            break;

                        default:
                            loadform.Text = "Sacrificing Taru-Taru's, please wait ...";
                            break;
                        }
                    }
                    else
                    {
                        loadform.Text = "Populating Listbox, please wait ...";
                    }
                    loadform.Show();
                    loadform.pb.Minimum = 0;
                    loadform.pb.Maximum = pList.Count();
                    lb.Items.Clear();
                    for (int i = 0; i < pList.Count(); i++)
                    {
                        PacketData pd = pList.GetPacket(i);
                        switch (pd.PacketLogType)
                        {
                        case PacketLogTypes.Outgoing:
                            lb.Items.Add("=> " + pd.HeaderText);
                            break;

                        case PacketLogTypes.Incoming:
                            lb.Items.Add("<= " + pd.HeaderText);
                            break;

                        default:
                            lb.Items.Add("?? " + pd.HeaderText);
                            break;
                        }
                        if ((GotoIndex < 0) && (GotTolastSync > 0) && (pd.PacketSync == GotTolastSync))
                        {
                            GotoIndex = lb.Items.Count - 1;
                        }
                        loadform.pb.Value = i;
                        if ((i % 50) == 0)
                        {
                            loadform.pb.Refresh();
                        }
                    }
                    if (GotoIndex >= 0)
                    {
                        lb.SelectedIndex = GotoIndex;
                    }
                    loadform.Hide();
                }
                catch
                {
                }
            }
            Application.UseWaitCursor = false;
        }
Ejemplo n.º 32
0
 public void GetObject(int senderID, int recieveID, PacketList packet, ref object obj)
 {
     Debug.Log(senderID + " " + recieveID + " " + packet + " " + obj);
     _gameModel.GetObject(senderID, recieveID, packet, ref obj);
 }
Ejemplo n.º 33
0
 public abstract void GetObject(PacketList packet, ref object obj);
Ejemplo n.º 34
0
 public void Send(PacketList packetList)
 {
     switch (_sendProtocol)
     {
         case Protocol.Delimited:
             {
                 MemoryStream stream = new MemoryStream();
                 BinaryWriter writer = new BinaryWriter(stream);
                 foreach (AbstractPacket packet in packetList)
                 {
                     writer.Write(packet.Command.ToCharArray());
                     if (packet.Arguments != null)
                     {
                         writer.Write((char)1);
                         writer.Write(string.Join(new string(new[] { (char)0 }), packet.Arguments).ToCharArray());
                     }
                     writer.Write((char)0);
                 }
                 writer.Close();
                 Send(stream.ToArray(), new State(_socket, packetList));
                 break;
             }
         case Protocol.Xml:
             {
                 MemoryStream stream = new MemoryStream();
                 XmlWriterSettings settings = new XmlWriterSettings
                 {
                     OmitXmlDeclaration = true,
                     NewLineHandling = NewLineHandling.None
                 };
                 XmlWriter writer = XmlWriter.Create(stream, settings);
                 writer.WriteStartElement("p");
                 {
                     writer.WriteAttributeString("c", packetList.Count.ToString());
                     foreach (AbstractPacket packet in packetList)
                     {
                         writer.WriteStartElement("m");
                         {
                             writer.WriteAttributeString("p", packet.Arguments.Length.ToString());
                             writer.WriteAttributeString("p0", packet.Command);
                             for (int index = 0; index < packet.Arguments.Length; index++) writer.WriteAttributeString(string.Format("p{0}", index + 1), packet.Arguments[index]);
                         }
                         writer.WriteEndElement();
                     }
                 }
                 writer.WriteEndElement();
                 writer.Close();
                 Send(stream.ToArray(), new State(_socket, packetList));
                 break;
             }
         default: throw new ArgumentOutOfRangeException();
     }
 }
Ejemplo n.º 35
0
 public void postMessage(int senderID, int receiveID, PacketList packet, int iPacket, object objPacket1, object objPacket2)
 {
     _gameModel.postMessage(senderID, receiveID, packet, iPacket, objPacket1, objPacket2);
 }
Ejemplo n.º 36
0
 public static PacketList Create(Protocol protocol, List<byte> data)
 {
     switch (protocol)
     {
         case Protocol.Delimited:
             {
                 string buffer = Encoding.ASCII.GetString(data.ToArray());
                 string[] parameters = buffer.Split((char)1);
                 string[] arguments = new string[parameters.Length - 1];
                 Array.Copy(parameters, 1, arguments, 0, arguments.Length);
                 Packet packet = new Packet(parameters[0], arguments);
                 return new PacketList(Cast(packet));
             }
         case Protocol.Xml:
             {
                 MemoryStream stream = new MemoryStream(data.ToArray());
                 XmlTextReader reader = new XmlTextReader(stream);
                 if (reader.Read())
                 {
                     PacketList packetList = new PacketList();
                     while (reader.Read() && reader.NodeType == XmlNodeType.Element)
                     {
                         string command = reader.GetAttribute(1);
                         string[] arguments = new string[reader.AttributeCount - 2];
                         for (int index = 2; index < reader.AttributeCount; index++)
                             arguments[index - 2] = reader.GetAttribute(index);
                         Packet packet = new Packet(command, arguments);
                         packetList.Add(Cast(packet));
                     }
                     return packetList;
                 }
                 throw new InvalidDataException();
             }
         default: throw new ArgumentOutOfRangeException();
     }
 }