diff --git a/BurnOutSharp/External/libmspack/CHM/Implementation.cs b/BurnOutSharp/External/libmspack/CHM/Implementation.cs index 839a963b..4ac9a862 100644 --- a/BurnOutSharp/External/libmspack/CHM/Implementation.cs +++ b/BurnOutSharp/External/libmspack/CHM/Implementation.cs @@ -1113,7 +1113,12 @@ namespace LibMSPackSharp.CHM /// private static int SysWrite(object file, byte[] buffer, int offset, int bytes) { - if (file is DecompressorImpl self) + // Null output file means skip those bytes + if (file == null) + { + return bytes; + } + else if (file is DecompressorImpl self) { self.State.Offset += (uint)bytes; if (self.State.OutputFileHandle != null) diff --git a/BurnOutSharp/External/libmspack/OAB/Implementation.cs b/BurnOutSharp/External/libmspack/OAB/Implementation.cs index 7e7b7f34..828c20ee 100644 --- a/BurnOutSharp/External/libmspack/OAB/Implementation.cs +++ b/BurnOutSharp/External/libmspack/OAB/Implementation.cs @@ -86,7 +86,12 @@ namespace LibMSPackSharp.OAB private static int SysWrite(object baseFile, byte[] buf, int pointer, int size) { - if (baseFile is InternalFile file) + // Null output file means skip those bytes + if (baseFile == null) + { + return size; + } + else if (baseFile is InternalFile file) { int bytes_written = file.OrigSys.Write(file.OrigFile, buf, pointer, size); if (bytes_written > 0) @@ -100,7 +105,7 @@ namespace LibMSPackSharp.OAB } // Unknown file to write to - return 0; + return -1; } #endregion diff --git a/BurnOutSharp/External/libmspack/SystemImpl.cs b/BurnOutSharp/External/libmspack/SystemImpl.cs index f21bf918..2d8a66d1 100644 --- a/BurnOutSharp/External/libmspack/SystemImpl.cs +++ b/BurnOutSharp/External/libmspack/SystemImpl.cs @@ -252,6 +252,12 @@ namespace LibMSPackSharp private static int DefaultWrite(object file, byte[] buffer, int pointer, int bytes) { + // Null output file means skip those bytes + if (file == null) + { + return bytes; + } + FileStream self = file as FileStream; if (self != null && buffer != null && bytes >= 0) {