示例#1
0
 public override long WriteReplacer(AssetsFileWriter writer)
 {
     writer.Write((short)0); //replacer type
     writer.Write((byte)0);  //file type (0 bundle, 1 assets)
     writer.WriteCountStringInt16(name);
     return(writer.Position);
 }
示例#2
0
 public void Write(AssetsFileWriter writer)
 {
     writer.Write(len);
     for (int i = 0; i < len; i++)
     {
         writer.Write(items[i].fileID);
         writer.Write(items[i].pathID);
     }
 }
示例#3
0
 public override long WriteReplacer(AssetsFileWriter writer)
 {
     writer.Write((short)1); //replacer type
     writer.Write((byte)0);  //file type (0 bundle, 1 assets)
     writer.WriteCountStringInt16(oldName);
     writer.WriteCountStringInt16(newName);
     writer.Write(hasSerializedData);
     return(writer.Position);
 }
示例#4
0
 public ulong Write(uint version, ulong pos, AssetsFileWriter writer)
 {
     if (version >= 0x0E)
     {
         writer.Write(index);
     }
     else
     {
         writer.Write((uint)index);
     }
     writer.Write(offs_curFile);
     writer.Write(curFileSize);
     writer.Write(curFileTypeOrIndex);
     if (version < 0x10)
     {
         writer.Write(inheritedUnityClass);
     }
     if (version <= 0x10)
     {
         writer.Write(scriptIndex);
     }
     if (0x0F <= version && version <= 0x10)
     {
         writer.Write(unknown1);
         writer.Write(new byte[] { 0x00, 0x00, 0x00 });
     }
     return(writer.Position);
 }
示例#5
0
 public void Write(uint version, AssetsFileWriter writer)
 {
     if (version >= 0x0E)
     {
         writer.Write(index);
     }
     else
     {
         writer.Write((uint)index);
     }
     writer.Write(curFileOffset);
     writer.Write(curFileSize);
     writer.Write(curFileTypeOrIndex);
     if (version < 0x10)
     {
         writer.Write(inheritedUnityClass);
     }
     if (version <= 0x10)
     {
         writer.Write(scriptIndex);
     }
     if (0x0F <= version && version <= 0x10)
     {
         writer.Write(unknown1);
         writer.Write(new byte[] { 0x00, 0x00, 0x00 });
     }
 }
示例#6
0
        public void Write(AssetsFileWriter writer)
        {
            writer.bigEndian = false;
            writer.Write(Encoding.ASCII.GetBytes(header));
            writer.Write(fileVersion);
            if (fileVersion == 4)
            {
                writer.Write(flags);
            }
            switch (fileVersion)
            {
            case 1:
                break;

            case 3:
            case 4:
                writer.Write(compressionType);
                writer.Write(compressedSize);
                writer.Write(uncompressedSize);
                break;

            default:
                return;
            }
            writer.Write(unityVersionCount);
            for (int i = 0; i < unityVersionCount; i++)
            {
                writer.WriteCountString(unityVersions[i]);
            }
            writer.Write(stringTableLen);
            writer.Write(stringTablePos);
        }
示例#7
0
 public ulong Write(AssetsFileWriter writer, ulong filePos, int version)
 {
     writer.Write(classId);
     writer.Write(baseClass);
     name.Write(writer, filePos);
     writer.Write(fields.Count);
     for (int i = 0; i < fields.Count; i++)
     {
         fields[i].Write(writer, filePos, version);
     }
     return(writer.Position);
 }
        public ulong Write(ulong absFilePos, AssetsFileWriter writer)
        {
            writer.Write(bufferedPath);
            guid.Write(writer.Position, writer);
            writer.Write(type);
            string assetPathTemp = assetPath;

            if (assetPathTemp.StartsWith("Resources\\"))
            {
                assetPathTemp = "library/" + assetPath.Substring(10);
            }
            writer.WriteNullTerminated(assetPathTemp);
            return(writer.Position);
        }
        public ulong Write(AssetsFileWriter writer, ulong filePos)
        {
            writer.bigEndian = false;
            writer.Write(Encoding.ASCII.GetBytes(header));
            writer.Write(fileVersion);
            switch (fileVersion)
            {
            case 1:
                break;

            case 3:
                writer.Write(compressionType);
                if (compressionType != 0)
                {
                    return(writer.Position);
                }
                writer.Write(compressedSize);
                writer.Write(uncompressedSize);
                break;

            default:
                return(writer.Position);
            }
            writer.Write(unityVersionCount);
            for (int i = 0; i < unityVersionCount; i++)
            {
                writer.WriteCountString(pUnityVersions[i]);
            }
            writer.Write(stringTableLen);
            writer.Write(stringTablePos);
            return(writer.Position);
        }
 public void Write(AssetsFileWriter writer, int version, byte flags)
 {
     writer.Write(classId);
     writer.Write(baseClass);
     name.Write(writer);
     if ((flags & 1) != 0)
     {
         assemblyFileName.Write(writer);
     }
     writer.Write(fields.Count);
     for (int i = 0; i < fields.Count; i++)
     {
         fields[i].Write(writer, version);
     }
 }
        public override long WriteReplacer(AssetsFileWriter writer)
        {
            writer.Write((short)4); //replacer type
            writer.Write((byte)0);  //file type (0 bundle, 1 assets)
            writer.WriteCountStringInt16(oldName);
            writer.WriteCountStringInt16(newName);
            writer.Write((byte)1); //probably hasSerializedData
            writer.Write((long)assetReplacers.Count);
            foreach (AssetsReplacer replacer in assetReplacers)
            {
                replacer.WriteReplacer(writer);
            }

            return(writer.Position);
        }
示例#12
0
        }//Minimum AssetsFile format : 6

        public void Write(AssetsFileWriter writer, uint version)
        {
            writer.WriteNullTerminated(unityVersion);
            writer.Write(this.version);
            writer.Write(hasTypeTree);
            fieldCount = unity5Types.Count;
            writer.Write(fieldCount);
            for (int i = 0; i < fieldCount; i++)
            {
                unity5Types[i].Write(hasTypeTree, writer, version);
            }
            if (version < 0x0E)
            {
                writer.WriteUInt24(dwUnknown);
            }
        }
 public override long Write(AssetsFileWriter writer)
 {
     byte[] assetData = new byte[size];
     stream.Read(assetData, (int)offset, (int)size);
     writer.Write(assetData);
     return(writer.Position);
 }
示例#14
0
 public void Write(uint version, AssetsFileWriter writer)
 {
     writer.Write(sizeFiles);
     for (int i = 0; i < sizeFiles; i++)
     {
         fileInfs[i].Write(version, writer);
     }
 }
示例#15
0
 public void Write(AssetsFileWriter writer)
 {
     writer.Write(dependencyCount);
     for (int i = 0; i < dependencyCount; i++)
     {
         dependencies[i].Write(writer);
     }
 }
 public ulong Write(ulong absFilePos, AssetsFileWriter writer, uint format)
 {
     writer.Write(dependencyCount);
     for (int i = 0; i < dependencyCount; i++)
     {
         pDependencies[i].Write(writer.Position, writer);
     }
     return(writer.Position);
 }
 public ulong Write(uint version, ulong pos, AssetsFileWriter writer)
 {
     writer.Write(sizeFiles);
     for (int i = 0; i < sizeFiles; i++)
     {
         fileInfs[i].Write(version, pos, writer);
     }
     return(writer.Position);
 }
示例#18
0
 public void Write(AssetsFileWriter writer, uint format)
 {
     writer.Write(version);
     writer.Write(depth);
     writer.Write(isArray);
     writer.Write(typeStringOffset);
     writer.Write(nameStringOffset);
     writer.Write(size);
     writer.Write(index);
     writer.Write(flags);
     if (format >= 0x12)
     {
         writer.Write(unknown);
     }
 }
示例#19
0
 public ulong Write(ulong curFilePos, AssetsFileWriter writer, uint format)
 {
     writer.Write(version);
     writer.Write(depth);
     writer.Write(isArray);
     writer.Write(typeStringOffset);
     writer.Write(nameStringOffset);
     writer.Write(size);
     writer.Write(index);
     writer.Write(flags);
     if (format >= 0x12)
     {
         writer.Write(unknown);
     }
     return(writer.Position);
 }
 public override long Write(AssetsFileWriter writer)
 {
     //memorystream for alignment issue
     using (MemoryStream ms = new MemoryStream())
         using (AssetsFileWriter w = new AssetsFileWriter(ms))
         {
             assetsFile.Write(w, -1, replacers, fileId, typeMeta);
             writer.Write(ms.ToArray());
         }
     return(writer.Position);
 }
示例#21
0
        public override long WriteReplacer(AssetsFileWriter writer)
        {
            writer.Write((short)0); //replacer type
            writer.Write((byte)1);  //file type (0 bundle, 1 assets)
            writer.Write((byte)1);  //idk, always 1
            writer.Write(0);        //always 0 even when fileid is something else
            writer.Write(pathID);
            writer.Write(classID);
            writer.Write(monoScriptIndex);
            writer.Write(0); //flags, which are ignored since this is a remover

            return(writer.Position);
        }
示例#22
0
        public void Write(AssetsFileWriter writer)
        {
            header.Write(writer);
            writer.Write(classes.Count);
            for (int i = 0; i < classes.Count; i++)
            {
                classes[i].Write(writer, header.fileVersion, header.flags);
            }
            long stringTablePos = writer.Position;

            writer.Write(stringTable);
            long stringTableLen = writer.Position - stringTablePos;
            long fileSize       = writer.Position;

            header.stringTablePos   = (uint)stringTablePos;
            header.stringTableLen   = (uint)stringTableLen;
            header.uncompressedSize = (uint)fileSize;
            writer.Position         = 0;
            header.Write(writer);
        }
        public ulong Write(AssetsFileWriter writer, ulong filePos, int optimizeStringTable, uint compress, bool writeStringTable = true)
        {
            header.Write(writer, writer.Position);
            writer.Write(classes.Count);
            for (int i = 0; i < classes.Count; i++)
            {
                classes[i].Write(writer, filePos, header.fileVersion);
            }
            ulong stringTablePos = writer.Position;

            writer.Write(stringTable);
            ulong stringTableLen = writer.Position - stringTablePos;
            ulong fileSize       = writer.Position;

            header.stringTablePos   = (uint)stringTablePos;
            header.stringTableLen   = (uint)stringTableLen;
            header.uncompressedSize = (uint)fileSize;
            writer.Position         = 0;
            header.Write(writer, writer.Position);
            return(0);
        }
示例#24
0
        public void Write(AssetsFileWriter writer)
        {
            writer.WriteNullTerminated(bufferedPath);
            guid.Write(writer);
            writer.Write(type);
            string assetPathTemp = assetPath;

            if (assetPathTemp.StartsWith("Resources\\") || assetPathTemp.StartsWith("Resources/"))
            {
                assetPathTemp = "library/" + assetPath.Substring(10);
            }
            writer.WriteNullTerminated(assetPathTemp);
        }
 public override long Write(AssetsFileWriter writer)
 {
     //todo, we have to write to ms because AssetsFile.Write
     //rewrites back at 0 which is the bundle header, not
     //the top of the assets file
     byte[] data;
     using (MemoryStream ms = new MemoryStream())
         using (AssetsFileWriter w = new AssetsFileWriter(ms))
         {
             assetsFile.Write(w, 0, replacers, fileId);
             data = ms.ToArray();
         }
     writer.Write(data);
     return(writer.Position);
 }
        public void Write(AssetsFileWriter writer)
        {
            writer.WriteNullTerminated(bufferedPath);
            guid.Write(writer);
            writer.Write(type);
            string assetPathTemp = assetPath;

            if ((assetPath == "Resources/unity_builtin_extra" ||
                 assetPath == "Resources/unity default resources" ||
                 assetPath == "Resources/unity editor resources") &&
                originalAssetPath != string.Empty)
            {
                assetPathTemp = originalAssetPath;
            }
            writer.WriteNullTerminated(assetPathTemp);
        }
示例#27
0
 //does NOT write the endianness byte for format < 9!
 public void Write(AssetsFileWriter writer)
 {
     writer.bigEndian = true;
     writer.Write(metadataSize);
     writer.Write(fileSize);
     writer.Write(format);
     writer.Write(firstFileOffset);
     writer.Write((byte)endianness);
     writer.bigEndian = endianness == 1 ? true : false;
     writer.Write(unknown);
 }
示例#28
0
 //does NOT write the endianness byte for format < 9!
 public ulong Write(ulong pos, AssetsFileWriter writer)
 {
     writer.bigEndian = true;
     writer.Write(metadataSize);
     writer.Write(fileSize);
     writer.Write(format);
     writer.Write(offs_firstFile);
     writer.Write((byte)endianness);
     writer.bigEndian = endianness == 1 ? true : false;
     writer.Write(unknown);
     return(writer.Position);
 }
        public void Write(AssetsFileWriter writer)
        {
            writer.bigEndian = false;
            writer.Write(Encoding.ASCII.GetBytes(header));
            writer.Write(fileVersion);
            if (fileVersion == 4)
            {
                writer.Write(flags);
            }
            switch (fileVersion)
            {
            case 1:
                break;

            case 3:
            case 4:
                if (compressionType != 0)
                {
                    throw new NotImplementedException("compressed cldb writing not supported");
                }
                writer.Write(compressionType);
                writer.Write(compressedSize);
                writer.Write(uncompressedSize);
                break;

            default:
                return;
            }
            writer.Write(unityVersionCount);
            for (int i = 0; i < unityVersionCount; i++)
            {
                writer.WriteCountString(unityVersions[i]);
            }
            writer.Write(stringTableLen);
            writer.Write(stringTablePos);
        }
        public override bool Init(AssetsFileReader entryReader, long entryPos, long entrySize, ClassDatabaseFile typeMeta = null)
        {
            if (assetsFile != null)
            {
                return(false);
            }

            this.typeMeta = typeMeta;

            entryReader.Position = entryPos;
            //memorystream for alignment issue
            MemoryStream     ms = new MemoryStream();
            AssetsFileReader r  = new AssetsFileReader(ms);
            AssetsFileWriter w  = new AssetsFileWriter(ms);

            {
                w.Write(entryReader.ReadBytes((int)entrySize));
                ms.Position = 0;
                assetsFile  = new AssetsFile(r);
            }
            return(true);
        }