From efca2a7557d6d317d422533c91b8fb51fa32122c Mon Sep 17 00:00:00 2001 From: VaDiM Date: Thu, 24 Jul 2025 15:55:29 +0300 Subject: [PATCH] Add support for bundles with obfuscated unity version --- AssetStudio/BundleFile.cs | 5 ++++- AssetStudio/SerializedFile.cs | 10 ++++------ AssetStudio/UnityVersion.cs | 14 ++++++++++++++ 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/AssetStudio/BundleFile.cs b/AssetStudio/BundleFile.cs index 5db5355..484e65a 100644 --- a/AssetStudio/BundleFile.cs +++ b/AssetStudio/BundleFile.cs @@ -83,7 +83,10 @@ namespace AssetStudio m_Header.signature = reader.ReadStringToNull(); m_Header.version = reader.ReadUInt32(); m_Header.unityVersion = reader.ReadStringToNull(); - m_Header.unityRevision = new UnityVersion(reader.ReadStringToNull()); + var revStr = reader.ReadStringToNull(); + if (!UnityVersion.TryParse(revStr, out m_Header.unityRevision)) + m_Header.unityRevision = new UnityVersion(); + switch (m_Header.signature) { case "UnityArchive": diff --git a/AssetStudio/SerializedFile.cs b/AssetStudio/SerializedFile.cs index b0b54bb..9c07940 100644 --- a/AssetStudio/SerializedFile.cs +++ b/AssetStudio/SerializedFile.cs @@ -70,15 +70,13 @@ namespace AssetStudio if (header.m_Version >= SerializedFileFormatVersion.Unknown_7) { var versionPos = reader.Position; - try - { - version = new UnityVersion(reader.ReadStringToNull()); - } - catch (NotSupportedException e) + + var verStr = reader.ReadStringToNull(); + if (!UnityVersion.TryParse(verStr, out version)) { if (assetsManager.SpecifyUnityVersion == null) { - Logger.Warning(e.Message); + Logger.Warning($"Failed to parse Unity version: \"{verStr}\""); version = new UnityVersion(); return; } diff --git a/AssetStudio/UnityVersion.cs b/AssetStudio/UnityVersion.cs index 5a086ca..535c830 100644 --- a/AssetStudio/UnityVersion.cs +++ b/AssetStudio/UnityVersion.cs @@ -66,6 +66,20 @@ namespace AssetStudio } } + public static bool TryParse(string versionStr, out UnityVersion version) + { + version = null; + try + { + version = new UnityVersion(versionStr); + return true; + } + catch (Exception) + { + return false; + } + } + #region UnityVer, UnityVer public static bool operator ==(UnityVersion left, UnityVersion right) {