diff --git a/BinaryObjectScanner/FileType/SGA.cs b/BinaryObjectScanner/FileType/SGA.cs index 53b6bcbd..d79bf815 100644 --- a/BinaryObjectScanner/FileType/SGA.cs +++ b/BinaryObjectScanner/FileType/SGA.cs @@ -230,6 +230,7 @@ namespace BinaryObjectScanner.FileType { // Inflate the data into the buffer var zstream = new ZLib.z_stream_s(); + var state = new ZLib.inflate_state(); data = new byte[outputFileSize]; unsafe { @@ -237,7 +238,14 @@ namespace BinaryObjectScanner.FileType fixed (byte* dataPtr = data) { zstream.next_in = payloadPtr; + zstream.avail_in = (uint)compressedData.Length; zstream.next_out = dataPtr; + zstream.avail_out = (uint)data.Length; + + state.strm = zstream; + state.mode = ZLib.inflate_mode.HEAD; + + zstream.i_state = state; int zret = ZLib.inflate(zstream, 1); } } diff --git a/BinaryObjectScanner/Packer/CExe.cs b/BinaryObjectScanner/Packer/CExe.cs index 21765ba8..e04aebb9 100644 --- a/BinaryObjectScanner/Packer/CExe.cs +++ b/BinaryObjectScanner/Packer/CExe.cs @@ -88,6 +88,7 @@ namespace BinaryObjectScanner.Packer { // Inflate the data into the buffer var zstream = new ZLib.z_stream_s(); + var state = new ZLib.inflate_state(); data = new byte[payload.Length * 4]; unsafe { @@ -95,7 +96,14 @@ namespace BinaryObjectScanner.Packer fixed (byte* dataPtr = data) { zstream.next_in = payloadPtr; + zstream.avail_in = (uint)payload.Length; zstream.next_out = dataPtr; + zstream.avail_out = (uint)data.Length; + + state.strm = zstream; + state.mode = ZLib.inflate_mode.HEAD; + + zstream.i_state = state; int zret = ZLib.inflate(zstream, 1); } }