public static string ReadAlignedString(this UnityBinaryReader reader) { string str = reader.ReadString(reader.ReadInt()); reader.Align(4); return(str); }
// version >= 11 private void readScripts(UnityBinaryReader reader) { int script_count = reader.ReadInt(); Scripts = new ScriptIdentifierType[script_count]; Scripts.Read(reader); }
public static void Read <T>(this T[] ary, UnityBinaryReader reader) where T : ISerializable { for (int i = 0; i < ary.Length; i++) { ary[i].Read(reader); } }
private void readExternals(UnityBinaryReader reader) { int external_count = reader.ReadInt(); Externals = new ExternalFileType[external_count]; Externals.Read(reader); }
public void Read(UnityBinaryReader reader) { var typeEmpty = reader.ReadStringToNull(); Guid = new Guid(reader.ReadBytes(16)); Type = reader.ReadInt(); PathName = reader.ReadStringToNull(); }
public static void Align(this UnityBinaryReader reader, int align) { var mod = reader.Position % align; if (mod != 0) { reader.Position += align - mod; } }
public void Read(UnityBinaryReader reader) { signature = reader.ReadStringToNull(); format = reader.ReadIntBE(); versionPlayer = reader.ReadStringToNull(); versionEngine = reader.ReadStringToNull(); bundleSize = reader.ReadLongBE(); }
public void Read(UnityBinaryReader reader) { MetadataSize = reader.ReadIntBE(); FileSize = reader.ReadIntBE(); Version = reader.ReadIntBE(); DataOffset = reader.ReadIntBE(); IsBigEndian = reader.ReadByte() == 0 ? false : true; Reserved = reader.ReadBytes(3); }
public BlockReader(BlockInfo[] infos, UnityBinaryReader reader) { _reader = reader; _infos = infos; idx = 0; buffer = null; begin = 0; end = 0; }
public void Read(UnityBinaryReader reader) { ClassID = reader.ReadInt(); IsStrippedType = reader.ReadByte() != 0; ScriptTypeIndex = reader.ReadShort(); if (ClassID == (int)ClassIDType.MonoBehaviour) { ScriptID = reader.ReadBytes(16); } OldTypeHash = reader.ReadBytes(16); }
public void Read(UnityBinaryReader reader) { // Read header int node_count = reader.ReadInt(); int strtable_length = reader.ReadInt(); // StringTable is at just after nodes UnityBinaryReader strtableReader = reader.Slice(reader.Position + 24 * node_count); // Read Nodes Nodes = new Node[node_count]; for (int i = 0; i < node_count; i++) { Nodes[i].Version = reader.ReadUShort(); Nodes[i].Level = reader.ReadByte(); Nodes[i].IsArray = reader.ReadByte() != 0; // Read TypeName var TypeStringOffset = reader.ReadUShort(); var temp = reader.ReadUShort(); if (temp == 0) { strtableReader.Position = TypeStringOffset; Nodes[i].Type = strtableReader.ReadStringToNull(); } else { Nodes[i].Type = GetCommonString(TypeStringOffset); } // Read Name var NameStringOffset = reader.ReadUShort(); temp = reader.ReadUShort(); if (temp == 0) { strtableReader.Position = NameStringOffset; Nodes[i].Name = strtableReader.ReadStringToNull(); } else { Nodes[i].Name = GetCommonString(NameStringOffset); } Nodes[i].ByteSize = reader.ReadInt(); Nodes[i].Index = reader.ReadInt(); Nodes[i].MetaFlag = reader.ReadInt(); } reader.Position += strtable_length; }
/// <summary> /// Read AssetBundle from binary using UnityBinaryReader. /// </summary> /// <remarks>Start of AssetBundle must be on the start Position of the reader.</remarks> /// <exception cref="UnknownFormatException">Format of given AssetBundle is not supported.</exception> /// <param name="reader">UnityBinaryReader to read from.</param> public void Read(UnityBinaryReader reader) { Header.Read(reader); // Only supports UnityFS if (Header.signature != "UnityFS") { throw new UnknownFormatException("Signature " + Header.signature + " is not supported"); } // Only supports format6 if (Header.format != FORMAT) { throw new UnknownFormatException("Format " + Header.format.ToString() + " is not supported"); } readFiles(reader); }
private void readMetadata(UnityBinaryReader reader) { // Read Header MetadataHeader.Read(reader); // Read Types int type_count = reader.ReadInt(); Types = new SerializedType[type_count]; for (int i = 0; i < type_count; i++) { Types[i].Read(reader); if (MetadataHeader.EnableTypeTree) { Types[i].TypeTree = new TypeTree(); Types[i].TypeTree.Read(reader); } } }
private void readObjects(UnityBinaryReader reader) { int object_count = reader.ReadInt(); Objects = new ObjectType[object_count]; for (int i = 0; i < object_count; i++) { Objects[i] = new ObjectType(); Objects[i].parent = new WeakReference <AssetsFile>(this); reader.Align(4); Objects[i].PathID = reader.ReadLong(); var byteStart = reader.ReadUInt(); var byteSize = reader.ReadUInt(); Objects[i].TypeID = reader.ReadInt(); // Read Body var final_pos = reader.Position; reader.Position = Header.DataOffset + (int)byteStart; Objects[i].Data = reader.ReadBytes((int)byteSize); reader.Position = final_pos; } }
public bool EnableTypeTree; // version >= 13 public void Read(UnityBinaryReader reader) { UnityVersion = reader.ReadStringToNull(); TargetPlatform = reader.ReadInt(); EnableTypeTree = reader.ReadByte() != 0; }
private void readFiles(UnityBinaryReader reader) { int compressedSize = reader.ReadIntBE(); int uncompressedSize = reader.ReadIntBE(); int flag = reader.ReadIntBE(); UnityBinaryReader inforeader; if ((flag & 0x80) != 0) // At end of file { throw new NotImplementedException("BlockInfos are at the end of file"); } // Decompress Infos (if needed) int compressiontype = flag & 0x3F; switch (compressiontype) { default: // None inforeader = reader; break; case 1: // LZMA(Not Supported) throw new NotSupportedException("LZMA is not supported"); case 2: //LZ4 case 3: //LZ4HC { byte[] infobytes = MemoryPool <AssetBundleFile> .GetBuffer(uncompressedSize); reader.ReadLZ4Data(compressedSize, uncompressedSize, infobytes, 0); inforeader = new UnityBinaryReader(infobytes, 0, uncompressedSize); break; } } // Read Block Infos inforeader.Position += 0x10; int blockcount = inforeader.ReadIntBE(); var blockinfos = new BlockInfo[blockcount]; blockinfos.Read(inforeader); // Read File Infos int filecount = inforeader.ReadIntBE(); Files = new FileType[filecount]; long[] fileoffsets = new long[filecount]; for (int i = 0; i < filecount; i++) { Files[i] = new FileType(); fileoffsets[i] = inforeader.ReadLongBE(); Files[i].Data = new byte[inforeader.ReadLongBE()]; flag = inforeader.ReadIntBE(); Files[i].Name = inforeader.ReadStringToNull(); } // Read Directories BlockReader blockreader = new BlockReader(blockinfos, reader); for (int i = 0; i < filecount; i++) { blockreader.Seek((int)fileoffsets[i]); blockreader.ReadBytes(Files[i].Data, 0, Files[i].Data.Length); } }
public void Read(UnityBinaryReader reader) { uncompressedSize = reader.ReadIntBE(); compressedSize = reader.ReadIntBE(); flag = reader.ReadShortBE(); }
public void Read(UnityBinaryReader reader) { Index = reader.ReadInt(); reader.Align(4); Identifier = reader.ReadLong(); }