本文整理汇总了C#中WowPacketParser.Misc.Packet.AsHex方法的典型用法代码示例。如果您正苦于以下问题:C# Packet.AsHex方法的具体用法?C# Packet.AsHex怎么用?C# Packet.AsHex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WowPacketParser.Misc.Packet
的用法示例。
在下文中一共展示了Packet.AsHex方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleCoded
public static void HandleCoded(Packet packet)
{
packet.AsHex();
var select = packet.ReadInt32("select");
switch(select)
{
case 2:
case 3:
case 4:
packet.ReadPackedGuid("Guid");
packet.ReadByte("unk");
break;
case 1:
case 9:
case 10:
break;
case 7:
packet.ReadByte("unk1");
packet.ReadByte("unk2");
break;
case 0:
case 5:
case 6:
case 8:
packet.ReadByte("unk");
break;
}
}
示例2: ParseBattlenet
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;
}
}
示例3: HandleClientChatMessageSay
public static void HandleClientChatMessageSay(Packet packet)
{
packet.Writer.WriteLine(packet.AsHex());
packet.ReadEnum<Language>("Language", TypeCode.Int32);
// 4.3.0 some kind of strlen is send before string, size of 2 bytes
packet.ReadCString("Message");
}
示例4: HandleClientWardenData
public static void HandleClientWardenData(Packet packet)
{
var Size = packet.ReadInt32();
byte[] WardenDataBuffer = packet.ReadBytes(Size);
//Packet WardenData = new Packet(WardenDataBuffer, packet.Opcode, packet.Time, packet.Direction, packet.Number, packet.Writer, packet.FileName);
//CoreParsers.WardenHandler.HandleClientWardenData(WardenData);
packet.AsHex();
packet.ReadToEnd();
}
示例5: TestAsHex
public void TestAsHex()
{
var bytes = new byte[] {0xB, 0xA, 0xD, 0xC, 0x0, 0xD, 0xE, 66, 65, 68, 67, 79, 68, 69, 0, 0, 0x42};
var packet = new Packet(bytes, 1, new DateTime(2012, 1, 1), Direction.ClientToServer, 1, "Test");
packet.AsHex();
var actual = packet.Writer.ToString();
var expected =
"|-------------------------------------------------|---------------------------------|" + Environment.NewLine +
"| 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F | 0 1 2 3 4 5 6 7 8 9 A B C D E F |" + Environment.NewLine +
"|-------------------------------------------------|---------------------------------|" + Environment.NewLine +
"| 0B 0A 0D 0C 00 0D 0E 42 41 44 43 4F 44 45 00 00 | . . . . . . . B A D C O D E . . |" + Environment.NewLine +
"| 42 | B |" + Environment.NewLine +
"|-------------------------------------------------|---------------------------------|" + Environment.NewLine;
Assert.AreEqual(expected, actual);
}
示例6: HandlePlayerMove
public static void HandlePlayerMove(Packet packet)
{
packet.AsHex();
packet.ReadToEnd();
}
示例7: HandleTradeStatusExtended422
public static void HandleTradeStatusExtended422(Packet packet)
{
packet.AsHex();
packet.ReadInt32("Unk 1");
packet.ReadInt32("Unk 2");
packet.ReadInt32("Unk 3");
packet.ReadInt32("Unk 4");
packet.ReadUInt64("Gold");
packet.ReadByte("Trader?");
var count = packet.ReadInt32("Unk Count");
packet.ReadInt32("Unk 7");
packet.ReadInt32("Unk 8");
var guids1 = new byte[count][];
var guids2 = new byte[count][];
for (var i = 0; i < count; ++i)
{
guids1[i] = new byte[8];
guids2[i] = new byte[8];
}
for (var i = 0; i < count; ++i)
{
guids1[i][0] = packet.ReadBit();
guids1[i][5] = packet.ReadBit();
guids1[i][7] = packet.ReadBit();
guids1[i][1] = packet.ReadBit();
guids1[i][6] = packet.ReadBit();
guids2[i][5] = packet.ReadBit();
guids2[i][3] = packet.ReadBit();
guids2[i][0] = packet.ReadBit();
guids2[i][6] = packet.ReadBit();
guids2[i][2] = packet.ReadBit();
guids2[i][4] = packet.ReadBit();
guids2[i][1] = packet.ReadBit();
guids1[i][3] = packet.ReadBit();
guids2[i][7] = packet.ReadBit();
guids1[i][2] = packet.ReadBit();
guids1[i][4] = packet.ReadBit();
}
for (var i = 0; i < count; ++i)
{
packet.ReadInt32("Unk 1", i);
packet.ReadXORByte(guids2[i], 0);
packet.ReadXORByte(guids2[i], 3);
packet.ReadXORByte(guids2[i], 4);
packet.ReadInt32("Unk 2", i);
packet.ReadXORByte(guids1[i], 7);
packet.ReadInt32("Item Id", i);
packet.ReadInt32("Unk 4", i);
packet.ReadInt32("Unk 5", i);
packet.ReadXORByte(guids2[i], 2);
packet.ReadXORByte(guids2[i], 5);
packet.ReadInt32("Unk 6", i);
packet.ReadXORByte(guids1[i], 1);
packet.ReadXORByte(guids2[i], 6);
packet.ReadXORByte(guids1[i], 0);
packet.ReadInt32("Unk 7", i);
packet.ReadUInt32("Unk 8", i);
packet.ReadInt32("Unk 9", i);
packet.ReadXORByte(guids1[i], 5);
packet.ReadInt32("Unk 10", i);
packet.ReadXORByte(guids1[i], 6);
packet.ReadXORByte(guids2[i], 7);
packet.ReadInt32("Unk 11", i);
packet.ReadByte("Unk 12", i);
packet.ReadXORByte(guids2[i], 1);
packet.ReadInt32("Unk 13", i);
packet.ReadInt32("Unk 14", i);
packet.ReadByte("Unk 15", i);
packet.ReadXORByte(guids1[i], 4);
packet.ReadXORByte(guids1[i], 2);
packet.ReadInt32("Unk 16", i);
packet.ReadXORByte(guids1[i], 3);
packet.WriteGuid("Item Creator Guid", guids1[i], i);
packet.WriteGuid("Item Gift Creator Guid", guids2[i], i);
}
//.........这里部分代码省略.........
示例8: HandleTextEmoteServer
public static void HandleTextEmoteServer(Packet packet)
{
packet.AsHex();
packet.ReadToEnd();
}
示例9: HandleDBReply
//.........这里部分代码省略.........
if (Storage.HotfixDataStore.ContainsKey(Tuple.Create(type, (int)entry)) && Settings.HotfixSQLOutputFlag.HasAnyFlagBit(HotfixSQLOutput.hotfix_data) ||
!Settings.HotfixSQLOutputFlag.HasAnyFlagBit(HotfixSQLOutput.hotfix_data))
Storage.ChrUpgradeBucketSpells.Add(chrUpgradeBucketSpell, packet.TimeSpan);
break;
}
case DB2Hash.BattlePetSpecies:
{
BattlePetSpecies battlePetSpecies = new BattlePetSpecies();
battlePetSpecies.ID = (uint)db2File.ReadEntry("Id").Key;
battlePetSpecies.CreatureID = db2File.ReadUInt32("CreatureID");
battlePetSpecies.IconFileID = db2File.ReadUInt32("IconFileID");
battlePetSpecies.SummonSpellID = db2File.ReadUInt32("SummonSpellID");
battlePetSpecies.PetType = db2File.ReadInt32("PetType");
battlePetSpecies.Source = db2File.ReadUInt32("Source");
battlePetSpecies.Flags = db2File.ReadUInt32("Flags");
ushort len1 = db2File.ReadUInt16();
battlePetSpecies.SourceText = db2File.ReadWoWString("SourceText", len1);
ushort len2 = db2File.ReadUInt16();
battlePetSpecies.Description = db2File.ReadWoWString("Description", len2);
if (Storage.HotfixDataStore.ContainsKey(Tuple.Create(type, (int)entry)) && Settings.HotfixSQLOutputFlag.HasAnyFlagBit(HotfixSQLOutput.hotfix_data) ||
!Settings.HotfixSQLOutputFlag.HasAnyFlagBit(HotfixSQLOutput.hotfix_data))
Storage.BattlePetSpeciesBag.Add(battlePetSpecies, packet.TimeSpan);
break;
}
case DB2Hash.OverrideSpellData:
{
OverrideSpellData overrideSpellData = new OverrideSpellData();
overrideSpellData.ID = db2File.ReadUInt32("Id");
overrideSpellData.SpellID = new uint?[10];
for (int i = 0; i < 10; ++i)
overrideSpellData.SpellID[i] = db2File.ReadUInt32("SpellID", i);
overrideSpellData.Flags = db2File.ReadUInt32("Flags");
overrideSpellData.PlayerActionbarFileDataID = db2File.ReadUInt32("PlayerActionbarFileDataID");
if (Storage.HotfixDataStore.ContainsKey(Tuple.Create(type, (int)entry)) && Settings.HotfixSQLOutputFlag.HasAnyFlagBit(HotfixSQLOutput.hotfix_data) ||
!Settings.HotfixSQLOutputFlag.HasAnyFlagBit(HotfixSQLOutput.hotfix_data))
Storage.OverrideSpellDatas.Add(overrideSpellData, packet.TimeSpan);
break;
}
case DB2Hash.PhaseXPhaseGroup:
{
PhaseXPhaseGroup phaseXPhaseGroup = new PhaseXPhaseGroup();
phaseXPhaseGroup.ID = db2File.ReadUInt32("Id");
phaseXPhaseGroup.PhaseID = db2File.ReadUInt32("PhaseID");
phaseXPhaseGroup.PhaseGroupID = db2File.ReadUInt32("PhaseGroupID");
if (Storage.HotfixDataStore.ContainsKey(Tuple.Create(type, (int)entry)) && Settings.HotfixSQLOutputFlag.HasAnyFlagBit(HotfixSQLOutput.hotfix_data) ||
!Settings.HotfixSQLOutputFlag.HasAnyFlagBit(HotfixSQLOutput.hotfix_data))
Storage.PhaseXPhaseGroups.Add(phaseXPhaseGroup, packet.TimeSpan);
break;
}
default:
{
db2File.AddValue("Unknown DB2 file type", string.Format("{0} (0x{0:x})", type));
for (int i = 0;; ++i)
{
if (db2File.Length - 4 >= db2File.Position)
{
UpdateField blockVal = db2File.ReadUpdateField();
string key = "Block Value " + i;
string value = blockVal.UInt32Value + "/" + blockVal.SingleValue;
packet.AddValue(key, value);
}
else
{
long left = db2File.Length - db2File.Position;
for (int j = 0; j < left; ++j)
{
string key = "Byte Value " + i;
byte value = db2File.ReadByte();
packet.AddValue(key, value);
}
break;
}
}
break;
}
}
if (db2File.Length != db2File.Position)
{
packet.WriteLine(
$"Packet not fully read! Current position is {db2File.Position}, length is {db2File.Length}, and diff is {db2File.Length - db2File.Position}.");
if (db2File.Length < 300) // If the packet isn't "too big" and it is not full read, print its hex table
packet.AsHex();
packet.Status = ParsedStatus.WithErrors;
}
}
示例10: Parse
public static void Parse(Packet packet, bool isMultiple = false)
{
ParsedStatus status;
var opcode = packet.Opcode;
packet.WriteLine(packet.GetHeader(isMultiple));
if (opcode == 0)
return;
Action<Packet> handler;
if (Handlers.TryGetValue(opcode, out handler))
{
if (Settings.DumpFormat == DumpFormatType.SniffDataOnly)
{
var attrs = handler.Method.GetCustomAttributes(typeof (HasSniffDataAttribute), false);
packet.AddSniffData(StoreNameType.Opcode, packet.Opcode, Opcodes.GetOpcodeName(packet.Opcode));
if (attrs.Length == 0)
{
packet.Status = ParsedStatus.NotParsed;
return; // skip parsing "useless" packets when in SniffData-only-mode
}
}
try
{
handler(packet);
if (packet.Position == packet.Length)
status = ParsedStatus.Success;
else
{
var pos = packet.Position;
var len = packet.Length;
packet.WriteLine("Packet not fully read! Current position is {0}, length is {1}, and diff is {2}.",
pos, len, len - pos);
if (len < 300) // If the packet isn't "too big" and it is not full read, print its hex table
packet.AsHex();
status = ParsedStatus.WithErrors;
}
}
catch (Exception ex)
{
packet.WriteLine(ex.GetType().ToString());
packet.WriteLine(ex.Message);
packet.WriteLine(ex.StackTrace);
status = ParsedStatus.WithErrors;
}
}
else
{
packet.AsHex();
status = ParsedStatus.NotParsed;
}
if (!isMultiple)
{
packet.Status = status;
if (Settings.DumpFormat != DumpFormatType.SniffDataOnly)
{
// added before for this type
var data = status == ParsedStatus.Success ? Opcodes.GetOpcodeName(packet.Opcode) : status.ToString();
packet.AddSniffData(StoreNameType.Opcode, packet.Opcode, data);
}
}
}
示例11: Parse
public static void Parse(Packet packet, bool headerOnly = false)
{
var opcode = packet.Opcode;
packet.Writer.WriteLine("{0}: {1} (0x{2}) Length: {3} Time: {4} Number: {5}",
packet.Direction, Opcodes.GetOpcodeName(opcode), opcode.ToString("X4"),
packet.GetLength(), packet.Time.ToString("MM/dd/yyyy HH:mm:ss.fff"), packet.Number);
if (headerOnly)
{
lock (Handlers)
{
Statistics.PacketsSuccessfullyParsed++;
}
return;
}
Action<Packet> handler;
if (Handlers.TryGetValue(opcode, out handler))
{
try
{
handler(packet);
if (packet.GetPosition() == packet.GetLength())
lock (Handlers)
{
Statistics.PacketsSuccessfullyParsed++;
}
else
{
var pos = packet.GetPosition();
var len = packet.GetLength();
packet.Writer.WriteLine("Packet not fully read! Current position is {0}, length is {1}, and diff is {2}.",
pos, len, len - pos);
if (len < 300) // If the packet isn't "too big" and it is not full read, print its hex table
packet.Writer.WriteLine(packet.AsHex());
lock (Handlers)
{
Statistics.PacketsParsedWithErrors++;
}
}
}
catch (Exception ex)
{
packet.Writer.WriteLine(ex.GetType());
packet.Writer.WriteLine(ex.Message);
packet.Writer.WriteLine(ex.StackTrace);
lock (Handlers)
{
Statistics.PacketsParsedWithErrors++;
}
}
}
else
{
packet.Writer.WriteLine(packet.AsHex());
lock (Handlers)
{
Statistics.PacketsNotParsed++;
}
}
}
示例12: ParseBattlenet
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 (EndOfStreamException)
{
// Processes the packet until it has all data to read - packet appears multiple times in the sniff file
// but only the last copy is complete
packet.Writer.Clear();
packet.AsHex();
packet.Status = ParsedStatus.WithErrors;
}
catch (Exception ex)
{
packet.WriteLine(ex.GetType().ToString());
packet.WriteLine(ex.Message);
packet.WriteLine(ex.StackTrace);
packet.Status = ParsedStatus.WithErrors;
}
}
示例13: HandleGuildRoster422
public static void HandleGuildRoster422(Packet packet)
{
packet.Writer.WriteLine(packet.AsHex()); // FIXME
}
示例14: HandleDBReply
//.........这里部分代码省略.........
spellMisc.AttributesExG = db2File.ReadUInt32("AttributesExG");
spellMisc.AttributesExH = db2File.ReadUInt32("AttributesExH");
spellMisc.AttributesExI = db2File.ReadUInt32("AttributesExI");
spellMisc.AttributesExJ = db2File.ReadUInt32("AttributesExJ");
spellMisc.AttributesExK = db2File.ReadUInt32("AttributesExK");
spellMisc.AttributesExL = db2File.ReadUInt32("AttributesExL");
spellMisc.AttributesExM = db2File.ReadUInt32("AttributesExM");
spellMisc.CastingTimeIndex = db2File.ReadUInt32("CastingTimeIndex");
spellMisc.DurationIndex = db2File.ReadUInt32("DurationIndex");
spellMisc.RangeIndex = db2File.ReadUInt32("RangeIndex");
spellMisc.Speed = db2File.ReadSingle("Speed");
spellMisc.SpellVisualID = new uint[2];
for (var i = 0; i < 2; ++i)
spellMisc.SpellVisualID[i] = db2File.ReadUInt32("SpellVisualID", i);
spellMisc.SpellIconID = db2File.ReadUInt32("SpellIconID");
spellMisc.ActiveIconID = db2File.ReadUInt32("ActiveIconID");
spellMisc.SchoolMask = db2File.ReadUInt32("SchoolMask");
spellMisc.MultistrikeSpeedMod = db2File.ReadSingle("MultistrikeSpeedMod");
Storage.SpellMiscs.Add((uint)id.Key, spellMisc, packet.TimeSpan);
break;
}
case DB2Hash.Toy: // New structure - 6.0.2
{
db2File.ReadUInt32("ID");
db2File.ReadUInt32<ItemId>("Item ID");
db2File.ReadUInt32("Flags");
var descriptionLength = db2File.ReadUInt16();
db2File.ReadWoWString("Description", descriptionLength);
db2File.ReadInt32("Source Type");
break;
}
case DB2Hash.Vignette:
{
db2File.ReadUInt32("Vignette ID");
var nameLength = db2File.ReadUInt16();
db2File.ReadWoWString("Name", nameLength);
db2File.ReadUInt32("Icon");
db2File.ReadUInt32("Flag"); // not 100% sure (8 & 32 as values only) - todo verify with more data
db2File.ReadSingle("Unk Float 1");
db2File.ReadSingle("Unk Float 2");
break;
}
case DB2Hash.WbAccessControlList:
{
db2File.ReadUInt32("Id");
var addressLength = db2File.ReadUInt16();
db2File.ReadWoWString("Address", addressLength);
db2File.ReadUInt32("Unk MoP 1");
db2File.ReadUInt32("Unk MoP 2");
db2File.ReadUInt32("Unk MoP 3");
db2File.ReadUInt32("Unk MoP 4"); // flags?
break;
}
default:
{
db2File.AddValue("Unknown DB2 file type", string.Format("{0} (0x{0:x})", type));
for (var i = 0;; ++i)
{
if (db2File.Length - 4 >= db2File.Position)
{
var blockVal = db2File.ReadUpdateField();
string key = "Block Value " + i;
string value = blockVal.UInt32Value + "/" + blockVal.SingleValue;
packet.AddValue(key, value);
}
else
{
var left = db2File.Length - db2File.Position;
for (var j = 0; j < left; ++j)
{
string key = "Byte Value " + i;
var value = db2File.ReadByte();
packet.AddValue(key, value);
}
break;
}
}
break;
}
}
if (db2File.Length != db2File.Position)
{
packet.WriteLine("Packet not fully read! Current position is {0}, length is {1}, and diff is {2}.",
db2File.Position, db2File.Length, db2File.Length - db2File.Position);
if (db2File.Length < 300) // If the packet isn't "too big" and it is not full read, print its hex table
packet.AsHex();
packet.Status = ParsedStatus.WithErrors;
}
}
示例15: HandleMoveStartPitchUp
//.........这里部分代码省略.........
guid[4] = packet.ReadBit(); // 20
packet.ReadBit("bit 172"); // 172
var hasSplineElev = !packet.ReadBit("Has no Spline Elevation"); // 144
if (hasTrans) // 104
{
transportGuid[5] = packet.ReadBit(); // 61
transportGuid[1] = packet.ReadBit(); // 57
hasTransTime2 = packet.ReadBit("hasTransTime2"); // 92
transportGuid[4] = packet.ReadBit(); // 60
transportGuid[2] = packet.ReadBit(); // 58
transportGuid[6] = packet.ReadBit(); // 62
transportGuid[0] = packet.ReadBit(); // 56
hasTransTime3 = packet.ReadBit("hasTransTime3"); // 100
transportGuid[7] = packet.ReadBit(); // 63
transportGuid[3] = packet.ReadBit(); // 59
}
if (hasMovementFlags2) // 28
packet.ReadEnum<MovementFlagExtra>("Extra Movement Flags", 13); // 28
if (hasMovementFlags) // 24
packet.ReadEnum<MovementFlag>("Movement Flags", 30); // 24
if (hasFallData) // 140
hasFallDirection = packet.ReadBit("Has Fall Direction"); // 136
packet.ResetBitReader(); // flush bits
packet.ParseBitStream(guid, 6);
if (Count > 0) // 152
for (var cnt = 0; cnt < Count; cnt++)
{
packet.ReadInt32("Dword 156", cnt); // 156
}
packet.ParseBitStream(guid, 0, 5, 7, 1, 3, 4, 2);
if (hasTrans) // 104
{
var tpos = new Vector4();
packet.ReadSByte("Transport Seat"); // 80
packet.ReadXORByte(transportGuid, 3); // 59
if (hasTransTime3) // 100
packet.ReadUInt32("Transport Time 3"); // 96
packet.ReadXORByte(transportGuid, 2); // 58
packet.ReadXORByte(transportGuid, 7); // 63
packet.ReadXORByte(transportGuid, 0); // 56
tpos.Y = packet.ReadSingle(); // 68
packet.ReadXORByte(transportGuid, 4); // 60
packet.ReadXORByte(transportGuid, 5); // 61
if (hasTransTime2) // 92
packet.ReadUInt32("Transport Time 2"); // 88
packet.ReadXORByte(transportGuid, 1); // 57
tpos.X = packet.ReadSingle(); // 64
tpos.O = packet.ReadSingle(); // 76
packet.ReadXORByte(transportGuid, 6); // 62
packet.ReadUInt32("Transport Time"); // 84
tpos.Z = packet.ReadSingle(); // 72
packet.WriteGuid("Transport Guid", transportGuid);
packet.WriteLine("Transport Position: {0}", tpos);
}
if (hasPitch)
packet.ReadSingle("Pitch"); // 112
if (hasO)
pos.O = packet.ReadSingle(); // 48
if (hasSplineElev)
packet.ReadSingle("Spline elevation"); // 144
if (hasFallData) // 140
{
packet.ReadSingle("Vertical Speed"); // 120
if (hasFallDirection) // 136
{
packet.ReadSingle("Horizontal Speed"); // 132
packet.ReadSingle("Fall Cos"); // 128
packet.ReadSingle("Fall Sin"); // 124
}
packet.ReadUInt32("Fall time"); // 116
}
if (hasSpline) // 168
packet.ReadInt32("Spline"); // 168
if (hasTime)
packet.ReadUInt32("Timestamp"); // 32
packet.WriteGuid("Guid", guid);
packet.WriteLine("Position: {0}", pos);
}
else
{
packet.WriteLine(" : SMSG_???");
packet.AsHex();
packet.ReadToEnd();
}
}