From 3a5e7004a3466c247ff0f4fd2e9ee32c0409a559 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Sat, 6 Sep 2025 10:58:46 -0400 Subject: [PATCH] Don't reopen the stream unnecessarily --- BinaryObjectScanner/FileType/NewExecutable.cs | 9 ++------- BinaryObjectScanner/FileType/PortableExecutable.cs | 9 ++------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/BinaryObjectScanner/FileType/NewExecutable.cs b/BinaryObjectScanner/FileType/NewExecutable.cs index c1f8c102..24568a9e 100644 --- a/BinaryObjectScanner/FileType/NewExecutable.cs +++ b/BinaryObjectScanner/FileType/NewExecutable.cs @@ -46,14 +46,9 @@ namespace BinaryObjectScanner.FileType } /// + /// Uses the already-generated wrapper public bool Extract(string file, string outDir, bool includeDebug) - { - if (!File.Exists(file)) - return false; - - using var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); - return Extract(fs, file, outDir, includeDebug); - } + => Extract(null, file, outDir, includeDebug); /// public bool Extract(Stream? stream, string file, string outDir, bool includeDebug) diff --git a/BinaryObjectScanner/FileType/PortableExecutable.cs b/BinaryObjectScanner/FileType/PortableExecutable.cs index 0e93a258..53f48bae 100644 --- a/BinaryObjectScanner/FileType/PortableExecutable.cs +++ b/BinaryObjectScanner/FileType/PortableExecutable.cs @@ -46,14 +46,9 @@ namespace BinaryObjectScanner.FileType } /// + /// Uses the already-generated wrapper public bool Extract(string file, string outDir, bool includeDebug) - { - if (!File.Exists(file)) - return false; - - using var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); - return Extract(fs, file, outDir, includeDebug); - } + => Extract(null, file, outDir, includeDebug); /// public bool Extract(Stream? stream, string file, string outDir, bool includeDebug)