From 3463936ae02f4911326ce25d02b1382b81a69817 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Thu, 28 Aug 2025 20:00:05 -0400 Subject: [PATCH] Fix extracting SFX archives --- .../Wrappers/PortableExecutable.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/SabreTools.Serialization/Wrappers/PortableExecutable.cs b/SabreTools.Serialization/Wrappers/PortableExecutable.cs index 5279ab14..49232b56 100644 --- a/SabreTools.Serialization/Wrappers/PortableExecutable.cs +++ b/SabreTools.Serialization/Wrappers/PortableExecutable.cs @@ -1094,6 +1094,7 @@ namespace SabreTools.Serialization.Wrappers /// - Archives and executables in the overlay /// - Archives and executables in resource data /// - CExe-compressed resource data + /// - SFX archives (7z, PKZIP, RAR) /// public bool Extract(string outputDirectory, bool includeDebug) { @@ -1101,13 +1102,17 @@ namespace SabreTools.Serialization.Wrappers bool overlay = ExtractFromOverlay(outputDirectory, includeDebug); bool resources = ExtractFromResources(outputDirectory, includeDebug); - var sevenZipSfx = SevenZip.Create(_dataSource); + // Use non-model constructors to allow looking for headers + _dataSource.Position = 0; + var sevenZipSfx = new SevenZip(_dataSource); bool sevenZip = sevenZipSfx?.Extract(outputDirectory, lookForHeader: true, includeDebug) ?? false; - var pkzipSfx = PKZIP.Create(_dataSource); + _dataSource.Position = 0; + var pkzipSfx = new PKZIP(_dataSource); bool pkzip = pkzipSfx?.Extract(outputDirectory, lookForHeader: true, includeDebug) ?? false; - var rarSfx = RAR.Create(_dataSource); + _dataSource.Position = 0; + var rarSfx = new RAR(_dataSource); bool rar = rarSfx?.Extract(outputDirectory, lookForHeader: true, includeDebug) ?? false; return cexe || overlay || resources || sevenZip || pkzip || rar;