Beispiel #1
0
 ///void Free();
 public void Read(long filePos, AssetsFileReader reader)
 {
     reader.Position = filePos;
     checksumLow     = reader.ReadUInt64();
     checksumHigh    = reader.ReadUInt64();
     blockCount      = reader.ReadInt32();
     blockInf        = new AssetBundleBlockInfo06[blockCount];
     for (int i = 0; i < blockCount; i++)
     {
         blockInf[i] = new AssetBundleBlockInfo06();
         blockInf[i].decompressedSize = reader.ReadUInt32();
         blockInf[i].compressedSize   = reader.ReadUInt32();
         blockInf[i].flags            = reader.ReadUInt16();
     }
     directoryCount = reader.ReadInt32();
     dirInf         = new AssetBundleDirectoryInfo06[directoryCount];
     for (int i = 0; i < directoryCount; i++)
     {
         dirInf[i]                  = new AssetBundleDirectoryInfo06();
         dirInf[i].offset           = reader.ReadInt64();
         dirInf[i].decompressedSize = reader.ReadInt64();
         dirInf[i].flags            = reader.ReadUInt32();
         dirInf[i].name             = reader.ReadNullTerminated();
     }
 }
 public ulong Read(ulong absFilePos, AssetsFileReader reader, uint format, bool bigEndian)
 {
     len   = reader.ReadUInt32();
     items = new AssetPPtr[len];
     for (int i = 0; i < len; i++)
     {
         items[i] = new AssetPPtr(reader.ReadUInt32(), reader.ReadUInt64());
     }
     return(reader.Position);
 }
 ///public bool ReadInitial(AssetsFileReader reader, LPARAM lPar, AssetsFileVerifyLogger errorLogger = NULL);
 public bool Read(AssetsFileReader reader /*, AssetsFileVerifyLogger errorLogger = null*/)
 {
     signature         = reader.ReadNullTerminated();
     fileVersion       = reader.ReadUInt32();
     minPlayerVersion  = reader.ReadNullTerminated();
     fileEngineVersion = reader.ReadNullTerminated();
     totalFileSize     = reader.ReadUInt64();
     compressedSize    = reader.ReadUInt32();
     decompressedSize  = reader.ReadUInt32();
     flags             = reader.ReadUInt32();
     return(true);
 }
Beispiel #4
0
 ///void Free();
 public bool Read(ulong filePos, AssetsFileReader reader /*, AssetsFileVerifyLogger errorLogger = NULL*/)
 {
     reader.Position = filePos;
     checksumLow     = reader.ReadUInt64();
     checksumHigh    = reader.ReadUInt64();
     blockCount      = reader.ReadUInt32();
     blockInf        = new AssetsBundleBlockInfo06[blockCount];
     for (int i = 0; i < blockCount; i++)
     {
         blockInf[i].decompressedSize = reader.ReadUInt32();
         blockInf[i].compressedSize   = reader.ReadUInt32();
         blockInf[i].flags            = reader.ReadUInt16();
     }
     directoryCount = reader.ReadUInt32();
     dirInf         = new AssetsBundleDirectoryInfo06[directoryCount];
     for (int i = 0; i < directoryCount; i++)
     {
         dirInf[i].offset           = reader.ReadUInt64();
         dirInf[i].decompressedSize = reader.ReadUInt64();
         dirInf[i].flags            = reader.ReadUInt32();
         dirInf[i].name             = reader.ReadNullTerminated();
     }
     return(true);
 }
Beispiel #5
0
 public AssetsFileTable(AssetsFile pFile, bool readNames = true)
 {
     this.pFile                 = pFile;
     reader                     = new AssetsFileReader(pFile.readerPar); //todo, look back and see why I made a new reader here
     readerPar                  = pFile.readerPar;
     reader.bigEndian           = pFile.header.endianness == 1 ? true : false;
     reader.BaseStream.Position = pFile.AssetTablePos;
     assetFileInfoCount         = pFile.AssetCount;
     pAssetFileInfo             = new AssetFileInfoEx[assetFileInfoCount];
     for (int i = 0; i < assetFileInfoCount; i++)
     {
         AssetFileInfoEx assetFileInfoSet = new AssetFileInfoEx();
         if (pFile.header.format >= 0x0E)
         {
             assetFileInfoSet.index = reader.ReadUInt64();
         }
         else
         {
             assetFileInfoSet.index = reader.ReadUInt32();
         }
         assetFileInfoSet.offs_curFile       = reader.ReadUInt32();
         assetFileInfoSet.curFileSize        = reader.ReadUInt32();
         assetFileInfoSet.curFileTypeOrIndex = reader.ReadUInt32();
         if (pFile.header.format < 0x10)
         {
             assetFileInfoSet.inheritedUnityClass = reader.ReadUInt16();
         }
         if (pFile.header.format <= 0x10)
         {
             assetFileInfoSet.scriptIndex = reader.ReadUInt16();
         }
         if (0x0F <= pFile.header.format && pFile.header.format <= 0x10)
         {
             assetFileInfoSet.unknown1 = reader.ReadByte();
             reader.ReadBytes(3);
         }
         assetFileInfoSet.absoluteFilePos = pFile.header.offs_firstFile + assetFileInfoSet.offs_curFile;
         assetFileInfoSet.curFileType     = (uint)pFile.typeTree.pTypes_Unity5[assetFileInfoSet.curFileTypeOrIndex].classId; //todo: fix this variable (it can be from a different variable (index))
         pAssetFileInfo[i] = assetFileInfoSet;
     }
 }
Beispiel #6
0
        public AssetTypeValueField ReadType(AssetsFileReader reader, ulong filePos, AssetTypeValueField valueField, bool bigEndian)
        {
            if (valueField.templateField.isArray)
            {
                if (valueField.templateField.childrenCount == 2)
                {
                    EnumValueTypes sizeType = valueField.templateField.children[0].valueType;
                    if (sizeType == EnumValueTypes.ValueType_Int32 ||
                        sizeType == EnumValueTypes.ValueType_UInt32)
                    {
                        valueField.childrenCount = reader.ReadUInt32();
                        valueField.pChildren     = new AssetTypeValueField[valueField.childrenCount];
                        for (int i = 0; i < valueField.childrenCount; i++)
                        {
                            valueField.pChildren[i] = new AssetTypeValueField();
                            valueField.pChildren[i].templateField = valueField.templateField.children[1];
                            valueField.pChildren[i] = ReadType(reader, reader.Position, valueField.pChildren[i], bigEndian);
                        }
                        if (valueField.templateField.align)
                        {
                            reader.Align();
                        }
                        AssetTypeArray ata = new AssetTypeArray();
                        ata.size         = valueField.childrenCount;
                        valueField.value = new AssetTypeValue(EnumValueTypes.ValueType_Array, 0);
                        valueField.value.Set(ata);
                    }
                    else
                    {
                        Debug.WriteLine("Invalid array value type! Found an unexpected " + sizeType.ToString() + " type instead!");
                    }
                }
                else
                {
                    Debug.WriteLine("Invalid array!");
                }
            }
            else
            {
                EnumValueTypes type = valueField.templateField.valueType;
                if (type != 0)
                {
                    valueField.value = new AssetTypeValue(type, 0);
                }
                if (type == EnumValueTypes.ValueType_String)
                {
                    valueField.value.Set(reader.ReadCountStringInt32());
                    reader.Align();
                }
                else
                {
                    valueField.childrenCount = valueField.templateField.childrenCount;
                    if (valueField.childrenCount == 0)
                    {
                        valueField.pChildren = new AssetTypeValueField[0];
                        switch (valueField.templateField.valueType)
                        {
                        case EnumValueTypes.ValueType_Int8:
                            valueField.value.Set(reader.ReadSByte());
                            if (valueField.templateField.align)
                            {
                                reader.Align();
                            }
                            break;

                        case EnumValueTypes.ValueType_UInt8:
                        case EnumValueTypes.ValueType_Bool:
                            valueField.value.Set(reader.ReadByte());
                            if (valueField.templateField.align)
                            {
                                reader.Align();
                            }
                            break;

                        case EnumValueTypes.ValueType_Int16:
                            valueField.value.Set(reader.ReadInt16());
                            if (valueField.templateField.align)
                            {
                                reader.Align();
                            }
                            break;

                        case EnumValueTypes.ValueType_UInt16:
                            valueField.value.Set(reader.ReadUInt16());
                            if (valueField.templateField.align)
                            {
                                reader.Align();
                            }
                            break;

                        case EnumValueTypes.ValueType_Int32:
                            valueField.value.Set(reader.ReadInt32());
                            break;

                        case EnumValueTypes.ValueType_UInt32:
                            valueField.value.Set(reader.ReadUInt32());
                            break;

                        case EnumValueTypes.ValueType_Int64:
                            valueField.value.Set(reader.ReadInt64());
                            break;

                        case EnumValueTypes.ValueType_UInt64:
                            valueField.value.Set(reader.ReadUInt64());
                            break;

                        case EnumValueTypes.ValueType_Float:
                            valueField.value.Set(reader.ReadSingle());
                            break;

                        case EnumValueTypes.ValueType_Double:
                            valueField.value.Set(reader.ReadDouble());
                            break;
                        }
                    }
                    else
                    {
                        valueField.pChildren = new AssetTypeValueField[valueField.childrenCount];
                        for (int i = 0; i < valueField.childrenCount; i++)
                        {
                            valueField.pChildren[i] = new AssetTypeValueField();
                            valueField.pChildren[i].templateField = valueField.templateField.children[i];
                            valueField.pChildren[i] = ReadType(reader, reader.Position, valueField.pChildren[i], bigEndian);
                        }
                    }
                }
            }
            return(valueField);
        }