Beispiel #1
0
        private void SendPacket(byte pktId, BnetPacket packet)
        {
            System.Diagnostics.Debug.WriteLine("BNET C->S {0:X} {1}", pktId, botAccount.AccountName);

            byte[] packetData = packet.GetBuffer(pktId);

            Send(packetData);
            packet.Dispose();
        }
        private void SendPacket(byte pktId, BnetPacket packet)
        {
            System.Diagnostics.Debug.WriteLine("BNET C->S {0:X} {1}", pktId, botAccount.AccountName);

            byte[] packetData = packet.GetBuffer(pktId);

            Send(packetData);
            packet.Dispose();
        }
Beispiel #3
0
        protected override void Connected()
        {
            base.Connected();

            DispatcherHelper.CheckBeginInvokeOnUI(() =>
            {
                BnetEvent b = new BnetEvent();
                b.EventId   = 0x19;
                b.Username  = string.Empty;
                b.Message   = "Connected to Battle.net.";

                Messenger.Default.Send <BnetEvent>(b, connectionToken);

                // Build 0x50
                BnetPacket bntPkt = new BnetPacket();
                bntPkt.InsertInt32(0x00);
                bntPkt.InsertInt32(0x49583836);

                if (botAccount.Product == BnetProduct.Starcraft)
                {
                    bntPkt.InsertBytes(System.Text.Encoding.UTF8.GetBytes("RATS"));
                }
                else if (botAccount.Product == BnetProduct.BroodWar)
                {
                    bntPkt.InsertBytes(System.Text.Encoding.UTF8.GetBytes("PXES"));
                }
                else if (botAccount.Product == BnetProduct.Warcraft2)
                {
                    bntPkt.InsertBytes(System.Text.Encoding.UTF8.GetBytes("NB2W"));
                }
                else if (botAccount.Product == BnetProduct.Diablo2)
                {
                    bntPkt.InsertBytes(System.Text.Encoding.UTF8.GetBytes("VD2D"));
                }
                else if (botAccount.Product == BnetProduct.Warcraft3)
                {
                    bntPkt.InsertBytes(System.Text.Encoding.UTF8.GetBytes("3RAW"));
                }

                if (ViewModelLocator.MainWindowViewModelStatic.AccountsModel.VersionBytes.ContainsKey(botAccount.Product))
                {
                    bntPkt.InsertInt32(ViewModelLocator.MainWindowViewModelStatic.AccountsModel.VersionBytes[botAccount.Product]);
                }
                else
                {
                    // Insert 0x00 just so that we don't have an invalid packet structure .. but we know we'll need to reconnect.
                    if (botAccount.Product == BnetProduct.Starcraft || botAccount.Product == BnetProduct.BroodWar)
                    {
                        bntPkt.InsertInt32(0xD3);
                    }
                    else if (botAccount.Product == BnetProduct.Diablo2 || botAccount.Product == BnetProduct.LordOfDest)
                    {
                        bntPkt.InsertInt32(0x0D);
                    }
                    else if (botAccount.Product == BnetProduct.Warcraft2)
                    {
                        bntPkt.InsertInt32(0x4F);
                    }
                    else if (botAccount.Product == BnetProduct.Warcraft3 || botAccount.Product == BnetProduct.FrozenThrone)
                    {
                        bntPkt.InsertInt32(0x13);
                    }
                }

                bntPkt.InsertInt32(0x00);
                bntPkt.InsertInt32(0x00);
                bntPkt.InsertInt32(0x00);
                bntPkt.InsertInt32(0x00);
                bntPkt.InsertInt32(0x00);
                bntPkt.InsertString("USA");
                bntPkt.InsertString("United States");

                using (DataBuffer sendProtocolBuffer = new DataBuffer())
                {
                    sendProtocolBuffer.InsertByte(0x01);     // Protocol ID
                    sendProtocolBuffer.InsertBytes(bntPkt.GetBuffer(0x50));

                    Send(sendProtocolBuffer.GetBuffer());
                    bntPkt.Dispose();
                }

                Receive(4, null);
            });
        }
        protected override void Connected()
        {
            base.Connected();

            DispatcherHelper.CheckBeginInvokeOnUI(() =>
                {
                    BnetEvent b = new BnetEvent();
                    b.EventId = 0x19;
                    b.Username = string.Empty;
                    b.Message = "Connected to Battle.net.";

                    Messenger.Default.Send<BnetEvent>(b, connectionToken);

                    // Build 0x50
                    BnetPacket bntPkt = new BnetPacket();
                    bntPkt.InsertInt32(0x00);
                    bntPkt.InsertInt32(0x49583836);

                    if (botAccount.Product == BnetProduct.Starcraft)
                        bntPkt.InsertBytes(System.Text.Encoding.UTF8.GetBytes("RATS"));
                    else if (botAccount.Product == BnetProduct.BroodWar)
                        bntPkt.InsertBytes(System.Text.Encoding.UTF8.GetBytes("PXES"));
                    else if (botAccount.Product == BnetProduct.Warcraft2)
                        bntPkt.InsertBytes(System.Text.Encoding.UTF8.GetBytes("NB2W"));
                    else if (botAccount.Product == BnetProduct.Diablo2)
                        bntPkt.InsertBytes(System.Text.Encoding.UTF8.GetBytes("VD2D"));
                    else if (botAccount.Product == BnetProduct.Warcraft3)
                        bntPkt.InsertBytes(System.Text.Encoding.UTF8.GetBytes("3RAW"));

                    if (ViewModelLocator.MainWindowViewModelStatic.AccountsModel.VersionBytes.ContainsKey(botAccount.Product))
                    {
                        bntPkt.InsertInt32(ViewModelLocator.MainWindowViewModelStatic.AccountsModel.VersionBytes[botAccount.Product]);
                    }
                    else
                    {
                        // Insert 0x00 just so that we don't have an invalid packet structure .. but we know we'll need to reconnect.
                        if (botAccount.Product == BnetProduct.Starcraft || botAccount.Product == BnetProduct.BroodWar)
                            bntPkt.InsertInt32(0xD3);
                        else if (botAccount.Product == BnetProduct.Diablo2 || botAccount.Product == BnetProduct.LordOfDest)
                            bntPkt.InsertInt32(0x0D);
                        else if (botAccount.Product == BnetProduct.Warcraft2)
                            bntPkt.InsertInt32(0x4F);
                        else if (botAccount.Product == BnetProduct.Warcraft3 || botAccount.Product == BnetProduct.FrozenThrone)
                            bntPkt.InsertInt32(0x13);
                    }

                    bntPkt.InsertInt32(0x00);
                    bntPkt.InsertInt32(0x00);
                    bntPkt.InsertInt32(0x00);
                    bntPkt.InsertInt32(0x00);
                    bntPkt.InsertInt32(0x00);
                    bntPkt.InsertString("USA");
                    bntPkt.InsertString("United States");

                    using (DataBuffer sendProtocolBuffer = new DataBuffer())
                    {
                        sendProtocolBuffer.InsertByte(0x01); // Protocol ID
                        sendProtocolBuffer.InsertBytes(bntPkt.GetBuffer(0x50));

                        Send(sendProtocolBuffer.GetBuffer());
                        bntPkt.Dispose();
                    }

                    Receive(4, null);
                });
        }