public ulong Read(AssetsFileReader reader, ulong filePos) { reader.bigEndian = false; header = reader.ReadStringLength(4); if (header != "cldb") { return(reader.Position); } fileVersion = reader.ReadByte(); if (fileVersion != 3) { return(reader.Position); } compressionType = reader.ReadByte(); if (compressionType != 0) { return(reader.Position); } compressedSize = reader.ReadUInt32(); uncompressedSize = reader.ReadUInt32(); unityVersionCount = reader.ReadByte(); pUnityVersions = new string[unityVersionCount]; for (int i = 0; i < unityVersionCount; i++) { pUnityVersions[i] = reader.ReadCountString(); } stringTableLen = reader.ReadUInt32(); stringTablePos = reader.ReadUInt32(); return(reader.Position); }
///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 ulong Read(ulong absFilePos, AssetsFileReader reader) { metadataSize = reader.ReadUInt32(); fileSize = reader.ReadUInt32(); format = reader.ReadUInt32(); offs_firstFile = reader.ReadUInt32(); endianness = reader.ReadByte(); reader.bigEndian = endianness == 1 ? true : false; unknown = reader.ReadBytes(3); return(reader.Position); }
///public bool ReadInitial(AssetsFileReader reader, LPARAM lPar, AssetsFileVerifyLogger errorLogger = NULL); public void Read(AssetsFileReader reader) { signature = reader.ReadNullTerminated(); fileVersion = reader.ReadUInt32(); minPlayerVersion = reader.ReadNullTerminated(); fileEngineVersion = reader.ReadNullTerminated(); totalFileSize = reader.ReadInt64(); compressedSize = reader.ReadUInt32(); decompressedSize = reader.ReadUInt32(); flags = reader.ReadUInt32(); }
///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); }
public uint flags; //0x14 public ulong Read(ulong absFilePos, AssetsFileReader reader, bool bigEndian) { version = reader.ReadUInt16(); depth = reader.ReadByte(); isArray = reader.ReadBoolean(); typeStringOffset = reader.ReadUInt32(); nameStringOffset = reader.ReadUInt32(); size = reader.ReadUInt32(); index = reader.ReadUInt32(); flags = reader.ReadUInt32(); return(reader.Position); }
public ulong Read(AssetsFileReader reader, ulong filePos, int version) { typeName = new ClassDatabaseFileString(); typeName.Read(reader, reader.Position); fieldName = new ClassDatabaseFileString(); fieldName.Read(reader, reader.Position); depth = reader.ReadByte(); isArray = reader.ReadByte(); size = reader.ReadUInt32(); version = reader.ReadUInt16(); flags2 = reader.ReadUInt32(); return(reader.Position); }
public bool Read(AssetsFileReader reader) { header = new ClassDatabaseFileHeader(); header.Read(reader, 0); if (header.header != "cldb" || header.fileVersion != 3 || header.compressionType != 0) { valid = false; return(valid); } classes = new List <ClassDatabaseType>(); long classTablePos = reader.BaseStream.Position; reader.BaseStream.Position = header.stringTablePos; stringTable = reader.ReadBytes((int)header.stringTableLen); reader.BaseStream.Position = classTablePos; uint size = reader.ReadUInt32(); for (int i = 0; i < size; i++) { ClassDatabaseType cdt = new ClassDatabaseType(); cdt.Read(reader, reader.Position, header.fileVersion); classes.Add(cdt); } valid = true; return(valid); }
//todo: bundleheader3 is read regardless of version 3 or 6, see https://7daystodie.com/forums/showthread.php?22675-Unity-Assets-Bundle-Extractor&p=761867&viewfull=1#post761867 //"just check if bundleHeader3.fileVersion is 3 or 6." public bool Read(AssetsFileReader reader, /*AssetsFileVerifyLogger errorLogger = NULL,*/ bool allowCompressed = false) { reader.ReadNullTerminated(); if (reader.ReadUInt32() == 6) { reader.Position = 0; bundleHeader6 = new AssetsBundleHeader06(); if (bundleHeader6.Read(reader)) { if (bundleHeader6.signature == "UnityFS") { bundleInf6 = new AssetsBundleBlockAndDirectoryList06(); if ((bundleHeader6.flags & 0x3F) != 0) { if (allowCompressed) { return(true); } else { Close(); return(false); } } else { return(bundleInf6.Read(bundleHeader6.GetBundleInfoOffset(), reader)); } } else { new NotImplementedException("Non UnityFS bundles are not supported yet."); } } } else if (reader.ReadUInt32() == 3) { new NotImplementedException("Version 3 bundles are not supported yet."); } else { new Exception("AssetsBundleFile.Read : Unknown file version!"); } return(false); }
public uint _fmt; //not stored here in the .assets file, the variable is just to remember the .assets file version public ulong Read(ulong absFilePos, AssetsFileReader reader, uint version, bool bigEndian) { unityVersion = reader.ReadNullTerminated(); this.version = reader.ReadUInt32(); hasTypeTree = reader.ReadBoolean(); fieldCount = reader.ReadUInt32(); pTypes_Unity5 = new Type_0D[fieldCount]; for (int i = 0; i < fieldCount; i++) { Type_0D type0d = new Type_0D(); type0d.Read(hasTypeTree, reader.Position, reader, version, version, bigEndian); pTypes_Unity5[i] = type0d; } if (version < 0x0E) { dwUnknown = reader.ReadUInt24(); } _fmt = version; //-todo: figure out what the heck this is for. if ver = -1 on write does it set it to default or something? return(reader.Position); }//Minimum AssetsFile format : 6
public ulong Read(ulong absFilePos, AssetsFileReader reader, uint version, bool bigEndian) { unityVersion = reader.ReadNullTerminated(); this.version = reader.ReadUInt32(); hasTypeTree = reader.ReadBoolean(); fieldCount = reader.ReadUInt32(); pTypes_Unity5 = new Type_0D[fieldCount]; for (int i = 0; i < fieldCount; i++) { Type_0D type0d = new Type_0D(); type0d.Read(hasTypeTree, reader.Position, reader, version, version, bigEndian); pTypes_Unity5[i] = type0d; } if (version < 0x0E) { dwUnknown = reader.ReadUInt32(); } _fmt = version; return(reader.Position); }
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; } }
public ulong Read(ulong absFilePos, AssetsFileReader reader, uint format, bool bigEndian) { dependencyCount = reader.ReadUInt32(); pDependencies = new AssetsFileDependency[dependencyCount]; for (int i = 0; i < dependencyCount; i++) { AssetsFileDependency dependency = new AssetsFileDependency(); dependency.Read(reader.Position, reader, bigEndian); pDependencies[i] = dependency; } return(reader.Position); }
public ulong Read(bool hasTypeTree, ulong absFilePos, AssetsFileReader reader, uint version, uint typeVersion, bool bigEndian) { classId = reader.ReadInt32(); if (version >= 0x10) { unknown16_1 = reader.ReadByte(); } if (version >= 0x11) { scriptIndex = reader.ReadUInt16(); } if ((version < 0x11 && classId < 0) || (version >= 0x11 && scriptIndex != 0xFFFF)) { unknown1 = reader.ReadUInt32(); unknown2 = reader.ReadUInt32(); unknown3 = reader.ReadUInt32(); unknown4 = reader.ReadUInt32(); } unknown5 = reader.ReadUInt32(); unknown6 = reader.ReadUInt32(); unknown7 = reader.ReadUInt32(); unknown8 = reader.ReadUInt32(); if (hasTypeTree) { typeFieldsExCount = reader.ReadUInt32(); stringTableLen = reader.ReadUInt32(); pTypeFieldsEx = new TypeField_0D[typeFieldsExCount]; for (int i = 0; i < typeFieldsExCount; i++) { TypeField_0D typefield0d = new TypeField_0D(); typefield0d.Read(reader.Position, reader, bigEndian); pTypeFieldsEx[i] = typefield0d; } string rawStringTable = Encoding.UTF8.GetString(reader.ReadBytes((int)stringTableLen)); pStringTable = rawStringTable.Split('\0'); Array.Resize(ref pStringTable, pStringTable.Length - 1); } return(reader.Position); }
public override void Parse(AssetIdentifier identifier, AssetsFileReader reader, ResourceAssets resourceAssets, Dictionary <int, string> relativeFileIdToPath) { GameObjectAsset gameObjectAsset = new GameObjectAsset(); gameObjectAsset.Identifier = identifier; uint componentCount = reader.ReadUInt32(); for (int i = 0; i < componentCount; i++) { AssetIdentifier component = new AssetIdentifier(relativeFileIdToPath[reader.ReadInt32()], reader.ReadInt64()); gameObjectAsset.Components.Add(component); } reader.ReadUInt32(); // Layer (not used) int length = reader.ReadInt32(); gameObjectAsset.Name = reader.ReadStringLength(length); GameObjectsByAssetId.Add(identifier, gameObjectAsset); }
public void Read(AssetsFileReader reader, int version) { typeName = new ClassDatabaseFileString(); typeName.Read(reader); fieldName = new ClassDatabaseFileString(); fieldName.Read(reader); depth = reader.ReadByte(); isArray = reader.ReadByte(); size = reader.ReadInt32(); switch (version) { case 1: flags2 = reader.ReadUInt32(); break; case 3: case 4: this.version = reader.ReadUInt16(); flags2 = reader.ReadUInt32(); break; } }
public void Read(AssetsFileReader reader) { fromStringTable = true; str.stringTableOffset = reader.ReadUInt32(); if (str.stringTableOffset != 0xFFFFFFFF) { fromStringTable = true; } else { //untested, probably wrong fromStringTable = false; str.@string = reader.ReadCountString(); } }
///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); }
public override void Parse(AssetIdentifier identifier, AssetsFileReader reader, ResourceAssets resourceAssets) { GameObjectAsset gameObjectAsset = new GameObjectAsset(); gameObjectAsset.Identifier = identifier; uint componentCount = reader.ReadUInt32(); for (int i = 0; i < componentCount; i++) { AssetIdentifier component = new AssetIdentifier(reader.ReadInt32(), reader.ReadInt64()); gameObjectAsset.Components.Add(component); } GameObjectsByAssetId.Add(identifier, gameObjectAsset); }
public ulong Read(AssetsFileReader reader, ulong filePos) { fromStringTable = true; str.stringTableOffset = reader.ReadUInt32(); if (str.stringTableOffset != 0xFFFFFFFF) { fromStringTable = true; } else { //untested, probably wrong fromStringTable = false; str.@string = reader.ReadCountString(); } return(reader.Position); }
public ulong Read(AssetsFileReader reader, ulong filePos) { fromStringTable = true; str.stringTableOffset = reader.ReadUInt32(); if (str.stringTableOffset != 0xFFFFFFFF) //total guess haha, havent messed with inline strings much { fromStringTable = true; } else { //untested, probably wrong fromStringTable = false; str.@string = reader.ReadCountString(); //this may be different } return(reader.Position); }
public ulong Read(AssetsFileReader reader, ulong filePos, int version) { classId = reader.ReadInt32(); baseClass = reader.ReadInt32(); name = new ClassDatabaseFileString(); name.Read(reader, reader.Position); uint fieldCount = reader.ReadUInt32(); fields = new List <ClassDatabaseTypeField>(); for (int j = 0; j < fieldCount; j++) { ClassDatabaseTypeField cdtf = new ClassDatabaseTypeField(); cdtf.Read(reader, filePos, version); fields.Add(cdtf); } return(reader.Position); }
public AssetsFile(AssetsFileReader reader) { this.reader = reader; readerPar = reader.BaseStream; header = new AssetsFileHeader(); header.Read(0, reader); typeTree = new TypeTree(); typeTree.Read(reader.Position, reader, header.format, reader.bigEndian); AssetCount = reader.ReadUInt32(); reader.Align(); AssetTablePos = Convert.ToUInt32(reader.BaseStream.Position); reader.BaseStream.Position += AssetFileInfo.GetSize(header.format) * AssetCount; preloadTable = new PreloadList(); preloadTable.Read(reader.Position, reader, header.format, reader.bigEndian); dependencies = new AssetsFileDependencyList(); dependencies.Read(reader.Position, reader, header.format, reader.bigEndian); }
public override void Parse(AssetIdentifier identifier, AssetIdentifier gameObjectIdentifier, AssetsFileReader reader, ResourceAssets resourceAssets, Dictionary <int, string> relativeFileIdToPath) { reader.Align(); uint size = reader.ReadUInt32(); WorldEntityInfo wei; for (int i = 0; i < size; i++) { wei = new WorldEntityInfo(); wei.classId = reader.ReadCountStringInt32(); wei.techType = (TechType)reader.ReadInt32(); wei.slotType = (EntitySlot.Type)reader.ReadInt32(); wei.prefabZUp = reader.ReadBoolean(); reader.Align(); wei.cellLevel = (LargeWorldEntity.CellLevel)reader.ReadInt32(); wei.localScale = new UnityEngine.Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()); resourceAssets.WorldEntitiesByClassId.Add(wei.classId, wei); } }
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); }
public void Read(AssetsFileReader reader) { fromStringTable = true; str.stringTableOffset = reader.ReadUInt32(); }
private List <AssetInfo> GetFSMInfos(AssetsFile file, AssetsFileTable table, bool hasDataField) { List <AssetInfo> assetInfos = new List <AssetInfo>(); uint assetCount = table.assetFileInfoCount; uint fsmTypeId = 0; foreach (AssetFileInfoEx info in table.assetFileInfo) { bool isMono = false; if (fsmTypeId == 0) { ushort monoType; if (file.header.format <= 0x10) { monoType = info.scriptIndex; } else { monoType = file.typeTree.unity5Types[info.curFileTypeOrIndex].scriptIndex; } if (monoType != 0xFFFF) { isMono = true; } } else if (info.curFileType == fsmTypeId) { isMono = true; } if (isMono) { AssetTypeInstance monoAti = am.GetATI(file, info); AssetExternal ext = am.GetExtAsset(curFile, monoAti.GetBaseField().Get("m_Script")); AssetTypeInstance scriptAti = am.GetExtAsset(curFile, monoAti.GetBaseField().Get("m_Script")).instance; AssetTypeInstance goAti = am.GetExtAsset(curFile, monoAti.GetBaseField().Get("m_GameObject")).instance; if (goAti == null) //found a scriptable object, oops { fsmTypeId = 0; continue; } string m_Name = goAti.GetBaseField().Get("m_Name").GetValue().AsString(); string m_ClassName = scriptAti.GetBaseField().Get("m_ClassName").GetValue().AsString(); if (m_ClassName == "PlayMakerFSM") { if (fsmTypeId == 0) { fsmTypeId = info.curFileType; } AssetsFileReader reader = file.reader; long oldPos = reader.BaseStream.Position; reader.BaseStream.Position = info.absoluteFilePos; reader.BaseStream.Position += 28; uint length = reader.ReadUInt32(); reader.ReadBytes((int)length); reader.Align(); reader.BaseStream.Position += 16; if (!hasDataField) { reader.BaseStream.Position -= 4; } uint length2 = reader.ReadUInt32(); string fsmName = Encoding.UTF8.GetString(reader.ReadBytes((int)length2)); reader.BaseStream.Position = oldPos; assetInfos.Add(new AssetInfo() { id = info.index, size = info.curFileSize, name = m_Name + "-" + fsmName }); } } } assetInfos.Sort((x, y) => x.name.CompareTo(y.name)); return(assetInfos); }