Esempio n. 1
0
        private void _sharedTradeDataProcess(OldPacket pkt, TradeUpdateEvent handler)
        {
            if (handler == null)
            {
                return;
            }

            short player1ID = pkt.GetShort();
            List <InventoryItem> player1Items = new List <InventoryItem>();

            while (pkt.PeekByte() != 255)
            {
                player1Items.Add(new InventoryItem(pkt.GetShort(), pkt.GetInt()));
            }
            pkt.Skip(1);

            short player2ID = pkt.GetShort();
            List <InventoryItem> player2Items = new List <InventoryItem>();

            while (pkt.PeekByte() != 255)
            {
                player2Items.Add(new InventoryItem(pkt.GetShort(), pkt.GetInt()));
            }
            pkt.Skip(1);

            handler(player1ID, player1Items, player2ID, player2Items);
        }
Esempio n. 2
0
        private void btnImportMultis_Click(object sender, EventArgs e)
        {
            string inp = Microsoft.VisualBasic.Interaction.InputBox("Paste the raw, colon-delimited packet data here: ", "Enter packet data");

            if (inp.Length == 0)
            {
                return;
            }

            inp = inp.Replace(":", "");
            if (inp.Length % 2 != 0)
            {
                return;
            }
            inp = inp.Substring(4);
            byte[] data = new byte[inp.Length / 2];
            for (int i = 0; i < inp.Length; i += 2)
            {
                data[i / 2] = Convert.ToByte(inp.Substring(i, 2), 16);
            }

            //no need to decrypt since it's init data
            OldPacket pkt = new OldPacket(data);

            pkt.Skip(3);
            txtDMulti.Text = pkt.GetByte().ToString();
            txtEMulti.Text = pkt.GetByte().ToString();
            _packetProcessActions.SetEncodeMultiples(pkt.Get()[5], pkt.Get()[6]);
        }
Esempio n. 3
0
        //this is only ever sent to MainPlayer (avatar handles other players)
        private void _handlePaperdollRemove(OldPacket pkt)
        {
            if (OnPlayerPaperdollChange == null)
            {
                return;
            }

            //the $strip command does this wrong (adding 0's in), somehow the original client is smart enough to figure it out
            //normally would put this block in the _handleAvatarAgree
            short      playerID = pkt.GetShort();
            AvatarSlot slot     = (AvatarSlot)pkt.GetChar();
            bool       sound    = pkt.GetChar() == 0; //sound : 0

            short boots = pkt.GetShort();

            if (pkt.Length != 45)
            {
                pkt.Skip(sizeof(short) * 3);                   //three 0s
            }
            short armor = pkt.GetShort();

            if (pkt.Length != 45)
            {
                pkt.Skip(sizeof(short));                   // one 0
            }
            short hat = pkt.GetShort();
            short shield, weapon;

            if (pkt.Length != 45)
            {
                shield = pkt.GetShort();
                weapon = pkt.GetShort();
            }
            else
            {
                weapon = pkt.GetShort();
                shield = pkt.GetShort();
            }

            AvatarData renderData = new AvatarData(playerID, slot, sound, boots, armor, hat, weapon, shield);
            //if (OnPlayerAvatarChange != null) //see PlayerAvatarChangeHandler
            //    OnPlayerAvatarChange(renderData);

            PaperdollEquipData data = new PaperdollEquipData(pkt, true);

            OnPlayerPaperdollChange(data);
        }
Esempio n. 4
0
        private void _handleTradeRequest(OldPacket pkt)
        {
            pkt.Skip(1); //something - will always be 123 from this client
            short  playerID = pkt.GetShort();
            string name     = pkt.GetEndString();

            if (OnTradeRequested != null)
            {
                OnTradeRequested(playerID, name);
            }
        }
Esempio n. 5
0
        internal CharacterData(OldPacket pkt)
        {
            m_name = pkt.GetBreakString();
            if (m_name.Length > 1)
            {
                m_name = char.ToUpper(m_name[0]) + m_name.Substring(1);
            }

            m_id  = pkt.GetShort();
            m_map = pkt.GetShort();
            m_x   = pkt.GetShort();
            m_y   = pkt.GetShort();

            m_facing = (EODirection)pkt.GetChar();
            pkt.GetChar(); //value is always 6? unknown
            m_guildTag = pkt.GetFixedString(3);

            m_level     = pkt.GetChar();
            m_gender    = pkt.GetChar();
            m_hairstyle = pkt.GetChar();
            m_haircolor = pkt.GetChar();
            m_race      = pkt.GetChar();

            m_maxhp = pkt.GetShort();
            m_hp    = pkt.GetShort();
            m_maxtp = pkt.GetShort();
            m_tp    = pkt.GetShort();

            m_boots = pkt.GetShort();
            pkt.Skip(3 * sizeof(short)); //other paperdoll data is 0'd out
            m_armor = pkt.GetShort();
            pkt.Skip(sizeof(short));
            m_hat    = pkt.GetShort();
            m_shield = pkt.GetShort();
            m_weapon = pkt.GetShort();

            m_sit    = (SitState)pkt.GetChar();
            m_hidden = pkt.GetChar() != 0;
        }
Esempio n. 6
0
        public override void OnInstalled()
        {
            while (!this.Initialized)
            {
                foreach (var window in OpenWindowGetter.GetOpenWindows())
                {
                    var handle = window.Key;
                    var title  = window.Value;

                    if (title.StartsWith("Endless Online"))
                    {
                        this.Initialized = true;

                        this.EndlessHandle = handle;
                        this.EndlessTitle  = title;
                    }
                }

                Thread.Sleep(100);
            }

            this.EOPacketManager = new EOPacketManager(this);
            this.NetworkDetour   = new NetworkDetour().Install(PacketChannel.Send | PacketChannel.WSARecv, new InterceptCallback((packet) => {
                if (packet.Destination.Port == 8076 || packet.Destination.Port == 0)
                {
                    return(new InterceptResponse(false));
                }

                if (!this.EOPacketInit)
                {
                    if (packet.Channel == PacketChannel.WSARecv)
                    {
                        var decode = new OldPacket(packet.Buffer.Skip(2));

                        if (decode.Family != PacketFamily.Init || decode.Action != PacketAction.Init)
                        {
                            return(new InterceptResponse(false));
                        }

                        this.EOPacketInit = true;
                        decode.Skip(3);

                        this.EOPacketManager.SetMultiples(decode.GetByte(), decode.GetByte());
                    }

                    return(new InterceptResponse(false));
                }

                var channel = packet.Channel == PacketChannel.Send ? EOPacketChannel.Send : EOPacketChannel.Receive;
                this.EOPacketManager.HandlePacket(channel, packet.Buffer.Skip(2));

                return(new InterceptResponse(false));
            }));

            Thread.Sleep(1000);

            EasyTimer.SetInterval(() => {
                if (this.IsMovingWindow)
                {
                    RepositionMarketWindow();
                }
            }, 16);

            EasyTimer.SetInterval(() => {
                if (Program.Market.Visible)
                {
                    SetWindowPos(Program.Market.Handle, HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS);
                    RepositionMarketWindow();
                }
            }, 5000);

            Program.Market.Load += (s, e) => {
                var threadId = GetWindowThreadProcessId(this.EndlessHandle, out var processId);
                this.CBTCallback = this.CBT_Callback;
                this.CBTHook     = SetWindowsHookEx(HookType.WH_CBT, CBTCallback, instancePtr: IntPtr.Zero, threadID: threadId);

                SetWindowPos(Program.Market.Handle, HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS);
                RepositionMarketWindow();
            };

            Program.Market.Shown += (s, e) => {
                SetWindowPos(Program.Market.Handle, HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS);
                RepositionMarketWindow();
            };

            Program.Market.VisibleChanged += (s, e) => {
                if (Program.Market.Visible)
                {
                    SetWindowPos(Program.Market.Handle, HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS);
                    RepositionMarketWindow();
                }
            };

            Program.Market.Hide();
            Application.EnableVisualStyles();

            new Thread(() => {
                Application.Run();
            }).Start();
        }