This project is read-only.

Skip gzip standard header on decompression

Sep 16, 2009 at 2:17 PM


There is a python script which allows extract information from some particular game files. Those files have blocks of data encoded with some algorithm and then compressed with zip.

Now I'm trying to translate that script into C# and I have problem with zlib decompression part. If you see the script on line 237 you'll see that the block size for extraction is negative. According to Python documentation it's undocumented mode that force the zlib decompressor to skip standard gzip header verification on read.

So my question is - how can I do the same with DotNetZip library? Cause when I try to decompress exactly the same data I got "Bad state (unknown compression method (0xDE))" exception (and I verified that I got identical data right before decompression step in both my version and python script version).

Sep 16, 2009 at 4:29 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Sep 16, 2009 at 4:30 PM

Can you give me a .gz file that requires this?  (Upload it to the workitem)

Sep 16, 2009 at 6:31 PM

M... I can either give you full code (it's very short cause it's my test project) and source file. Or I can give you the encrypted block only. What would be more convient for you?

PS: I can upload the file only tomorrow when I'll be on work.

Sep 16, 2009 at 11:26 PM

full code?   not sure what that code would do.

What I would like is the .gz file that omits the GZIP header.  I want to be able to verify that the Ionic.Zlib.GZipStream can read the file.


Sep 17, 2009 at 8:26 AM
Edited Sep 17, 2009 at 8:29 AM

Ok, it's here:

The content of that archive:

  • test.bin - source binary block of data
  • - Python script that can unpack test.bin into python_test.dat file (to run it simply install Python 2.6 and run from command line)
  • python_test.dat - unpacked (by Python zlib) test.bin, you can see it contains a collection of structures with utf32 text data in them

What I'm trying to achieve is that this C# code:


File.WriteAllBytes (@"c#_test.dat", ZlibStream.UncompressBuffer (File.ReadAllBytes (@"test.bin")));


Could get me the same data as Python version. Now it's only gives me "Ionic.Zlib.ZlibException: Bad state (unknown compression method (0xA4))"

Sep 18, 2009 at 9:06 PM

I'll have a look.

Sep 19, 2009 at 2:10 AM

That file is a bare DEFLATE stream.  What you want is DeflateStream.UncompressBuffer().  I just added that method into v1.9.0.8. 


Sep 19, 2009 at 10:13 AM

Oh! Thank you very much!