public override void Read(StreamHandler Reader) { this.Count = Reader.ReadByte(); this.Seed = Reader.ReadUInt32(); this.ClientSeed = Reader.ReadBytes(16); this.ServerSeed = Reader.ReadBytes(16); }
protected override void ElementRead(StreamHandler reader, int index) { if (index == -5) this.Unk = reader.ReadUInt32(); else this.Data[-index - 1] = reader.ReadBytes(reader.ReadInt32()); }
public static NetworkLog GetNetworkLog(string filename) { if (!s_initialized) Initialize(); var ext = Path.GetExtension(filename); var extFittingDumps = new List<NetworkLogWrapper>(); foreach (var info in s_logs) { if (info.FileExtension == ext) extFittingDumps.Add(info); } if (extFittingDumps.Count == 0) extFittingDumps = s_logs; else if (extFittingDumps.Count == 1) return extFittingDumps[0].Activate(NetworkLogMode.Reading); byte[] header; using (var sh = new StreamHandler(filename, FileMode.Open)) header = sh.ReadBytes(Math.Min((int)sh.Length, s_maxHeaderLength)); foreach (var wrapper in extFittingDumps) { if (wrapper.Fits(header)) return wrapper.Activate(NetworkLogMode.Reading); } return null; }
protected override void ElementRead(StreamHandler reader, int index) { if (index == -5) { this.Unk = reader.ReadUInt32(); } else { this.Data[-index - 1] = reader.ReadBytes(reader.ReadInt32()); } }
public override void Read(StreamHandler Reader) { byte[] blob = Reader.ReadBytes(256); Token = Reader.ReadUInt32(); UnknownULong = Reader.ReadUInt64(); ConnectionIndex = Reader.ReadByte(); // hardcoded in client byte[] modulus1 = { 0x91, 0xD5, 0x9B, 0xB7, 0xD4, 0xE1, 0x83, 0xA5, 0x22, 0x2B, 0x5F, 0x38, 0xF4, 0xB8, 0x86, 0xFF, 0x32, 0x84, 0x38, 0x2D, 0x99, 0x38, 0x8F, 0xBA, 0xF3, 0xC9, 0x22, 0x5D, 0x51, 0x73, 0x1E, 0x28, 0x87, 0x24, 0x8F, 0xB5, 0xC9, 0xB0, 0x7C, 0x95, 0xD0, 0x6B, 0x5B, 0xF4, 0x94, 0xC5, 0x94, 0x9D, 0xFA, 0x6F, 0x47, 0x3A, 0xA3, 0x86, 0xC0, 0xA8, 0x37, 0xF3, 0x9B, 0xEF, 0x2F, 0xC1, 0xFB, 0xB3, 0xF4, 0x1C, 0x2B, 0x0E, 0xD3, 0x6D, 0x88, 0xBB, 0x02, 0xE0, 0x4E, 0x63, 0xFA, 0x76, 0xE3, 0x43, 0xF9, 0x01, 0xFD, 0x23, 0x5E, 0x6A, 0x0B, 0x14, 0xEC, 0x5E, 0x91, 0x34, 0x0D, 0x0B, 0x4F, 0xA3, 0x5A, 0x46, 0xC5, 0x5E, 0xDC, 0xB5, 0xCD, 0xC1, 0x47, 0x6B, 0x59, 0xCA, 0xFA, 0xA9, 0xBE, 0x24, 0x9F, 0xF5, 0x05, 0x6B, 0xBB, 0x67, 0x8B, 0xB7, 0xE4, 0x3A, 0x43, 0x00, 0x5C, 0x1C, 0xB7, 0xCA, 0x98, 0x90, 0x79, 0x77, 0x6D, 0x05, 0x4F, 0x83, 0xCC, 0xAC, 0x06, 0x2E, 0x50, 0x11, 0x87, 0x23, 0xD8, 0xA6, 0xF7, 0x6F, 0x7A, 0x59, 0x87, 0xA6, 0xDE, 0x5D, 0xD8, 0xEC, 0x44, 0xBE, 0x45, 0x31, 0x7F, 0x8A, 0xF0, 0x58, 0x89, 0x53, 0x74, 0xDF, 0xCC, 0xAD, 0x01, 0x24, 0xD8, 0x19, 0x65, 0x1C, 0x25, 0xD3, 0xE1, 0x6B, 0x8B, 0xDA, 0xFE, 0x1D, 0xA4, 0x2C, 0x8B, 0x25, 0xED, 0x7C, 0xFF, 0x6A, 0xE0, 0x63, 0xD0, 0x52, 0x20, 0x7E, 0x62, 0x49, 0xD2, 0xB3, 0x6B, 0xCC, 0x91, 0x69, 0xA5, 0x08, 0x8B, 0x69, 0x65, 0xFF, 0xB9, 0xC9, 0x17, 0x02, 0x5D, 0xD8, 0x8E, 0x1A, 0x63, 0xD9, 0x2A, 0x7F, 0xDB, 0xE3, 0xF8, 0x76, 0x6D, 0xEA, 0x0E, 0x36, 0x98, 0x78, 0x19, 0xC5, 0x87, 0xBA, 0x6C, 0x20, 0xB6, 0x08, 0x44, 0x04, 0x4C, 0xA8, 0xD5, 0xB6, 0x9D, 0x4D, 0x00, 0x20, 0x40, 0x00, 0x90, 0x04 }; // hardcoded in client byte[] exp = { 0x01, 0x00, 0x01, 0x00 }; BigInteger res_bn = BigInteger.ModPow(new BigInteger(blob), new BigInteger(exp), new BigInteger(modulus1)); FixedBlob = FixBlob(res_bn.ToByteArray()); ServerHash = new byte[0]; Port = BitConverter.ToUInt16(FixedBlob, 21); IP = new IPAddress(FixedBlob.Take(4).ToArray()); //byte[] bytes = new byte[0] // .Concat(BitConverter.GetBytes(Port)) // .Concat(BitConverter.GetBytes(ip)) // .ToArray(); //SHA1Managed sha1 = new SHA1Managed(); ComputedHash = new byte[0]; //sha1.ComputeHash(bytes); }
private static string PascalStringReader(StreamHandler sh, int length) { if (length > 0) { byte[] bytes = sh.ReadBytes(length + 1); int len = length + 1; if (bytes[bytes.Length - 1] == 0x00) { --len; } return(Encoding.UTF8.GetString(bytes, 0, len)); } else { return(string.Empty); } }
public static NetworkLog GetNetworkLog(string filename) { if (!s_initialized) { Initialize(); } var ext = Path.GetExtension(filename); var extFittingDumps = new List <NetworkLogWrapper>(); foreach (var info in s_logs) { if (info.FileExtension == ext) { extFittingDumps.Add(info); } } if (extFittingDumps.Count == 0) { extFittingDumps = s_logs; } else if (extFittingDumps.Count == 1) { return(extFittingDumps[0].Activate(NetworkLogMode.Reading)); } byte[] header; using (var sh = new StreamHandler(filename, FileMode.Open)) header = sh.ReadBytes(Math.Min((int)sh.Length, s_maxHeaderLength)); foreach (var wrapper in extFittingDumps) { if (wrapper.Fits(header)) { return(wrapper.Activate(NetworkLogMode.Reading)); } } return(null); }
public static StreamHandler DecompressBlock(this StreamHandler reader) { if (reader == null) { throw new ArgumentNullException("reader"); } int uncompressedLength = reader.ReadInt32(); if (uncompressedLength == 0) { return(new StreamHandler(new byte[0])); } reader.Skip(2); byte[] compressedBytes = reader.ReadBytes((int)reader.RemainingLength); byte[] uncompressedBytes = new byte[uncompressedLength]; using (var stream = new MemoryStream(compressedBytes)) using (var dStream = new DeflateStream(stream, CompressionMode.Decompress, true)) dStream.Read(uncompressedBytes, 0, uncompressedLength); return(new StreamHandler(uncompressedBytes)); }
protected override unsafe void InternalOpenForReading(Stream stream, bool closeStream) { m_isLoaded = true; var mainHeaderBytes = new byte[MainHeader.Size]; stream.Read(mainHeaderBytes, 0, MainHeader.Size); MainHeader *mainHeader; fixed(byte *mainHeaderBytesPtr = mainHeaderBytes) { mainHeader = (MainHeader *)mainHeaderBytesPtr; m_nPackets = mainHeader->PacketCount; this.StartTime = mainHeader->StartedOnUnix.AsUnixTime(); this.StartTicks = mainHeader->StartedOnTicks; this.InternalSetCapacity(m_nPackets); } int extraLen = mainHeader->ExtraDataLength; if (extraLen > 0) { byte[] extraData = new byte[extraLen]; stream.Read(extraData, 0, extraLen); using (var reader = new StreamHandler(extraData)) { ExtraDataFlags flags = mainHeader->ExtraInfoFlags; if (flags.HasFlag(ExtraDataFlags.HasClientIPv4)) { this.ClientAddress = new IPAddress(reader.ReadBytes(4)); } if (flags.HasFlag(ExtraDataFlags.HasServerIPv4)) { this.ServerAddress = new IPAddress(reader.ReadBytes(4)); } if (flags.HasFlag(ExtraDataFlags.HasClientIPv6)) { this.ClientAddress = new IPAddress(reader.ReadBytes(16)); } if (flags.HasFlag(ExtraDataFlags.HasServerIPv6)) { this.ServerAddress = new IPAddress(reader.ReadBytes(16)); } if (flags.HasFlag(ExtraDataFlags.HasClientPort)) { this.ClientPort = reader.ReadInt32(); } if (flags.HasFlag(ExtraDataFlags.HasServerPort)) { this.ServerPort = reader.ReadInt32(); } if (flags.HasFlag(ExtraDataFlags.HasSnifferIdString)) { int origLen = reader.ReadInt32(); int cmprLen = reader.ReadInt32(); var arr = new byte[origLen]; using (var iStream = new MemoryStream(reader.ReadBytes(cmprLen))) using (var ds = new DeflateStream(iStream, CompressionMode.Decompress, true)) ds.Read(arr, 0, arr.Length); this.SnifferDesc = Encoding.UTF8.GetString(arr); } } } m_stream = new StreamHandler(stream, closeStream); }
protected unsafe override void InternalOpenForReading(Stream stream, bool closeStream) { m_isLoaded = true; var mainHeaderBytes = new byte[MainHeader.Size]; stream.Read(mainHeaderBytes, 0, MainHeader.Size); MainHeader* mainHeader; fixed (byte* mainHeaderBytesPtr = mainHeaderBytes) { mainHeader = (MainHeader*)mainHeaderBytesPtr; m_nPackets = mainHeader->PacketCount; this.StartTime = mainHeader->StartedOnUnix.AsUnixTime(); this.StartTicks = mainHeader->StartedOnTicks; this.InternalSetCapacity(m_nPackets); } int extraLen = mainHeader->ExtraDataLength; if (extraLen > 0) { byte[] extraData = new byte[extraLen]; stream.Read(extraData, 0, extraLen); using (var reader = new StreamHandler(extraData)) { ExtraDataFlags flags = mainHeader->ExtraInfoFlags; if (flags.HasFlag(ExtraDataFlags.HasClientIPv4)) this.ClientAddress = new IPAddress(reader.ReadBytes(4)); if (flags.HasFlag(ExtraDataFlags.HasServerIPv4)) this.ServerAddress = new IPAddress(reader.ReadBytes(4)); if (flags.HasFlag(ExtraDataFlags.HasClientIPv6)) this.ClientAddress = new IPAddress(reader.ReadBytes(16)); if (flags.HasFlag(ExtraDataFlags.HasServerIPv6)) this.ServerAddress = new IPAddress(reader.ReadBytes(16)); if (flags.HasFlag(ExtraDataFlags.HasClientPort)) this.ClientPort = reader.ReadInt32(); if (flags.HasFlag(ExtraDataFlags.HasServerPort)) this.ServerPort = reader.ReadInt32(); if (flags.HasFlag(ExtraDataFlags.HasSnifferIdString)) { int origLen = reader.ReadInt32(); int cmprLen = reader.ReadInt32(); var arr = new byte[origLen]; using (var iStream = new MemoryStream(reader.ReadBytes(cmprLen))) using (var ds = new DeflateStream(iStream, CompressionMode.Decompress, true)) ds.Read(arr, 0, arr.Length); this.SnifferDesc = Encoding.UTF8.GetString(arr); } } } m_stream = new StreamHandler(stream, closeStream); }
private static string PascalStringReader(StreamHandler sh, int length) { if (length > 0) { byte[] bytes = sh.ReadBytes(length + 1); int len = length + 1; if (bytes[bytes.Length - 1] == 0x00) --len; return Encoding.UTF8.GetString(bytes, 0, len); } else return string.Empty; }
public unsafe MovementInfo(StreamHandler Reader) { var guid = new WowGuid(); this.HaveAttackingTarget = Reader.UnalignedReadBit(); guid.Bytes[2] = Reader.UnalignedReadTinyInt(1); this.HaveVehicleData = Reader.UnalignedReadBit(); guid.Bytes[1] = Reader.UnalignedReadTinyInt(1); guid.Bytes[4] = Reader.UnalignedReadTinyInt(1); guid.Bytes[3] = Reader.UnalignedReadTinyInt(1); this.HaveTransportTime = Reader.UnalignedReadBit(); this.HaveGameObjectPosition = Reader.UnalignedReadBit(); bool field_1C8 = Reader.UnalignedReadBit(); bool field_1AC = Reader.UnalignedReadBit(); this.HaveGameObjectRotation = Reader.UnalignedReadBit(); this.Living = Reader.UnalignedReadBit(); this.HavePosition = Reader.UnalignedReadBit(); var arrCounter = Reader.UnalignedReadInt(24); guid.Bytes[0] = Reader.UnalignedReadTinyInt(1); bool havePFlags = false; WowGuid p_guid; uint splinePoints = 0; bool havePFlags2 = false; bool haveOrientation = false; if (this.Living) { this.HaveTransportData = Reader.UnalignedReadBit(); if (this.HaveTransportData) { fixed(byte *bytes = this.TransportGuid.Bytes) { bytes[2] = Reader.UnalignedReadTinyInt(1); bytes[7] = Reader.UnalignedReadTinyInt(1); bytes[5] = Reader.UnalignedReadTinyInt(1); this.HaveTransportTime3 = Reader.UnalignedReadBit(); bytes[3] = Reader.UnalignedReadTinyInt(1); bytes[0] = Reader.UnalignedReadTinyInt(1); bytes[4] = Reader.UnalignedReadTinyInt(1); bytes[1] = Reader.UnalignedReadTinyInt(1); this.HaveTransportTime2 = Reader.UnalignedReadBit(); bytes[6] = Reader.UnalignedReadTinyInt(1); } } this.HaveSpline2 = Reader.UnalignedReadBit(); p_guid.Bytes[7] = Reader.UnalignedReadTinyInt(1); p_guid.Bytes[6] = Reader.UnalignedReadTinyInt(1); p_guid.Bytes[5] = Reader.UnalignedReadTinyInt(1); p_guid.Bytes[2] = Reader.UnalignedReadTinyInt(1); p_guid.Bytes[4] = Reader.UnalignedReadTinyInt(1); havePFlags = !Reader.UnalignedReadBit(); p_guid.Bytes[1] = Reader.UnalignedReadTinyInt(1); this.SelfTarget = Reader.UnalignedReadBit(); this.TimeStamp = !Reader.UnalignedReadBit() ? 1U : 0U; havePFlags2 = !Reader.UnalignedReadBit(); if (this.HaveSpline2) { this.HaveSpline = Reader.UnalignedReadBit(); if (this.HaveSpline) { this.Spline.HaveDurationMultiplier = Reader.UnalignedReadBit(); this.Spline.Flags = (SplineFlags)Reader.UnalignedReadInt(25); this.Spline.SplineMode = (SplineMode)Reader.UnalignedReadTinyInt(2); this.Spline.HaveUnknown1 = Reader.UnalignedReadBit(); splinePoints = Reader.UnalignedReadInt(22); var type = Reader.UnalignedReadTinyInt(2); switch (type) { case 0: this.Spline.SplineType = SplineType.FacingSpot; break; case 1: this.Spline.SplineType = SplineType.Normal; break; case 2: this.Spline.SplineType = SplineType.FacingTarget; break; case 3: this.Spline.SplineType = SplineType.FacingAngle; break; } if (this.Spline.SplineType == SplineType.FacingTarget) { fixed(byte *bytes = this.Spline.FacingTarget.Bytes) { bytes[7] = Reader.UnalignedReadTinyInt(1); bytes[3] = Reader.UnalignedReadTinyInt(1); bytes[4] = Reader.UnalignedReadTinyInt(1); bytes[2] = Reader.UnalignedReadTinyInt(1); bytes[1] = Reader.UnalignedReadTinyInt(1); bytes[6] = Reader.UnalignedReadTinyInt(1); bytes[0] = Reader.UnalignedReadTinyInt(1); bytes[5] = Reader.UnalignedReadTinyInt(1); } } } } p_guid.Bytes[3] = Reader.UnalignedReadTinyInt(1); if (havePFlags) { this.Flags = (MovementFlags)Reader.UnalignedReadInt(30); } this.HavePitch = !Reader.UnalignedReadBit(); this.HaveFallData = Reader.UnalignedReadBit(); if (havePFlags2) { this.Flags2 = (MovementFlags2)Reader.UnalignedReadSmallInt(12); } p_guid.Bytes[0] = Reader.UnalignedReadTinyInt(1); haveOrientation = !Reader.UnalignedReadBit(); if (this.HaveFallData) { this.HaveFallDirection = Reader.UnalignedReadBit(); } this.HaveSplineElevation = !Reader.UnalignedReadBit(); } if (this.HaveGameObjectPosition) { fixed(byte *bytes = this.TransportGuid.Bytes) { bytes[1] = Reader.UnalignedReadTinyInt(1); this.HaveTransportTime3 = Reader.UnalignedReadBit(); bytes[3] = Reader.UnalignedReadTinyInt(1); bytes[2] = Reader.UnalignedReadTinyInt(1); bytes[6] = Reader.UnalignedReadTinyInt(1); bytes[5] = Reader.UnalignedReadTinyInt(1); bytes[0] = Reader.UnalignedReadTinyInt(1); bytes[4] = Reader.UnalignedReadTinyInt(1); this.HaveTransportTime2 = Reader.UnalignedReadBit(); bytes[7] = Reader.UnalignedReadTinyInt(1); } } ushort field_1B2 = 0; ushort field_1AE = 0; ushort field_1B0 = 0; if (field_1AC) { field_1B2 = (ushort)(!Reader.UnalignedReadBit() ? 1 : 0); field_1AE = (ushort)(!Reader.UnalignedReadBit() ? 1 : 0); field_1B0 = (ushort)(!Reader.UnalignedReadBit() ? 1 : 0); } if (this.HaveAttackingTarget) { fixed(byte *bytes = this.AttackingTarget.Bytes) { bytes[3] = Reader.UnalignedReadTinyInt(1); bytes[4] = Reader.UnalignedReadTinyInt(1); bytes[6] = Reader.UnalignedReadTinyInt(1); bytes[0] = Reader.UnalignedReadTinyInt(1); bytes[1] = Reader.UnalignedReadTinyInt(1); bytes[7] = Reader.UnalignedReadTinyInt(1); bytes[5] = Reader.UnalignedReadTinyInt(1); bytes[2] = Reader.UnalignedReadTinyInt(1); } } this.UnkUInt32 = new uint[arrCounter]; for (uint i = 0; i < arrCounter; ++i) { this.UnkUInt32[i] = Reader.ReadUInt32(); } if (this.HavePosition) { Reader .ReadSingle(out this.Position.Z) .ReadSingle(out this.Orientation) .ReadSingle(out this.Position.X) .ReadSingle(out this.Position.Y); } if (this.HaveVehicleData) { Reader .ReadUInt32(out this.VehicleId) .ReadSingle(out this.VehicleAimAdjustement); } if (this.HaveGameObjectPosition) { fixed(byte *bytes = this.TransportGuid.Bytes) { Reader .ReadXorByte(ref bytes[1]) .ReadXorByte(ref bytes[4]) .ReadSingle(out this.TransportPosition.Z); if (this.HaveTransportTime3) { this.TransportTime3 = Reader.ReadUInt32(); } this.TransportTime = Reader.ReadUInt32(); Reader .ReadXorByte(ref bytes[5]) .ReadXorByte(ref bytes[6]) .ReadSingle(out this.TransportPosition.X) .ReadXorByte(ref bytes[2]); if (this.HaveTransportTime2) { this.TransportTime2 = Reader.ReadUInt32(); } Reader .ReadSByte(out this.TransportSeat) .ReadXorByte(ref bytes[3]) .ReadSingle(out this.TransportPosition.Y) .ReadSingle(out this.TransportFacing) .ReadXorByte(ref bytes[7]) .ReadXorByte(ref bytes[0]); } } if (this.Living) { if (this.HaveSpline2) { if (this.HaveSpline) { var points = this.Spline.Points; points.Capacity = (int)splinePoints; for (int i = 0; i < splinePoints; i++) { points.Add(new Vector3() { Y = Reader.ReadSingle(), X = Reader.ReadSingle(), Z = Reader.ReadSingle() }); } if (this.Spline.HaveDurationMultiplier) { this.Spline.DurationMultiplier = Reader.ReadSingle(); } this.Spline.UnknownFloat2 = Reader.ReadSingle(); if (this.Spline.SplineType == SplineType.FacingTarget) { fixed(byte *bytes = this.Spline.FacingTarget.Bytes) { Reader .ReadXorByte(ref bytes[3]) .ReadXorByte(ref bytes[4]) .ReadXorByte(ref bytes[5]) .ReadXorByte(ref bytes[7]) .ReadXorByte(ref bytes[2]) .ReadXorByte(ref bytes[0]) .ReadXorByte(ref bytes[6]) .ReadXorByte(ref bytes[1]); } } if (this.Spline.HaveUnknown1) { this.Spline.Unknown1 = Reader.ReadUInt32(); } this.Spline.UnknownFloat3 = Reader.ReadSingle(); this.Spline.Unknown2 = Reader.ReadUInt32(); if (this.Spline.SplineType == SplineType.FacingSpot) { Reader .ReadSingle(out this.Spline.FacingSpot.Y) .ReadSingle(out this.Spline.FacingSpot.Z) .ReadSingle(out this.Spline.FacingSpot.X); } this.Spline.CurrentTime = Reader.ReadUInt32(); if (this.Spline.SplineType == SplineType.FacingAngle) { this.Spline.FacingAngle = Reader.ReadSingle(); } } Reader .ReadSingle(out this.Spline.EndPoint.Z) .ReadSingle(out this.Spline.EndPoint.Y) .ReadUInt32(out this.Spline.FullTime) .ReadSingle(out this.Spline.EndPoint.X); } this.Speeds[8] = Reader.ReadSingle(); // Transport Data if (this.HaveTransportData) { fixed(byte *bytes = this.TransportGuid.Bytes) { Reader .ReadXorByte(ref bytes[4]) .ReadSingle(out this.TransportPosition.Z) .ReadXorByte(ref bytes[7]) .ReadXorByte(ref bytes[5]) .ReadXorByte(ref bytes[1]) .ReadSingle(out this.TransportPosition.X) .ReadXorByte(ref bytes[3]) .ReadXorByte(ref bytes[6]); if (this.HaveTransportTime3) { this.TransportTime3 = Reader.ReadUInt32(); } Reader .ReadSingle(out this.TransportPosition.Y) .ReadSByte(out this.TransportSeat) .ReadSingle(out this.TransportFacing); if (this.HaveTransportTime2) { this.TransportTime2 = Reader.ReadUInt32(); } Reader .ReadXorByte(ref bytes[2]) .ReadUInt32(out this.TransportTime) .ReadXorByte(ref bytes[0]); } } Reader .ReadSingle(out this.Speeds[7]) .ReadSingle(out this.Position.X); if (this.HavePitch) { Reader.ReadSingle(out this.Pitch); } // Fall Data if (this.HaveFallData) { Reader.ReadUInt32(out this.FallTime); if (this.HaveFallDirection) { Reader .ReadSingle(out this.FallSinAngle) .ReadSingle(out this.FallHorizontalSpeed) .ReadSingle(out this.FallCosAngle); } Reader.ReadSingle(out this.FallVerticalSpeed); } Reader .ReadXorByte(ref p_guid.Bytes[7]) .ReadSingle(out this.Speeds[4]) .ReadXorByte(ref p_guid.Bytes[0]) .ReadXorByte(ref p_guid.Bytes[5]); if (this.TimeStamp != 0) { this.TimeStamp = Reader.ReadUInt32(); } Reader .ReadSingle(out this.Position.Z) .ReadSingle(out this.Speeds[6]) .ReadXorByte(ref p_guid.Bytes[1]) .ReadSingle(out this.Speeds[2]) .ReadSingle(out this.Speeds[5]) .ReadSingle(out this.Speeds[3]) .ReadSingle(out this.Speeds[0]) .ReadXorByte(ref p_guid.Bytes[3]) .ReadXorByte(ref p_guid.Bytes[4]) .ReadXorByte(ref p_guid.Bytes[2]) .ReadXorByte(ref p_guid.Bytes[6]); if (this.HaveSplineElevation) { this.SplineElevation = Reader.ReadSingle(); } this.Position.Y = Reader.ReadSingle(); if (haveOrientation) { this.Orientation = Reader.ReadSingle(); } this.Speeds[1] = Reader.ReadSingle(); } if (field_1C8) { Console.WriteLine("Error: 16 floats @ 1CC detected !!!"); Reader.ReadBytes(16 * 4); // 16 floats starting at 1CC var field_20C = Reader.ReadByte(); } // transport time if (this.HaveTransportTime) { Reader.ReadUInt32(out this.TransportTime); } // unk2 ? if (field_1AC) { Console.WriteLine("Error: 3 shorts @ 1AE detected !!!"); if (field_1B0 != 0) { field_1B0 = Reader.ReadUInt16(); } if (field_1B2 != 0) { field_1B2 = Reader.ReadUInt16(); } if (field_1AE != 0) { field_1AE = Reader.ReadUInt16(); } } // go rotation? if (this.HaveGameObjectRotation) { this.GameObjectRotation = Reader.ReadUInt64().UnpackQuaternion(); } // target guid? if (this.HaveAttackingTarget) { fixed(byte *bytes = this.AttackingTarget.Bytes) { Reader .ReadXorByte(ref bytes[3]) .ReadXorByte(ref bytes[5]) .ReadXorByte(ref bytes[0]) .ReadXorByte(ref bytes[7]) .ReadXorByte(ref bytes[2]) .ReadXorByte(ref bytes[4]) .ReadXorByte(ref bytes[6]) .ReadXorByte(ref bytes[1]); } } this.Guid = guid; }
protected override unsafe void InternalOpenForReading(Stream stream, bool closeStream) { base.InternalOpenForReading(stream, closeStream); int optLen; var headerBytes = m_stream.ReadBytes(MainHeader.Size); fixed(byte *ptr = headerBytes) { var header = (MainHeader *)ptr; GetClientBuildInfo(header->ClientBuild); var langBytes = stackalloc byte[5]; langBytes[0] = header->Lang[0]; langBytes[1] = header->Lang[1]; langBytes[2] = (byte)'-'; langBytes[3] = header->Lang[2]; langBytes[4] = header->Lang[3]; var lang = new string((sbyte *)langBytes, 0, 5); try { this.Culture = CultureInfo.GetCultureInfo(lang); } catch { } optLen = header->OptionalHeaderLength; Marshal.Copy(new IntPtr(header->SessionKey), m_sessionKey, 0, 40); this.SnifferId = (PktSnifferId)header->SnifferId; this.StartTicks = header->StartedOnTicks; this.StartTime = header->StartedOnUnix.AsUnixTime(); } if (this.SnifferId == PktSnifferId.Kamilla) { using (var reader = new StreamHandler(m_stream.ReadBytes(optLen))) { var flags = (OptHeaderFlags)reader.ReadUInt32(); if ((flags & OptHeaderFlags.HasOCAD) != 0) { reader.Skip(4); } if ((flags & OptHeaderFlags.HasSnifferDescString) != 0) { this.SnifferDesc = reader.ReadCString(); } if ((flags & OptHeaderFlags.HasFCAD) != 0) { this.FCAD = reader.ReadBytes(16); } if ((flags & OptHeaderFlags.HasSCAD) != 0) { this.SCAD = reader.ReadBytes(16); } } } else { m_stream.Skip(optLen); } this.InternalSetCapacity((int)((m_stream.Length - m_stream.Position) / 100)); }
protected unsafe override void InternalOpenForReading(Stream stream, bool closeStream) { base.InternalOpenForReading(stream, closeStream); int optLen; var headerBytes = m_stream.ReadBytes(MainHeader.Size); fixed (byte* ptr = headerBytes) { var header = (MainHeader*)ptr; GetClientBuildInfo(header->ClientBuild); var langBytes = stackalloc byte[5]; langBytes[0] = header->Lang[0]; langBytes[1] = header->Lang[1]; langBytes[2] = (byte)'-'; langBytes[3] = header->Lang[2]; langBytes[4] = header->Lang[3]; var lang = new string((sbyte*)langBytes, 0, 5); try { this.Culture = CultureInfo.GetCultureInfo(lang); } catch { } optLen = header->OptionalHeaderLength; Marshal.Copy(new IntPtr(header->SessionKey), m_sessionKey, 0, 40); this.SnifferId = (PktSnifferId)header->SnifferId; this.StartTicks = header->StartedOnTicks; this.StartTime = header->StartedOnUnix.AsUnixTime(); } if (this.SnifferId == PktSnifferId.Kamilla) { using (var reader = new StreamHandler(m_stream.ReadBytes(optLen))) { var flags = (OptHeaderFlags)reader.ReadUInt32(); if ((flags & OptHeaderFlags.HasOCAD) != 0) reader.Skip(4); if ((flags & OptHeaderFlags.HasSnifferDescString) != 0) this.SnifferDesc = reader.ReadCString(); if ((flags & OptHeaderFlags.HasFCAD) != 0) this.FCAD = reader.ReadBytes(16); if ((flags & OptHeaderFlags.HasSCAD) != 0) this.SCAD = reader.ReadBytes(16); } } else m_stream.Skip(optLen); this.InternalSetCapacity((int)((m_stream.Length - m_stream.Position) / 100)); }
public unsafe MovementInfo(StreamHandler Reader) { var guid = new WowGuid(); this.HaveAttackingTarget = Reader.UnalignedReadBit(); guid.Bytes[2] = Reader.UnalignedReadTinyInt(1); this.HaveVehicleData = Reader.UnalignedReadBit(); guid.Bytes[1] = Reader.UnalignedReadTinyInt(1); guid.Bytes[4] = Reader.UnalignedReadTinyInt(1); guid.Bytes[3] = Reader.UnalignedReadTinyInt(1); this.HaveTransportTime = Reader.UnalignedReadBit(); this.HaveGameObjectPosition = Reader.UnalignedReadBit(); bool field_1C8 = Reader.UnalignedReadBit(); bool field_1AC = Reader.UnalignedReadBit(); this.HaveGameObjectRotation = Reader.UnalignedReadBit(); this.Living = Reader.UnalignedReadBit(); this.HavePosition = Reader.UnalignedReadBit(); var arrCounter = Reader.UnalignedReadInt(24); guid.Bytes[0] = Reader.UnalignedReadTinyInt(1); bool havePFlags = false; WowGuid p_guid; uint splinePoints = 0; bool havePFlags2 = false; bool haveOrientation = false; if (this.Living) { this.HaveTransportData = Reader.UnalignedReadBit(); if (this.HaveTransportData) { fixed (byte* bytes = this.TransportGuid.Bytes) { bytes[2] = Reader.UnalignedReadTinyInt(1); bytes[7] = Reader.UnalignedReadTinyInt(1); bytes[5] = Reader.UnalignedReadTinyInt(1); this.HaveTransportTime3 = Reader.UnalignedReadBit(); bytes[3] = Reader.UnalignedReadTinyInt(1); bytes[0] = Reader.UnalignedReadTinyInt(1); bytes[4] = Reader.UnalignedReadTinyInt(1); bytes[1] = Reader.UnalignedReadTinyInt(1); this.HaveTransportTime2 = Reader.UnalignedReadBit(); bytes[6] = Reader.UnalignedReadTinyInt(1); } } this.HaveSpline2 = Reader.UnalignedReadBit(); p_guid.Bytes[7] = Reader.UnalignedReadTinyInt(1); p_guid.Bytes[6] = Reader.UnalignedReadTinyInt(1); p_guid.Bytes[5] = Reader.UnalignedReadTinyInt(1); p_guid.Bytes[2] = Reader.UnalignedReadTinyInt(1); p_guid.Bytes[4] = Reader.UnalignedReadTinyInt(1); havePFlags = !Reader.UnalignedReadBit(); p_guid.Bytes[1] = Reader.UnalignedReadTinyInt(1); this.SelfTarget = Reader.UnalignedReadBit(); this.TimeStamp = !Reader.UnalignedReadBit() ? 1U : 0U; havePFlags2 = !Reader.UnalignedReadBit(); if (this.HaveSpline2) { this.HaveSpline = Reader.UnalignedReadBit(); if (this.HaveSpline) { this.Spline.HaveDurationMultiplier = Reader.UnalignedReadBit(); this.Spline.Flags = (SplineFlags)Reader.UnalignedReadInt(25); this.Spline.SplineMode = (SplineMode)Reader.UnalignedReadTinyInt(2); this.Spline.HaveUnknown1 = Reader.UnalignedReadBit(); splinePoints = Reader.UnalignedReadInt(22); var type = Reader.UnalignedReadTinyInt(2); switch (type) { case 0: this.Spline.SplineType = SplineType.FacingSpot; break; case 1: this.Spline.SplineType = SplineType.Normal; break; case 2: this.Spline.SplineType = SplineType.FacingTarget; break; case 3: this.Spline.SplineType = SplineType.FacingAngle; break; } if (this.Spline.SplineType == SplineType.FacingTarget) { fixed (byte* bytes = this.Spline.FacingTarget.Bytes) { bytes[7] = Reader.UnalignedReadTinyInt(1); bytes[3] = Reader.UnalignedReadTinyInt(1); bytes[4] = Reader.UnalignedReadTinyInt(1); bytes[2] = Reader.UnalignedReadTinyInt(1); bytes[1] = Reader.UnalignedReadTinyInt(1); bytes[6] = Reader.UnalignedReadTinyInt(1); bytes[0] = Reader.UnalignedReadTinyInt(1); bytes[5] = Reader.UnalignedReadTinyInt(1); } } } } p_guid.Bytes[3] = Reader.UnalignedReadTinyInt(1); if (havePFlags) this.Flags = (MovementFlags)Reader.UnalignedReadInt(30); this.HavePitch = !Reader.UnalignedReadBit(); this.HaveFallData = Reader.UnalignedReadBit(); if (havePFlags2) this.Flags2 = (MovementFlags2)Reader.UnalignedReadSmallInt(12); p_guid.Bytes[0] = Reader.UnalignedReadTinyInt(1); haveOrientation = !Reader.UnalignedReadBit(); if (this.HaveFallData) this.HaveFallDirection = Reader.UnalignedReadBit(); this.HaveSplineElevation = !Reader.UnalignedReadBit(); } if (this.HaveGameObjectPosition) { fixed (byte* bytes = this.TransportGuid.Bytes) { bytes[1] = Reader.UnalignedReadTinyInt(1); this.HaveTransportTime3 = Reader.UnalignedReadBit(); bytes[3] = Reader.UnalignedReadTinyInt(1); bytes[2] = Reader.UnalignedReadTinyInt(1); bytes[6] = Reader.UnalignedReadTinyInt(1); bytes[5] = Reader.UnalignedReadTinyInt(1); bytes[0] = Reader.UnalignedReadTinyInt(1); bytes[4] = Reader.UnalignedReadTinyInt(1); this.HaveTransportTime2 = Reader.UnalignedReadBit(); bytes[7] = Reader.UnalignedReadTinyInt(1); } } ushort field_1B2 = 0; ushort field_1AE = 0; ushort field_1B0 = 0; if (field_1AC) { field_1B2 = (ushort)(!Reader.UnalignedReadBit() ? 1 : 0); field_1AE = (ushort)(!Reader.UnalignedReadBit() ? 1 : 0); field_1B0 = (ushort)(!Reader.UnalignedReadBit() ? 1 : 0); } if (this.HaveAttackingTarget) { fixed (byte* bytes = this.AttackingTarget.Bytes) { bytes[3] = Reader.UnalignedReadTinyInt(1); bytes[4] = Reader.UnalignedReadTinyInt(1); bytes[6] = Reader.UnalignedReadTinyInt(1); bytes[0] = Reader.UnalignedReadTinyInt(1); bytes[1] = Reader.UnalignedReadTinyInt(1); bytes[7] = Reader.UnalignedReadTinyInt(1); bytes[5] = Reader.UnalignedReadTinyInt(1); bytes[2] = Reader.UnalignedReadTinyInt(1); } } this.UnkUInt32 = new uint[arrCounter]; for (uint i = 0; i < arrCounter; ++i) { this.UnkUInt32[i] = Reader.ReadUInt32(); } if (this.HavePosition) { Reader .ReadSingle(out this.Position.Z) .ReadSingle(out this.Orientation) .ReadSingle(out this.Position.X) .ReadSingle(out this.Position.Y); } if (this.HaveVehicleData) { Reader .ReadUInt32(out this.VehicleId) .ReadSingle(out this.VehicleAimAdjustement); } if (this.HaveGameObjectPosition) { fixed (byte* bytes = this.TransportGuid.Bytes) { Reader .ReadXorByte(ref bytes[1]) .ReadXorByte(ref bytes[4]) .ReadSingle(out this.TransportPosition.Z); if (this.HaveTransportTime3) this.TransportTime3 = Reader.ReadUInt32(); this.TransportTime = Reader.ReadUInt32(); Reader .ReadXorByte(ref bytes[5]) .ReadXorByte(ref bytes[6]) .ReadSingle(out this.TransportPosition.X) .ReadXorByte(ref bytes[2]); if (this.HaveTransportTime2) this.TransportTime2 = Reader.ReadUInt32(); Reader .ReadSByte(out this.TransportSeat) .ReadXorByte(ref bytes[3]) .ReadSingle(out this.TransportPosition.Y) .ReadSingle(out this.TransportFacing) .ReadXorByte(ref bytes[7]) .ReadXorByte(ref bytes[0]); } } if (this.Living) { if (this.HaveSpline2) { if (this.HaveSpline) { var points = this.Spline.Points; points.Capacity = (int)splinePoints; for (int i = 0; i < splinePoints; i++) points.Add(new Vector3() { Y = Reader.ReadSingle(), X = Reader.ReadSingle(), Z = Reader.ReadSingle() }); if (this.Spline.HaveDurationMultiplier) { this.Spline.DurationMultiplier = Reader.ReadSingle(); } this.Spline.UnknownFloat2 = Reader.ReadSingle(); if (this.Spline.SplineType == SplineType.FacingTarget) { fixed (byte* bytes = this.Spline.FacingTarget.Bytes) { Reader .ReadXorByte(ref bytes[3]) .ReadXorByte(ref bytes[4]) .ReadXorByte(ref bytes[5]) .ReadXorByte(ref bytes[7]) .ReadXorByte(ref bytes[2]) .ReadXorByte(ref bytes[0]) .ReadXorByte(ref bytes[6]) .ReadXorByte(ref bytes[1]); } } if (this.Spline.HaveUnknown1) { this.Spline.Unknown1 = Reader.ReadUInt32(); } this.Spline.UnknownFloat3 = Reader.ReadSingle(); this.Spline.Unknown2 = Reader.ReadUInt32(); if (this.Spline.SplineType == SplineType.FacingSpot) { Reader .ReadSingle(out this.Spline.FacingSpot.Y) .ReadSingle(out this.Spline.FacingSpot.Z) .ReadSingle(out this.Spline.FacingSpot.X); } this.Spline.CurrentTime = Reader.ReadUInt32(); if (this.Spline.SplineType == SplineType.FacingAngle) this.Spline.FacingAngle = Reader.ReadSingle(); } Reader .ReadSingle(out this.Spline.EndPoint.Z) .ReadSingle(out this.Spline.EndPoint.Y) .ReadUInt32(out this.Spline.FullTime) .ReadSingle(out this.Spline.EndPoint.X); } this.Speeds[8] = Reader.ReadSingle(); // Transport Data if (this.HaveTransportData) { fixed (byte* bytes = this.TransportGuid.Bytes) { Reader .ReadXorByte(ref bytes[4]) .ReadSingle(out this.TransportPosition.Z) .ReadXorByte(ref bytes[7]) .ReadXorByte(ref bytes[5]) .ReadXorByte(ref bytes[1]) .ReadSingle(out this.TransportPosition.X) .ReadXorByte(ref bytes[3]) .ReadXorByte(ref bytes[6]); if (this.HaveTransportTime3) this.TransportTime3 = Reader.ReadUInt32(); Reader .ReadSingle(out this.TransportPosition.Y) .ReadSByte(out this.TransportSeat) .ReadSingle(out this.TransportFacing); if (this.HaveTransportTime2) this.TransportTime2 = Reader.ReadUInt32(); Reader .ReadXorByte(ref bytes[2]) .ReadUInt32(out this.TransportTime) .ReadXorByte(ref bytes[0]); } } Reader .ReadSingle(out this.Speeds[7]) .ReadSingle(out this.Position.X); if (this.HavePitch) Reader.ReadSingle(out this.Pitch); // Fall Data if (this.HaveFallData) { Reader.ReadUInt32(out this.FallTime); if (this.HaveFallDirection) { Reader .ReadSingle(out this.FallSinAngle) .ReadSingle(out this.FallHorizontalSpeed) .ReadSingle(out this.FallCosAngle); } Reader.ReadSingle(out this.FallVerticalSpeed); } Reader .ReadXorByte(ref p_guid.Bytes[7]) .ReadSingle(out this.Speeds[4]) .ReadXorByte(ref p_guid.Bytes[0]) .ReadXorByte(ref p_guid.Bytes[5]); if (this.TimeStamp != 0) this.TimeStamp = Reader.ReadUInt32(); Reader .ReadSingle(out this.Position.Z) .ReadSingle(out this.Speeds[6]) .ReadXorByte(ref p_guid.Bytes[1]) .ReadSingle(out this.Speeds[2]) .ReadSingle(out this.Speeds[5]) .ReadSingle(out this.Speeds[3]) .ReadSingle(out this.Speeds[0]) .ReadXorByte(ref p_guid.Bytes[3]) .ReadXorByte(ref p_guid.Bytes[4]) .ReadXorByte(ref p_guid.Bytes[2]) .ReadXorByte(ref p_guid.Bytes[6]); if (this.HaveSplineElevation) this.SplineElevation = Reader.ReadSingle(); this.Position.Y = Reader.ReadSingle(); if (haveOrientation) this.Orientation = Reader.ReadSingle(); this.Speeds[1] = Reader.ReadSingle(); } if (field_1C8) { Console.WriteLine("Error: 16 floats @ 1CC detected !!!"); Reader.ReadBytes(16 * 4); // 16 floats starting at 1CC var field_20C = Reader.ReadByte(); } // transport time if (this.HaveTransportTime) Reader.ReadUInt32(out this.TransportTime); // unk2 ? if (field_1AC) { Console.WriteLine("Error: 3 shorts @ 1AE detected !!!"); if (field_1B0 != 0) field_1B0 = Reader.ReadUInt16(); if (field_1B2 != 0) field_1B2 = Reader.ReadUInt16(); if (field_1AE != 0) field_1AE = Reader.ReadUInt16(); } // go rotation? if (this.HaveGameObjectRotation) this.GameObjectRotation = Reader.ReadUInt64().UnpackQuaternion(); // target guid? if (this.HaveAttackingTarget) { fixed (byte* bytes = this.AttackingTarget.Bytes) { Reader .ReadXorByte(ref bytes[3]) .ReadXorByte(ref bytes[5]) .ReadXorByte(ref bytes[0]) .ReadXorByte(ref bytes[7]) .ReadXorByte(ref bytes[2]) .ReadXorByte(ref bytes[4]) .ReadXorByte(ref bytes[6]) .ReadXorByte(ref bytes[1]); } } this.Guid = guid; }