private static byte[] LoadZeroCompressed(BinaryReader reader) { var ret = new List<byte>(); uint packedLen = reader.ReadSizeEx(); long max = reader.BaseStream.Position + packedLen; while (reader.BaseStream.Position < max) { var opcode = new ZeroCompressOpcode(reader.ReadByte()); if (opcode.FirstIsZero) { for (int n = 0; n < (opcode.FirstLength+1); n++) ret.Add(0x00); } else { int bytes = (int)Math.Min(8 - opcode.FirstLength, max - reader.BaseStream.Position); for (int n = 0; n < bytes; n++) ret.Add(reader.ReadByte()); } if (opcode.SecondIsZero) { for (int n = 0; n < (opcode.SecondLength+1); n++) ret.Add(0x00); } else { int bytes = (int)Math.Min(8 - opcode.SecondLength, max - reader.BaseStream.Position); for (int n = 0; n < bytes; n++) ret.Add(reader.ReadByte()); } } return ret.ToArray(); }
public override void Decode(Unmarshal context, MarshalOpcode op, BinaryReader source) { uint len = source.ReadSizeEx(); RawData = source.ReadBytes((int) len); DataUnmarshal = new Unmarshal(); Data = DataUnmarshal.Process(RawData); }
public override void Decode(Unmarshal context, MarshalOpcode op, BinaryReader source) { var entries = source.ReadSizeEx(); Dictionary = new Dictionary<PyObject, PyObject>((int)entries); for (uint i = 0; i < entries; i++) { var value = context.ReadObject(source); var key = context.ReadObject(source); Dictionary.Add(key, value); } }
public override void Decode(Unmarshal context, MarshalOpcode op, BinaryReader source) { if (op == MarshalOpcode.StringEmpty) Update(new byte[0]); else if (op == MarshalOpcode.StringChar) Update(new[]{source.ReadByte()}); else if (op == MarshalOpcode.WStringUTF8) UpdateUTF8(source.ReadBytes((int)source.ReadSizeEx())); else if (op == MarshalOpcode.WStringUCS2Char) Update(new[]{source.ReadByte(), source.ReadByte()}, true); else if (op == MarshalOpcode.WStringEmpty) Update(new byte[0]); else if (op == MarshalOpcode.WStringUCS2) Update(source.ReadBytes((int)source.ReadSizeEx()), true); else if (op == MarshalOpcode.StringShort) Update(source.ReadBytes(source.ReadByte())); else if (op == MarshalOpcode.StringLong) Update(source.ReadBytes((int)source.ReadSizeEx())); else if (op == MarshalOpcode.StringTable) { byte index = source.ReadByte(); Update(StringTable.Entries[index-1]); } }
public static byte[] LoadZeroCompressed(BinaryReader reader) { MemoryStream retStream = new MemoryStream(); BinaryWriter ret = new BinaryWriter(retStream); uint packedLen = reader.ReadSizeEx(); long max = reader.BaseStream.Position + packedLen; while (reader.BaseStream.Position < max) { var opcode = new ZeroCompressOpcode(reader.ReadByte()); if (opcode.FirstIsZero) { ret.Write(new byte[opcode.FirstLength + 1]); // Faster than whiles } else { int bytes = (int)Math.Min(8 - opcode.FirstLength, max - reader.BaseStream.Position); for (int n = 0; n < bytes; n++) ret.Write(reader.ReadByte()); } if (opcode.SecondIsZero) { ret.Write(new byte[opcode.SecondLength + 1]); // Faster than whiles } else { int bytes = (int)Math.Min(8 - opcode.SecondLength, max - reader.BaseStream.Position); for (int n = 0; n < bytes; n++) ret.Write(reader.ReadByte()); } } return retStream.ToArray(); }
public override void Decode(Unmarshal context, MarshalOpcode op, BinaryReader source) { var len = source.ReadSizeEx(); Raw = source.ReadBytes((int) len); }
public override void Decode(Unmarshal context, MarshalOpcode op, BinaryReader source) { var size = source.ReadSizeEx(); Data = source.ReadBytes((int)size); }
public static byte[] LoadZeroCompressed(BinaryReader reader) { var ret = new List<byte>(); uint packedLen = reader.ReadSizeEx(); long max = reader.BaseStream.Position + packedLen; while (reader.BaseStream.Position < max) { var opcode = new ZeroCompressOpcode(reader.ReadByte()); if (opcode.FirstIsZero) { for (int n = 0; n < (opcode.FirstLength + 1); n++) ret.Add(0x00); } else { int bytes = (int)(Math.Min(8 - opcode.FirstLength, max - reader.BaseStream.Position)); for(int n = 0; n < bytes; n ++) ret.Add(reader.ReadByte()); } if(opcode.SecondIsZero) { for(int n = 0; n < (opcode.SecondLength + 1); n ++) ret.Add(0x00); } else { int bytes = (int)(Math.Min(8 - opcode.SecondLength, max - reader.BaseStream.Position)); for(int n = 0; n < bytes; n ++) ret.Add(reader.ReadByte()); } } return ret.ToArray(); /*MemoryStream retStream = new MemoryStream(); BinaryWriter ret = new BinaryWriter(retStream); uint packedLen = reader.ReadSizeEx(); long max = reader.BaseStream.Position + packedLen; while (reader.BaseStream.Position < max) { var opcode = new ZeroCompressOpcode(reader.ReadByte()); if (opcode.FirstIsZero) { byte len = (byte)(opcode.FirstLength + 1); while (0 < len--) ret.Write((byte)(0x00)); } else { int bytes = (int)Math.Min(8 - opcode.FirstLength, max - reader.BaseStream.Position); for (int n = 0; n < bytes; n++) ret.Write(reader.ReadByte()); } if (opcode.SecondIsZero) { byte len = (byte)(opcode.SecondLength + 1); while (0 < len--) ret.Write((byte)(0x00)); } else { int bytes = (int)Math.Min(8 - opcode.SecondLength, max - reader.BaseStream.Position); for (int n = 0; n < bytes; n++) ret.Write(reader.ReadByte()); } } return retStream.ToArray();*/ }