public void Read(UnityBinaryReader reader)
            {
                var typeEmpty = reader.ReadStringToNull();

                Guid     = new Guid(reader.ReadBytes(16));
                Type     = reader.ReadInt();
                PathName = reader.ReadStringToNull();
            }
예제 #2
0
            public void Read(UnityBinaryReader reader)
            {
                signature = reader.ReadStringToNull();
                format    = reader.ReadIntBE();

                versionPlayer = reader.ReadStringToNull();
                versionEngine = reader.ReadStringToNull();
                bundleSize    = reader.ReadLongBE();
            }
예제 #3
0
        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;
        }
예제 #4
0
        public void Read(UnityBinaryReader reader)
        {
            // Read Header
            Header.Read(reader);

            // Only Supports version = 17
            if (Header.Version != 17)
            {
                throw new NotSupportedException("Version " + Header.Version.ToString() + " is not supported");
            }
            // Only Supports LittleEndian
            if (Header.IsBigEndian)
            {
                throw new NotSupportedException("BigEndian file is not supported");
            }

            // Read Metadata
            readMetadata(reader);

            // Read Objects
            readObjects(reader);

            // Read Scripts
            readScripts(reader);

            // Read Externals
            readExternals(reader);

            // Read UserInformation
            UserInformation = reader.ReadStringToNull();
        }
예제 #5
0
            public bool   EnableTypeTree; // version >= 13

            public void Read(UnityBinaryReader reader)
            {
                UnityVersion   = reader.ReadStringToNull();
                TargetPlatform = reader.ReadInt();
                EnableTypeTree = reader.ReadByte() != 0;
            }
예제 #6
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);
            }
        }