Skip to content
This repository has been archived by the owner on May 11, 2024. It is now read-only.

Commit

Permalink
- [Core] fix bug with parsing bundles [SR]
Browse files Browse the repository at this point in the history
  • Loading branch information
Razmoth committed Sep 19, 2023
1 parent 4fcc549 commit 2e3dcdc
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions AssetStudio/AssetsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,7 @@ private void LoadBlockFile(FileReader reader)
var subReader = new FileReader(dummyPath, stream, true);
switch (subReader.FileType)
{
case FileType.ENCRFile:
case FileType.BundleFile:
LoadBundleFile(subReader, reader.FullPath, offset, false);
break;
Expand Down
9 changes: 5 additions & 4 deletions AssetStudio/FileReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ private FileType CheckFileType()
Logger.Verbose($"Parsed signature is {signature}");
switch (signature)
{
case "ENCR":
case "UnityWeb":
case "UnityRaw":
case "UnityArchive":
Expand All @@ -48,6 +47,8 @@ private FileType CheckFileType()
return FileType.WebFile;
case "blk":
return FileType.BlkFile;
case "ENCR":
return FileType.ENCRFile;
default:
{
Logger.Verbose("signature does not match any of the supported string signatures, attempting to check bytes signatures");
Expand Down Expand Up @@ -201,7 +202,7 @@ public static FileReader PreProcessing(this FileReader reader, Game game)
break;
}
}
if (reader.FileType == FileType.BundleFile && game.Type.IsBlockFile() || reader.FileType == FileType.BlbFile)
if (reader.FileType == FileType.BundleFile && game.Type.IsBlockFile() || reader.FileType == FileType.ENCRFile || reader.FileType == FileType.BlbFile)
{
Logger.Verbose("File might have multiple bundles !!");
try
Expand All @@ -211,9 +212,9 @@ public static FileReader PreProcessing(this FileReader reader, Game game)
reader.ReadStringToNull();
reader.ReadStringToNull();
var size = reader.ReadInt64();
if (!(signature == "UnityFS" && size == reader.BaseStream.Length))
if (size != reader.BaseStream.Length)
{
Logger.Verbose($"Found signature UnityFS, expected bundle size is 0x{size:X8}, found 0x{reader.BaseStream.Length} instead !!");
Logger.Verbose($"Found signature {signature}, expected bundle size is 0x{size:X8}, found 0x{reader.BaseStream.Length} instead !!");
Logger.Verbose("Loading as block file !!");
reader.FileType = FileType.BlockFile;
}
Expand Down
1 change: 1 addition & 0 deletions AssetStudio/FileType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public enum FileType
BlkFile,
Mhy0File,
BlbFile,
ENCRFile,
BlockFile
}
}
1 change: 1 addition & 0 deletions AssetStudio/OffsetStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public IEnumerable<long> GetOffsets(string path)
FileType.BundleFile => "UnityFS\x00",
FileType.BlbFile => "Blb\x02",
FileType.Mhy0File => "mhy0",
FileType.ENCRFile => "ENCR\x00",
_ => throw new InvalidOperationException()
};

Expand Down

0 comments on commit 2e3dcdc

Please sign in to comment.