本文整理匯總了C#中WowPacketParser.Misc.Packet.SetPosition方法的典型用法代碼示例。如果您正苦於以下問題:C# Packet.SetPosition方法的具體用法?C# Packet.SetPosition怎麽用?C# Packet.SetPosition使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類WowPacketParser.Misc.Packet
的用法示例。
在下文中一共展示了Packet.SetPosition方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: HandleServerWardenData
public static void HandleServerWardenData(Packet packet)
{
var opcode = packet.ReadEnum<WardenServerOpcode>("Warden Server Opcode", TypeCode.Byte);
packet.SetPosition(0);
switch (opcode)
{
case WardenServerOpcode.ModuleInfo:
{
packet.ReadByte();
packet.ReadBytes("Module MD5", 16);
packet.ReadBytes("Module RC4", 16);
packet.ReadUInt32("Module Length");
break;
}
case WardenServerOpcode.ModuleChunk:
{
packet.ReadByte();
var length = packet.ReadUInt16("Chunk Length");
packet.ReadBytes("Module Chunk", length);
break;
}
case WardenServerOpcode.CheatChecks:
{
packet.ReadByte();
byte length;
while ((length = packet.ReadByte()) != 0)
{
packet.ReadBytes("String", length);
}
// var rest = (int)(packet.GetLength() - packet.GetPosition());
break;
}
case WardenServerOpcode.Data:
{
while (packet.CanRead())
{
packet.ReadByte();
var length = packet.ReadUInt16("Data Length");
packet.ReadInt32("Data Checksum");
packet.ReadBytes("Data", length);
}
break;
}
case WardenServerOpcode.Seed:
{
packet.ReadByte();
packet.ReadBytes("Seed", 16);
break;
}
}
}
示例2: HandleServerWardenData
public static void HandleServerWardenData(Packet packet)
{
var opcode = packet.ReadEnum<WardenServerOpcode>("Warden Server Opcode", TypeCode.Byte);
packet.SetPosition(0);
switch (opcode)
{
case WardenServerOpcode.ModuleInfo:
{
packet.ReadByte();
var md5 = packet.ReadBytes(16);
packet.WriteLine("Module MD5: " + Utilities.ByteArrayToHexString(md5));
var rc4 = packet.ReadBytes(16);
packet.WriteLine("Module RC4: " + Utilities.ByteArrayToHexString(rc4));
packet.ReadUInt32("Module Length");
break;
}
case WardenServerOpcode.ModuleChunk:
{
packet.ReadByte();
var length = packet.ReadUInt16("Chunk Length");
var chunk = packet.ReadBytes(length);
packet.WriteLine("Module Chunk: " + Utilities.ByteArrayToHexString(chunk));
break;
}
case WardenServerOpcode.CheatChecks:
{
packet.ReadByte();
byte length;
while ((length = packet.ReadByte()) != 0)
{
var strBytes = packet.ReadBytes(length);
var str = Encoding.ASCII.GetString(strBytes);
packet.WriteLine("String: " + str);
}
// var rest = (int)(packet.GetLength() - packet.GetPosition());
break;
}
case WardenServerOpcode.Data:
{
while (packet.CanRead())
{
packet.ReadByte();
var length = packet.ReadUInt16("Data Length");
packet.ReadInt32("Data Checksum");
var data = packet.ReadBytes(length);
packet.WriteLine("Data: " + Utilities.ByteArrayToHexString(data));
}
break;
}
case WardenServerOpcode.Seed:
{
packet.ReadByte();
var seed = packet.ReadBytes(16);
packet.WriteLine("Seed: " + Utilities.ByteArrayToHexString(seed));
break;
}
}
}