Start fixing zlib implementation

This commit is contained in:
Matt Nadareski
2024-03-25 16:58:11 -04:00
parent cbaf004e25
commit 03ca0faf2e
2 changed files with 16 additions and 0 deletions

View File

@@ -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);
}
}

View File

@@ -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);
}
}