Beispiel #1
0
        static void ReadHotfixData(Packet packet, params object[] indexes)
        {
            packet.ResetBitReader();

            var id       = packet.ReadUInt64();
            var hotfixId = packet.AddValue("HotfixID", Utilities.PAIR64_LOPART(id), indexes);
            var type     = packet.AddValue("TableHash", (DB2Hash)Utilities.PAIR64_HIPART(id), indexes);

            var entry = packet.ReadInt32("RecordID", indexes);

            packet.ResetBitReader();
            var allow    = packet.ReadBit("Allow", indexes);
            var dataSize = packet.ReadInt32("Size", indexes);
            var data     = packet.ReadBytes(dataSize);
            var db2File  = new Packet(data, packet.Opcode, packet.Time, packet.Direction, packet.Number, packet.Writer, packet.FileName);

            if (!allow)
            {
                packet.WriteLine($"Row {entry} has been removed.");
                HotfixStoreMgr.RemoveRecord(type, entry);
            }
            else
            {
                packet.AddSniffData(StoreNameType.None, entry, type.ToString());
                HotfixStoreMgr.AddRecord(type, entry, db2File);

                if (HotfixStoreMgr.GetStore(type) == null)
                {
                    db2File.WriteLine($"(Entry: {entry} TableHash: {type}) has missing structure. HotfixBlob entry generated!");
                    db2File.AsHex();

                    HotfixBlob hotfixBlob = new HotfixBlob
                    {
                        TableHash = type,
                        RecordID  = entry,
                        Blob      = "0x" + Utilities.ByteArrayToHexString(data)
                    };

                    Storage.HotfixBlobs.Add(hotfixBlob);
                }
                else if (db2File.Position != db2File.Length)
                {
                    db2File.WriteLine($"(Entry: {entry} TableHash: {type}) has incorrect structure");
                    db2File.AsHex();
                }

                db2File.ClosePacket(false);
            }

            HotfixData hotfixData = new HotfixData
            {
                ID        = hotfixId,
                TableHash = type,
                RecordID  = entry,
                Deleted   = !allow
            };

            Storage.HotfixDatas.Add(hotfixData);
        }
Beispiel #2
0
        static void ReadHotfixData810(Packet packet, List <HotfixRecord> records, params object[] indexes)
        {
            int count = 0;

            foreach (var record in records)
            {
                var hotfixId = packet.AddValue("HotfixID", record.HotfixId, count, indexes, "HotfixRecord");
                var type     = packet.AddValue("TableHash", record.Type, count, indexes, "HotfixRecord");
                var entry    = packet.AddValue("RecordID", record.RecordId, count, indexes, "HotfixRecord");
                var dataSize = packet.AddValue("Size", record.HotfixDataSize, count, indexes, "HotfixRecord");
                var allow    = packet.AddValue("Allow", record.Allow, count, indexes, "HotfixRecord");
                var data     = packet.ReadBytes(dataSize);
                var db2File  = new Packet(data, packet.Opcode, packet.Time, packet.Direction, packet.Number, packet.Writer, packet.FileName);

                if (!allow)
                {
                    packet.WriteLine($"Row {entry} has been removed.");
                    HotfixStoreMgr.RemoveRecord(type, entry);
                }
                else
                {
                    packet.AddSniffData(StoreNameType.None, entry, type.ToString());
                    HotfixStoreMgr.AddRecord(type, entry, db2File);

                    if (HotfixStoreMgr.GetStore(type) == null)
                    {
                        db2File.WriteLine($"(Entry: {entry} TableHash: {type}) has missing structure. HotfixBlob entry generated!");
                        db2File.AsHex();

                        HotfixBlob hotfixBlob = new HotfixBlob
                        {
                            TableHash = type,
                            RecordID  = entry,
                            Blob      = "0x" + Utilities.ByteArrayToHexString(data)
                        };

                        Storage.HotfixBlobs.Add(hotfixBlob);
                    }
                    else if (db2File.Position != db2File.Length)
                    {
                        db2File.WriteLine($"(Entry: {entry} TableHash: {type}) has incorrect structure");
                        db2File.AsHex();
                    }

                    db2File.ClosePacket(false);
                }

                HotfixData hotfixData = new HotfixData
                {
                    ID        = hotfixId,
                    TableHash = type,
                    RecordID  = entry,
                    Deleted   = !allow
                };

                Storage.HotfixDatas.Add(hotfixData);
                count++;
            }
        }
        static void ReadHotfixRecord(Packet packet, int hotfixId, params object[] indexes)
        {
            packet.ResetBitReader();
            var type     = packet.ReadUInt32E <DB2Hash>("TableHash", indexes);
            var entry    = packet.ReadInt32("RecordID", indexes);
            var allow    = packet.ReadBit("Allow", indexes);
            var dataSize = packet.ReadInt32("Size", indexes);
            var data     = packet.ReadBytes(dataSize);
            var db2File  = new Packet(data, packet.Opcode, packet.Time, packet.Direction, packet.Number, packet.Writer, packet.FileName);

            if (!allow)
            {
                packet.WriteLine($"Row {entry} has been removed.");
                HotfixStoreMgr.RemoveRecord(type, entry);
            }
            else
            {
                packet.AddSniffData(StoreNameType.None, entry, type.ToString());
                HotfixStoreMgr.AddRecord(type, entry, db2File);

                if (db2File.Position != db2File.Length)
                {
                    db2File.WriteLine($"(Entry: {entry} TableHash: {type}) has missing structure");
                    db2File.AsHex();
                }

                db2File.ClosePacket(false);
            }

            HotfixData hotfixData = new HotfixData
            {
                ID        = (uint)hotfixId,
                TableHash = type,
                RecordID  = entry,
                Deleted   = !allow
            };

            Storage.HotfixDatas.Add(hotfixData);
        }
        static void ReadHotfixData(Packet packet, List <HotfixRecord> records, params object[] indexes)
        {
            int count = 0;

            foreach (var record in records)
            {
                var hotfixId = packet.AddValue("HotfixID", record.HotfixId, count, indexes, "HotfixRecord");
                var uniqueId = packet.AddValue("UniqueID", record.UniqueId, count, indexes, "HotfixRecord");
                var type     = packet.AddValue("TableHash", record.Type, count, indexes, "HotfixRecord");
                var entry    = packet.AddValue("RecordID", record.RecordId, count, indexes, "HotfixRecord");
                var dataSize = packet.AddValue("Size", record.HotfixDataSize, count, indexes, "HotfixRecord");
                var status   = packet.AddValue("Status", record.Status, count, indexes, "HotfixRecord");
                var data     = packet.ReadBytes(dataSize);
                var db2File  = new Packet(data, packet.Opcode, packet.Time, packet.Direction, packet.Number, packet.Writer, packet.FileName);

                switch (status)
                {
                case HotfixStatus.Valid:
                {
                    packet.AddSniffData(StoreNameType.None, entry, type.ToString());
                    HotfixStoreMgr.AddRecord(type, entry, db2File);

                    if (HotfixStoreMgr.GetStore(type) == null)
                    {
                        db2File.WriteLine($"(Entry: {entry} TableHash: {type}) has missing structure. HotfixBlob entry generated!");
                        db2File.AsHex();

                        HotfixBlob hotfixBlob = new HotfixBlob
                        {
                            TableHash = type,
                            RecordID  = entry,
                            Blob      = new Blob(data)
                        };

                        Storage.HotfixBlobs.Add(hotfixBlob);
                    }
                    else if (db2File.Position != db2File.Length)
                    {
                        HandleHotfixOptionalData(packet, type, entry, db2File);
                    }

                    db2File.ClosePacket(false);
                    break;
                }

                case HotfixStatus.RecordRemoved:
                {
                    packet.WriteLine($"Row {entry} has been removed.");
                    HotfixStoreMgr.RemoveRecord(type, entry);
                    break;
                }

                case HotfixStatus.Invalid:
                {
                    // sniffs from others may have the data
                    packet.WriteLine($"Row {entry} is invalid.");
                    break;
                }

                default:
                {
                    packet.WriteLine($"Unhandled status: {status}");
                    break;
                }
                }

                HotfixData hotfixData = new HotfixData
                {
                    ID        = hotfixId,
                    UniqueID  = uniqueId,
                    TableHash = type,
                    RecordID  = entry,
                    Status    = status
                };

                Storage.HotfixDatas.Add(hotfixData);
                count++;
            }
        }
Beispiel #5
0
        static void ReadHotfixData(Packet packet, List <HotfixRecord> records, params object[] indexes)
        {
            for (var i = 0; i < records.Count; ++i)
            {
                var record = records[i];

                packet.AddValue("HotfixId", record.HotfixId, i, indexes, "HotfixRecord");
                packet.AddValue("UniqueId", record.UniqueId, i, indexes, "HotfixRecord");
                packet.AddValue("RecordId", record.RecordId, i, indexes, "HotfixRecord");
                packet.AddValue("TableHash", record.Type, i, indexes, "HotfixRecord");
                packet.AddValue("Status", record.Status, i, indexes, "HotfixRecord");
                packet.AddValue("Size", record.HotfixDataSize, i, indexes, "HotfixRecord");

                switch (record.Status)
                {
                case HotfixStatus.Valid:
                {
                    packet.AddSniffData(StoreNameType.None, record.RecordId, record.Type.ToString());

                    var data = packet.ReadBytes(record.HotfixDataSize);
                    using (var db2File = new Packet(data, packet.Opcode, packet.Time, packet.Direction,
                                                    packet.Number, packet.Writer, packet.FileName))
                    {
                        HotfixStoreMgr.AddRecord(record.Type, record.RecordId, db2File);

                        if (HotfixStoreMgr.GetStore(record.Type) == null)
                        {
                            db2File.WriteLine($"(RecordID: {record.RecordId} TableHash: {record.Type}) has missing structure. HotfixBlob entry generated!");
                            db2File.AsHex();

                            var hotfixBlob = new HotfixBlob
                            {
                                TableHash = record.Type,
                                RecordID  = record.RecordId,
                                Blob      = new Blob(data)
                            };

                            Storage.HotfixBlobs.Add(hotfixBlob);
                        }
                        else if (db2File.Position != db2File.Length)
                        {
                            HandleHotfixOptionalData(packet, record.Type, record.RecordId, db2File);
                        }
                    }

                    break;
                }

                case HotfixStatus.Invalid:
                {
                    packet.WriteLine($"Row {record.RecordId} is invalid.");
                    break;
                }

                case HotfixStatus.RecordRemoved:
                {
                    packet.WriteLine($"Row {record.RecordId} has been deleted.");
                    HotfixStoreMgr.RemoveRecord(record.Type, record.RecordId);
                    break;
                }

                default:
                {
                    packet.WriteLine($"Row: {record.RecordId} TableHash: {record.Type} has unknown Status: {record.Status}");
                    break;
                }
                }

                var hotfixData = new HotfixData
                {
                    ID        = record.HotfixId,
                    TableHash = record.Type,
                    RecordID  = record.RecordId,
                    Status    = record.Status
                };
                Storage.HotfixDatas.Add(hotfixData);
            }
        }