diff --git a/BinaryObjectScanner/BinaryObjectScanner.csproj b/BinaryObjectScanner/BinaryObjectScanner.csproj index 85cb080a..b4eddced 100644 --- a/BinaryObjectScanner/BinaryObjectScanner.csproj +++ b/BinaryObjectScanner/BinaryObjectScanner.csproj @@ -73,7 +73,7 @@ - + @@ -81,14 +81,14 @@ - + - + - - - - + + + + diff --git a/BinaryObjectScanner/FileType/InstallShieldArchiveV3.cs b/BinaryObjectScanner/FileType/InstallShieldArchiveV3.cs index 253059bb..fdde7e87 100644 --- a/BinaryObjectScanner/FileType/InstallShieldArchiveV3.cs +++ b/BinaryObjectScanner/FileType/InstallShieldArchiveV3.cs @@ -31,16 +31,16 @@ namespace BinaryObjectScanner.FileType Directory.CreateDirectory(tempPath); UnshieldSharp.Archive.InstallShieldArchiveV3 archive = new UnshieldSharp.Archive.InstallShieldArchiveV3(file); - foreach (CompressedFile cfile in archive.Files.Select(kvp => kvp.Value)) + foreach (var cfile in archive.Files) { try { - string tempFile = Path.Combine(tempPath, cfile.FullPath!); + string tempFile = Path.Combine(tempPath, cfile.Key); var directoryName = Path.GetDirectoryName(tempFile); if (directoryName != null && !Directory.Exists(directoryName)) Directory.CreateDirectory(directoryName); - (byte[]? fileContents, string? error) = archive.Extract(cfile.FullPath!); + (byte[]? fileContents, string? error) = archive.Extract(cfile.Key); if (fileContents == null || !string.IsNullOrEmpty(error)) continue; diff --git a/BinaryObjectScanner/FileType/InstallShieldCAB.cs b/BinaryObjectScanner/FileType/InstallShieldCAB.cs index 710d32d9..f67ecc7d 100644 --- a/BinaryObjectScanner/FileType/InstallShieldCAB.cs +++ b/BinaryObjectScanner/FileType/InstallShieldCAB.cs @@ -59,21 +59,21 @@ namespace BinaryObjectScanner.FileType Directory.CreateDirectory(tempPath); var cabfile = InstallShieldCabinet.Open(file); - if (cabfile == null) + if (cabfile?.HeaderList == null) return null; - for (int i = 0; i < cabfile.FileCount; i++) + for (int i = 0; i < cabfile.HeaderList.FileCount; i++) { try { // Check if the file is valid first - if (!cabfile.FileIsValid(i)) + if (!cabfile.HeaderList.FileIsValid(i)) continue; string tempFile; try { - string? filename = cabfile.FileName(i); + string? filename = cabfile.HeaderList.GetFileName(i); tempFile = Path.Combine(tempPath, filename ?? string.Empty); } catch diff --git a/BinaryObjectScanner/Packer/WiseInstaller.cs b/BinaryObjectScanner/Packer/WiseInstaller.cs index 7d7d4f60..a735f759 100644 --- a/BinaryObjectScanner/Packer/WiseInstaller.cs +++ b/BinaryObjectScanner/Packer/WiseInstaller.cs @@ -7,7 +7,7 @@ using SabreTools.IO.Extensions; using SabreTools.Matching; using SabreTools.Serialization.Wrappers; using WiseUnpacker; -using Wise = WiseUnpacker.WiseUnpacker; +using WiseUnpacker.EWISE; namespace BinaryObjectScanner.Packer { @@ -82,8 +82,7 @@ namespace BinaryObjectScanner.Packer try { // TODO: Try to find where the file data lives and how to get it - var unpacker = new Wise(); - if (!unpacker.ExtractTo(file, tempPath)) + if (!Extractor.ExtractTo(file, tempPath)) { try { @@ -191,8 +190,7 @@ namespace BinaryObjectScanner.Packer // If we have DEFLATE -- TODO: Port implementation here or use DeflateStream else { - Wise unpacker = new Wise(); - if (!unpacker.ExtractTo(file, tempPath)) + if (!Extractor.ExtractTo(file, tempPath)) { try { diff --git a/Test/Extractor.cs b/Test/Extractor.cs index 442b7380..1da25c24 100644 --- a/Test/Extractor.cs +++ b/Test/Extractor.cs @@ -94,10 +94,14 @@ namespace Test // If an individual entry fails try { - // If we have a directory, skip it + // If the entry is a directory if (entry.IsDirectory) continue; + // If the entry has an invalid key + if (entry.Key == null) + continue; + string tempFile = Path.Combine(outputDirectory, entry.Key); entry.WriteToFile(tempFile); } @@ -293,10 +297,14 @@ namespace Test // If an individual entry fails try { - // If we have a directory, skip it + // If the entry is a directory if (entry.IsDirectory) continue; + // If the entry has an invalid key + if (entry.Key == null) + continue; + string tempFile = Path.Combine(outputDirectory, entry.Key); entry.WriteToFile(tempFile); } @@ -321,17 +329,17 @@ namespace Test try { var archive = new InstallShieldArchiveV3(file); - foreach (var cfile in archive.Files.Select(kvp => kvp.Value)) + foreach (var cfile in archive.Files) { // If an individual entry fails try { - string tempFile = Path.Combine(outputDirectory, cfile.FullPath ?? string.Empty); + string tempFile = Path.Combine(outputDirectory, cfile.Key); string? directoryName = Path.GetDirectoryName(tempFile); if (!string.IsNullOrEmpty(directoryName) && !Directory.Exists(directoryName)) Directory.CreateDirectory(directoryName); - (byte[]? fileContents, string? error) = archive.Extract(cfile.FullPath ?? string.Empty); + (byte[]? fileContents, string? error) = archive.Extract(cfile.Key); if (!string.IsNullOrEmpty(error)) continue; @@ -343,7 +351,7 @@ namespace Test } catch (Exception ex) { - Console.WriteLine($"Something went wrong extracting InstallShield Archive V3 entry {cfile.Name}: {ex}"); + Console.WriteLine($"Something went wrong extracting InstallShield Archive V3 entry {cfile.Value.Name}: {ex}"); Console.WriteLine(); } } @@ -366,12 +374,19 @@ namespace Test try { var cabfile = UnshieldSharp.Cabinet.InstallShieldCabinet.Open(file); - for (int i = 0; i < (cabfile?.FileCount ?? 0); i++) + if (cabfile?.HeaderList == null) + { + Console.WriteLine("Something went wrong parsing IS-CAB archive"); + Console.WriteLine(); + return; + } + + for (int i = 0; i < cabfile!.HeaderList.FileCount; i++) { // If an individual entry fails try { - string? filename = cabfile?.FileName(i); + string? filename = cabfile.HeaderList.GetFileName(i); string tempFile; try { @@ -618,10 +633,14 @@ namespace Test // If an individual entry fails try { - // If we have a directory, skip it + // If the entry is a directory if (entry.IsDirectory) continue; + // If the entry has an invalid key + if (entry.Key == null) + continue; + string tempFile = Path.Combine(outputDirectory, entry.Key); string? directoryName = Path.GetDirectoryName(tempFile); if (directoryName != null) @@ -690,10 +709,14 @@ namespace Test // If an individual entry fails try { - // If we have a directory, skip it + // If the entry is a directory if (entry.IsDirectory) continue; + // If the entry has an invalid key + if (entry.Key == null) + continue; + string tempFile = Path.Combine(outputDirectory, entry.Key); entry.WriteToFile(tempFile); } @@ -759,10 +782,14 @@ namespace Test // If an individual entry fails try { - // If we have a directory, skip it + // If the entry is a directory if (entry.IsDirectory) continue; + // If the entry has an invalid key + if (entry.Key == null) + continue; + string tempFile = Path.Combine(outputDirectory, entry.Key); entry.WriteToFile(tempFile); } diff --git a/Test/Test.csproj b/Test/Test.csproj index 7b036c36..eef0ce8e 100644 --- a/Test/Test.csproj +++ b/Test/Test.csproj @@ -27,13 +27,13 @@ - - + + - + - - + + \ No newline at end of file