- [Core] fix but with wrongly identified sigantures [GI]

This commit is contained in:
Razmoth
2024-01-27 16:23:08 +04:00
parent 2d965c021d
commit 873597730c
5 changed files with 15 additions and 46 deletions

View File

@@ -512,8 +512,8 @@ namespace AssetStudio
}
try
{
var mhyFile = new MhyFile(reader, reader.FullPath, (Mhy)Game);
Logger.Verbose($"mhy total size: {mhyFile.TotalSize:X8}");
var mhyFile = new MhyFile(reader, (Mhy)Game);
Logger.Verbose($"mhy total size: {mhyFile.m_Header.size:X8}");
foreach (var file in mhyFile.fileList)
{
var dummyPath = Path.Combine(Path.GetDirectoryName(reader.FullPath), file.fileName);

View File

@@ -14,15 +14,11 @@ namespace AssetStudio
public BundleFile.Header m_Header;
public List<StreamFile> fileList;
public long Offset;
public Mhy mhy;
public long TotalSize => 8 + m_Header.compressedBlocksInfoSize + m_BlocksInfo.Sum(x => x.compressedSize);
public MhyFile(FileReader reader, string path, Mhy mhy)
public MhyFile(FileReader reader, Mhy mhy)
{
this.mhy = mhy;
Offset = reader.Position;
reader.Endian = EndianType.LittleEndian;
signature = reader.ReadStringToNull(4);
@@ -40,9 +36,14 @@ namespace AssetStudio
};
Logger.Verbose($"Header: {m_Header}");
ReadBlocksInfoAndDirectory(reader);
using var blocksStream = CreateBlocksStream(path);
using var blocksStream = CreateBlocksStream(reader.FullPath);
ReadBlocks(reader, blocksStream);
ReadFiles(blocksStream, path);
ReadFiles(blocksStream, reader.FullPath);
m_Header.size = 8 + m_Header.compressedBlocksInfoSize + m_BlocksInfo.Sum(x => x.compressedSize);
while (reader.PeekChar() == '\0')
{
reader.Position++;
}
}
private void ReadBlocksInfoAndDirectory(FileReader reader)

View File

@@ -81,42 +81,10 @@ namespace AssetStudio
}
else
{
using var reader = new FileReader(path, this, true);
var signature = reader.FileType switch
while (Remaining > 0)
{
FileType.BundleFile => "UnityFS\x00",
FileType.BlbFile => "Blb\x02",
FileType.MhyFile => Encoding.UTF8.GetString(reader.ReadBytes(4)),
FileType.ENCRFile => "ENCR\x00",
_ => throw new InvalidOperationException()
};
reader.Position = 0;
Logger.Verbose($"Prased signature: {signature}");
var signatureBytes = Encoding.UTF8.GetBytes(signature);
var buffer = ArrayPool<byte>.Shared.Rent(BufferSize);
try
{
while (Remaining > 0)
{
var index = 0;
var absOffset = AbsolutePosition;
var read = Read(buffer);
while (index < read)
{
index = buffer.AsSpan(0, read).Search(signatureBytes, index);
if (index == -1) break;
var offset = absOffset + index;
Offset = offset;
yield return offset;
index++;
}
}
}
finally
{
ArrayPool<byte>.Shared.Return(buffer, true);
Offset = AbsolutePosition;
yield return AbsolutePosition;
}
}
}