private void Parse(Stream stream) { var s = new BinaryStreamWrapper(stream, ByteOrder.LittleEndian); mInstance = s.ReadUInt64(); mUnknown1 = s.ReadUInt32(); mUnknown2 = s.ReadUInt32(); }
protected override void Parse(Stream s) { var bw = new BinaryStreamWrapper(s, ByteOrder.BigEndian); uint index = bw.ReadUInt32(); while (index != 0xFFFFFFFF) { var item = new VisualEffectName(0, base.handler, s, index); index = bw.ReadUInt32(); base.Add(item); } }
protected void Parse(Stream s) { BinaryStreamWrapper wrapper = new BinaryStreamWrapper(s, ByteOrder.BigEndian); uint index = wrapper.ReadUInt32(); while (index != uint.MaxValue) { VisualEffectName item = new VisualEffectName(0, base.handler, s, index); index = wrapper.ReadUInt32(); base.Add(item); } }
private void Parse(Stream s) { var br = new BinaryStreamWrapper(s); br.ByteOrder = ByteOrder.BigEndian; mId = (SoundProperty)br.ReadUInt32(); mTypeCode = (DataType)br.ReadUInt16(); mRepCode = br.ReadUInt16(); var data = new List <TypedData>(); if (!HasTypeData) { data.Add(ReadTypedData(0, handler, mTypeCode, s)); } else { int count = br.ReadInt32(); int itemSize = br.ReadInt32(); if (itemSize != ItemSize) { throw new InvalidDataException(String.Format("Bad item size: Expected {0}, but got {1}", ItemSize, itemSize)); } for (int i = 0; i < count; i++) { data.Add(ReadTypedData(0, handler, mTypeCode, s)); } } mItems = new DataList(handler, data, this); }
public unsafe void TestMethod() { MemoryStream stream = new MemoryStream(); BinaryStreamWrapper bs = new BinaryStreamWrapper(stream, false); Random rand = new Random(); int seed = rand.Next(); rand = new Random(seed); byte[] data = new byte[16]; byte[] data2 = new byte[16]; fixed(byte *lp = data) { for (int x = 0; x < 10000; x++) { rand.NextBytes(data); while (rand.Next(4) < 2) { bs.Write(*lp); } int skip = rand.Next(40) + 1; bs.Position += skip; bs.Position -= rand.Next(skip); rand.NextBytes(data); while (rand.Next(4) < 2) { bs.Write(*(sbyte *)lp); } rand.NextBytes(data); while (rand.Next(4) < 2) { bs.Write(*(short *)lp); } rand.NextBytes(data); while (rand.Next(4) < 2) { bs.Write(*(int *)lp); } rand.NextBytes(data); while (rand.Next(4) < 2) { bs.Write(*(long *)lp); } rand.NextBytes(data); while (rand.Next(4) < 2) { bs.Write(*(ushort *)lp); } rand.NextBytes(data); while (rand.Next(4) < 2) { bs.Write(*(uint *)lp); } rand.NextBytes(data); while (rand.Next(4) < 2) { bs.Write(*(ulong *)lp); } rand.NextBytes(data); while (rand.Next(4) < 2) { bs.Write(NextDecimal(data, rand)); } rand.NextBytes(data); while (rand.Next(4) < 2) { bs.Write(*(Guid *)lp); } rand.NextBytes(data); while (rand.Next(4) < 2) { bs.Write(NextDate(data, rand)); } rand.NextBytes(data); while (rand.Next(4) < 2) { bs.Write(NextSingle(data, rand)); } rand.NextBytes(data); while (rand.Next(4) < 2) { bs.Write(NextDouble(data, rand)); } rand.NextBytes(data); bool value = *lp != 0; while (rand.Next(4) < 2) { bs.Write(value); } rand.NextBytes(data); while (rand.Next(4) < 2) { bs.Write7Bit(*(uint *)lp); } data[3] = 0; while (rand.Next(4) < 2) { bs.Write7Bit(*(uint *)lp); } data[2] = 0; while (rand.Next(4) < 2) { bs.Write7Bit(*(uint *)lp); } data[1] = 0; while (rand.Next(4) < 2) { bs.Write7Bit(*(uint *)lp); } rand.NextBytes(data); while (rand.Next(4) < 2) { bs.Write7Bit(*(ulong *)lp); } data[7] = 0; while (rand.Next(4) < 2) { bs.Write7Bit(*(ulong *)lp); } data[6] = 0; while (rand.Next(4) < 2) { bs.Write7Bit(*(ulong *)lp); } data[5] = 0; while (rand.Next(4) < 2) { bs.Write7Bit(*(ulong *)lp); } data[4] = 0; while (rand.Next(4) < 2) { bs.Write7Bit(*(ulong *)lp); } data[3] = 0; while (rand.Next(4) < 2) { bs.Write7Bit(*(ulong *)lp); } data[2] = 0; while (rand.Next(4) < 2) { bs.Write7Bit(*(ulong *)lp); } data[1] = 0; while (rand.Next(4) < 2) { bs.Write7Bit(*(ulong *)lp); } rand.NextBytes(data); bs.Write(data, 0, data.Length); while (rand.Next(4) < 2) { if (bs.Position > 100) { bs.Position -= 100; int insertCount = rand.Next(16) + 1; bs.InsertBytes(insertCount, 100); bs.Write(data, 0, insertCount); bs.Position -= insertCount; bs.ReadAll(data2, 0, insertCount); bs.Position -= insertCount; bs.RemoveBytes(insertCount, 100); bs.Position += 100; for (int y = 0; y < insertCount; y++) { if (data[y] != data2[y]) { throw new Exception(); } } } } } rand = new Random(seed); bs.Position = 0; for (int x = 0; x < 10000; x++) { rand.NextBytes(data); while (rand.Next(4) < 2) { if (bs.ReadUInt8() != *lp) { throw new Exception(); } } int skip = rand.Next(40) + 1; bs.Position += skip; bs.Position -= rand.Next(skip); rand.NextBytes(data); while (rand.Next(4) < 2) { if (bs.ReadInt8() != *(sbyte *)lp) { throw new Exception(); } } rand.NextBytes(data); while (rand.Next(4) < 2) { if (bs.ReadInt16() != *(short *)lp) { throw new Exception(); } } rand.NextBytes(data); while (rand.Next(4) < 2) { if (bs.ReadInt32() != *(int *)lp) { throw new Exception(); } } rand.NextBytes(data); while (rand.Next(4) < 2) { if (bs.ReadInt64() != *(long *)lp) { throw new Exception(); } } rand.NextBytes(data); while (rand.Next(4) < 2) { if (bs.ReadUInt16() != *(ushort *)lp) { throw new Exception(); } } rand.NextBytes(data); while (rand.Next(4) < 2) { if (bs.ReadUInt32() != *(uint *)lp) { throw new Exception(); } } rand.NextBytes(data); while (rand.Next(4) < 2) { if (bs.ReadUInt64() != *(ulong *)lp) { throw new Exception(); } } rand.NextBytes(data); while (rand.Next(4) < 2) { if (bs.ReadDecimal() != NextDecimal(data, rand)) { throw new Exception(); } } rand.NextBytes(data); while (rand.Next(4) < 2) { if (bs.ReadGuid() != *(Guid *)lp) { throw new Exception(); } } rand.NextBytes(data); while (rand.Next(4) < 2) { if (bs.ReadDateTime() != NextDate(data, rand)) { throw new Exception(); } } rand.NextBytes(data); while (rand.Next(4) < 2) { if (bs.ReadSingle() != NextSingle(data, rand)) { throw new Exception(); } } rand.NextBytes(data); while (rand.Next(4) < 2) { if (bs.ReadDouble() != NextDouble(data, rand)) { throw new Exception(); } } rand.NextBytes(data); bool b2 = *lp != 0; while (rand.Next(4) < 2) { if (bs.ReadBoolean() != b2) { throw new Exception(); } } rand.NextBytes(data); while (rand.Next(4) < 2) { if (bs.Read7BitUInt32() != *(uint *)lp) { throw new Exception(); } } data[3] = 0; while (rand.Next(4) < 2) { if (bs.Read7BitUInt32() != *(uint *)lp) { throw new Exception(); } } data[2] = 0; while (rand.Next(4) < 2) { if (bs.Read7BitUInt32() != *(uint *)lp) { throw new Exception(); } } data[1] = 0; while (rand.Next(4) < 2) { if (bs.Read7BitUInt32() != *(uint *)lp) { throw new Exception(); } } rand.NextBytes(data); while (rand.Next(4) < 2) { if (bs.Read7BitUInt64() != *(ulong *)lp) { throw new Exception(); } } data[7] = 0; while (rand.Next(4) < 2) { if (bs.Read7BitUInt64() != *(ulong *)lp) { throw new Exception(); } } data[6] = 0; while (rand.Next(4) < 2) { if (bs.Read7BitUInt64() != *(ulong *)lp) { throw new Exception(); } } data[5] = 0; while (rand.Next(4) < 2) { if (bs.Read7BitUInt64() != *(ulong *)lp) { throw new Exception(); } } data[4] = 0; while (rand.Next(4) < 2) { if (bs.Read7BitUInt64() != *(ulong *)lp) { throw new Exception(); } } data[3] = 0; while (rand.Next(4) < 2) { if (bs.Read7BitUInt64() != *(ulong *)lp) { throw new Exception(); } } data[2] = 0; while (rand.Next(4) < 2) { if (bs.Read7BitUInt64() != *(ulong *)lp) { throw new Exception(); } } data[1] = 0; while (rand.Next(4) < 2) { if (bs.Read7BitUInt64() != *(ulong *)lp) { throw new Exception(); } } rand.NextBytes(data); bs.ReadAll(data2, 0, 16); if (!data2.SequenceEqual(data)) { throw new Exception(); } while (rand.Next(4) < 2) { if (bs.Position > 100) { int insertCount = rand.Next(16); } } } } }
public unsafe void TestMethod() { MemoryStream stream = new MemoryStream(); BinaryStreamWrapper bs = new BinaryStreamWrapper(stream, false); Random rand = new Random(); int seed = rand.Next(); rand = new Random(seed); byte[] data = new byte[16]; byte[] data2 = new byte[16]; fixed (byte* lp = data) { for (int x = 0; x < 10000; x++) { rand.NextBytes(data); while (rand.Next(4) < 2) bs.Write(*(byte*)lp); int skip = rand.Next(40) + 1; bs.Position += skip; bs.Position -= rand.Next(skip); rand.NextBytes(data); while (rand.Next(4) < 2) bs.Write(*(sbyte*)lp); rand.NextBytes(data); while (rand.Next(4) < 2) bs.Write(*(short*)lp); rand.NextBytes(data); while (rand.Next(4) < 2) bs.Write(*(int*)lp); rand.NextBytes(data); while (rand.Next(4) < 2) bs.Write(*(long*)lp); rand.NextBytes(data); while (rand.Next(4) < 2) bs.Write(*(ushort*)lp); rand.NextBytes(data); while (rand.Next(4) < 2) bs.Write(*(uint*)lp); rand.NextBytes(data); while (rand.Next(4) < 2) bs.Write(*(ulong*)lp); rand.NextBytes(data); while (rand.Next(4) < 2) bs.Write(NextDecimal(data, rand)); rand.NextBytes(data); while (rand.Next(4) < 2) bs.Write(*(Guid*)lp); rand.NextBytes(data); while (rand.Next(4) < 2) bs.Write(NextDate(data, rand)); rand.NextBytes(data); while (rand.Next(4) < 2) bs.Write(NextSingle(data, rand)); rand.NextBytes(data); while (rand.Next(4) < 2) bs.Write(NextDouble(data, rand)); rand.NextBytes(data); bool value = (*lp != 0); while (rand.Next(4) < 2) bs.Write(value); rand.NextBytes(data); while (rand.Next(4) < 2) bs.Write7Bit(*(uint*)lp); data[3] = 0; while (rand.Next(4) < 2) bs.Write7Bit(*(uint*)lp); data[2] = 0; while (rand.Next(4) < 2) bs.Write7Bit(*(uint*)lp); data[1] = 0; while (rand.Next(4) < 2) bs.Write7Bit(*(uint*)lp); rand.NextBytes(data); while (rand.Next(4) < 2) bs.Write7Bit(*(ulong*)lp); data[7] = 0; while (rand.Next(4) < 2) bs.Write7Bit(*(ulong*)lp); data[6] = 0; while (rand.Next(4) < 2) bs.Write7Bit(*(ulong*)lp); data[5] = 0; while (rand.Next(4) < 2) bs.Write7Bit(*(ulong*)lp); data[4] = 0; while (rand.Next(4) < 2) bs.Write7Bit(*(ulong*)lp); data[3] = 0; while (rand.Next(4) < 2) bs.Write7Bit(*(ulong*)lp); data[2] = 0; while (rand.Next(4) < 2) bs.Write7Bit(*(ulong*)lp); data[1] = 0; while (rand.Next(4) < 2) bs.Write7Bit(*(ulong*)lp); rand.NextBytes(data); bs.Write(data, 0, data.Length); while (rand.Next(4) < 2) { if (bs.Position > 100) { bs.Position -= 100; int insertCount = rand.Next(16) + 1; bs.InsertBytes(insertCount, 100); bs.Write(data, 0, insertCount); bs.Position -= insertCount; bs.ReadAll(data2, 0, insertCount); bs.Position -= insertCount; bs.RemoveBytes(insertCount, 100); bs.Position += 100; for (int y = 0; y < insertCount; y++) { if (data[y] != data2[y]) throw new Exception(); } } } } rand = new Random(seed); bs.Position = 0; for (int x = 0; x < 10000; x++) { rand.NextBytes(data); while (rand.Next(4) < 2) if (bs.ReadUInt8() != (*(byte*)lp)) throw new Exception(); int skip = rand.Next(40) + 1; bs.Position += skip; bs.Position -= rand.Next(skip); rand.NextBytes(data); while (rand.Next(4) < 2) if (bs.ReadInt8() != (*(sbyte*)lp)) throw new Exception(); rand.NextBytes(data); while (rand.Next(4) < 2) if (bs.ReadInt16() != (*(short*)lp)) throw new Exception(); rand.NextBytes(data); while (rand.Next(4) < 2) if (bs.ReadInt32() != (*(int*)lp)) throw new Exception(); rand.NextBytes(data); while (rand.Next(4) < 2) if (bs.ReadInt64() != (*(long*)lp)) throw new Exception(); rand.NextBytes(data); while (rand.Next(4) < 2) if (bs.ReadUInt16() != (*(ushort*)lp)) throw new Exception(); rand.NextBytes(data); while (rand.Next(4) < 2) if (bs.ReadUInt32() != (*(uint*)lp)) throw new Exception(); rand.NextBytes(data); while (rand.Next(4) < 2) if (bs.ReadUInt64() != (*(ulong*)lp)) throw new Exception(); rand.NextBytes(data); while (rand.Next(4) < 2) if (bs.ReadDecimal() != NextDecimal(data, rand)) throw new Exception(); rand.NextBytes(data); while (rand.Next(4) < 2) if (bs.ReadGuid() != (*(Guid*)lp)) throw new Exception(); rand.NextBytes(data); while (rand.Next(4) < 2) if (bs.ReadDateTime() != NextDate(data, rand)) throw new Exception(); rand.NextBytes(data); while (rand.Next(4) < 2) if (bs.ReadSingle() != NextSingle(data, rand)) throw new Exception(); rand.NextBytes(data); while (rand.Next(4) < 2) if (bs.ReadDouble() != NextDouble(data, rand)) throw new Exception(); rand.NextBytes(data); bool b2 = (*lp != 0); while (rand.Next(4) < 2) if (bs.ReadBoolean() != b2) throw new Exception(); rand.NextBytes(data); while (rand.Next(4) < 2) if (bs.Read7BitUInt32() != (*(uint*)lp)) throw new Exception(); data[3] = 0; while (rand.Next(4) < 2) if (bs.Read7BitUInt32() != (*(uint*)lp)) throw new Exception(); data[2] = 0; while (rand.Next(4) < 2) if (bs.Read7BitUInt32() != (*(uint*)lp)) throw new Exception(); data[1] = 0; while (rand.Next(4) < 2) if (bs.Read7BitUInt32() != (*(uint*)lp)) throw new Exception(); rand.NextBytes(data); while (rand.Next(4) < 2) if (bs.Read7BitUInt64() != (*(ulong*)lp)) throw new Exception(); data[7] = 0; while (rand.Next(4) < 2) if (bs.Read7BitUInt64() != (*(ulong*)lp)) throw new Exception(); data[6] = 0; while (rand.Next(4) < 2) if (bs.Read7BitUInt64() != (*(ulong*)lp)) throw new Exception(); data[5] = 0; while (rand.Next(4) < 2) if (bs.Read7BitUInt64() != (*(ulong*)lp)) throw new Exception(); data[4] = 0; while (rand.Next(4) < 2) if (bs.Read7BitUInt64() != (*(ulong*)lp)) throw new Exception(); data[3] = 0; while (rand.Next(4) < 2) if (bs.Read7BitUInt64() != (*(ulong*)lp)) throw new Exception(); data[2] = 0; while (rand.Next(4) < 2) if (bs.Read7BitUInt64() != (*(ulong*)lp)) throw new Exception(); data[1] = 0; while (rand.Next(4) < 2) if (bs.Read7BitUInt64() != (*(ulong*)lp)) throw new Exception(); rand.NextBytes(data); bs.ReadAll(data2, 0, 16); if (!data2.SequenceEqual<byte>(data)) throw new Exception(); while (rand.Next(4) < 2) { if (bs.Position > 100) { int insertCount = rand.Next(16); } } } } }
protected override void Parse(Stream stream) { var s = new BinaryStreamWrapper(stream, ByteOrder.BigEndian); mData = s.ReadUInt32(); }