diff --git a/BinaryObjectScanner/FileType/Executable.cs b/BinaryObjectScanner/FileType/Executable.cs index c1bc3a4b..e01e910d 100644 --- a/BinaryObjectScanner/FileType/Executable.cs +++ b/BinaryObjectScanner/FileType/Executable.cs @@ -165,14 +165,14 @@ namespace BinaryObjectScanner.FileType else if (!File.Exists(file)) return protections; - // If the stream isn't seekable - if (!stream.CanSeek) - return protections; - // Read the file contents byte[] fileContent = []; try { + // If the stream isn't seekable + if (!stream.CanSeek) + return protections; + stream.Seek(0, SeekOrigin.Begin); fileContent = stream.ReadBytes((int)stream.Length); if (fileContent == null) diff --git a/BinaryObjectScanner/Scanner.cs b/BinaryObjectScanner/Scanner.cs index bed0d840..c9b6c2b5 100644 --- a/BinaryObjectScanner/Scanner.cs +++ b/BinaryObjectScanner/Scanner.cs @@ -231,7 +231,7 @@ namespace BinaryObjectScanner private ProtectionDictionary GetInternalProtections(string fileName, Stream stream) { // Quick sanity check before continuing - if (stream == null || !stream.CanRead || !stream.CanSeek) + if (!stream.CanRead) return []; // Initialize the protections found