Ejemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)// aply
        {
            pck_window_dat pck_dat = new pck_window_dat();

            pck_dat.action = 6;
            Globals.pck_thread.mine_queue.Enqueue(pck_dat);
        }
Ejemplo n.º 2
0
        public System.Windows.Forms.ListViewItem[] cache_lictview_items;//= new System.Windows.Forms.ListViewItem[10000];
        //public int max_listview_count = 0;

        public packet_window()
        {
            InitializeComponent();
            this.listView1.DoubleBuffer();
            Globals.pck_thread.load_client_names();
            Globals.pck_thread.load_server_names();
            checkBox_filter.Checked = Globals.pck_thread.filter_wind_pck;
            if (checkBox_filter.Checked)
            {
                checkBox2.Enabled = true;
                checkBox3.Enabled = true;
            }
            else
            {
                checkBox2.Enabled = false;
                checkBox3.Enabled = false;
            }
            checkBox2.Checked = Globals.pck_thread.hide_cli_pck;     // hide client
            checkBox3.Checked = Globals.pck_thread.hide_srv_pck;     // hide server
            checkBox4.Checked = Globals.pck_thread.search_pck_names; // search in pck names

            if (Globals.pck_thread.wind_combo_set == true)
            {
                comboBox_srv_cli.SelectedIndex = 1;// client
            }
            else
            {
                comboBox_srv_cli.SelectedIndex = 0; // server
            }

            if (Globals.pck_thread.pck_recording == false)
            {
                button_start_rec.Text = "Start Recording";
            }
            else
            {
                button_start_rec.Text = "Stop Recording";
            }
            pck_window_dat temp_pck = new pck_window_dat();

            temp_pck.action = 5;
            Globals.pck_thread.mine_queue.Enqueue(temp_pck);
            //Globals.pck_thread.mine_queue.Enqueue(temp_pck);
            if (Globals.pck_thread.folow_new_pck)// folow pck
            {
                checkBox1.Checked = true;
            }
            else
            {
                checkBox1.Checked = false;
            }
            checkBox5.Checked = Globals.pck_thread.save_visable; // save visable
            this.Text         = "Packet Window (" + Globals.gamedata.my_char.Name + ")";


            //SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
            //this.SetStyle(ControlStyles.DoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);
            // this.UpdateStyles();
        }
Ejemplo n.º 3
0
        private void checkBox3_CheckedChanged(object sender, EventArgs e)
        {
            Globals.pck_thread.hide_srv_pck = checkBox3.Checked;
            pck_window_dat temp_pck = new pck_window_dat();

            temp_pck.action = 5;
            Globals.pck_thread.mine_queue.Enqueue(temp_pck);
        }
Ejemplo n.º 4
0
        public System.Windows.Forms.ListViewItem[] cache_lictview_items;//= new System.Windows.Forms.ListViewItem[10000];
        //public int max_listview_count = 0;

        public packet_window()
        {
            InitializeComponent();
            this.listView1.DoubleBuffer();
            Globals.pck_thread.load_client_names();
            Globals.pck_thread.load_server_names();
            checkBox_filter.Checked = Globals.pck_thread.filter_wind_pck;
            if (checkBox_filter.Checked)
            {
                checkBox2.Enabled = true;
                checkBox3.Enabled = true;
            }
            else
            {
                checkBox2.Enabled = false;
                checkBox3.Enabled = false;
            }
            checkBox2.Checked = Globals.pck_thread.hide_cli_pck; // hide client
            checkBox3.Checked = Globals.pck_thread.hide_srv_pck; // hide server
            checkBox4.Checked =Globals.pck_thread.search_pck_names; // search in pck names

            if (Globals.pck_thread.wind_combo_set == true)
            {
                comboBox_srv_cli.SelectedIndex = 1;// client
            }
            else
            {
                comboBox_srv_cli.SelectedIndex = 0; // server
            }

            if (Globals.pck_thread.pck_recording == false)
            {
                button_start_rec.Text = "Start Recording";
            }
            else
            {
                button_start_rec.Text = "Stop Recording";
            }
            pck_window_dat temp_pck = new pck_window_dat();
            temp_pck.action = 5;
            Globals.pck_thread.mine_queue.Enqueue(temp_pck);
            //Globals.pck_thread.mine_queue.Enqueue(temp_pck);
            if (Globals.pck_thread.folow_new_pck)// folow pck
            {
                checkBox1.Checked = true;
            }
            else
            {
                checkBox1.Checked = false;
            }
            checkBox5.Checked = Globals.pck_thread.save_visable; // save visable
            this.Text = "Packet Window (" + Globals.gamedata.my_char.Name + ")";


            //SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
            //this.SetStyle(ControlStyles.DoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);
            // this.UpdateStyles();
        }
Ejemplo n.º 5
0
 private void button6_Click(object sender, EventArgs e)// load ?
 {
     if (MessageBox.Show("Load and apply filters ?", "Pika Pika!", MessageBoxButtons.YesNo) == DialogResult.Yes)
     {
         pck_window_dat pck_dat = new pck_window_dat();
         pck_dat.action = 8;
         Globals.pck_thread.mine_queue.Enqueue(pck_dat);
     }
 }
Ejemplo n.º 6
0
 private void button_clear_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Clear Packet Log?", "Pika Pika!", MessageBoxButtons.YesNo) == DialogResult.Yes)
     {
         pck_window_dat pck_dat = new pck_window_dat();
         pck_dat.action = 2;
         Globals.pck_thread.mine_queue.Enqueue(pck_dat);
     }
 }
Ejemplo n.º 7
0
 public pck_window_dat(pck_window_dat dat)
         {
             action = dat.action;
             type = dat.type;
             time = String.Copy(dat.time);
             bytebuffer = new byte[dat.bytebuffer.Length];
             for (int i = 0; i < bytebuffer.Length; i++)
             {
                 bytebuffer[i] = dat.bytebuffer[i];
             }
           }
Ejemplo n.º 8
0
 public pck_window_dat(pck_window_dat dat)
 {
     action     = dat.action;
     type       = dat.type;
     time       = String.Copy(dat.time);
     bytebuffer = new byte[dat.bytebuffer.Length];
     for (int i = 0; i < bytebuffer.Length; i++)
     {
         bytebuffer[i] = dat.bytebuffer[i];
     }
 }
Ejemplo n.º 9
0
        private void button_Save_list_Click(object sender, EventArgs e)
        {
            //DialogResult sav_win_res;
            SaveFileDialog saveFileDialog1 = new SaveFileDialog();

            saveFileDialog1.Filter           = "Packet log(*.lpl)|*.lpl";
            saveFileDialog1.FilterIndex      = 1;
            saveFileDialog1.RestoreDirectory = true;
            saveFileDialog1.InitialDirectory = Globals.PATH + "\\Packet Logs";
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                pck_window_dat temp_pck = new pck_window_dat();
                temp_pck.action = 4;
                temp_pck.time   = saveFileDialog1.FileName; // same type so i dont see problem here :P
                Globals.pck_thread.mine_queue.Enqueue(temp_pck);
            }
        }
Ejemplo n.º 10
0
        private void checkBox_filter_CheckedChanged(object sender, EventArgs e)
        {
            Globals.pck_thread.filter_wind_pck = checkBox_filter.Checked;
            pck_window_dat temp_pck = new pck_window_dat();

            temp_pck.action = 5;
            if (checkBox_filter.Checked)
            {
                checkBox2.Enabled = true;
                checkBox3.Enabled = true;
            }
            else
            {
                checkBox2.Enabled = false;
                checkBox3.Enabled = false;
            }
            Globals.pck_thread.mine_queue.Enqueue(temp_pck);
        }
Ejemplo n.º 11
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (textBox3.TextLength > 0)
     {
         if (radioButton1.Checked == true) // client
         {
             if (checkBox4.Checked)
             {
                 pck_window_dat temp_pck = new pck_window_dat();
                 temp_pck.time   = textBox3.Text;
                 temp_pck.type   = 1;
                 temp_pck.action = 14;
                 Globals.pck_thread.mine_queue.Enqueue(temp_pck);
             }
             else
             {
                 pck_window_dat temp_pck = new pck_window_dat();
                 temp_pck.time   = textBox3.Text;
                 temp_pck.type   = 1;
                 temp_pck.action = 10;
                 Globals.pck_thread.mine_queue.Enqueue(temp_pck);
             }
         }
         else if (radioButton2.Checked == true) // server
         {
             if (checkBox4.Checked)
             {
                 pck_window_dat temp_pck = new pck_window_dat();
                 temp_pck.time   = textBox3.Text;
                 temp_pck.type   = 2;
                 temp_pck.action = 14;
                 Globals.pck_thread.mine_queue.Enqueue(temp_pck);
             }
             else
             {
                 pck_window_dat temp_pck = new pck_window_dat();
                 temp_pck.time   = textBox3.Text;
                 temp_pck.type   = 2;
                 temp_pck.action = 10;
                 Globals.pck_thread.mine_queue.Enqueue(temp_pck);
             }
         }
     }
 } // serarch up
Ejemplo n.º 12
0
        private void button_Load_list_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            //openFileDialog1.InitialDirectory = "c:\\" ;
            openFileDialog1.Title            = "Load Packet log";
            openFileDialog1.Filter           = "Packet log (*.lpl)|*.lpl";
            openFileDialog1.FilterIndex      = 1;
            openFileDialog1.InitialDirectory = Globals.PATH + "\\Packet Logs";
            openFileDialog1.RestoreDirectory = true;

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                //FileStream fs = new FileStream(openFileDialog1.FileName, FileMode.Open, FileAccess.Read);
                pck_window_dat temp_pck = new pck_window_dat();
                temp_pck.action = 3;
                temp_pck.time   = openFileDialog1.FileName; // same type so i dont see problem here :P
                Globals.pck_thread.mine_queue.Enqueue(temp_pck);
            }
        }
Ejemplo n.º 13
0
        private void save_data(pck_window_dat tmp_dat)
        {
            try
            {
                    //System.IO.BinaryWriter test =  new BinaryWriter(File.Open(tmp_dat.time, FileMode.Create));
                    if (save_visable)
                    {
                        if (filter_wind_pck == true)
                        {
                            System.IO.BinaryWriter test = new BinaryWriter(File.Open(tmp_dat.time, FileMode.Create));
                            test.Write(filtered_pck.Count);
                            for (int i = 0; i < filtered_pck.Count; i++)
                            {
                                test.Write((Globals.pck_thread.pck_record[filtered_pck[i]]).action);
                                test.Write((Globals.pck_thread.pck_record[filtered_pck[i]]).type);
                                test.Write((Globals.pck_thread.pck_record[filtered_pck[i]]).time);
                                test.Write((Globals.pck_thread.pck_record[filtered_pck[i]]).bytebuffer.Length);
                                //test.Write(Globals.pck_thread.pck_record[i]).bytebuffer);
                                for (int j = 0; j < (Globals.pck_thread.pck_record[filtered_pck[i]]).bytebuffer.Length; j++)
                                    test.Write((Globals.pck_thread.pck_record[filtered_pck[i]]).bytebuffer[j]);
                            }
                            test.Flush();
                        }
                        else
                        {
                            rec_fun(tmp_dat);
                        }
                    }
                    else
                    {
                        rec_fun(tmp_dat);
                        /*
                        test.Write(Globals.pck_thread.pck_record.Count);
                        for (int i = 0; i < Globals.pck_thread.pck_record.Count; i++)
                        {
                            test.Write((Globals.pck_thread.pck_record[i]).action);
                            test.Write((Globals.pck_thread.pck_record[i]).type);
                            test.Write((Globals.pck_thread.pck_record[i]).time);
                            test.Write((Globals.pck_thread.pck_record[i]).bytebuffer.Length);
                            //test.Write(Globals.pck_thread.pck_record[i]).bytebuffer);
                            for (int j = 0; j < (Globals.pck_thread.pck_record[i]).bytebuffer.Length; j++)
                                test.Write((Globals.pck_thread.pck_record[i]).bytebuffer[j]);
                        }
                        test.Flush();
                         */
                    }
            }

            catch
            {
                // to do ...
            }

        }
Ejemplo n.º 14
0
		private void GameReadThread()
		{
            byte[] buffread = new byte[Globals.BUFFER_MAX];
			byte[] buffpacket;

			int cnt = 0;
			int size = 0;
            bool handle = true;
            bool forward = true;
            string tmp;

			ByteBuffer bbuffer0;
			ByteBuffer bbuffer1;
            ByteBuffer bbtmp;
			ByteBuffer bbtmp1;
            
            uint b0 = 0; //byte

            System.Text.StringBuilder dumpbuilder;

            System.Collections.ArrayList names;

            Globals.l2net_home.Add_Text("Welcome to the game loop", Globals.Red, TextType.BOT);

			try
			{
				while(Globals.gamedata.running)
				{
                    cnt += Globals.Game_GameSocket.Receive(buffread, cnt, Globals.BUFFER_PACKET - cnt, System.Net.Sockets.SocketFlags.None);
                    size = System.BitConverter.ToUInt16(buffread, 0);

                       
                        while (cnt >= size && cnt > 2)
                        {
                            //if we got partial shit we cant use, read some more until it is full
                            while (size > cnt)
                            {
                                cnt += Globals.Game_GameSocket.Receive(buffread, cnt, Globals.BUFFER_PACKET - cnt, System.Net.Sockets.SocketFlags.None);
                            }

                            while (size < 2)
                            {
                                Globals.l2net_home.Add_Text("L2J : tiny packet - start", Globals.Red, TextType.BOT);
                                if (!Globals.gamedata.OOG)
                                {
                                    Globals.Game_ClientSocket.Send(buffread, cnt, System.Net.Sockets.SocketFlags.None);
                                }
                                cnt = 0;
                                Globals.l2net_home.Add_Text("L2J : tiny packet - finished", Globals.Red, TextType.BOT);
                                cnt = Globals.Game_GameSocket.Receive(buffread, 0, Globals.BUFFER_PACKET, System.Net.Sockets.SocketFlags.None);
                                size = System.BitConverter.ToUInt16(buffread, 0);
                            }

                            buffpacket = new byte[size - 2];

                            Array.Copy(buffread, 2, buffpacket, 0, size - 2);

                            Globals.gamedata.crypt_in.decrypt(buffpacket);
                            if (Globals.pck_thread.pck_recording)
                            {
                                //*                             lock (Globals.pck_thread.lock_obj)
                                //{
                                pck_window_dat pck_dat = new pck_window_dat(buffpacket);
                                pck_dat.action = 1;
                                pck_dat.type = 2;
                                pck_dat.time = System.DateTime.Now.TimeOfDay.ToString();
                                Globals.pck_thread.mine_queue.Enqueue(pck_dat);
                                //* }
                            }
#if DEBUG

                            //need to output to the send to gameserver log file
                            Globals.gamedataout.WriteLine("-size: " + size.ToString() + " -count:" + cnt.ToString() + " :::time:::" + System.DateTime.Now.TimeOfDay.ToString() + ":::");
                            Globals.gamedataout.WriteLine("-data from game server to bot hex-");
                            for (uint i = 0; i < size - 2; i++)
                            {
                                Globals.gamedataout.Write(buffpacket[i].ToString("X2"));
                                Globals.gamedataout.Write(" ");
                            }
                            Globals.gamedataout.WriteLine("");
                            Globals.gamedataout.WriteLine("-data from game server to bot string-");
                            for (uint i = 0; i < size - 2; i++)
                            {
                                Globals.gamedataout.Write((char)buffpacket[i]);
                            }
                            Globals.gamedataout.WriteLine("");
#endif

                            if (Globals.DumpModeServer)
                            {
                                dumpbuilder = new System.Text.StringBuilder();

                                for (int i = 0; i < size - 2; i++)
                                {
                                    dumpbuilder.Append(buffpacket[i].ToString("X2"));
                                    dumpbuilder.Append(" ");
                                }

                                Globals.l2net_home.Add_Dump(dumpbuilder.ToString(), true);
                            }

                            //shift the data over by size
                            for (uint i = 0; i < cnt - size; i++)
                            {
                                buffread[i] = buffread[size + i];
                            }

                            cnt -= size;

                            if (buffpacket.Length > 0)
                            {
                                handle = true;
                                forward = true;

                                bbuffer0 = new ByteBuffer(buffpacket);

                                if (Globals.gamedata.CurrentScriptState == ScriptState.Running)
                                {
                                    if ((PServer)buffpacket[0] == PServer.EXPacket)
                                    {
                                        if (ScriptEngine.Blocked_ServerPacketsEX.ContainsKey(System.Convert.ToInt32(buffpacket[1])))
                                        {
                                            forward = false;
                                        }
                                    }
                                    else
                                    {
                                        if (ScriptEngine.Blocked_ServerPackets.ContainsKey(System.Convert.ToInt32(buffpacket[0])))
                                        {
                                            forward = false;
                                        }
                                    }
                                }

                                switch ((PServer)buffpacket[0])
                                {
                                    case PServer.VersionCheck:
                                        handle = false;
                                        forward = false;

                                        if (!Globals.gamedata.ManualGameKey)
                                        {
                                            Globals.gamedata.game_key[0] = buffpacket[2];
                                            Globals.gamedata.game_key[1] = buffpacket[3];
                                            Globals.gamedata.game_key[2] = buffpacket[4];
                                            Globals.gamedata.game_key[3] = buffpacket[5];
                                            Globals.gamedata.game_key[4] = buffpacket[6];//0xa1;
                                            Globals.gamedata.game_key[5] = buffpacket[7];//0x6c;
                                            Globals.gamedata.game_key[6] = buffpacket[8];//0x54;
                                            Globals.gamedata.game_key[7] = buffpacket[9];//0x87
                                            Globals.gamedata.game_key[8] = 0xc8;
                                            Globals.gamedata.game_key[9] = 0x27;
                                            Globals.gamedata.game_key[10] = 0x93;
                                            Globals.gamedata.game_key[11] = 0x01;
                                            Globals.gamedata.game_key[12] = 0xa1;
                                            Globals.gamedata.game_key[13] = 0x6c;
                                            Globals.gamedata.game_key[14] = 0x31;
                                            Globals.gamedata.game_key[15] = 0x97;
                                            //buff[10] - d 0x01
                                            //buff[14] - d 0x01
                                            //buff[18] - c 0x00
                                            //buff[19] - d new packet encryption
                                            //buff[20] - 
                                            //buff[21] - 
                                            //buff[22] - 
                                            Globals.l2net_home.Add_Text("gameserver - got packet encryption key", Globals.Red, TextType.BOT);
                                        }


                                        // ugly
                                        bbtmp1 = new ByteBuffer(buffpacket);

                                        bbtmp1.ReadByte();
                                        bbtmp1.ReadByte();
                                        bbtmp1.ReadInt32();
                                        bbtmp1.ReadInt32();
                                        bbtmp1.ReadInt32();
                                        Globals.gamedata.Server_ID = bbtmp1.ReadInt32();
                                        bbtmp1.ReadByte();
                                        Globals.gamedata.Obfuscation_Key = bbtmp1.ReadInt32();

                                        if (Globals.gamedata.OOG)
                                        {
                                            //don't need to send this packet anywhere...
                                        }
                                        else
                                        {
                                            //need to send this here... so it dones't get encrypted
                                            byte[] key_send = new byte[2 + buffpacket.Length];

                                            byte[] b2 = System.BitConverter.GetBytes((short)key_send.Length);
                                            key_send[0] = b2[0];
                                            key_send[1] = b2[1];

                                            buffpacket.CopyTo(key_send, 2);

                                            Globals.Game_ClientSocket.Send(key_send);
                                            Globals.l2net_home.Add_Text("gameserver - keys forwarded to client", Globals.Red, TextType.BOT);
                                            if (Globals.gamedata.ManualGameKey)
                                            {
                                                Globals.l2net_home.Add_Text("Start gamekey setup", Globals.Red, TextType.BOT);
                                                ManualGameKey setkey = new ManualGameKey();
                                                setkey.ShowDialog();
                                            }
                                        }

                                        if (Globals.gamedata.Chron >= Chronicle.CT1_5)
                                        {
                                            if (buffpacket.Length > 18)
                                            {
                                                try
                                                {
                                                    Globals.Mixer = new MixedPackets(System.BitConverter.ToInt32(buffpacket, 19));
                                                }
                                                catch
                                                {
                                                    //Globals.l2net_home.Add_Text("gameserver - Negative client ID encryption key... going to continue", Globals.Red, TextType.BOT);
                                                }
                                                finally
                                                {
                                                    Globals.l2net_home.Add_Text("gameserver - got client ID encryption key", Globals.Red, TextType.BOT);
                                                }
                                            }
                                            else
                                            {
                                                Globals.l2net_home.Add_Text("gameserver - missing client ID encryption key... going to continue", Globals.Red, TextType.BOT);
                                            }
                                        }

                                        //setup the key
                                        Globals.gamedata.crypt_in.setKey(Globals.gamedata.game_key);
                                        Globals.gamedata.crypt_out.setKey(Globals.gamedata.game_key);
                                        Globals.gamedata.crypt_clientin.setKey(Globals.gamedata.game_key);
                                        Globals.gamedata.crypt_clientout.setKey(Globals.gamedata.game_key);

                                        Globals.gamedata.logged_in = true;

                                        if (Globals.gamedata.OOG)
                                        {
                                            //send our request player list packet
                                            int startlen = Globals.UserName.Length * 2 + 2;
                                            ByteBuffer send;

                                            //CT2.3 increased length by 4
                                            if (Globals.gamedata.Chron > Chronicle.CT2_2)
                                            {
                                                send = new ByteBuffer(startlen + 33); //CT 2.3 and above
                                            }
                                            else if (Globals.gamedata.Chron < Chronicle.CT2_1)
                                            {
                                                send = new ByteBuffer(startlen + 21); //CT 1.5 and below
                                            }
                                            else
                                            {
                                                send = new ByteBuffer(startlen + 29); //CT 2.1, 2.2 (?)
                                            }

                                            send.WriteByte((byte)PClient.RequestPlayerList);
                                            send.WriteString(Globals.UserName);

                                            send.WriteByte(Globals.gamedata.play_ok[4]);
                                            send.WriteByte(Globals.gamedata.play_ok[5]);
                                            send.WriteByte(Globals.gamedata.play_ok[6]);
                                            send.WriteByte(Globals.gamedata.play_ok[7]);

                                            send.WriteByte(Globals.gamedata.play_ok[0]);
                                            send.WriteByte(Globals.gamedata.play_ok[1]);
                                            send.WriteByte(Globals.gamedata.play_ok[2]);
                                            send.WriteByte(Globals.gamedata.play_ok[3]);

                                            send.WriteByte(Globals.gamedata.login_ok[0]);
                                            send.WriteByte(Globals.gamedata.login_ok[1]);
                                            send.WriteByte(Globals.gamedata.login_ok[2]);
                                            send.WriteByte(Globals.gamedata.login_ok[3]);

                                            send.WriteByte(Globals.gamedata.login_ok[4]);
                                            send.WriteByte(Globals.gamedata.login_ok[5]);
                                            send.WriteByte(Globals.gamedata.login_ok[6]);
                                            send.WriteByte(Globals.gamedata.login_ok[7]);

                                            send.WriteByte(0x01);
                                            send.WriteByte(0x00);
                                            send.WriteByte(0x00);
                                            send.WriteByte(0x00);

                                            //15 44 34 92 1D 00 00 00 -different?
                                            //3C 01 00 00 00 00 00 00 - CT2.3 prot 83
                                            //D8 02 00 00 00 00 00 00 - CT 2.3 new
                                            //D8 02 00 00 00 00 00 00 - CT 2.4 (same as 2.3 new)
                                            //3C 01 00 00 00 00 00 00 00 00 00 00 - CT 2.6
                                            //69 02 00 00 00 00 00 00 00 00 00 00 - CT 3.0

                                            if (Globals.gamedata.Chron == Chronicle.CT3_0)
                                            {
                                                send.WriteByte(0x69);
                                                send.WriteByte(0x02);
                                                send.WriteByte(0x00);
                                                send.WriteByte(0x00);
                                                send.WriteByte(0x00);
                                                send.WriteByte(0x00);
                                                send.WriteByte(0x00);
                                                send.WriteByte(0x00);
                                                /*
                                                send.WriteByte(0x00);
                                                send.WriteByte(0x00);
                                                send.WriteByte(0x00);
                                                send.WriteByte(0x00);*/

                                            }

                                            else if (Globals.gamedata.Chron == Chronicle.CT2_6)
                                            {
                                                send.WriteByte(0x3C); //0x3C
                                                send.WriteByte(0x01); //0x01
                                                send.WriteByte(0x00);
                                                send.WriteByte(0x00);
                                                send.WriteByte(0x00);
                                                send.WriteByte(0x00);
                                                send.WriteByte(0x00);
                                                send.WriteByte(0x00);

                                            }

                                            else if (Globals.gamedata.Chron > Chronicle.CT1_5)
                                            {
                                                send.WriteByte(0xD8); //0x3C
                                                send.WriteByte(0x02); //0x01
                                                send.WriteByte(0x00);
                                                send.WriteByte(0x00);
                                                send.WriteByte(0x00);
                                                send.WriteByte(0x00);
                                                send.WriteByte(0x00);
                                                send.WriteByte(0x00);
                                            }

                                            if (Globals.gamedata.Chron == Chronicle.CT2_3)
                                            {
                                                send.WriteByte(0x01); //CT 2.3 0x01, CT 2.4 0x00 //CT 2.6 0x00 //CT3.0 0x00
                                            }

                                            //old
                                            //send.WriteByte(0xc0);
                                            //send.WriteByte(0xa8);
                                            //send.WriteByte(0x01);
                                            //send.WriteByte(0x64);

                                            Globals.gamedata.SendToGameServer(send);
                                        }
                                        break;
                                    case PServer.GameGuardQuery: //Don't forward gameguard packets to client if GG client is activated, but forward them to bot
                                        if (Globals.GG_Clientmode)
                                        {
                                            handle = true;
                                            forward = false;
                                        }
                                        break;
                                    case PServer.AskJoinParty://request party invite
                                        if (Globals.gamedata.botoptions.AcceptParty == 1)
                                        {
                                            bbtmp = new ByteBuffer(buffpacket);
                                            bbtmp.ReadByte();
                                            tmp = bbtmp.ReadString().ToUpperInvariant();

                                            names = Util.GetArray(Globals.gamedata.botoptions.AcceptPartyNames);

                                            if (names.Contains(tmp))
                                            {
                                                //accept party invite
                                                ServerPackets.JoinPartyReply(true);
                                                handle = false;
                                                forward = false;
                                            }
                                        }
                                        break;
                                    case PServer.ConfirmDlg://request rezz invite
                                        int sent = 0;
                                            bbtmp = new ByteBuffer(buffpacket);
                                            bbtmp.ReadByte();
                                            Globals.LastRezz1 = bbtmp.ReadUInt32();
                                            bbtmp.ReadInt32();
                                            bbtmp.ReadInt32();
                                            tmp = bbtmp.ReadString().ToUpperInvariant();
                                            switch (bbtmp.ReadInt32())
                                            {
                                                case 0://string
                                                    bbtmp.ReadString();
                                                    break;
                                                case 1://number
                                                    bbtmp.ReadInt32();
                                                    break;
                                                case 2://npc name
                                                    bbtmp.ReadUInt32();//GetNPCName
                                                    break;
                                                case 3://item name
                                                    bbtmp.ReadUInt32();//GetItemName
                                                    break;
                                                case 4://skill name
                                                    bbtmp.ReadUInt32();//id - 2037
                                                    bbtmp.ReadUInt32();//level - 1
                                                    break;
                                                case 5://poop
                                                    bbtmp.ReadUInt32();//
                                                    break;
                                                case 6://number double
                                                    bbtmp.ReadInt64();
                                                    break;
                                                case 7://zone name
                                                    bbtmp.ReadInt32();//x
                                                    bbtmp.ReadInt32();//y
                                                    bbtmp.ReadInt32();//z
                                                    break;
                                                case 8://augmented item
                                                    bbtmp.ReadUInt32();//item type id
                                                    bbtmp.ReadUInt32();//the augment data?
                                                    break;
                                                default://poop
                                                    bbtmp.ReadUInt32();//
                                                    break;
                                            }
                                            bbtmp.ReadUInt32();
                                            Globals.LastRezz2 = bbtmp.ReadUInt32();
                                            if (Globals.gamedata.botoptions.AcceptRez == 1)
                                            {
                                            names = Util.GetArray(Globals.gamedata.botoptions.AcceptRezNames);

                                            if (names.Contains(tmp))
                                            {
                                                //accept party invite
                                                ServerPackets.DialogReply(true);
                                                handle = false;
                                                forward = false;
                                            }
                                        }
                                        foreach (CharInfo player in Globals.gamedata.nearby_chars.Values)
                                        {
                                            if (player.Name == tmp && player.ClanID == Globals.gamedata.my_char.ClanID && Globals.gamedata.botoptions.AcceptRezClan == 1 && sent == 0)
                                            {
                                                ServerPackets.DialogReply(true);
                                                handle = false;
                                                forward = false;
                                                sent = 1;
                                            }
                                            if (player.Name == tmp && player.AllyID == Globals.gamedata.my_char.AllyID && Globals.gamedata.botoptions.AcceptRezAlly == 1 && sent == 0)
                                            {
                                                ServerPackets.DialogReply(true);
                                                handle = false;
                                                forward = false;
                                                sent = 1;
                                            }
                                        }
                                        if (Globals.gamedata.botoptions.AcceptRezParty == 1 && sent == 0)
                                        {
                                            //accept rez from party
                                            int found = 0;

                                            //loop through each member
                                            foreach (PartyMember pl in Globals.gamedata.PartyMembers.Values)
                                            {
                                                if (String.Equals(pl.Name, tmp, StringComparison.OrdinalIgnoreCase))
                                                {
                                                    found = 1;
                                                }
                                            }
                                            if (found == 1)
                                            {
                                                ServerPackets.DialogReply(true);
                                                handle = false;
                                                forward = false;
                                                sent = 1;
                                            }
                                        }
                                        break;
                                    case PServer.Earthquake:
                                        if (Globals.Suppress_Quakes)
                                        {
                                            forward = false;
                                            break;
                                        }
                                        break;
                                    case PServer.TargetSelected:
                                        if (Globals.lagfilter_TargetSelected)
                                        {
                                            bbtmp = new ByteBuffer(buffpacket);
                                            bbtmp.ReadByte();
                                            uint source = bbtmp.ReadUInt32();
                                            uint dest = bbtmp.ReadUInt32();

                                            forward = false;

                                            // Party Member targeting something ?
                                            if (Globals.gamedata.PartyMembers.ContainsKey(source))
                                            {
                                                forward = true;
                                            }
                                            else
                                            {
                                                // Somebody targeting a partymember or me?
                                                if ((Globals.gamedata.PartyMembers.ContainsKey(dest)) || (dest == Globals.gamedata.my_char.ID))
                                                {
                                                    forward = true;
                                                }
                                            }
                                        }
                                        break;
                                    case PServer.TargetUnselected:
                                        if (Globals.lagfilter_TargetUnselected)
                                        {
                                            bbtmp = new ByteBuffer(buffpacket);
                                            bbtmp.ReadByte();
                                            uint source = bbtmp.ReadUInt32();

                                            TargetType target_type = Util.GetType(source);

                                            if (target_type == TargetType.PLAYER)
                                            {
                                                forward = false;
                                                Globals.PlayerLock.EnterReadLock();
                                                try
                                                {
                                                    CharInfo player = Util.GetChar(source);

                                                    if (player != null)
                                                    {
                                                        // Was this person who broke target originally on a party member/me ?
                                                        if ((Globals.gamedata.PartyMembers.ContainsKey(player.TargetID)) ||
                                                           ((player.TargetID == Globals.gamedata.my_char.ID)))
                                                        {
                                                            forward = true;
                                                        }
                                                    }
                                                }
                                                finally
                                                {
                                                    Globals.PlayerLock.ExitReadLock();
                                                }
                                            }
                                        }
                                        break;
                                    case PServer.MagicSkillUser:
                                        if (Globals.lagfilter_Skills)
                                        {
                                            bbtmp = new ByteBuffer(buffpacket);
                                            bbtmp.ReadByte();
                                            uint source = bbtmp.ReadUInt32();
                                            uint dest = bbtmp.ReadUInt32();
                                            uint skill_id = bbtmp.ReadUInt32();

                                            forward = true;

                                            foreach (uint sid in Globals.lagfilter_ignoreskills)
                                            {
                                                // Is the skill one of the filtered skills
                                                if (skill_id == sid)
                                                {
                                                    // Default drop the packet unless..
                                                    forward = false;

                                                    // Party Member targeting something ?
                                                    if (Globals.gamedata.PartyMembers.ContainsKey(source))
                                                    {
                                                        forward = true;
                                                    }
                                                    else
                                                    {
                                                        // Somebody targeting a partymember or me?
                                                        if ((Globals.gamedata.PartyMembers.ContainsKey(dest)) || (dest == Globals.gamedata.my_char.ID))
                                                        {
                                                            forward = true;
                                                        }
                                                    }
                                                    break;
                                                }
                                            }
                                        }
                                        break;
                                    case PServer.MagicSkillLaunched:
                                        bbtmp = new ByteBuffer(buffpacket);
                                        bbtmp.ReadByte();
                                        uint src = bbtmp.ReadUInt32();
                                        uint sk_id = bbtmp.ReadUInt32();
                                        bbtmp.ReadUInt32();
                                        bbtmp.ReadUInt32();
                                        uint dst = bbtmp.ReadUInt32();

                                        if (src == Globals.gamedata.my_char.ID)
                                        {
                                            Globals.gamedata.my_char.isAttacking = false;
                                        }

                                        if (Globals.lagfilter_Skills)
                                        {
                                            forward = true;

                                            foreach (uint sid in Globals.lagfilter_ignoreskills)
                                            {
                                                // Is the skill one of the filtered skills
                                                if (sk_id == sid)
                                                {
                                                    // Default drop the packet unless..
                                                    forward = false;

                                                    // Party Member targeting something ?
                                                    if (Globals.gamedata.PartyMembers.ContainsKey(src))
                                                    {
                                                        forward = true;
                                                    }
                                                    else
                                                    {
                                                        // Somebody targeting a partymember or me?
                                                        if ((Globals.gamedata.PartyMembers.ContainsKey(dst)) || (dst == Globals.gamedata.my_char.ID))
                                                        {
                                                            forward = true;
                                                        }
                                                    }
                                                    break;
                                                }
                                            }
                                        }
                                        break;
                                    case PServer.CI:
                                        if (Globals.gamedata.Chron >= Chronicle.CT2_5)
                                        {

                                            if ((Globals.lagfilter_xf_ci_striptitle == false) &&
                                                (Globals.lagfilter_xf_ci_stripenchant == false) &&
                                                (Globals.lagfilter_xf_ci_stripaug == false) &&
                                                (Globals.lagfilter_xf_ci_stripunseen == false) &&
                                                (Globals.lagfilter_xf_ci_striprecs == false) &&
                                                (Globals.lagfilter_xf_ci_simple_gender == false) &&
                                                (Globals.lagfilter_xf_ci_simple_apperance == false))
                                            {
                                            }
                                            else
                                            {
                                                bbtmp = new ByteBuffer(buffpacket);
                                                ByteBuffer xf_CI = new ByteBuffer();

                                                xf_CI.Resize(bbtmp.Length());

                                                xf_CI.WriteByte(bbtmp.ReadByte());                      // CI Header
                                                xf_CI.WriteInt32(bbtmp.ReadInt32());                    // X
                                                xf_CI.WriteInt32(bbtmp.ReadInt32());                    // Y
                                                xf_CI.WriteInt32(bbtmp.ReadInt32());                    // Z
                                                xf_CI.WriteInt32(bbtmp.ReadInt32());                    // VID
                                                xf_CI.WriteUInt32(bbtmp.ReadUInt32());                  // OID
                                                xf_CI.WriteString(bbtmp.ReadString());                  // Name

                                                if (Globals.lagfilter_xf_ci_simple_race)
                                                {
                                                    xf_CI.WriteUInt32(4);
                                                    bbtmp.ReadUInt32();
                                                }
                                                else
                                                {
                                                    xf_CI.WriteUInt32(bbtmp.ReadUInt32());                  // Race
                                                }

                                                if (Globals.lagfilter_xf_ci_simple_gender)
                                                {
                                                    xf_CI.WriteUInt32(1);
                                                    bbtmp.ReadUInt32();
                                                }
                                                else
                                                {
                                                    xf_CI.WriteUInt32(bbtmp.ReadUInt32());              // Gender
                                                }

                                                xf_CI.WriteUInt32(bbtmp.ReadUInt32());                  // Root Class

                                                if (Globals.lagfilter_xf_ci_stripunseen)
                                                {
                                                    xf_CI.WriteUInt32(0);
                                                    xf_CI.WriteUInt32(0);
                                                    bbtmp.ReadUInt32();
                                                    bbtmp.ReadUInt32();
                                                }
                                                else
                                                {
                                                    xf_CI.WriteUInt32(bbtmp.ReadUInt32());              // OID Underwear
                                                    xf_CI.WriteUInt32(bbtmp.ReadUInt32());              // OID Head
                                                }

                                                xf_CI.WriteUInt32(bbtmp.ReadUInt32());  	            // OID RHand
                                                xf_CI.WriteUInt32(bbtmp.ReadUInt32());      		    // OID LHand
                                                xf_CI.WriteUInt32(bbtmp.ReadUInt32());		            // OID Gloves
                                                xf_CI.WriteUInt32(bbtmp.ReadUInt32());		            // OID Chest
                                                xf_CI.WriteUInt32(bbtmp.ReadUInt32());	        	    // OID Legs
                                                xf_CI.WriteUInt32(bbtmp.ReadUInt32());	        	    // OID Feet
                                                xf_CI.WriteUInt32(bbtmp.ReadUInt32());	        	    // OID Back
                                                xf_CI.WriteUInt32(bbtmp.ReadUInt32());	        	    // OID LRHand
                                                xf_CI.WriteUInt32(bbtmp.ReadUInt32());	        	    // OID Hair
                                                xf_CI.WriteUInt32(bbtmp.ReadUInt32());	        	    // OID DollFace

                                                if (Globals.lagfilter_xf_ci_stripunseen)
                                                {
                                                    for (int i = 0; i < 8; i++)
                                                    {
                                                        xf_CI.WriteUInt32(0);
                                                        bbtmp.ReadUInt32();
                                                    }
                                                }
                                                else
                                                {
                                                    xf_CI.WriteUInt32(bbtmp.ReadUInt32());                 // OID R Bracelet
                                                    xf_CI.WriteUInt32(bbtmp.ReadUInt32());                 // OID L Bracelet
                                                    xf_CI.WriteUInt32(bbtmp.ReadUInt32());                 // OID Talisman 1
                                                    xf_CI.WriteUInt32(bbtmp.ReadUInt32());                 // OID Talisman 2
                                                    xf_CI.WriteUInt32(bbtmp.ReadUInt32());                 // OID Talisman 3
                                                    xf_CI.WriteUInt32(bbtmp.ReadUInt32());                 // OID Talisman 4
                                                    xf_CI.WriteUInt32(bbtmp.ReadUInt32());                 // OID Talisman 5
                                                    xf_CI.WriteUInt32(bbtmp.ReadUInt32());                 // OID Talisman 6                
                                                }

                                                if (Globals.gamedata.Chron >= Chronicle.CT2_3)
                                                {
                                                    if (Globals.lagfilter_xf_ci_stripunseen)
                                                    {
                                                        xf_CI.WriteUInt32(0);
                                                        bbtmp.ReadUInt32();
                                                    }
                                                    else
                                                    {
                                                        xf_CI.WriteUInt32(bbtmp.ReadUInt32()); // OID Belt
                                                    }
                                                }

                                                if ((Globals.lagfilter_xf_ci_stripunseen) || (Globals.lagfilter_xf_ci_stripaug))
                                                {
                                                    xf_CI.WriteUInt32(0);
                                                    xf_CI.WriteUInt32(0);
                                                    bbtmp.ReadUInt32();
                                                    bbtmp.ReadUInt32();
                                                }
                                                else
                                                {
                                                    xf_CI.WriteUInt32(bbtmp.ReadUInt32());		            // AID underwear
                                                    xf_CI.WriteUInt32(bbtmp.ReadUInt32());	        	    // AID head                
                                                }

                                                if (Globals.lagfilter_xf_ci_stripaug)
                                                {
                                                    for (int i = 0; i < 10; i++)
                                                    {
                                                        xf_CI.WriteUInt32(0);
                                                        bbtmp.ReadUInt32();
                                                    }
                                                }
                                                else
                                                {
                                                    xf_CI.WriteUInt32(bbtmp.ReadUInt32());              // AID RHand
                                                    xf_CI.WriteUInt32(bbtmp.ReadUInt32());              // AID LHand
                                                    xf_CI.WriteUInt32(bbtmp.ReadUInt32());	    	    // AID gloves
                                                    xf_CI.WriteUInt32(bbtmp.ReadUInt32());	    	    // AID chest
                                                    xf_CI.WriteUInt32(bbtmp.ReadUInt32());	    	    // AID legs
                                                    xf_CI.WriteUInt32(bbtmp.ReadUInt32());	    	    // AID feet
                                                    xf_CI.WriteUInt32(bbtmp.ReadUInt32());	    	    // AID back
                                                    xf_CI.WriteUInt32(bbtmp.ReadUInt32());	    	    // AID lr hand
                                                    xf_CI.WriteUInt32(bbtmp.ReadUInt32());	    	    // AID hair
                                                    xf_CI.WriteUInt32(bbtmp.ReadUInt32());	    	    // AID doll face                
                                                }

                                                if ((Globals.lagfilter_xf_ci_stripunseen) || (Globals.lagfilter_xf_ci_stripaug))
                                                {
                                                    for (int i = 0; i < 8; i++)
                                                    {
                                                        xf_CI.WriteUInt32(0);
                                                        bbtmp.ReadUInt32();
                                                    }
                                                }
                                                else
                                                {
                                                    xf_CI.WriteUInt32(bbtmp.ReadUInt32());	        // AID right bracelet
                                                    xf_CI.WriteUInt32(bbtmp.ReadUInt32());		    // AID left bracelet
                                                    xf_CI.WriteUInt32(bbtmp.ReadUInt32());		    // AID Talisman 1
                                                    xf_CI.WriteUInt32(bbtmp.ReadUInt32());		    // AID Talisman 2
                                                    xf_CI.WriteUInt32(bbtmp.ReadUInt32());		    // AID Talisman 3
                                                    xf_CI.WriteUInt32(bbtmp.ReadUInt32());		    // AID Talisman 4
                                                    xf_CI.WriteUInt32(bbtmp.ReadUInt32());		    // AID Talisman 5
                                                    xf_CI.WriteUInt32(bbtmp.ReadUInt32());		    // AID Talisman 6
                                                }

                                                if (Globals.gamedata.Chron >= Chronicle.CT2_3)
                                                {
                                                    if ((Globals.lagfilter_xf_ci_stripunseen) || (Globals.lagfilter_xf_ci_stripaug))
                                                    {
                                                        xf_CI.WriteUInt32(0);
                                                        bbtmp.ReadUInt32();
                                                    }
                                                    else
                                                    {
                                                        xf_CI.WriteUInt32(bbtmp.ReadUInt32()); // AID Belt
                                                    }
                                                }

                                                if (Globals.gamedata.Chron >= Chronicle.CT2_3)
                                                {
                                                    xf_CI.WriteUInt32(bbtmp.ReadUInt32());
                                                    xf_CI.WriteUInt32(bbtmp.ReadUInt32());
                                                }

                                                xf_CI.WriteUInt32(bbtmp.ReadUInt32());                 // PvP Flag
                                                xf_CI.WriteUInt32(bbtmp.ReadUInt32());                 // Karma
                                                xf_CI.WriteUInt32(bbtmp.ReadUInt32());                 // Matkspd
                                                xf_CI.WriteUInt32(bbtmp.ReadUInt32());                 // Patkspd

                                                if (Globals.gamedata.Chron >= Chronicle.CT2_5)
                                                {
                                                    xf_CI.WriteUInt32(bbtmp.ReadUInt32());
                                                }
                                                else if (Globals.gamedata.Chron >= Chronicle.CT2_3)
                                                {
                                                    xf_CI.WriteUInt32(bbtmp.ReadUInt32());
                                                    xf_CI.WriteUInt32(bbtmp.ReadUInt32());
                                                }

                                                xf_CI.WriteUInt32(bbtmp.ReadUInt32());		    // RunSpeed
                                                xf_CI.WriteUInt32(bbtmp.ReadUInt32());		    // WalkSpeed
                                                xf_CI.WriteUInt32(bbtmp.ReadUInt32());		    // SwimRunSpeed
                                                xf_CI.WriteUInt32(bbtmp.ReadUInt32());		    // SwimWalkSpeed
                                                xf_CI.WriteUInt32(bbtmp.ReadUInt32());		    // flRunSpeed
                                                xf_CI.WriteUInt32(bbtmp.ReadUInt32());		    // flWalkSpeed
                                                xf_CI.WriteUInt32(bbtmp.ReadUInt32());		    // FlyRunSpeed
                                                xf_CI.WriteUInt32(bbtmp.ReadUInt32());		    // FlyWalkSpeed


                                                xf_CI.WriteDouble(bbtmp.ReadDouble());		    // MoveSpeedMult
                                                xf_CI.WriteDouble(bbtmp.ReadDouble());		    // AttackSpeedMult
                                                xf_CI.WriteDouble(bbtmp.ReadDouble());		    // CollisionRadius
                                                xf_CI.WriteDouble(bbtmp.ReadDouble());		    // CollisionHeight

                                                if (Globals.lagfilter_xf_ci_simple_apperance)
                                                {
                                                    xf_CI.WriteUInt32(0);
                                                    xf_CI.WriteUInt32(0);
                                                    xf_CI.WriteUInt32(0);
                                                    bbtmp.ReadUInt32();
                                                    bbtmp.ReadUInt32();
                                                    bbtmp.ReadUInt32();
                                                }
                                                else
                                                {
                                                    xf_CI.WriteUInt32(bbtmp.ReadUInt32());		    // HairSytle
                                                    xf_CI.WriteUInt32(bbtmp.ReadUInt32());		    // HairColor
                                                    xf_CI.WriteUInt32(bbtmp.ReadUInt32());		    // Face
                                                }

                                                if (Globals.lagfilter_xf_ci_striptitle)
                                                {
                                                    bbtmp.ReadString();
                                                    xf_CI.WriteString("");
                                                }
                                                else
                                                {
                                                    xf_CI.WriteString(bbtmp.ReadString());		            // Title
                                                }

                                                xf_CI.WriteUInt32(bbtmp.ReadUInt32());		                // ClanID
                                                xf_CI.WriteUInt32(bbtmp.ReadUInt32());		                // ClanCrestID
                                                xf_CI.WriteUInt32(bbtmp.ReadUInt32());		                // AllyID
                                                xf_CI.WriteUInt32(bbtmp.ReadUInt32());		                // AllyCrestID

                                                if (Globals.gamedata.Chron < Chronicle.CT2_5)
                                                {
                                                    xf_CI.WriteUInt32(bbtmp.ReadUInt32());
                                                }

                                                xf_CI.WriteByte(bbtmp.ReadByte());		                // isSitting
                                                xf_CI.WriteByte(bbtmp.ReadByte());		                // isRunning
                                                xf_CI.WriteByte(bbtmp.ReadByte());		                // isInCombat
                                                xf_CI.WriteByte(bbtmp.ReadByte());		                // isAlikeDead
                                                xf_CI.WriteByte(bbtmp.ReadByte());		                // Invisible
                                                xf_CI.WriteByte(bbtmp.ReadByte());		                // MountType
                                                xf_CI.WriteByte(bbtmp.ReadByte());		                // PrivateStoreType	
                                                int CC = bbtmp.ReadUInt16();	                        // CubicCount
                                                xf_CI.WriteUInt16((ushort)CC);

                                                for (uint i = 0; i < CC; i++)
                                                {
                                                    xf_CI.WriteUInt16(bbtmp.ReadUInt16());
                                                }

                                                xf_CI.WriteByte(bbtmp.ReadByte());		                // FindParty
                                                xf_CI.WriteUInt32(bbtmp.ReadUInt32());		            // AbnormalEffects
                                                xf_CI.WriteByte(bbtmp.ReadByte());		                // isFlying

                                                if (Globals.lagfilter_xf_ci_striprecs)
                                                {
                                                    xf_CI.WriteUInt16(0);
                                                    bbtmp.ReadUInt16();
                                                }
                                                else
                                                {
                                                    xf_CI.WriteUInt16(bbtmp.ReadUInt16());		            // RecAmount
                                                }

                                                xf_CI.WriteUInt32(bbtmp.ReadUInt32());		                // MountNpcID npc id
                                                xf_CI.WriteUInt32(bbtmp.ReadUInt32());		                // CurrentClass
                                                xf_CI.WriteUInt32(bbtmp.ReadUInt32());

                                                if (Globals.lagfilter_xf_ci_stripenchant)
                                                {
                                                    xf_CI.WriteByte(0);
                                                    bbtmp.ReadByte();
                                                }
                                                else
                                                {
                                                    xf_CI.WriteByte(bbtmp.ReadByte());		                // EnchantAmount
                                                }

                                                xf_CI.WriteByte(bbtmp.ReadByte());		                    // TeamCircle
                                                xf_CI.WriteUInt32(bbtmp.ReadUInt32());		                // ClanCrestIDLarge
                                                xf_CI.WriteByte(bbtmp.ReadByte());		                    // isNoble noble
                                                xf_CI.WriteByte(bbtmp.ReadByte());		                    // isHero hero
                                                xf_CI.WriteByte(bbtmp.ReadByte());		                    // isFishing
                                                xf_CI.WriteInt32(bbtmp.ReadInt32());		                // FishX
                                                xf_CI.WriteInt32(bbtmp.ReadInt32());		                // FishY
                                                xf_CI.WriteInt32(bbtmp.ReadInt32());		                // FishZ
                                                xf_CI.WriteUInt32(bbtmp.ReadUInt32());		                // NameColor
                                                xf_CI.WriteInt32(bbtmp.ReadInt32());		                // Heading
                                                xf_CI.WriteUInt32(bbtmp.ReadUInt32());		                // PledgeClass
                                                xf_CI.WriteUInt32(bbtmp.ReadUInt32());
                                                xf_CI.WriteUInt32(bbtmp.ReadUInt32());		                // TitleColor
                                                xf_CI.WriteUInt32(bbtmp.ReadUInt32());		                // DemonSword
                                                xf_CI.WriteUInt32(bbtmp.ReadUInt32());		                // ClanRep
                                                xf_CI.WriteUInt32(bbtmp.ReadUInt32());		                // Transform_ID
                                                xf_CI.WriteUInt32(bbtmp.ReadUInt32());		                // Agathon_ID

                                                if (Globals.gamedata.Chron >= Chronicle.CT2_1)
                                                {
                                                    xf_CI.WriteUInt32(bbtmp.ReadUInt32());
                                                }

                                                if (Globals.gamedata.Chron >= Chronicle.CT2_5)
                                                {
                                                    xf_CI.WriteUInt32(bbtmp.ReadUInt32());              // Extended Effects
                                                }
                                                else if (Globals.gamedata.Chron >= Chronicle.CT2_3)
                                                {
                                                    xf_CI.WriteUInt32(bbtmp.ReadUInt32());//CT2.3
                                                    xf_CI.WriteUInt32(bbtmp.ReadUInt32());//CT2.3
                                                    xf_CI.WriteUInt32(bbtmp.ReadUInt32());//CT2.3
                                                    xf_CI.WriteUInt32(bbtmp.ReadUInt32());//CT2.3
                                                }

                                                /*
                                                if (Globals.lagfilter_xf_ci_striptitle)
                                                {                                                
                                                    xf_CI.ResetIndex();
                                                
                                                    dumpbuilder = new System.Text.StringBuilder();
                                                    int z = 0;
                                                    for (int i = 0; i < xf_CI.Length(); i++)
                                                    {
                                                        z = xf_CI.ReadByte();
                                                        dumpbuilder.Append(z.ToString("X2"));
                                                        dumpbuilder.Append(" ");
                                                    }

                                                    Globals.l2net_home.Add_Dump(dumpbuilder.ToString(), true);

                                                    dumpbuilder = new System.Text.StringBuilder();
                                                    z = 0;
                                                    bbtmp.ResetIndex();
                                                    for (int i = 0; i < bbtmp.Length(); i++)
                                                    {
                                                        z = bbtmp.ReadByte();
                                                        dumpbuilder.Append(z.ToString("X2"));
                                                        dumpbuilder.Append(" ");
                                                    }

                                                    Globals.l2net_home.Add_Dump(dumpbuilder.ToString(), true);
                                          
                                                }
                                                */

                                                xf_CI.TrimToIndex();

                                                forward = false;
                                                if (Globals.dump_pbuff_on_ig_close)
                                                {
                                                    if (Globals.gamedata.stc_buffer.Count > 100)
                                                    {
                                                        Globals.gamedata.stc_buffer.Pop();
                                                        Globals.gamedata.stc_buffer.Push(xf_CI);
                                                    }
                                                    else
                                                    {
                                                        Globals.gamedata.stc_buffer.Push(xf_CI);
                                                    }
                                                }
                                                Globals.gamedata.SendToClient(xf_CI);
                                            }
                                        }
                                        break;
                                    case PServer.EXPacket:
                                        bbtmp = new ByteBuffer(buffpacket);
                                        b0 = bbtmp.ReadByte();

                                        switch ((PServerEX)b0)
                                        {
                                            case PServerEX.ExBrExtraUserInfo:
                                                if (Globals.lagfilter_ExBrExtraUserInfo)
                                                {
                                                    bbtmp = new ByteBuffer(buffpacket);
                                                    bbtmp.ReadByte();
                                                    bbtmp.ReadByte();
                                                    uint source = bbtmp.ReadUInt32();

                                                    forward = true;

                                                    TargetType target_type = Util.GetType(source);

                                                    if (target_type == TargetType.PLAYER)
                                                    {
                                                        forward = false;
                                                        Globals.PlayerLock.EnterReadLock();
                                                        try
                                                        {
                                                            CharInfo player = Util.GetChar(source);

                                                            if (player != null)
                                                            {
                                                                // Was this person targeting me or my party ?
                                                                if ((Globals.gamedata.PartyMembers.ContainsKey(player.TargetID)) ||
                                                                   ((player.TargetID == Globals.gamedata.my_char.ID)))
                                                                {
                                                                    forward = true;
                                                                }
                                                            }
                                                        }
                                                        finally
                                                        {
                                                            Globals.PlayerLock.ExitReadLock();
                                                        }
                                                    }
                                                }
                                                break;
                                        }
                                        break;
                                }
                                if (forward)
                                {
                                    bbuffer1 = new ByteBuffer(buffpacket);

                                    if (Globals.dump_pbuff_on_ig_close)
                                    {
                                        if (Globals.gamedata.stc_buffer.Count > 100)
                                        {
                                            Globals.gamedata.stc_buffer.Pop();
                                            Globals.gamedata.stc_buffer.Push(bbuffer1);
                                        }
                                        else
                                        {
                                            Globals.gamedata.stc_buffer.Push(bbuffer1);
                                        }
                                    }
                                    Globals.gamedata.SendToClient(bbuffer1);
                                }
                                if (handle)
                                {
                                    Globals.gamedata.SendToBotRead(bbuffer0);
                                }
                            }

                            if (cnt > 2)
                                size = System.BitConverter.ToUInt16(buffread, 0);
                        }//end of while loop
				}//end of while running
			}
            catch (System.Exception e)
            {
               Globals.l2net_home.Add_Error("crash: GameReadThread : " + e.Message);
            }
		}//end of read data
Ejemplo n.º 15
0
 private void checkBox_filter_CheckedChanged(object sender, EventArgs e)
 {
     Globals.pck_thread.filter_wind_pck = checkBox_filter.Checked;
     pck_window_dat temp_pck = new pck_window_dat();
     temp_pck.action = 5;
     if (checkBox_filter.Checked)
     {
         checkBox2.Enabled = true;
         checkBox3.Enabled = true;
     }
     else
     {
         checkBox2.Enabled = false;
         checkBox3.Enabled = false;
     }
     Globals.pck_thread.mine_queue.Enqueue(temp_pck);
 }
Ejemplo n.º 16
0
		private void ClientReadThread()
		{
            byte[] buffread = new byte[Globals.BUFFER_MAX];
			byte[] buffpacket;
            byte[] buffpacketin;

			int cnt = 0;
			int size = 0;
            int ggcnt = 0;
            bool forward = true;

			ByteBuffer bbuffer0;
            System.Text.StringBuilder dumpbuilder;

			//Add_Text("Welcome to the game loop",Color.Red);

			try
			{
				while(Globals.gamedata.running && !Globals.gamedata.OOG)
				{
                    cnt += Globals.Game_ClientSocket.Receive(buffread, cnt, Globals.BUFFER_PACKET - cnt, System.Net.Sockets.SocketFlags.None);
					size = System.BitConverter.ToUInt16(buffread,0);

					while(cnt >= size && cnt > 2)
					{
						//if we got partial shit we cant use, read some more until it is full
						while(size > cnt)
						{
                            cnt += Globals.Game_ClientSocket.Receive(buffread, cnt, Globals.BUFFER_PACKET - cnt, System.Net.Sockets.SocketFlags.None);
						}

						buffpacketin = new byte[size - 2];
                        buffpacket = new byte[size - 2];

                        Array.Copy(buffread, 2, buffpacketin, 0, size - 2);

						Globals.gamedata.crypt_clientin.decrypt(buffpacketin);

                        Array.Copy(buffpacketin, 0, buffpacket, 0, size - 2);

                        if (Globals.Mixer != null)
                        {
                            Globals.Mixer.Decrypt0(buffpacket);
                        }
                        if (Globals.pck_thread.pck_recording)
                        {

                            pck_window_dat pck_dat = new pck_window_dat(buffpacket);
                            pck_dat.action = 1;
                            pck_dat.type = 1;
                            pck_dat.time = System.DateTime.Now.TimeOfDay.ToString();
                            Globals.pck_thread.mine_queue.Enqueue(pck_dat);
                             
                        }
#if DEBUG
                        try
                        {
                            //
                           /* if (Globals.pck_thread.pck_recording)
                             {
                            // *                             lock (Globals.pck_thread.lock_obj)
                            // {
                                 pck_window_dat pck_dat = new pck_window_dat(buffpacket);
                                 pck_dat.action = 1;
                                 pck_dat.type = 1;
                                 pck_dat.time = System.DateTime.Now.TimeOfDay.ToString();
                                 Globals.pck_thread.mine_queue.Enqueue(pck_dat);
                             //* }
                             }*/
                            //
                            Globals.clientdataout.WriteLine("packet...-size: " + size.ToString() + " -count:" + cnt.ToString() + " :::time:::" + System.DateTime.Now.TimeOfDay.ToString() + ":::");
                            Globals.clientdataout.WriteLine("-data from client to bot hex-");
                            for (uint i = 0; i < size - 2; i++)
                            {
                                Globals.clientdataout.Write(buffpacket[i].ToString("X2"));
                                Globals.clientdataout.Write(" ");
                            }
                            Globals.clientdataout.WriteLine("");
                            Globals.clientdataout.WriteLine("-data from client to bot string-");
                            for (uint i = 0; i < size - 2; i++)
                            {
                                Globals.clientdataout.Write((char)buffpacket[i]);
                            }
                            Globals.clientdataout.WriteLine("");
                        }
                        catch
                        {
                            //failed to write... oh well
                        }
#endif

                        if (Globals.DumpModeClient)
                        {
                            dumpbuilder = new System.Text.StringBuilder();

                            for (int i = 0; i < size - 2; i++)
                            {
                                dumpbuilder.Append(buffpacket[i].ToString("X2"));
                                dumpbuilder.Append(" ");
                            }
                            Globals.l2net_home.Add_Dump(dumpbuilder.ToString(), false);
                        }

						//shift the data over by size
						for(uint i = 0; i < cnt - size; i ++)
						{
							buffread[i] = buffread[size + i];
						}

						cnt -= size;

						if(buffpacket.Length > 0)
						{
                            forward = true;

                            if (Globals.gamedata.CurrentScriptState == ScriptState.Running)
                            {
                                if ((PClient)buffpacket[0] == PClient.EXPacket)
                                {
                                    if (ScriptEngine.Blocked_ClientPacketsEX.ContainsKey(System.Convert.ToInt32(buffpacket[1])))
                                    {
                                        forward = false;
                                    }

                                    if (ScriptEngine.ClientPacketsEXContainsKey(System.Convert.ToInt32(buffpacket[1])))
                                    {
                                        ByteBuffer bb = new ByteBuffer(buffpacket);

                                        ScriptEvent sc_ev = new ScriptEvent();
                                        sc_ev.Type = EventType.ClientPacketEX;
                                        sc_ev.Type2 = System.Convert.ToInt32(buffpacket[1]);
                                        sc_ev.Variables.Add(new ScriptVariable(bb, "PACKET", Var_Types.BYTEBUFFER, Var_State.PUBLIC));
                                        sc_ev.Variables.Add(new ScriptVariable(System.DateTime.Now.Ticks, "TIMESTAMP", Var_Types.INT, Var_State.PUBLIC));
                                        ScriptEngine.SendToEventQueue(sc_ev);
                                    }
                                }
                                else
                                {
                                    if (ScriptEngine.Blocked_ClientPackets.ContainsKey(System.Convert.ToInt32(buffpacket[0])))
                                    {
                                        forward = false;
                                    }

                                    if (ScriptEngine.ClientPacketsContainsKey(System.Convert.ToInt32(buffpacket[0])))
                                    {
                                        ByteBuffer bb = new ByteBuffer(buffpacket);

                                        ScriptEvent sc_ev = new ScriptEvent();
                                        sc_ev.Type = EventType.ClientPacket;
                                        sc_ev.Type2 = System.Convert.ToInt32(buffpacket[0]);
                                        sc_ev.Variables.Add(new ScriptVariable(bb, "PACKET", Var_Types.BYTEBUFFER, Var_State.PUBLIC));
                                        sc_ev.Variables.Add(new ScriptVariable(System.DateTime.Now.Ticks, "TIMESTAMP", Var_Types.INT, Var_State.PUBLIC));
                                        ScriptEngine.SendToEventQueue(sc_ev);
                                    }
                                }
                            }

							//this is where we would want to handle packets sent by the client
                            switch ((PClient)buffpacket[0])
							{
                                case PClient.AuthLogin://protocol version
                                    int prot = System.BitConverter.ToInt16(buffpacket, 1);
                                    Globals.l2net_home.Add_Text("protocol version: " + prot.ToString(), Globals.Red, TextType.BOT);

                                    if (prot == -2)
                                    {
                                        Globals.l2net_home.Add_Text("-2 protocol... just a ping... we've been had XD...", Globals.Red, TextType.BOT);
                                    }
                                    else
                                    {
                                        //valid protocol...
                                        Globals.l2net_home.Add_Text("valid protocol...", Globals.Red, TextType.BOT);
                                    }
                                    break;
								case PClient.GameGuardReply://gameguard reply
                                    if (Globals.GG_Servermode)
                                    {
                                        if (Globals.GG_QueryReceived)
                                        {
                                            ggcnt++;
                                            if (ggcnt == 1)
                                            {
                                                //GameGuardServer.send_gg_answer(buffpacket, false);
                                                GameGuardServer.SendGGReply(buffpacket);
                                            }
                                            
                                            if (ggcnt == 2)
                                            {
                                                Globals.GG_QueryReceived = false;
                                                //GameGuardServer.send_gg_answer(buffpacket, true);
                                                GameGuardServer.SendGGReply(buffpacket);
                                                ggcnt = 0;
                                            }
                                            forward = false;
                                        }
                                    }
                                    if (Globals.Script_Debugging)
                                    {
                                        string gg = "";

                                        for (int i = 1; i < buffpacket.Length; i++)
                                        {
                                            gg += buffpacket[i].ToString("X2") + " ";
                                        }

                                        Globals.l2net_home.Add_Debug("GameGuard Reply: " + gg);
                                    }
									break;
								case PClient.Say2://say text
									if(Globals.gamedata.OOG == false)
									{
                                        ByteBuffer bbuff = new ByteBuffer(buffpacket);

                                        bbuff.ReadByte();
                                        string start = bbuff.ReadString();
                                        uint type = bbuff.ReadUInt32();
                                        string end = bbuff.ReadString();
                                        
                                        //wanna handle text if prefaced with "-"
                                        //since these are commands to the bot

                                        if (start.StartsWith("--"))
                                        {
                                            forward = false;

                                            start = start.Substring(1, start.Length - 1);

                                            ServerPackets.Send_Text(type, start, end);
                                        }
                                        else if (start.StartsWith("-"))
                                        {
                                            forward = false;

                                            start = start.Substring(1, start.Length - 1);

                                            if (Globals.gamedata.CurrentScriptState == ScriptState.Running)
                                            {
                                                ScriptEvent sc_ev = new ScriptEvent();
                                                sc_ev.Type = EventType.ChatToBot;
                                                sc_ev.Variables.Add(new ScriptVariable((long)type, "MESSAGETYPE", Var_Types.INT, Var_State.PUBLIC));
                                                sc_ev.Variables.Add(new ScriptVariable(end, "TARGETNAME", Var_Types.STRING, Var_State.PUBLIC));
                                                sc_ev.Variables.Add(new ScriptVariable(start, "MESSAGE", Var_Types.STRING, Var_State.PUBLIC));
                                                ScriptEngine.SendToEventQueue(sc_ev);
                                            }
                                        }
									}
									break;
                                case PClient.CharacterSelect:
                                    if ((!Globals.gamedata.OOG) && (!System.String.IsNullOrEmpty(Globals.SecurityPin)) && (Globals.gamedata.SecurityPinOldClient) && (!Globals.gamedata.SecurityPinSent))
                                    {
                                        ServerPackets.RequestSecurityPinWindow();

                                        while (!Globals.gamedata.SecurityPinWindow)
                                        {
                                            System.Threading.Thread.Sleep(100);
                                        }

                                        Globals.l2net_home.Add_Text("Sending security pin: " + Globals.SecurityPin, Globals.Green, TextType.BOT);

                                        ServerPackets.SecurityPin();

                                        while (!Globals.gamedata.SecurityPinOk)
                                        {
                                            System.Threading.Thread.Sleep(100);
                                        }
                                        Globals.l2net_home.Add_Text("Pin OK", Globals.Green, TextType.BOT);
                                        Globals.gamedata.SecurityPinSent = true;
                                    }
                                    break;
							}

                            if (forward)
                            {
                                //send packets from the client right to the server
                                bbuffer0 = new ByteBuffer(buffpacketin);

                                Globals.gamedata.SendToGameServerNF(bbuffer0);
                            }
						}

						if(cnt > 2)
							size = System.BitConverter.ToUInt16(buffread,0);
					}//end of while loop
				}//end of while running
			}
            catch (System.Exception e)
            {
                Globals.l2net_home.Add_Error("crash: ClientReadThread : " + e.Message);
                network_exception();
            }
		}//end of read data
Ejemplo n.º 17
0
           private bool check_Serwer_pck_in_filter(pck_window_dat tmp_dat)
           {
               try
               {
                   if (tmp_dat.bytebuffer[0] != 0xfe)// not ex client pck
                   {
                       for (int i = 0; i < Globals.pck_thread.server_pck_filter.Count; i++)
                       {
                           if (tmp_dat.bytebuffer[0] == Globals.pck_thread.server_pck_filter[i])
                           {
                               return true;
                           }
                       }
                       return false;
                   }
                   else // id ts ex ...
                   {
                       byte[] temp_array = new byte[4];
                       temp_array[0] = tmp_dat.bytebuffer[0];
                       temp_array[1] = tmp_dat.bytebuffer[1];
                       temp_array[2] = tmp_dat.bytebuffer[2];
                       int temp_id = System.BitConverter.ToInt32(temp_array, 0);
                       //temp_id = temp_id + 0xfe;
                       for (int i = 0; i < Globals.pck_thread.server_pck_filter.Count; i++)
                       {
                           if (temp_id == Globals.pck_thread.server_pck_filter[i])
                           {
                               return true;
                           }
                       }
                       return false;
                   }

               }
               catch
               {
                   return false;
                   // len packet wrong ...
               }
           }
Ejemplo n.º 18
0
 private void checkBox3_CheckedChanged(object sender, EventArgs e)
 {
     Globals.pck_thread.hide_srv_pck = checkBox3.Checked;
     pck_window_dat temp_pck = new pck_window_dat();
     temp_pck.action = 5;
     Globals.pck_thread.mine_queue.Enqueue(temp_pck);
 }
Ejemplo n.º 19
0
        private void button_Save_list_Click(object sender, EventArgs e)
        {
            //DialogResult sav_win_res;
            SaveFileDialog saveFileDialog1 = new SaveFileDialog();

            saveFileDialog1.Filter = "Packet log(*.lpl)|*.lpl";
            saveFileDialog1.FilterIndex = 1;
            saveFileDialog1.RestoreDirectory = true;
            saveFileDialog1.InitialDirectory = Globals.PATH + "\\Packet Logs";
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                pck_window_dat temp_pck = new pck_window_dat();
                temp_pck.action = 4;
                temp_pck.time = saveFileDialog1.FileName; // same type so i dont see problem here :P
                Globals.pck_thread.mine_queue.Enqueue(temp_pck);
            }

        }
Ejemplo n.º 20
0
        public void add_to_list(pck_window_dat dat) // add thing to list
        {
           
            try
            {
                ListViewItem temp_item = new ListViewItem();
                int temp_count = listView1.Items.Count;
                //listView1.Items.Add(temp_count.ToString());
                temp_item.Text = temp_count.ToString();
                if(dat.type == 1) // client
                {
                    //listView1.Items[temp_count].SubItems.Add("Cli");
                     temp_item.SubItems.Add("Cli");
                }
                else // server
                {
                    temp_item.SubItems.Add("Srv");
                    //listView1.Items[temp_count].SubItems.Add("Srv");
                }
                temp_item.SubItems.Add(dat.time);
                //listView1.Items[temp_count].SubItems.Add(dat.time);
                temp_item.SubItems.Add(dat.bytebuffer.Length.ToString());
                //listView1.Items[temp_count].SubItems.Add(dat.bytebuffer.Length.ToString());
                if (dat.type == 1)//cli
                {
                    int temp_id = 0;
                    if (dat.bytebuffer.Length > 3)
                    {
                        if (dat.bytebuffer[0] < 0xd0)
                        {
                            temp_item.SubItems.Add(Globals.pck_thread.new_get_client_pck_name(dat.bytebuffer[0]));
                            //listView1.Items[temp_count].SubItems.Add(Globals.pck_thread.new_get_client_pck_name(dat.bytebuffer[0]));
                        }
                        else
                        {
                            for (int i = 0; i < 3; i++)
                            {
                                temp_id += dat.bytebuffer[i];
                            }
                            temp_item.SubItems.Add(Globals.pck_thread.new_get_client_pck_name(temp_id));
                           // listView1.Items[temp_count].SubItems.Add(Globals.pck_thread.new_get_client_pck_name(temp_id));
                        }
                    }
                    else
                    {
                        if (dat.bytebuffer[0] < 0xd0)
                        {
                            temp_item.SubItems.Add(Globals.pck_thread.new_get_client_pck_name(dat.bytebuffer[0]));
                           // listView1.Items[temp_count].SubItems.Add(Globals.pck_thread.new_get_client_pck_name(dat.bytebuffer[0]));
                        }
                        else
                        {
                            for (int i = 0; i < dat.bytebuffer.Length; i++)
                            {
                                temp_id += dat.bytebuffer[i];
                            }
                              temp_item.SubItems.Add(Globals.pck_thread.new_get_client_pck_name(temp_id));
                           // listView1.Items[temp_count].SubItems.Add(Globals.pck_thread.new_get_client_pck_name(temp_id));
                        }
                    }
                    //listView1.Items[temp_count].SubItems.Add(Globals.pck_thread.new_get_client_pck_name(dat.bytebuffer));
                    string pck_id;
                    if (dat.bytebuffer[0] == 0xd0)
                    {
                        pck_id = dat.bytebuffer[0].ToString("X2");
                        pck_id += ":";
                        pck_id += dat.bytebuffer[1].ToString("X2");
                        pck_id += dat.bytebuffer[2].ToString("X2");
                    }
                    else
                    {
                        pck_id = dat.bytebuffer[0].ToString("X2");
                    }
                    temp_item.SubItems.Add(pck_id);
                    //listView1.Items[temp_count].SubItems.Add(pck_id);
                    temp_item.BackColor = System.Drawing.Color.LightSeaGreen;
                    //listView1.Items[temp_count].BackColor = System.Drawing.Color.LightSeaGreen;
                    //
                }
                else//srv
                {
                    int temp_id = 0;
                    if (dat.bytebuffer.Length > 3)
                    {
                        if (dat.bytebuffer[0] < 0xfe)
                        {
                            temp_item.SubItems.Add(Globals.pck_thread.new_get_server_pck_name(dat.bytebuffer[0]));
                           // listView1.Items[temp_count].SubItems.Add(Globals.pck_thread.new_get_server_pck_name(dat.bytebuffer[0]));
                        }
                        else
                        {
                            for (int i = 0; i < 3; i++)
                            {
                                temp_id += dat.bytebuffer[i];
                            }
                            temp_item.SubItems.Add(Globals.pck_thread.new_get_server_pck_name(temp_id));
                           // listView1.Items[temp_count].SubItems.Add(Globals.pck_thread.new_get_server_pck_name(temp_id));
                        }
                    }
                    else
                    {
                        if (dat.bytebuffer[0] < 0xfe)
                        {
                            temp_item.SubItems.Add(Globals.pck_thread.new_get_server_pck_name(dat.bytebuffer[0]));
                           // listView1.Items[temp_count].SubItems.Add(Globals.pck_thread.new_get_server_pck_name(dat.bytebuffer[0]));
                        }
                        else
                        {
                            for (int i = 0; i < dat.bytebuffer.Length; i++)
                            {
                                temp_id += dat.bytebuffer[i];
                            }
                            temp_item.SubItems.Add(Globals.pck_thread.new_get_server_pck_name(temp_id));
                            //listView1.Items[temp_count].SubItems.Add(Globals.pck_thread.new_get_server_pck_name(temp_id));
                        }
                    }
                    //listView1.Items[temp_count].SubItems.Add(Globals.pck_thread.get_srv_pck_name(dat.bytebuffer));
                    string pck_id;
                    if (dat.bytebuffer[0] == 0xfe)
                    {
                        pck_id = dat.bytebuffer[0].ToString("X2");
                        pck_id += ":";
                        pck_id += dat.bytebuffer[1].ToString("X2");
                        pck_id += dat.bytebuffer[2].ToString("X2");
                    }
                    else
                    {
                        pck_id = dat.bytebuffer[0].ToString("X2");
                    }
                    temp_item.SubItems.Add(pck_id);
                    //listView1.Items[temp_count].SubItems.Add(pck_id);
                    temp_item.BackColor = System.Drawing.Color.Yellow;
                   //listView1.Items[temp_count].BackColor = System.Drawing.Color.Yellow;
                }
                listView1.Items.Add(temp_item);
                if (Globals.pck_thread.folow_new_pck)//folow pcjk
                {
                    listView1.Items[temp_count].EnsureVisible();
                }
                 //listView1.Items[temp_count].SubItems.Add(dat.bytebuffer[0].ToString("X2"));
            }
                //11:16 < Infant> srv rgb: 224 ; 245 ; 192
                //11:16 < Infant> client rgb: 255 ; 250 ; 168

                //
            // to do
            catch
            {

                // error ...ListViewNF
            }
        }
Ejemplo n.º 21
0
           private void search_up(pck_window_dat tmp_dat)
           {
               try
               {
                   string txt_from_box = "";
                   int index_start = Globals.pck_thread.pck_window.ret_select();
                   index_start--;
                   if (index_start != -1)
                   {
                       if (tmp_dat.type == 2) // search in server packets
                       {
                           #region server pck check2
                           txt_from_box = tmp_dat.time.Replace(" ", ""); // removing spaces
                           txt_from_box = txt_from_box.Replace(":", ""); // removing :

                           if (txt_from_box.Length >= 2 && txt_from_box.Length <= 6)
                           {
                               if (txt_from_box.Length % 2 == 0)// check for 3 and 5 legh...
                               {
                                   byte[] bytebuf = new byte[4];
                                   byte[] tem_bytebuf = StringToByteArray2(txt_from_box);
                                   for (int i = 0; i < tem_bytebuf.Length; i++)
                                   {
                                       bytebuf[i] = tem_bytebuf[i];
                                   }
                                   //check part
                                   int index = search_server_pck_new(bytebuf, index_start, 2);
                                   if (index != -1)//
                                   {
                                       Globals.pck_thread.pck_window.selectitem(index);
                                   }

                                   /*
                                   if (bytebuf[0] != 0xfe) // not ex pck
                                   {
                                       // fun for check
                                       int index = search_server_pck(bytebuf[0], index_start,2);
                                       if (index != -1)//
                                       {
                                           Globals.pck_thread.pck_window.selectitem(index);
                                       }

                                   }
                                   else // ex pck
                                   {
                                       int temp_id = System.BitConverter.ToUInt16(bytebuf, 1);
                                       temp_id = temp_id + 0xfe;
                                       int index = search_server_pck(temp_id, index_start,2);
                                       if (index != -1)//
                                       {
                                           Globals.pck_thread.pck_window.selectitem(index);
                                       }

                                   }
                                   */
                               }

                           }
                           #endregion
                       }
                       else if (tmp_dat.type == 1)//search in client pck ...
                       {
                           #region client pck check2
                           txt_from_box = tmp_dat.time.Replace(" ", ""); // removing spaces
                           txt_from_box = tmp_dat.time.Replace(":", ""); // removing :
                           if (txt_from_box.Length >= 2 && txt_from_box.Length <= 6)
                           {
                               if (txt_from_box.Length % 2 == 0)// check for 3 and 5 legh...
                               {
                                   byte[] bytebuf = new byte[4];
                                   byte[] tem_bytebuf = Globals.pck_thread.StringToByteArray2(txt_from_box);
                                   for (int i = 0; i < tem_bytebuf.Length; i++)
                                   {
                                       bytebuf[i] = tem_bytebuf[i];
                                   }
                                   int index = search_cli_pck_new(bytebuf, index_start, 2);
                                   if (index != -1)//
                                   {
                                       Globals.pck_thread.pck_window.selectitem(index);
                                   }

                                   /*
                                   //check part
                                   if (bytebuf[0] != 0xd0) // not d0 pck
                                   {
                                       // fun for check
                                       int index = search_cli_pck(bytebuf[0], index_start,2);
                                       if (index != -1)//
                                       {
                                           Globals.pck_thread.pck_window.selectitem(index);
                                       }

                                   }
                                   else //  d0 pck
                                   {
                                       int temp_id = System.BitConverter.ToUInt16(bytebuf, 1);
                                       temp_id = temp_id + 0xd0;
                                       int index = search_cli_pck(temp_id, index_start,2);
                                       if (index != -1)//
                                       {
                                           Globals.pck_thread.pck_window.selectitem(index);
                                       }

                                   }
                                   */
                               }

                           }
                           #endregion
                       }
                   }
               }
               catch
               {
                   //throw pika
               }
           }
Ejemplo n.º 22
0
           private void add_pck(pck_window_dat tmp_dat)
           {
               try
               {
                   Globals.pck_thread.pck_record.Add(tmp_dat);
                   if (Globals.pck_thread.filter_wind_pck == true)
                   {
                       if (tmp_dat.type == 1)// client pck
                       {
                           if (check_client_pck_in_filter(tmp_dat))
                           {
                               if (Globals.pck_thread.white_list_filter)
                               {
                                   if (!hide_cli_pck)// hide client pck
                                   {
                                       int temp_count = Globals.pck_thread.pck_record.Count - 1;
                                       Globals.pck_thread.filtered_pck.Add(temp_count);
                                       //Globals.pck_thread.pck_window.add_one_to_cache();
                                       Globals.pck_thread.pck_window.add_to_list(tmp_dat);
                                   }
                               }
                               //Globals.pck_thread.pck_window.add_to_list(Globals.pck_thread.mine_queue.First()); // add to normal list
                           }
                           else// not in filter list ...
                           {
                               if (!Globals.pck_thread.white_list_filter)
                               {
                                   if (!hide_cli_pck)// hide client pck
                                   {
                                       int temp_count = Globals.pck_thread.pck_record.Count - 1;
                                       Globals.pck_thread.filtered_pck.Add(temp_count);
                                       //Globals.pck_thread.pck_window.add_one_to_cache();
                                       Globals.pck_thread.pck_window.add_to_list(tmp_dat);
                                   }
                               }
                           }
                           // spr w liscie filtra
                           // ex packi tez
                           // jak niema to dodanie do filtered
                           // dodanei do okna
                       }
                       else // server pck
                       {
                           if (check_Serwer_pck_in_filter(tmp_dat))
                           {

                               if (Globals.pck_thread.white_list_filter)
                               {
                                   if (!hide_srv_pck)// hide client pck
                                   {
                                       int temp_count = Globals.pck_thread.pck_record.Count - 1;
                                       Globals.pck_thread.filtered_pck.Add(temp_count);
                                       //Globals.pck_thread.pck_window.add_one_to_cache();
                                       Globals.pck_thread.pck_window.add_to_list(tmp_dat);
                                   }
                               }
                               //Globals.pck_thread.pck_window.add_to_list(Globals.pck_thread.mine_queue.First()); // add to normal list

                           }
                           else// not in filter list ...
                           {
                               if (!Globals.pck_thread.white_list_filter)
                               {
                                   if (!hide_srv_pck)// hide client pck
                                   {
                                       int temp_count = Globals.pck_thread.pck_record.Count - 1;
                                       Globals.pck_thread.filtered_pck.Add(temp_count);
                                       //Globals.pck_thread.pck_window.add_one_to_cache();
                                       Globals.pck_thread.pck_window.add_to_list(tmp_dat);
                                   }
                               }
                           }
                       }
                   }
                   else // without pck filter
                   {
                       //Globals.pck_thread.pck_window.add_one_to_cache();
                       Globals.pck_thread.pck_window.add_to_list(tmp_dat);
                   }
               }
               catch
               {

               }
           }
Ejemplo n.º 23
0
 private void button6_Click(object sender, EventArgs e)// load ?
 {
     if (MessageBox.Show("Load and apply filters ?", "Pika Pika!", MessageBoxButtons.YesNo) == DialogResult.Yes)
     {
         pck_window_dat pck_dat = new pck_window_dat();
         pck_dat.action = 8;
         Globals.pck_thread.mine_queue.Enqueue(pck_dat);
     }
 }
Ejemplo n.º 24
0
 private void button1_Click(object sender, EventArgs e)// aply
 {
     pck_window_dat pck_dat = new pck_window_dat();
     pck_dat.action = 6;
     Globals.pck_thread.mine_queue.Enqueue(pck_dat);
 }
Ejemplo n.º 25
0
        public void add_one_to_temp_cache(pck_window_dat dat)
        {

            try
            {
                ListViewItem temp_item = new ListViewItem();
                int temp_count = listView1.Items.Count;
                temp_count +=Globals.pck_thread.temp_cache_for_pck_window.Count;
                //listView1.Items.Add(temp_count.ToString());
                temp_item.Text = temp_count.ToString();
                if (dat.type == 1) // client
                {
                    //listView1.Items[temp_count].SubItems.Add("Cli");
                    temp_item.SubItems.Add("Cli");
                }
                else // server
                {
                    temp_item.SubItems.Add("Srv");
                    //listView1.Items[temp_count].SubItems.Add("Srv");
                }
                temp_item.SubItems.Add(dat.time);
                //listView1.Items[temp_count].SubItems.Add(dat.time);
                temp_item.SubItems.Add(dat.bytebuffer.Length.ToString());
                //listView1.Items[temp_count].SubItems.Add(dat.bytebuffer.Length.ToString());
                if (dat.type == 1)//cli
                {
                    int temp_id = 0;
                    if (dat.bytebuffer.Length > 3)
                    {
                        if (dat.bytebuffer[0] < 0xd0)
                        {
                            temp_item.SubItems.Add(Globals.pck_thread.new_get_client_pck_name(dat.bytebuffer[0]));
                            //listView1.Items[temp_count].SubItems.Add(Globals.pck_thread.new_get_client_pck_name(dat.bytebuffer[0]));
                        }
                        else
                        {
                            for (int i = 0; i < 3; i++)
                            {
                                temp_id += dat.bytebuffer[i];
                            }
                            temp_item.SubItems.Add(Globals.pck_thread.new_get_client_pck_name(temp_id));
                            // listView1.Items[temp_count].SubItems.Add(Globals.pck_thread.new_get_client_pck_name(temp_id));
                        }
                    }
                    else
                    {
                        if (dat.bytebuffer[0] < 0xd0)
                        {
                            temp_item.SubItems.Add(Globals.pck_thread.new_get_client_pck_name(dat.bytebuffer[0]));
                            // listView1.Items[temp_count].SubItems.Add(Globals.pck_thread.new_get_client_pck_name(dat.bytebuffer[0]));
                        }
                        else
                        {
                            for (int i = 0; i < dat.bytebuffer.Length; i++)
                            {
                                temp_id += dat.bytebuffer[i];
                            }
                            temp_item.SubItems.Add(Globals.pck_thread.new_get_client_pck_name(temp_id));
                            // listView1.Items[temp_count].SubItems.Add(Globals.pck_thread.new_get_client_pck_name(temp_id));
                        }
                    }
                    //listView1.Items[temp_count].SubItems.Add(Globals.pck_thread.new_get_client_pck_name(dat.bytebuffer));
                    string pck_id;
                    if (dat.bytebuffer[0] == 0xd0)
                    {
                        pck_id = dat.bytebuffer[0].ToString("X2");
                        pck_id += ":";
                        pck_id += dat.bytebuffer[1].ToString("X2");
                        pck_id += dat.bytebuffer[2].ToString("X2");
                    }
                    else
                    {
                        pck_id = dat.bytebuffer[0].ToString("X2");
                    }
                    temp_item.SubItems.Add(pck_id);
                    //listView1.Items[temp_count].SubItems.Add(pck_id);
                    temp_item.BackColor = System.Drawing.Color.LightSeaGreen;
                    //listView1.Items[temp_count].BackColor = System.Drawing.Color.LightSeaGreen;
                    //
                }
                else//srv
                {
                    int temp_id = 0;
                    if (dat.bytebuffer.Length > 3)
                    {
                        if (dat.bytebuffer[0] < 0xfe)
                        {
                            temp_item.SubItems.Add(Globals.pck_thread.new_get_server_pck_name(dat.bytebuffer[0]));
                            // listView1.Items[temp_count].SubItems.Add(Globals.pck_thread.new_get_server_pck_name(dat.bytebuffer[0]));
                        }
                        else
                        {
                            for (int i = 0; i < 3; i++)
                            {
                                temp_id += dat.bytebuffer[i];
                            }
                            temp_item.SubItems.Add(Globals.pck_thread.new_get_server_pck_name(temp_id));
                            // listView1.Items[temp_count].SubItems.Add(Globals.pck_thread.new_get_server_pck_name(temp_id));
                        }
                    }
                    else
                    {
                        if (dat.bytebuffer[0] < 0xfe)
                        {
                            temp_item.SubItems.Add(Globals.pck_thread.new_get_server_pck_name(dat.bytebuffer[0]));
                            // listView1.Items[temp_count].SubItems.Add(Globals.pck_thread.new_get_server_pck_name(dat.bytebuffer[0]));
                        }
                        else
                        {
                            for (int i = 0; i < dat.bytebuffer.Length; i++)
                            {
                                temp_id += dat.bytebuffer[i];
                            }
                            temp_item.SubItems.Add(Globals.pck_thread.new_get_server_pck_name(temp_id));
                            //listView1.Items[temp_count].SubItems.Add(Globals.pck_thread.new_get_server_pck_name(temp_id));
                        }
                    }
                    //listView1.Items[temp_count].SubItems.Add(Globals.pck_thread.get_srv_pck_name(dat.bytebuffer));
                    string pck_id;
                    if (dat.bytebuffer[0] == 0xfe)
                    {
                        pck_id = dat.bytebuffer[0].ToString("X2");
                        pck_id += ":";
                        pck_id += dat.bytebuffer[1].ToString("X2");
                        pck_id += dat.bytebuffer[2].ToString("X2");
                    }
                    else
                    {
                        pck_id = dat.bytebuffer[0].ToString("X2");
                    }
                    temp_item.SubItems.Add(pck_id);
                    //listView1.Items[temp_count].SubItems.Add(pck_id);
                    temp_item.BackColor = System.Drawing.Color.Yellow;
                    //listView1.Items[temp_count].BackColor = System.Drawing.Color.Yellow;
                }

               Globals.pck_thread.temp_cache_for_pck_window.Add(temp_item);
            }

            catch
            {

                // error ...ListViewNF
            }
        }
Ejemplo n.º 26
0
        public void add_to_list(pck_window_dat dat) // add thing to list
        {
            try
            {
                ListViewItem temp_item  = new ListViewItem();
                int          temp_count = listView1.Items.Count;
                //listView1.Items.Add(temp_count.ToString());
                temp_item.Text = temp_count.ToString();
                if (dat.type == 1) // client
                {
                    //listView1.Items[temp_count].SubItems.Add("Cli");
                    temp_item.SubItems.Add("Cli");
                }
                else // server
                {
                    temp_item.SubItems.Add("Srv");
                    //listView1.Items[temp_count].SubItems.Add("Srv");
                }
                temp_item.SubItems.Add(dat.time);
                //listView1.Items[temp_count].SubItems.Add(dat.time);
                temp_item.SubItems.Add(dat.bytebuffer.Length.ToString());
                //listView1.Items[temp_count].SubItems.Add(dat.bytebuffer.Length.ToString());
                if (dat.type == 1)//cli
                {
                    int temp_id = 0;
                    if (dat.bytebuffer.Length > 3)
                    {
                        if (dat.bytebuffer[0] < 0xd0)
                        {
                            temp_item.SubItems.Add(Globals.pck_thread.new_get_client_pck_name(dat.bytebuffer[0]));
                            //listView1.Items[temp_count].SubItems.Add(Globals.pck_thread.new_get_client_pck_name(dat.bytebuffer[0]));
                        }
                        else
                        {
                            for (int i = 0; i < 3; i++)
                            {
                                temp_id += dat.bytebuffer[i];
                            }
                            temp_item.SubItems.Add(Globals.pck_thread.new_get_client_pck_name(temp_id));
                            // listView1.Items[temp_count].SubItems.Add(Globals.pck_thread.new_get_client_pck_name(temp_id));
                        }
                    }
                    else
                    {
                        if (dat.bytebuffer[0] < 0xd0)
                        {
                            temp_item.SubItems.Add(Globals.pck_thread.new_get_client_pck_name(dat.bytebuffer[0]));
                            // listView1.Items[temp_count].SubItems.Add(Globals.pck_thread.new_get_client_pck_name(dat.bytebuffer[0]));
                        }
                        else
                        {
                            for (int i = 0; i < dat.bytebuffer.Length; i++)
                            {
                                temp_id += dat.bytebuffer[i];
                            }
                            temp_item.SubItems.Add(Globals.pck_thread.new_get_client_pck_name(temp_id));
                            // listView1.Items[temp_count].SubItems.Add(Globals.pck_thread.new_get_client_pck_name(temp_id));
                        }
                    }
                    //listView1.Items[temp_count].SubItems.Add(Globals.pck_thread.new_get_client_pck_name(dat.bytebuffer));
                    string pck_id;
                    if (dat.bytebuffer[0] == 0xd0)
                    {
                        pck_id  = dat.bytebuffer[0].ToString("X2");
                        pck_id += ":";
                        pck_id += dat.bytebuffer[1].ToString("X2");
                        pck_id += dat.bytebuffer[2].ToString("X2");
                    }
                    else
                    {
                        pck_id = dat.bytebuffer[0].ToString("X2");
                    }
                    temp_item.SubItems.Add(pck_id);
                    //listView1.Items[temp_count].SubItems.Add(pck_id);
                    temp_item.BackColor = System.Drawing.Color.LightSeaGreen;
                    //listView1.Items[temp_count].BackColor = System.Drawing.Color.LightSeaGreen;
                    //
                }
                else//srv
                {
                    int temp_id = 0;
                    if (dat.bytebuffer.Length > 3)
                    {
                        if (dat.bytebuffer[0] < 0xfe)
                        {
                            temp_item.SubItems.Add(Globals.pck_thread.new_get_server_pck_name(dat.bytebuffer[0]));
                            // listView1.Items[temp_count].SubItems.Add(Globals.pck_thread.new_get_server_pck_name(dat.bytebuffer[0]));
                        }
                        else
                        {
                            for (int i = 0; i < 3; i++)
                            {
                                temp_id += dat.bytebuffer[i];
                            }
                            temp_item.SubItems.Add(Globals.pck_thread.new_get_server_pck_name(temp_id));
                            // listView1.Items[temp_count].SubItems.Add(Globals.pck_thread.new_get_server_pck_name(temp_id));
                        }
                    }
                    else
                    {
                        if (dat.bytebuffer[0] < 0xfe)
                        {
                            temp_item.SubItems.Add(Globals.pck_thread.new_get_server_pck_name(dat.bytebuffer[0]));
                            // listView1.Items[temp_count].SubItems.Add(Globals.pck_thread.new_get_server_pck_name(dat.bytebuffer[0]));
                        }
                        else
                        {
                            for (int i = 0; i < dat.bytebuffer.Length; i++)
                            {
                                temp_id += dat.bytebuffer[i];
                            }
                            temp_item.SubItems.Add(Globals.pck_thread.new_get_server_pck_name(temp_id));
                            //listView1.Items[temp_count].SubItems.Add(Globals.pck_thread.new_get_server_pck_name(temp_id));
                        }
                    }
                    //listView1.Items[temp_count].SubItems.Add(Globals.pck_thread.get_srv_pck_name(dat.bytebuffer));
                    string pck_id;
                    if (dat.bytebuffer[0] == 0xfe)
                    {
                        pck_id  = dat.bytebuffer[0].ToString("X2");
                        pck_id += ":";
                        pck_id += dat.bytebuffer[1].ToString("X2");
                        pck_id += dat.bytebuffer[2].ToString("X2");
                    }
                    else
                    {
                        pck_id = dat.bytebuffer[0].ToString("X2");
                    }
                    temp_item.SubItems.Add(pck_id);
                    //listView1.Items[temp_count].SubItems.Add(pck_id);
                    temp_item.BackColor = System.Drawing.Color.Yellow;
                    //listView1.Items[temp_count].BackColor = System.Drawing.Color.Yellow;
                }
                listView1.Items.Add(temp_item);
                if (Globals.pck_thread.folow_new_pck)//folow pcjk
                {
                    listView1.Items[temp_count].EnsureVisible();
                }
                //listView1.Items[temp_count].SubItems.Add(dat.bytebuffer[0].ToString("X2"));
            }
            //11:16 < Infant> srv rgb: 224 ; 245 ; 192
            //11:16 < Infant> client rgb: 255 ; 250 ; 168

            //
            // to do
            catch
            {
                // error ...ListViewNF
            }
        }
Ejemplo n.º 27
0
 private void button_clear_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Clear Packet Log?", "Pika Pika!", MessageBoxButtons.YesNo) == DialogResult.Yes)
     {
         pck_window_dat pck_dat = new pck_window_dat();
         pck_dat.action = 2;
         Globals.pck_thread.mine_queue.Enqueue(pck_dat);
     }
 }
Ejemplo n.º 28
0
        private void button_Load_list_Click(object sender, EventArgs e)
        {

            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            //openFileDialog1.InitialDirectory = "c:\\" ;
            openFileDialog1.Title = "Load Packet log";
            openFileDialog1.Filter = "Packet log (*.lpl)|*.lpl";
            openFileDialog1.FilterIndex = 1;
            openFileDialog1.InitialDirectory = Globals.PATH + "\\Packet Logs";
            openFileDialog1.RestoreDirectory = true;

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                //FileStream fs = new FileStream(openFileDialog1.FileName, FileMode.Open, FileAccess.Read);
                pck_window_dat temp_pck = new pck_window_dat();
                temp_pck.action = 3;
                temp_pck.time = openFileDialog1.FileName; // same type so i dont see problem here :P
                Globals.pck_thread.mine_queue.Enqueue(temp_pck);
            }
        }
Ejemplo n.º 29
0
        private void Load_data(pck_window_dat tmp_dat)
        {
            try
            {
                clean_data();
                System.IO.BinaryReader redfil = new BinaryReader(File.Open(tmp_dat.time, FileMode.Open));
                int temp_ilo = redfil.ReadInt32();
                pck_window_dat temp_dat;
                for (int i = 0; i < temp_ilo; i++)
                {
                    temp_dat = new pck_window_dat();
                    temp_dat.action = redfil.ReadInt32();
                    temp_dat.type = redfil.ReadInt32();
                    temp_dat.time = redfil.ReadString();
                    temp_dat.bytebuffer = redfil.ReadBytes(redfil.ReadInt32());

                    //for (int j = 0; j < temp_dat.bytebuffer.Length; j++)
                    //{
                       // temp_dat.bytebuffer[j] = redfil.ReadByte();
                    //}
                    Globals.pck_thread.pck_record.Add(temp_dat);
                }
                if (Globals.pck_thread.filter_wind_pck == true)
                {
                    create_filtered_list();
                }
                Globals.pck_thread.pck_window.refresh_window();
                //Globals.pck_thread.pck_recording = true;

            }
            catch
            {
                // to do ...
            }
        }
Ejemplo n.º 30
0
        private void ClientReadThread()
        {
            byte[] buffread = new byte[Globals.BUFFER_MAX];
            byte[] buffpacket;
            byte[] buffpacketin;

            int  cnt     = 0;
            int  size    = 0;
            int  ggcnt   = 0;
            bool forward = true;

            ByteBuffer bbuffer0;

            System.Text.StringBuilder dumpbuilder;

            Globals.l2net_home.Add_Text("Welcome to the game loop", Globals.Red, TextType.BOT);

            try
            {
                while (Globals.gamedata.running && !Globals.gamedata.OOG)
                {
                    cnt += Globals.Game_ClientSocket.Receive(buffread, cnt, Globals.BUFFER_PACKET - cnt, System.Net.Sockets.SocketFlags.None);
                    size = System.BitConverter.ToUInt16(buffread, 0);

                    while (cnt >= size && cnt > 2)
                    {
                        //if we got partial shit we cant use, read some more until it is full
                        while (size > cnt)
                        {
                            cnt += Globals.Game_ClientSocket.Receive(buffread, cnt, Globals.BUFFER_PACKET - cnt, System.Net.Sockets.SocketFlags.None);
                        }

                        buffpacketin = new byte[size - 2];
                        buffpacket   = new byte[size - 2];

                        Array.Copy(buffread, 2, buffpacketin, 0, size - 2);

                        Globals.gamedata.crypt_clientin.decrypt(buffpacketin);

                        Array.Copy(buffpacketin, 0, buffpacket, 0, size - 2);

                        if (Globals.Mixer != null)
                        {
                            Globals.Mixer.Decrypt0(buffpacket);
                        }
                        if (Globals.pck_thread.pck_recording)
                        {
                            pck_window_dat pck_dat = new pck_window_dat(buffpacket);
                            pck_dat.action = 1;
                            pck_dat.type   = 1;
                            pck_dat.time   = System.DateTime.Now.TimeOfDay.ToString();
                            Globals.pck_thread.mine_queue.Enqueue(pck_dat);
                        }
#if DEBUG
                        try
                        {
                            //

                            /* if (Globals.pck_thread.pck_recording)
                             * {
                             * // *                             lock (Globals.pck_thread.lock_obj)
                             * // {
                             *    pck_window_dat pck_dat = new pck_window_dat(buffpacket);
                             *    pck_dat.action = 1;
                             *    pck_dat.type = 1;
                             *    pck_dat.time = System.DateTime.Now.TimeOfDay.ToString();
                             *    Globals.pck_thread.mine_queue.Enqueue(pck_dat);
                             * //* }
                             * }*/
                            //
                            Globals.clientdataout.WriteLine("packet...-size: " + size.ToString() + " -count:" + cnt.ToString() + " :::time:::" + System.DateTime.Now.TimeOfDay.ToString() + ":::");
                            Globals.clientdataout.WriteLine("-data from client to bot hex-");
                            for (uint i = 0; i < size - 2; i++)
                            {
                                Globals.clientdataout.Write(buffpacket[i].ToString("X2"));
                                Globals.clientdataout.Write(" ");
                            }
                            Globals.clientdataout.WriteLine("");
                            Globals.clientdataout.WriteLine("-data from client to bot string-");
                            for (uint i = 0; i < size - 2; i++)
                            {
                                Globals.clientdataout.Write((char)buffpacket[i]);
                            }
                            Globals.clientdataout.WriteLine("");
                        }
                        catch
                        {
                            //failed to write... oh well
                        }
#endif

                        if (Globals.DumpModeClient)
                        {
                            dumpbuilder = new System.Text.StringBuilder();

                            for (int i = 0; i < size - 2; i++)
                            {
                                dumpbuilder.Append(buffpacket[i].ToString("X2"));
                                dumpbuilder.Append(" ");
                            }
                            Globals.l2net_home.Add_Dump(dumpbuilder.ToString(), false);
                        }

                        //shift the data over by size
                        for (uint i = 0; i < cnt - size; i++)
                        {
                            buffread[i] = buffread[size + i];
                        }

                        cnt -= size;

                        if (buffpacket.Length > 0)
                        {
                            forward = true;

                            if (Globals.gamedata.CurrentScriptState == ScriptState.Running)
                            {
                                if ((PClient)buffpacket[0] == PClient.EXPacket)
                                {
                                    if (ScriptEngine.Blocked_ClientPacketsEX.ContainsKey(System.Convert.ToInt32(buffpacket[1])))
                                    {
                                        forward = false;
                                    }

                                    if (ScriptEngine.ClientPacketsEXContainsKey(System.Convert.ToInt32(buffpacket[1])))
                                    {
                                        ByteBuffer bb = new ByteBuffer(buffpacket);

                                        ScriptEvent sc_ev = new ScriptEvent();
                                        sc_ev.Type  = EventType.ClientPacketEX;
                                        sc_ev.Type2 = System.Convert.ToInt32(buffpacket[1]);
                                        sc_ev.Variables.Add(new ScriptVariable(bb, "PACKET", Var_Types.BYTEBUFFER, Var_State.PUBLIC));
                                        sc_ev.Variables.Add(new ScriptVariable(System.DateTime.Now.Ticks, "TIMESTAMP", Var_Types.INT, Var_State.PUBLIC));
                                        ScriptEngine.SendToEventQueue(sc_ev);
                                    }
                                }
                                else
                                {
                                    if (ScriptEngine.Blocked_ClientPackets.ContainsKey(System.Convert.ToInt32(buffpacket[0])))
                                    {
                                        forward = false;
                                    }

                                    if (ScriptEngine.ClientPacketsContainsKey(System.Convert.ToInt32(buffpacket[0])))
                                    {
                                        ByteBuffer bb = new ByteBuffer(buffpacket);

                                        ScriptEvent sc_ev = new ScriptEvent();
                                        sc_ev.Type  = EventType.ClientPacket;
                                        sc_ev.Type2 = System.Convert.ToInt32(buffpacket[0]);
                                        sc_ev.Variables.Add(new ScriptVariable(bb, "PACKET", Var_Types.BYTEBUFFER, Var_State.PUBLIC));
                                        sc_ev.Variables.Add(new ScriptVariable(System.DateTime.Now.Ticks, "TIMESTAMP", Var_Types.INT, Var_State.PUBLIC));
                                        ScriptEngine.SendToEventQueue(sc_ev);
                                    }
                                }
                            }

                            //this is where we would want to handle packets sent by the client
                            switch ((PClient)buffpacket[0])
                            {
                            case PClient.AuthLogin:    //protocol version
                                int prot = System.BitConverter.ToInt16(buffpacket, 1);
                                Globals.l2net_home.Add_Text("protocol version: " + prot.ToString(), Globals.Red, TextType.BOT);

                                if (prot == -2)
                                {
                                    Globals.l2net_home.Add_Text("-2 protocol... just a ping... we've been had XD...", Globals.Red, TextType.BOT);
                                }
                                else
                                {
                                    //valid protocol...
                                    Globals.l2net_home.Add_Text("valid protocol...", Globals.Red, TextType.BOT);
                                }
                                break;

                            case PClient.GameGuardReply:                                    //gameguard reply
                                if (Globals.GG_Servermode)
                                {
                                    if (Globals.GG_QueryReceived)
                                    {
                                        ggcnt++;
                                        if (ggcnt == 1)
                                        {
                                            //GameGuardServer.send_gg_answer(buffpacket, false);
                                            GameGuardServer.SendGGReply(buffpacket);
                                        }

                                        if (ggcnt == 2)
                                        {
                                            Globals.GG_QueryReceived = false;
                                            //GameGuardServer.send_gg_answer(buffpacket, true);
                                            GameGuardServer.SendGGReply(buffpacket);
                                            ggcnt = 0;
                                        }
                                        forward = false;
                                    }
                                }
                                if (Globals.Script_Debugging)
                                {
                                    string gg = "";

                                    for (int i = 1; i < buffpacket.Length; i++)
                                    {
                                        gg += buffpacket[i].ToString("X2") + " ";
                                    }

                                    Globals.l2net_home.Add_Debug("GameGuard Reply: " + gg);
                                }
                                break;

                            case PClient.Say2:                                    //say text
                                if (Globals.gamedata.OOG == false)
                                {
                                    ByteBuffer bbuff = new ByteBuffer(buffpacket);

                                    bbuff.ReadByte();
                                    string start = bbuff.ReadString();
                                    uint   type  = bbuff.ReadUInt32();
                                    string end   = bbuff.ReadString();

                                    //wanna handle text if prefaced with "-"
                                    //since these are commands to the bot

                                    if (start.StartsWith("--"))
                                    {
                                        forward = false;

                                        start = start.Substring(1, start.Length - 1);

                                        ServerPackets.Send_Text(type, start, end);
                                    }
                                    else if (start.StartsWith("-"))
                                    {
                                        forward = false;

                                        start = start.Substring(1, start.Length - 1);

                                        if (Globals.gamedata.CurrentScriptState == ScriptState.Running)
                                        {
                                            ScriptEvent sc_ev = new ScriptEvent();
                                            sc_ev.Type = EventType.ChatToBot;
                                            sc_ev.Variables.Add(new ScriptVariable((long)type, "MESSAGETYPE", Var_Types.INT, Var_State.PUBLIC));
                                            sc_ev.Variables.Add(new ScriptVariable(end, "TARGETNAME", Var_Types.STRING, Var_State.PUBLIC));
                                            sc_ev.Variables.Add(new ScriptVariable(start, "MESSAGE", Var_Types.STRING, Var_State.PUBLIC));
                                            ScriptEngine.SendToEventQueue(sc_ev);
                                        }
                                    }
                                }
                                break;

                            case PClient.CharacterSelect:
                                if ((!Globals.gamedata.OOG) && (!System.String.IsNullOrEmpty(Globals.SecurityPin)) && (Globals.gamedata.SecurityPinOldClient) && (!Globals.gamedata.SecurityPinSent))
                                {
                                    ServerPackets.RequestSecurityPinWindow();

                                    while (!Globals.gamedata.SecurityPinWindow)
                                    {
                                        System.Threading.Thread.Sleep(100);
                                    }

                                    Globals.l2net_home.Add_Text("Sending security pin: " + Globals.SecurityPin, Globals.Green, TextType.BOT);

                                    ServerPackets.SecurityPin();

                                    while (!Globals.gamedata.SecurityPinOk)
                                    {
                                        System.Threading.Thread.Sleep(100);
                                    }
                                    Globals.l2net_home.Add_Text("Pin OK", Globals.Green, TextType.BOT);
                                    Globals.gamedata.SecurityPinSent = true;
                                }
                                break;
                            }

                            if (forward)
                            {
                                //send packets from the client right to the server
                                bbuffer0 = new ByteBuffer(buffpacketin);

                                Globals.gamedata.SendToGameServerNF(bbuffer0);
                            }
                        }

                        if (cnt > 2)
                        {
                            size = System.BitConverter.ToUInt16(buffread, 0);
                        }
                    }            //end of while loop
                }                //end of while running
            }
            catch (System.Exception e)
            {
                Globals.l2net_home.Add_Error("crash: ClientReadThread : " + e.Message);
                network_exception();
            }
        } //end of read data
Ejemplo n.º 31
0
           private bool check_client_pck_in_filter(pck_window_dat tmp_dat)
           {
               try
               {
                   if (tmp_dat.bytebuffer[0] != 0xd0)// not ex client pck
                   {
                       for (int i = 0; i < Globals.pck_thread.client_pck_filter.Count; i++)
                       {
                           if(tmp_dat.bytebuffer[0] ==  Globals.pck_thread.client_pck_filter[i])
                           {
                               return true;
                           }
                       }
                       return false;
                   }
                   else // id ts ex ...
                   {
                        int temp_id = System.BitConverter.ToUInt16(tmp_dat.bytebuffer,1);
                        temp_id=temp_id+0xd0;
                        for (int i = 0; i < Globals.pck_thread.client_pck_filter.Count; i++)
                         {
                            if(temp_id ==  Globals.pck_thread.client_pck_filter[i])
                            {
                               return true;
                            }
                          }
                       return false;
                   }

               }
               catch
               {
                   return false;
                    // len packet wrong ...
               }
           }
Ejemplo n.º 32
0
        private void rec_fun(pck_window_dat tmp_dat)
        {
            try
            {
                System.IO.BinaryWriter test = new BinaryWriter(File.Open(tmp_dat.time, FileMode.Create));
                test.Write(Globals.pck_thread.pck_record.Count);
                for (int i = 0; i < Globals.pck_thread.pck_record.Count; i++)
                {
                    test.Write((Globals.pck_thread.pck_record[i]).action);
                    test.Write((Globals.pck_thread.pck_record[i]).type);
                    test.Write((Globals.pck_thread.pck_record[i]).time);
                    test.Write((Globals.pck_thread.pck_record[i]).bytebuffer.Length);
                    //test.Write(Globals.pck_thread.pck_record[i]).bytebuffer);
                    for (int j = 0; j < (Globals.pck_thread.pck_record[i]).bytebuffer.Length; j++)
                        test.Write((Globals.pck_thread.pck_record[i]).bytebuffer[j]);
                }
                test.Flush();
            }
            catch
            {

            }
        }
Ejemplo n.º 33
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (textBox3.TextLength > 0)
            {
                if (radioButton1.Checked == true) // client
                {
                    if (checkBox4.Checked)
                    {
                        pck_window_dat temp_pck = new pck_window_dat();
                        temp_pck.time = textBox3.Text;
                        temp_pck.type = 1;
                        temp_pck.action = 14;
                        Globals.pck_thread.mine_queue.Enqueue(temp_pck);
                    }
                    else
                    {
                        pck_window_dat temp_pck = new pck_window_dat();
                        temp_pck.time = textBox3.Text;
                        temp_pck.type = 1;
                        temp_pck.action = 10;
                        Globals.pck_thread.mine_queue.Enqueue(temp_pck);
                    }
                }
                else if (radioButton2.Checked == true) // server
                {
                    if (checkBox4.Checked)
                    {
                        pck_window_dat temp_pck = new pck_window_dat();
                        temp_pck.time = textBox3.Text;
                        temp_pck.type = 2;
                        temp_pck.action = 14;
                        Globals.pck_thread.mine_queue.Enqueue(temp_pck);
                    }
                    else
                    {
                        pck_window_dat temp_pck = new pck_window_dat();
                        temp_pck.time = textBox3.Text;
                        temp_pck.type = 2;
                        temp_pck.action = 10;
                        Globals.pck_thread.mine_queue.Enqueue(temp_pck);
                    }
                }

            }
        } // serarch up
Ejemplo n.º 34
0
        public void add_one_to_temp_cache(pck_window_dat dat)
        {
            try
            {
                ListViewItem temp_item  = new ListViewItem();
                int          temp_count = listView1.Items.Count;
                temp_count += Globals.pck_thread.temp_cache_for_pck_window.Count;
                //listView1.Items.Add(temp_count.ToString());
                temp_item.Text = temp_count.ToString();
                if (dat.type == 1) // client
                {
                    //listView1.Items[temp_count].SubItems.Add("Cli");
                    temp_item.SubItems.Add("Cli");
                }
                else // server
                {
                    temp_item.SubItems.Add("Srv");
                    //listView1.Items[temp_count].SubItems.Add("Srv");
                }
                temp_item.SubItems.Add(dat.time);
                //listView1.Items[temp_count].SubItems.Add(dat.time);
                temp_item.SubItems.Add(dat.bytebuffer.Length.ToString());
                //listView1.Items[temp_count].SubItems.Add(dat.bytebuffer.Length.ToString());
                if (dat.type == 1)//cli
                {
                    int temp_id = 0;
                    if (dat.bytebuffer.Length > 3)
                    {
                        if (dat.bytebuffer[0] < 0xd0)
                        {
                            temp_item.SubItems.Add(Globals.pck_thread.new_get_client_pck_name(dat.bytebuffer[0]));
                            //listView1.Items[temp_count].SubItems.Add(Globals.pck_thread.new_get_client_pck_name(dat.bytebuffer[0]));
                        }
                        else
                        {
                            for (int i = 0; i < 3; i++)
                            {
                                temp_id += dat.bytebuffer[i];
                            }
                            temp_item.SubItems.Add(Globals.pck_thread.new_get_client_pck_name(temp_id));
                            // listView1.Items[temp_count].SubItems.Add(Globals.pck_thread.new_get_client_pck_name(temp_id));
                        }
                    }
                    else
                    {
                        if (dat.bytebuffer[0] < 0xd0)
                        {
                            temp_item.SubItems.Add(Globals.pck_thread.new_get_client_pck_name(dat.bytebuffer[0]));
                            // listView1.Items[temp_count].SubItems.Add(Globals.pck_thread.new_get_client_pck_name(dat.bytebuffer[0]));
                        }
                        else
                        {
                            for (int i = 0; i < dat.bytebuffer.Length; i++)
                            {
                                temp_id += dat.bytebuffer[i];
                            }
                            temp_item.SubItems.Add(Globals.pck_thread.new_get_client_pck_name(temp_id));
                            // listView1.Items[temp_count].SubItems.Add(Globals.pck_thread.new_get_client_pck_name(temp_id));
                        }
                    }
                    //listView1.Items[temp_count].SubItems.Add(Globals.pck_thread.new_get_client_pck_name(dat.bytebuffer));
                    string pck_id;
                    if (dat.bytebuffer[0] == 0xd0)
                    {
                        pck_id  = dat.bytebuffer[0].ToString("X2");
                        pck_id += ":";
                        pck_id += dat.bytebuffer[1].ToString("X2");
                        pck_id += dat.bytebuffer[2].ToString("X2");
                    }
                    else
                    {
                        pck_id = dat.bytebuffer[0].ToString("X2");
                    }
                    temp_item.SubItems.Add(pck_id);
                    //listView1.Items[temp_count].SubItems.Add(pck_id);
                    temp_item.BackColor = System.Drawing.Color.LightSeaGreen;
                    //listView1.Items[temp_count].BackColor = System.Drawing.Color.LightSeaGreen;
                    //
                }
                else//srv
                {
                    int temp_id = 0;
                    if (dat.bytebuffer.Length > 3)
                    {
                        if (dat.bytebuffer[0] < 0xfe)
                        {
                            temp_item.SubItems.Add(Globals.pck_thread.new_get_server_pck_name(dat.bytebuffer[0]));
                            // listView1.Items[temp_count].SubItems.Add(Globals.pck_thread.new_get_server_pck_name(dat.bytebuffer[0]));
                        }
                        else
                        {
                            for (int i = 0; i < 3; i++)
                            {
                                temp_id += dat.bytebuffer[i];
                            }
                            temp_item.SubItems.Add(Globals.pck_thread.new_get_server_pck_name(temp_id));
                            // listView1.Items[temp_count].SubItems.Add(Globals.pck_thread.new_get_server_pck_name(temp_id));
                        }
                    }
                    else
                    {
                        if (dat.bytebuffer[0] < 0xfe)
                        {
                            temp_item.SubItems.Add(Globals.pck_thread.new_get_server_pck_name(dat.bytebuffer[0]));
                            // listView1.Items[temp_count].SubItems.Add(Globals.pck_thread.new_get_server_pck_name(dat.bytebuffer[0]));
                        }
                        else
                        {
                            for (int i = 0; i < dat.bytebuffer.Length; i++)
                            {
                                temp_id += dat.bytebuffer[i];
                            }
                            temp_item.SubItems.Add(Globals.pck_thread.new_get_server_pck_name(temp_id));
                            //listView1.Items[temp_count].SubItems.Add(Globals.pck_thread.new_get_server_pck_name(temp_id));
                        }
                    }
                    //listView1.Items[temp_count].SubItems.Add(Globals.pck_thread.get_srv_pck_name(dat.bytebuffer));
                    string pck_id;
                    if (dat.bytebuffer[0] == 0xfe)
                    {
                        pck_id  = dat.bytebuffer[0].ToString("X2");
                        pck_id += ":";
                        pck_id += dat.bytebuffer[1].ToString("X2");
                        pck_id += dat.bytebuffer[2].ToString("X2");
                    }
                    else
                    {
                        pck_id = dat.bytebuffer[0].ToString("X2");
                    }
                    temp_item.SubItems.Add(pck_id);
                    //listView1.Items[temp_count].SubItems.Add(pck_id);
                    temp_item.BackColor = System.Drawing.Color.Yellow;
                    //listView1.Items[temp_count].BackColor = System.Drawing.Color.Yellow;
                }

                Globals.pck_thread.temp_cache_for_pck_window.Add(temp_item);
            }

            catch
            {
                // error ...ListViewNF
            }
        }
Ejemplo n.º 35
0
           private void search_up_by_name(pck_window_dat tmp_dat)
           {
               try
               {
                   string txt_from_box = "";
                   txt_from_box = tmp_dat.time.Replace(" ", ""); // removing spaces
                   txt_from_box = txt_from_box.Replace(":", ""); // removing :
                   txt_from_box = txt_from_box.Replace("[", ""); // removing [
                   txt_from_box = txt_from_box.Replace("]", ""); // removing ]
                   txt_from_box = txt_from_box.ToLower();
                   int index_start = Globals.pck_thread.pck_window.ret_select();
                   index_start--;
                   if (index_start != -1)
                   {
                       if (tmp_dat.type == 1) // search clients packets
                       {
                           if (Globals.pck_thread.filter_wind_pck == true)
                           {
                               int temp_id = 0;
                               for (int i = index_start; i >= 0; i--)
                               {
                                   if (Globals.pck_thread.pck_record[Globals.pck_thread.filtered_pck[i]].type == 1)
                                   {
                                       if (Globals.pck_thread.pck_record[Globals.pck_thread.filtered_pck[i]].bytebuffer[0] < 0xd0)
                                       {
                                           temp_id = Globals.pck_thread.pck_record[Globals.pck_thread.filtered_pck[i]].bytebuffer[0];
                                       }
                                       else
                                       {
                                           if (Globals.pck_thread.pck_record[Globals.pck_thread.filtered_pck[i]].bytebuffer.Length > 3)
                                           {
                                               for (int j = 0; j < 3; j++)
                                               {
                                                   temp_id += Globals.pck_thread.pck_record[Globals.pck_thread.filtered_pck[i]].bytebuffer[j];
                                               }
                                           }
                                       }

                                       string tmp_name = new_get_client_pck_name(temp_id).ToLower();
                                       if (tmp_name.Contains(tmp_dat.time))
                                       {
                                           Globals.pck_thread.pck_window.selectitem(i);
                                           return;
                                       }
                                       /*
                                       if (tmp_dat.time.Length < tmp_name.Length)
                                       {
                                           int par_count = tmp_dat.time.Length;
                                           for (int j = 0; j < tmp_dat.time.Length; j++)
                                           {
                                               if (tmp_dat.time[j] == tmp_name[j])
                                               {
                                                   par_count--;
                                               }
                                           }
                                           if (par_count == 0)
                                           {
                                               Globals.pck_thread.pck_window.selectitem(i);
                                               return;
                                           }
                                       }
                                        */
                                   }
                               }
                           }
                           else
                           {
                               int temp_id = 0;
                               for (int i = index_start; i >= 0; i--)
                               {
                                   if (Globals.pck_thread.pck_record[i].type == 1)
                                   {
                                       if (Globals.pck_thread.pck_record[i].bytebuffer[0] < 0xd0)
                                       {
                                           temp_id = Globals.pck_thread.pck_record[i].bytebuffer[0];
                                       }
                                       else
                                       {
                                           if (Globals.pck_thread.pck_record[i].bytebuffer.Length > 3)
                                           {
                                               for (int j = 0; j < 3; j++)
                                               {
                                                   temp_id += Globals.pck_thread.pck_record[i].bytebuffer[j];
                                               }
                                           }
                                       }
                                       string tmp_name = new_get_client_pck_name(temp_id).ToLower();
                                       if (tmp_name.Contains(tmp_dat.time))
                                       {
                                           Globals.pck_thread.pck_window.selectitem(i);
                                           return;
                                       }
                                       /*
                                       if (tmp_dat.time.Length < tmp_name.Length)
                                       {
                                           int par_count = tmp_dat.time.Length;
                                           for (int j = 0; j < tmp_dat.time.Length; j++)
                                           {
                                               if (tmp_dat.time[j] == tmp_name[j])
                                               {
                                                   par_count--;
                                               }
                                           }
                                           if (par_count == 0)
                                           {
                                               Globals.pck_thread.pck_window.selectitem(i);
                                               return;
                                           }
                                       }

                                        */
                                   }// if cli
                               }//for
                               // string tmp_name= new_get_client_pck_name();
                           }
                       }
                       else//server
                       {
                           if (Globals.pck_thread.filter_wind_pck == true)
                           {
                               int temp_id = 0;
                               for (int i = index_start; i >= 0; i--)
                               {
                                   if (Globals.pck_thread.pck_record[Globals.pck_thread.filtered_pck[i]].type == 2)
                                   {
                                       if (Globals.pck_thread.pck_record[Globals.pck_thread.filtered_pck[i]].bytebuffer[0] < 0xfe)
                                       {
                                           temp_id = Globals.pck_thread.pck_record[Globals.pck_thread.filtered_pck[i]].bytebuffer[0];
                                       }
                                       else
                                       {
                                           if (Globals.pck_thread.pck_record[Globals.pck_thread.filtered_pck[i]].bytebuffer.Length > 3)
                                           {
                                               for (int j = 0; j < 3; j++)
                                               {
                                                   temp_id += Globals.pck_thread.pck_record[Globals.pck_thread.filtered_pck[i]].bytebuffer[j];
                                               }
                                           }
                                       }

                                       string tmp_name = new_get_server_pck_name(temp_id).ToLower();
                                       if (tmp_name.Contains(tmp_dat.time))
                                       {
                                           Globals.pck_thread.pck_window.selectitem(i);
                                           return;
                                       }
                                       /*
                                       if (tmp_dat.time.Length < tmp_name.Length)
                                       {
                                           int par_count = tmp_dat.time.Length;
                                           for (int j = 0; j < tmp_dat.time.Length; j++)
                                           {
                                               if (tmp_dat.time[j] == tmp_name[j])
                                               {
                                                   par_count--;
                                               }
                                           }
                                           if (par_count == 0)
                                           {
                                               Globals.pck_thread.pck_window.selectitem(i);
                                               return;
                                           }
                                       }
                                        */
                                   }
                               }

                           }
                           else
                           {
                               int temp_id = 0;
                               for (int i = index_start; i >= 0; i--)
                               {
                                   if (Globals.pck_thread.pck_record[i].type == 2)
                                   {
                                       if (Globals.pck_thread.pck_record[i].bytebuffer[0] < 0xfe)
                                       {
                                           temp_id = Globals.pck_thread.pck_record[i].bytebuffer[0];
                                       }
                                       else
                                       {
                                           if (Globals.pck_thread.pck_record[i].bytebuffer.Length > 3)
                                           {
                                               for (int j = 0; j < 3; j++)
                                               {
                                                   temp_id += Globals.pck_thread.pck_record[i].bytebuffer[j];
                                               }
                                           }
                                       }
                                       string tmp_name = new_get_server_pck_name(temp_id).ToLower();
                                       if (tmp_name.Contains(tmp_dat.time))
                                       {
                                           Globals.pck_thread.pck_window.selectitem(i);
                                           return;
                                       }
                                       /*
                                       if (tmp_dat.time.Length < tmp_name.Length)
                                       {
                                           int par_count = tmp_dat.time.Length;
                                           for (int j = 0; j < tmp_dat.time.Length; j++)
                                           {
                                               if (tmp_dat.time[j] == tmp_name[j])
                                               {
                                                   par_count--;
                                               }
                                           }
                                           if (par_count == 0)
                                           {
                                               Globals.pck_thread.pck_window.selectitem(i);
                                               return;
                                           }
                                       }
                                        */
                                   }
                               }
                           }
                       }// type

                   }
               }
               catch
               {
                   // qwert
               }
           }