Exemple #1
0
        public static void HandleUpdateNotify(BattlenetPacket packet)
        {
            packet.ReadSkip(6);
            packet.Read<uint>("IdMaster", 0, 32);
            packet.ReadSkip(6);
            var count = packet.Read<int>(0, 4);
            for (var i = 0; i < count; ++i)
                packet.Read<uint>("Handle", 0, 32, "Update", "HandlesCleared", i);

            count = packet.Read<int>(0, 4);
            var varSizes = new Queue<ushort>();
            for (var i = 0; i < count; ++i)
                varSizes.Enqueue(packet.Read<ushort>(0, 16));

            count = packet.Read<int>(0, 4);
            var handles = new List<uint>();
            for (var i = 0; i < count; ++i)
                handles.Add(packet.Read<uint>(0, 32));

            var data = packet.ReadBytes(packet.Read<int>(0, 11));
            HandleUpdateNotifyFields(packet.Stream, handles, data, varSizes);

            if (packet.ReadBoolean())
            {
                packet.Read<uint>("Target", 0, 32, "Level0");
                packet.ReadBoolean("IsLastPacket", "Level0");
            }

            packet.ReadBoolean("ServerOnly");
            packet.Read<byte>("Online", 0, 8);
            packet.Read<uint>("IdLocal", 0, 32);
        }
Exemple #2
0
        public static void HandleFieldSpecAnnounce(BattlenetPacket packet)
        {
            _fields.Clear();

            var fields = packet.Read <int>(0, 7);

            for (var i = 0; i < fields; ++i)
            {
                var field = new FieldInfo();

                packet.ReadBoolean("Writable", i, "Spec");
                packet.ReadBoolean("ServerOnly", i, "Spec");
                packet.ReadBoolean("Ephemeral", i, "Spec");
                field.VariableLength = packet.ReadBoolean("Variable", i, "Spec", "Size");
                if (!field.VariableLength)
                {
                    field.FixedLength = packet.Read <ushort>("Fixed", 0, 16, i, "Spec", "Size");
                }

                field.FieldType = packet.Read <PresenceFieldType>("Id", 0, 8, i, "Spec");
                packet.ReadBoolean("ClientOnly", i, "Spec");
                var handle = packet.Read <uint>("Handle", 0, 32, i);

                _fields.Add(handle, field);
            }
        }
Exemple #3
0
        public static void HandleJoinResponse(BattlenetPacket packet)
        {
            if (packet.ReadBoolean())
            {
                packet.Read<WowAuthResult>("Failure", 0, 8);
                return;
            }

            packet.Read<uint>("ServerSalt", 0, 32);
            var count = packet.Read<uint>(0, 5);
            for (var i = 0; i < count; ++i)
            {
                var ip = packet.ReadBytes(4);
                var port = packet.ReadBytes(2);

                Array.Reverse(port);

                packet.Stream.AddValue("Address", new IPEndPoint(new IPAddress(ip), BitConverter.ToUInt16(port, 0)), "v4", i);
            }

            count = packet.Read<uint>(0, 5);
            for (var i = 0; i < count; ++i)
            {
                var ip = packet.ReadBytes(16);
                var port = packet.ReadBytes(2);

                Array.Reverse(port);

                packet.Stream.AddValue("Address", new IPEndPoint(new IPAddress(ip), BitConverter.ToUInt16(port, 0)), "v6", i);
            }
        }
        public static void HandleServerRealmUpdate(BattlenetPacket packet)
        {
            if (packet.Read <bool>(1))
            {
                packet.Read <uint>("Timezone", 32);
                packet.ReadSingle("Population");
                packet.Read <byte>("Lock", 8);
                packet.Read <uint>("Unk", 19);
                packet.Stream.AddValue("Type", packet.Read <uint>(32) + int.MinValue);
                packet.ReadString("Name", packet.Read <int>(10));
                if (packet.Read <bool>("Has version", 1))
                {
                    packet.ReadString("Version", packet.Read <int>(5));
                    packet.Read <uint>("RealmId4", 32);

                    var ip   = packet.ReadBytes(4);
                    var port = packet.ReadBytes(2);

                    Array.Reverse(port);

                    packet.Stream.AddValue("IP address", new IPAddress(ip));
                    packet.Stream.AddValue("Port", BitConverter.ToUInt16(port, 0));
                }

                packet.Read <byte>("Flags", 8);
            }

            packet.Read <byte>("Region", 8);
            packet.Read <short>("Unk2", 12);
            packet.Read <byte>("Battlegroup", 8);
            packet.Read <uint>("Battlegroup index", 32);
        }
Exemple #5
0
        public static void HandleListUpdate(BattlenetPacket packet)
        {
            if (packet.ReadBoolean())
            {
                packet.Read <uint>("Category", 0, 32);
                packet.ReadSingle("Population");
                packet.Read <byte>("StateFlags", 0, 8);
                packet.ReadSkip(19);
                packet.Read <uint>("Type", int.MinValue, 32);
                packet.ReadString("Name", 0, 10);
                if (packet.ReadBoolean())
                {
                    packet.ReadString("Version", 0, 5, "PrivilegedData");
                    packet.Read <uint>("ConfigId", 0, 32, "PrivilegedData");

                    var ip   = packet.ReadBytes(4);
                    var port = packet.ReadBytes(2);

                    Array.Reverse(port);

                    packet.Stream.AddValue("Address", new IPEndPoint(new IPAddress(ip), BitConverter.ToUInt16(port, 0)), "PrivilegedData");
                }

                packet.Read <RealmInfoFlags>("InfoFlags", 0, 8);
            }

            packet.Read <byte>("Region", 0, 8);
            packet.ReadSkip(12);
            packet.Read <byte>("Site", 0, 8);
            packet.Read <uint>("Realm", 0, 32);
        }
        public static void ParseBattlenet(Packet packet)
        {
            try
            {
                var bnetPacket = new BattlenetPacket(packet);
                Action<BattlenetPacket> handler;

                bnetPacket.Stream.WriteLine(bnetPacket.GetHeader());

                if (BattlenetHandlers.TryGetValue(bnetPacket.Header, out handler))
                {
                    handler(bnetPacket);
                    packet.Status = ParsedStatus.Success;
                }
                else
                {
                    packet.AsHex();
                    packet.Status = ParsedStatus.NotParsed;
                }
            }
            catch (Exception ex)
            {
                packet.WriteLine(ex.GetType().ToString());
                packet.WriteLine(ex.Message);
                packet.WriteLine(ex.StackTrace);

                packet.Status = ParsedStatus.WithErrors;
            }
        }
        public static void HandleServerProofRequest(BattlenetPacket packet)
        {
            var modules = packet.Read <byte>(3);
            var module  = new BattlenetModuleHandler(packet);

            for (var i = 0; i < modules; ++i)
            {
                packet.ReadString("Type", 4, i);
                packet.ReadFourCC("Region", i);
                var id = Utilities.ByteArrayToHexString(packet.ReadBytes(32));
                packet.Stream.WriteLine(string.Format("[{0}] ModuleId: {1}", i, id));
                var dataSize = packet.Read <int>("Data size", 10, i);
                var data     = packet.ReadBytes(dataSize);

                var result = module.HandleData(id, data, i);
                if (!result.HasValue)
                {
                    packet.Stream.WriteLine(string.Format("[{0}] Data: {1}", i, Utilities.ByteArrayToHexString(data)));
                }
                else if (!result.Value)
                {
                    ModulesWaitingForData.Add(id);
                }
            }
        }
        public static void HandleJoinResponse(BattlenetPacket packet)
        {
            if (packet.Read <bool>("Failed", 1))
            {
                packet.Read <byte>("Error code", 8);
                return;
            }

            packet.Read <uint>("Server salt", 32);
            var count = packet.Read <uint>("IPv4 count", 5);

            for (var i = 0; i < count; ++i)
            {
                var ip   = packet.ReadBytes(4);
                var port = packet.ReadBytes(2);

                Array.Reverse(port);

                packet.Stream.AddValue("IP address", new IPAddress(ip), i);
                packet.Stream.AddValue("Port", BitConverter.ToUInt16(port, 0), i);
            }

            count = packet.Read <uint>("IPv6 count", 5);
            for (var i = 0; i < count; ++i)
            {
                var ip   = packet.ReadBytes(16);
                var port = packet.ReadBytes(2);

                Array.Reverse(port);

                packet.Stream.AddValue("IP address", new IPAddress(ip), i);
                packet.Stream.AddValue("Port", BitConverter.ToUInt16(port, 0), i);
            }
        }
Exemple #9
0
        public static void HandleJoinResponse(BattlenetPacket packet)
        {
            if (packet.ReadBoolean())
            {
                packet.Read <WowAuthResult>("Failure", 0, 8);
                return;
            }

            packet.Read <uint>("ServerSalt", 0, 32);
            var count = packet.Read <uint>(0, 5);

            for (var i = 0; i < count; ++i)
            {
                var ip   = packet.ReadBytes(4);
                var port = packet.ReadBytes(2);

                Array.Reverse(port);

                packet.Stream.AddValue("Address", new IPEndPoint(new IPAddress(ip), BitConverter.ToUInt16(port, 0)), "v4", i);
            }

            count = packet.Read <uint>(0, 5);
            for (var i = 0; i < count; ++i)
            {
                var ip   = packet.ReadBytes(16);
                var port = packet.ReadBytes(2);

                Array.Reverse(port);

                packet.Stream.AddValue("Address", new IPEndPoint(new IPAddress(ip), BitConverter.ToUInt16(port, 0)), "v6", i);
            }
        }
        public static void HandleLogonRequest3(BattlenetPacket packet)
        {
            ReadRequestCommon(packet, "Common");
            if (packet.ReadBoolean())
                packet.ReadString("Account", 3, 9);

            packet.Read<ulong>("Compatibility", 0, 64);
        }
 public static void HandleJoinRequest(BattlenetPacket packet)
 {
     packet.Read <uint>("Client seed", 32);
     packet.Read <uint>("Checksum?", 20);
     packet.Read <byte>("Region", 8);
     packet.Read <short>("Unk2", 12);
     packet.Read <byte>("Battlegroup", 8);
     packet.Read <uint>("Battlegroup index", 32);
 }
Exemple #12
0
 public static void HandleSettingsAvailable(BattlenetPacket packet)
 {
     packet.Read <byte>(5);   // padding
     packet.Stream.AddValue("Smh", Utilities.ByteArrayToHexString(packet.ReadBytes(packet.Read <int>(6))));
     packet.Read <int>(21);   // padding
     packet.Read <ulong>("Flags", 64);
     packet.Read <uint>("Int", 32);
     packet.Read <byte>("Settings type", 2);
 }
Exemple #13
0
 public static void HandleJoinRequestV2(BattlenetPacket packet)
 {
     packet.Read <uint>("ClientSalt", 0, 32);
     packet.ReadSkip(20);
     packet.Read <byte>("Region", 0, 8);
     packet.ReadSkip(12);
     packet.Read <byte>("Site", 0, 8);
     packet.Read <uint>("Realm", 0, 32);
 }
Exemple #14
0
 public static void HandleJoinRequestV2(BattlenetPacket packet)
 {
     packet.Read<uint>("ClientSalt", 0, 32);
     packet.ReadSkip(20);
     packet.Read<byte>("Region", 0, 8);
     packet.ReadSkip(12);
     packet.Read<byte>("Site", 0, 8);
     packet.Read<uint>("Realm", 0, 32);
 }
 public static void HandleAuthorizedLicenses(BattlenetPacket packet)
 {
     packet.ReadBoolean("Persistent");
     var licenses = packet.Read<int>(0, 9);
     for (var i = 0; i < licenses; ++i)
     {
         if (packet.ReadBoolean())
             packet.Read<int>("Expiration", int.MinValue, 32);
         packet.Read<uint>("Id", 0, 32);
     }
 }
 public static void HandleGenerateSingleSignOnTokenResponse2(BattlenetPacket packet)
 {
     packet.Read<uint>("Token", 0, 32);
     if (!packet.ReadBoolean())
     {
         packet.ReadByteArray("SsoToken", 0, 9);
         packet.ReadByteArray("SsoId", 0, 10);
     }
     else
         packet.Read<uint>("Error", 0, 16);
 }
Exemple #17
0
        public static void HandleReadRequest(BattlenetPacket packet)
        {
            packet.ReadSkip(21);
            packet.Read<ulong>("Id", 0, 64, "RecordAddress");
            packet.Read<uint>("Label", 0, 32, "RecordAddress");
            packet.Read<uint>("RequestId", 0, 32);
            if (packet.ReadBoolean())
            {
                var profiles = packet.Read<int>(0, 4);
                for (var i = 0; i < profiles; ++i)
                    packet.Read<ulong>("ProfileId", 0, 64, "Specification", "Reader");
            }

            var selection = packet.Read<int>(0, 3);
            switch (selection)
            {
                case 0:
                    packet.ReadByteArray("PrefixPath", 0, 6, "All");
                    break;
                case 1:
                    packet.ReadByteArray("PrefixPath", 0, 6, "Slice");
                    if (packet.ReadBoolean())
                        packet.Read<ulong>("SliceStart", long.MinValue, 64, "Slice");
                    if (packet.ReadBoolean())
                        packet.Read<ulong>("SliceEnd", long.MinValue, 64, "Slice");
                    if (packet.ReadBoolean())
                        packet.Read<uint>("RowLimit", 0, 32, "Slice");
                    if (packet.ReadBoolean())
                        packet.ReadBoolean("SingleDepth", "Slice");
                    break;
                case 2:
                    packet.ReadByteArray("PrefixPath", 0, 6, "Random");
                    var indices = packet.Read<int>(0, 7);
                    for (var i = 0; i < indices; ++i)
                        packet.Read<ulong>("Index", 0, 64, "Random", "Indices");
                    break;
                case 3:
                    var paths = packet.Read<int>(0, 5);
                    for (var i = 0; i < paths; ++i)
                        packet.ReadByteArray("PrefixPath", 0, 6, "MultiPath", "Paths");
                    break;
                case 4:
                    packet.ReadByteArray("PrefixPath", 0, 6, "Range");
                    if (packet.ReadBoolean())
                        packet.Read<ulong>("RangeStart", long.MinValue, 64, "Range");
                    if (packet.ReadBoolean())
                        packet.Read<ulong>("RangeEnd", long.MinValue, 64, "Range");
                    if (packet.ReadBoolean())
                        packet.Read<uint>("RowLimit", 0, 32, "Range");
                    if (packet.ReadBoolean())
                        packet.ReadBoolean("SingleDepth", "Range");
                    break;
            }
        }
Exemple #18
0
 public static void HandleToonReady(BattlenetPacket packet)
 {
     packet.Read <byte>("Region", 0, 8, "Name");
     packet.ReadFourCC("ProgramId", "Name");
     packet.Read <uint>("Realm", 0, 32, "Name");
     packet.ReadString("Name", 2, 7, "Name");
     packet.ReadSkip(21);
     packet.Read <ulong>("Id", 0, 64, "ProfileAddress");
     packet.Read <uint>("Label", 0, 32, "ProfileAddress");
     packet.Read <ulong>("Id", 0, 64, "Handle");
     packet.Read <uint>("Realm", 0, 32, "Handle");
     packet.Read <byte>("Region", 0, 8, "Handle");
     packet.ReadFourCC("ProgramId", "Handle");
 }
Exemple #19
0
        public static void HandleSTUNServers(BattlenetPacket packet)
        {
            var ip = packet.ReadBytes(4);
            var port = packet.ReadBytes(2);
            Array.Reverse(port);

            packet.Stream.AddValue("Server1", new IPEndPoint(new IPAddress(ip), BitConverter.ToUInt16(port, 0)));

            ip = packet.ReadBytes(4);
            port = packet.ReadBytes(2);
            Array.Reverse(port);

            packet.Stream.AddValue("Server2", new IPEndPoint(new IPAddress(ip), BitConverter.ToUInt16(port, 0)));
        }
Exemple #20
0
 public static void HandleGetStreamItemsResponse(BattlenetPacket packet)
 {
     packet.Read<ushort>("Offset", 0, 16);
     packet.Read<ushort>("TotalNumItems", 0, 16);
     packet.Read<uint>("Token", 0, 32);
     var items = packet.Read<byte>(0, 6);
     for (var i = 0; i < items; ++i)
     {
         packet.ReadFixedLengthString("Type", 4, "Items", i);
         packet.ReadFourCC("Region", "Items", i);
         packet.ReadBytes("ModuleId", 32, "Items", i);
         packet.ReadSkip(27);
         packet.Read<uint>("PublicationTime", 0, 32, "Items", i);
     }
 }
Exemple #21
0
 public static void HandleGetStreamItemsRequest(BattlenetPacket packet)
 {
     packet.ReadSkip(31);
     packet.Read<uint>("Token", 0, 32);
     packet.Read<uint>("ReferenceTime", int.MinValue, 32);
     packet.Read<StreamDirection>("Direction", 0, 1);
     packet.Read<byte>("MaxItems", 0, 6);
     packet.ReadFourCC("Locale");
     if (packet.ReadBoolean())
     {
         packet.ReadFourCC("ItemName");
         packet.ReadFourCC("Channel");
     }
     else
         packet.Read<ushort>("Index", 0, 16);
 }
        public static void HandleProofResponse(BattlenetPacket packet)
        {
            var modules = packet.Read <byte>(3);
            var module  = new BattlenetModuleHandler(packet);

            for (var i = 0; i < modules; ++i)
            {
                var dataSize = packet.Read <int>("Data size", 10, i);
                var data     = packet.ReadBytes(dataSize);
                if (!module.HandleData(ModulesWaitingForData[i], data, i).HasValue)
                {
                    packet.Stream.WriteLine(string.Format("[{0}] Data: {1}", i, Utilities.ByteArrayToHexString(data)));
                }
            }

            ModulesWaitingForData.Clear();
        }
Exemple #23
0
        public static void HandleListSubscribeResponse(BattlenetPacket packet)
        {
            if (packet.ReadBoolean())
            {
                packet.Read<WowAuthResult>("Failure", 0, 8);
                return;
            }

            var charNumberCount = packet.Read<int>(0, 7);
            for (var i = 0; i < charNumberCount; ++i)
            {
                packet.Read<byte>("Region", 0, 8, "ToonCountEntry", i);
                packet.ReadSkip(12);
                packet.Read<byte>("Site", 0, 8, "ToonCountEntry", i);
                packet.Read<uint>("Realm", 0, 32, "ToonCountEntry", i);
                packet.Read<short>("Count", 0, 16, "ToonCountEntry", i);
            }
        }
Exemple #24
0
        public static void HandleFieldSpecAnnounce(BattlenetPacket packet)
        {
            _fields.Clear();

            var fields = packet.Read<int>(0, 7);
            for (var i = 0; i < fields; ++i)
            {
                var field = new FieldInfo();

                packet.ReadBoolean("Writable", i, "Spec");
                packet.ReadBoolean("ServerOnly", i, "Spec");
                packet.ReadBoolean("Ephemeral", i, "Spec");
                field.VariableLength = packet.ReadBoolean("Variable", i, "Spec", "Size");
                if (!field.VariableLength)
                    field.FixedLength = packet.Read<ushort>("Fixed", 0, 16, i, "Spec", "Size");

                field.FieldType = packet.Read<PresenceFieldType>("Id", 0, 8, i, "Spec");
                packet.ReadBoolean("ClientOnly", i, "Spec");
                var handle = packet.Read<uint>("Handle", 0, 32, i);

                _fields.Add(handle, field);
            }
        }
Exemple #25
0
        public static void HandleConnectionClosing(BattlenetPacket packet)
        {
            var packets = packet.Read<int>(0, 6);
            for (var i = 0; i < packets; ++i)
            {
                packet.ReadFourCC("Command", i);
                packet.Read<uint>("Time", 0, 32, i);
                packet.Read<ushort>("Size", 0, 16, i);
                packet.ReadFourCC("Layer", 0, 16, i);
                packet.Read<ushort>("Offset", 0, 16, i);
            }

            packet.Read<ClosingReason>("Reason", 0, 4);
            packet.ReadByteArray("BadData", 0, 8);

            if (packet.ReadBoolean())
            {
                packet.Read<ushort>("Command", 0, 6);
                if (packet.ReadBoolean())
                    packet.Read<ushort>("Channel", 0, 4);
            }

            packet.Read<uint>("Now", 0, 32);
        }
 public static void HandleLogonRequest(BattlenetPacket packet)
 {
     ReadRequestCommon(packet, "Common");
     if (packet.ReadBoolean())
         packet.ReadString("Account", 3, 9);
 }
        public static void HandleServerProofRequest(BattlenetPacket packet)
        {
            var modules = packet.Read<byte>(3);
            var module = new BattlenetModuleHandler(packet);
            for (var i = 0; i < modules; ++i)
            {
                packet.ReadString("Type", 4, i);
                packet.ReadFourCC("Region", i);
                var id = Utilities.ByteArrayToHexString(packet.ReadBytes(32));
                packet.Stream.WriteLine(string.Format("[{0}] ModuleId: {1}", i, id));
                var dataSize = packet.Read<int>("Data size", 10, i);
                var data = packet.ReadBytes(dataSize);

                var result = module.HandleData(id, data, i);
                if (!result.HasValue)
                    packet.Stream.WriteLine(string.Format("[{0}] Data: {1}", i, Utilities.ByteArrayToHexString(data)));
                else if (!result.Value)
                    ModulesWaitingForData.Add(id);
            }
        }
 public static void HandleGenerateSingleSignOnTokenRequest2(BattlenetPacket packet)
 {
     packet.Read<uint>("Token", 0, 32);
     if (packet.ReadBoolean())
         packet.ReadFourCC("TargetProgram");
 }
        private static void ReadRequestCommon(BattlenetPacket packet, string fieldName)
        {
            packet.ReadFourCC("Program", fieldName);
            packet.ReadFourCC("Platform", fieldName);
            packet.ReadFourCC("Locale", fieldName);

            var components = packet.Read<int>(0, 6);
            for (var i = 0; i < components; ++i)
            {
                packet.ReadFourCC("ProgramId", fieldName, i, "Versions");
                packet.ReadFourCC("Component", fieldName, i, "Versions");
                packet.Read<uint>("Version", 0, 32, fieldName, i, "Versions");
            }
        }
 public static void HandleSingleSignOnRequest3(BattlenetPacket packet)
 {
     ReadRequestCommon(packet, "Common");
     packet.ReadByteArray("SsoId", 0, 10);
     packet.Read<ulong>("Compatibility", 0, 64);
 }
        public static void HandleServerRealmUpdate(BattlenetPacket packet)
        {
            if (!packet.Read<bool>(1))
                return;

            packet.Read<uint>("Timezone", 32);
            packet.ReadSingle("Population");
            packet.Read<byte>("Lock", 8);
            packet.Read<uint>("Unk", 19);
            packet.Stream.WriteLine(string.Format("Type: {0}", packet.Read<uint>(32) + int.MinValue));
            packet.ReadString("Name", packet.Read<int>(10));
            if (packet.Read<bool>("Has version", 1))
            {
                packet.ReadString("Version", packet.Read<int>(5));
                packet.Read<uint>("RealmId4", 32);

                var ip = packet.ReadBytes(4);
                var port = packet.ReadBytes(2);

                Array.Reverse(port);

                packet.Stream.WriteLine("IP address: {0}", new IPAddress(ip));
                packet.Stream.WriteLine("Port: {0}", BitConverter.ToUInt16(port, 0));
            }

            packet.Read<byte>("Flags", 8);
            packet.Read<byte>("Region", 8);
            packet.Read<short>("Unk2", 12);
            packet.Read<byte>("Battlegroup", 8);
            packet.Read<uint>("Battlegroup index", 32);
        }
        public static void HandleProofResponse(BattlenetPacket packet)
        {
            var modules = packet.Read<byte>(0, 3);
            var module = new BattlenetModuleHandler(packet);
            for (var i = 0; i < modules; ++i)
            {
                var dataSize = packet.Read<int>("Data size", 0, 10, i);
                var data = packet.ReadBytes(dataSize);
                if (!module.HandleData(ModulesWaitingForData[i], data, i).HasValue)
                    packet.Stream.AddValue("Data", data, i);
            }

            ModulesWaitingForData.Clear();
        }
        public static void HandleProofRequest(BattlenetPacket packet)
        {
            var modules = packet.Read<byte>(0, 3);
            var module = new BattlenetModuleHandler(packet);
            for (var i = 0; i < modules; ++i)
            {
                packet.ReadFixedLengthString("Type", 4, i);
                packet.ReadFourCC("Region", i);
                var id = Utilities.ByteArrayToHexString(packet.ReadBytes("ModuleId", 32, i));
                var dataSize = packet.Read<int>("Data size", 0, 10, i);
                var data = packet.ReadBytes(dataSize);

                var result = module.HandleData(id, data, i);
                if (!result.HasValue)
                    packet.Stream.AddValue("Data", data, i);
                else if (!result.Value)
                    ModulesWaitingForData.Add(id);
            }
        }
 public static void HandlePatch(BattlenetPacket packet)
 {
     packet.ReadFourCC("ProgramId");
     packet.ReadFourCC("Component");
     packet.ReadString("Instructions", 0, 8);
     packet.ReadBoolean("More");
 }
Exemple #35
0
 public static void HandleMultiLogonRequestV2(BattlenetPacket packet)
 {
     packet.Read<uint>("ClientSalt", 0, 32);
 }
Exemple #36
0
        public static void HandleListUpdate(BattlenetPacket packet)
        {
            if (packet.ReadBoolean())
            {
                packet.Read<uint>("Category", 0, 32);
                packet.ReadSingle("Population");
                packet.Read<byte>("StateFlags", 0, 8);
                packet.ReadSkip(19);
                packet.Read<uint>("Type", int.MinValue, 32);
                packet.ReadString("Name", 0, 10);
                if (packet.ReadBoolean())
                {
                    packet.ReadString("Version", 0, 5, "PrivilegedData");
                    packet.Read<uint>("ConfigId", 0, 32, "PrivilegedData");

                    var ip = packet.ReadBytes(4);
                    var port = packet.ReadBytes(2);

                    Array.Reverse(port);

                    packet.Stream.AddValue("Address", new IPEndPoint(new IPAddress(ip), BitConverter.ToUInt16(port, 0)), "PrivilegedData");
                }

                packet.Read<RealmInfoFlags>("InfoFlags", 0, 8);
            }

            packet.Read<byte>("Region", 0, 8);
            packet.ReadSkip(12);
            packet.Read<byte>("Site", 0, 8);
            packet.Read<uint>("Realm", 0, 32);
        }
        public static void HandleComplete(BattlenetPacket packet)
        {
            var failed = packet.Read<bool>(1);
            if (failed)
            {
                if (packet.Read<bool>(1)) // has module
                {
                    var type = packet.ReadString(4);
                    var region = packet.ReadFourCC();
                    var id = Utilities.ByteArrayToHexString(packet.ReadBytes(32));
                    var dataSize = packet.Read<int>(10);
                    var data = packet.ReadBytes(dataSize);
                    var module = new BattlenetModuleHandler(packet);

                    packet.Stream.WriteLine(string.Format("Type: {0}", type));
                    packet.Stream.WriteLine(string.Format("Region: {0}", region));
                    packet.Stream.WriteLine(string.Format("ModuleId: {0}", id));
                    packet.Stream.WriteLine(string.Format("Data size: {0}", dataSize));
                    if (!module.HandleData(id, data).HasValue)
                        packet.Stream.WriteLine(string.Format("Data: {0}", Utilities.ByteArrayToHexString(data)));
                }

                var errorType = packet.Read<byte>(2);
                if (errorType == 1)
                {
                    packet.Stream.WriteLine(string.Format("Result: {0}", packet.Read<ushort>(16)));
                    packet.Stream.WriteLine(string.Format("Unk: {0}", packet.Read<uint>(32)));
                }
            }
            else
            {
                var modules = packet.Read<byte>(3);
                var module = new BattlenetModuleHandler(packet);
                for (var i = 0; i < modules; ++i)
                {
                    var type = packet.ReadString(4);
                    var region = packet.ReadFourCC();
                    var id = Utilities.ByteArrayToHexString(packet.ReadBytes(32));
                    var dataSize = packet.Read<int>(10);
                    var data = packet.ReadBytes(dataSize);

                    packet.Stream.WriteLine(string.Format("[{0}] Type: {1}", i, type));
                    packet.Stream.WriteLine(string.Format("[{0}] Region: {1}", i, region));
                    packet.Stream.WriteLine(string.Format("[{0}] ModuleId: {1}", i, id));
                    packet.Stream.WriteLine(string.Format("[{0}] Data size: {1}", i, dataSize));
                    if (!module.HandleData(id, data, i).HasValue)
                        packet.Stream.WriteLine(string.Format("[{0}] Data: {1}", i, Utilities.ByteArrayToHexString(data)));
                }

                packet.Stream.WriteLine(string.Format("Ping timeout: {0}", packet.Read<uint>(32) + int.MinValue));

                var hasOptionalData = packet.Read<bool>(1);
                if (hasOptionalData)
                {
                    var hasConnectionInfo = packet.Read<bool>(1);
                    if (hasConnectionInfo)
                    {
                        packet.Read<uint>("Threshold", 32);
                        packet.Read<uint>("Rate", 32);
                    }
                }

                packet.ReadString("First name", packet.Read<int>(8));
                packet.ReadString("Last name", packet.Read<int>(8));

                packet.Read<uint>("Account id", 32);

                packet.Read<byte>("Unk8", 8);
                packet.Read<ulong>("Unk64", 64);
                packet.Read<byte>("Unk8", 8);

                packet.ReadString("Account name", packet.Read<int>(5) + 1);

                packet.Read<ulong>("Unk64", 64);
                packet.Read<uint>("Unk32", 32);
                if (packet.Read<bool>("Unk1", 1))
                    packet.Stream.WriteLine(string.Format("Data: {0}", Utilities.ByteArrayToHexString(packet.ReadBytes(packet.Read<int>(10)))));
            }
        }
        public static void HandleLogonResponse3(BattlenetPacket packet)
        {
            if (packet.ReadBoolean())
            {
                if (packet.ReadBoolean()) // has module
                {
                    packet.ReadFixedLengthString("Type", 4, "Strings");
                    packet.ReadFourCC("Region", "Strings");
                    var id = Utilities.ByteArrayToHexString(packet.ReadBytes("ModuleId", 32, "Strings"));
                    var dataSize = packet.Read<int>("Data size", 0, 10);
                    var data = packet.ReadBytes(dataSize);
                    var module = new BattlenetModuleHandler(packet);

                    if (!module.HandleData(id, data).HasValue)
                        packet.Stream.AddValue("Data", data, "Strings");
                }

                var errorType = packet.Read<byte>(2, 0);
                if (errorType == 1)
                {
                    packet.Read<ushort>("Error", 0, 16);
                    packet.Read<uint>("Failure", 0, 32);
                }
            }
            else
            {
                var modules = packet.Read<byte>(0, 3);
                var module = new BattlenetModuleHandler(packet);
                for (var i = 0; i < modules; ++i)
                {
                    packet.ReadFixedLengthString("Type", 4, "FinalRequest", i);
                    packet.ReadFourCC("Region", "FinalRequest", i);
                    var id = Utilities.ByteArrayToHexString(packet.ReadBytes("ModuleId", 32, "FinalRequest", i));
                    var dataSize = packet.Read<int>("Data size", 0, 10, i);
                    var data = packet.ReadBytes(dataSize);

                    if (!module.HandleData(id, data, i).HasValue)
                        packet.Stream.AddValue("Data", data, "FinalRequest", i);
                }

                packet.Read<uint>("PingTimeout", int.MinValue, 32);

                if (packet.ReadBoolean())
                    Connection.ReadRegulatorInfo(packet, "RegulatorRules");

                packet.ReadString("GivenName", 0, 8);
                packet.ReadString("Surname", 0, 8);

                packet.Read<uint>("AccountId", 0, 32);
                packet.Read<byte>("Region", 0, 8);
                packet.Read<AccountFlags>("Flags", 0, 64);

                packet.Read<byte>("GameAccountRegion", 0, 8);
                packet.ReadString("GameAccountName", 1, 5);
                packet.Read<GameAccountFlags>("GameAccountFlags", 0, 64);

                packet.Read<uint>("LogonFailures", 0, 32);
                if (packet.ReadBoolean())
                    packet.ReadByteArray("Raf", 0, 10);
            }
        }
 public static void HandleResumeRequest(BattlenetPacket packet)
 {
     ReadRequestCommon(packet, "Common");
     packet.ReadString("Account", 3, 9);
     packet.Read<byte>("GameAccountRegion", 0, 8);
     packet.ReadString("GameAccountName", 1, 5);
 }
Exemple #40
0
 public static void HandleToonReady(BattlenetPacket packet)
 {
     packet.Read<byte>("Region", 0, 8, "Name");
     packet.ReadFourCC("ProgramId", "Name");
     packet.Read<uint>("Realm", 0, 32, "Name");
     packet.ReadString("Name", 2, 7, "Name");
     packet.ReadSkip(21);
     packet.Read<ulong>("Id", 0, 64, "ProfileAddress");
     packet.Read<uint>("Label", 0, 32, "ProfileAddress");
     packet.Read<ulong>("Id", 0, 64, "Handle");
     packet.Read<uint>("Realm", 0, 32, "Handle");
     packet.Read<byte>("Region", 0, 8, "Handle");
     packet.ReadFourCC("ProgramId", "Handle");
 }
Exemple #41
0
 public static void HandleEmpty(BattlenetPacket packet)
 {
 }