diff --git a/BinaryObjectScanner/FileType/GCF.cs b/BinaryObjectScanner/FileType/GCF.cs index a48b8750..f4d8911b 100644 --- a/BinaryObjectScanner/FileType/GCF.cs +++ b/BinaryObjectScanner/FileType/GCF.cs @@ -1,3 +1,4 @@ +using System; using System.IO; namespace BinaryObjectScanner.FileType @@ -16,19 +17,19 @@ public GCF(SabreTools.Wrappers.GCF wrapper) : base(wrapper) { } // Filename is worth reporting, since it's descriptive and has to match the Steam2 CDN in order to work. string fileName = Path.GetFileName(file); uint depotId = _wrapper.Model.Header.CacheID; - uint manifestVersion = _wrapper.Model.Header.LastVersionPlayed; + uint depotVersion = _wrapper.Model.Header.LastVersionPlayed; - // At the moment, all samples of GCF files on redump are unencrypted. Combined with being uncertain about - // whether this is the best way to check whether the GCF is encrypted, this block will be left commented - // out until further research is done. - // bool encrypted = false; - // if (_wrapper.Files != null && _wrapper.Files.Length > 0) - // encrypted = _wrapper.Files[0].Encrypted; + // While there is a depot-level encrypted flag on the GCF, it's unfortunately completely unreliable. + // Technically speaking, there are some known GCFs that only have some files encrypted. HL2 discs from + // 2004 have several GCFs like this, one being base_source_engine.gcf (depot 200). Thus, it's necessary + // to iterate all file info to check if any files are encrypted + bool encrypted = false; + if (_wrapper.Files != null && _wrapper.Files.Length > 0) + encrypted = Array.Exists(_wrapper.Files, fileInfo => fileInfo.Encrypted); - // string encryptedString = encrypted ? "encrypted" : "unencrypted"; - // string returnString = $"{fileName} - {depotId} (v{manifestVersion}, {encryptedString})"; - - string returnString = $"{fileName} - {depotId} (v{manifestVersion})"; + // Only note encryption status if the GCF is encrypted + string encryptedString = encrypted ? ", encrypted" : ""; + string returnString = $"{fileName} - {depotId} (v{depotVersion}{encryptedString})"; return returnString; } }