From cf7a68602bfaca7dae5c1b5bebef184ff11f76e5 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Mon, 28 Jul 2025 13:09:08 -0400 Subject: [PATCH] Add MS-CAB GetFolderIndex helper --- BinaryObjectScanner/FileType/MicrosoftCAB.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/BinaryObjectScanner/FileType/MicrosoftCAB.cs b/BinaryObjectScanner/FileType/MicrosoftCAB.cs index 6f673eaa..98d906c7 100644 --- a/BinaryObjectScanner/FileType/MicrosoftCAB.cs +++ b/BinaryObjectScanner/FileType/MicrosoftCAB.cs @@ -104,7 +104,7 @@ namespace BinaryObjectScanner.FileType // Loop through the files foreach (var compressedFile in cabArchive.Model.Files) { - if (compressedFile?.Name == null || compressedFile.FolderIndex != (FolderIndex)f) + if (compressedFile?.Name == null || GetFolderIndex(cabArchive, compressedFile) != f) continue; try @@ -169,5 +169,19 @@ namespace BinaryObjectScanner.FileType } #endif } + + /// + /// Get the corrected folder index + /// + private int GetFolderIndex(SabreTools.Serialization.Wrappers.MicrosoftCabinet cabArchive, CFFILE file) + { + return file.FolderIndex switch + { + FolderIndex.CONTINUED_FROM_PREV => 0, + FolderIndex.CONTINUED_TO_NEXT => (cabArchive.Model.Header?.FolderCount ?? 1) - 1, + FolderIndex.CONTINUED_PREV_AND_NEXT => 0, + _ => (int)file.FolderIndex, + }; + } } }