Atvaark / FtexTool

Fox Engine Texture (.ftex) to DDS converter
MIT License
32 stars 9 forks source link

SharpZipLib exception, invalid header #7

Closed emperor06 closed 6 years ago

emperor06 commented 7 years ago

I'm getting a consistant crash while trying to convert a few specific ftex files. Those textures render well in-game. It seems that SharpZipLib doesn't like the header. While it may be a bug in SharpZipLib, I think it's best to let you know.

Here's the error (ftex file attached)

Unhandled Exception: ICSharpCode.SharpZipLib.SharpZipBaseException: Header checksum illegal at ICSharpCode.SharpZipLib.Zip.Compression.Inflater.DecodeHeader() at ICSharpCode.SharpZipLib.Zip.Compression.Inflater.Decode() at ICSharpCode.SharpZipLib.Zip.Compression.Inflater.Inflate(Byte[] buffer, Int32 offset, Int32 count) at ICSharpCode.SharpZipLib.Zip.Compression.Streams.InflaterInputStream.Read(Byte[] buffer, Int32 offset, Int32 count) at System.IO.Stream.InternalCopyTo(Stream destination, Int32 bufferSize) at System.IO.Stream.CopyTo(Stream destination) at FtexTool.ZipUtility.Inflate(Byte[] buffer) in FtexTool\ZipUtility.cs:line 12 at FtexTool.Ftexs.FtexsFileChunk.SetData(Byte[] chunkData, Boolean compressed) in FtexTool\Ftexs\FtexsFileChunk.cs:line 41 at FtexTool.Ftexs.FtexsFileChunk.Read(Stream inputStream, Int32 baseOffset) in FtexTool\Ftexs\FtexsFileChunk.cs:line32 at FtexTool.Ftexs.FtexsFileChunk.ReadFtexsFileChunk(Stream inputStream, Int32 baseOffset) in FtexTool\Ftexs\FtexsFileChunk.cs:line 18 at FtexTool.Ftexs.FtexsFileMipMap.Read(Stream inputStream, Int16 chunkCount,Int32 baseOffset) in FtexTool\Ftexs\FtexsFileMipMap.cs:line 58 at FtexTool.Ftexs.FtexsFileMipMap.ReadFtexsFileMipMap(Stream inputStream, Int16 chunkCount, Int32 baseOffset) in FtexTool\Ftexs\FtexsFileMipMap.cs:line 50 at FtexTool.Ftexs.FtexsFile.Read(Stream inputStream, Int16 chunkCount, Int32baseOffset) in FtexTool\Ftexs\FtexsFile.cs:line 35 at FtexTool.Program.GetFtexFile(String filePath) in FtexTool\Program.cs:line 182 at FtexTool.Program.UnpackFtexFile(String filePath, String outputPath) in FtexTool\Program.cs:line 138 at FtexTool.Program.Main(String[] args) in FtexTool\Program.cs:line 52

texture.zip

Atvaark commented 7 years ago

SharpZipLib is working correctly. FtexTool does some assumptions to work with a majority of the files and this one gets handled incorrectly. This .ftex file has an unknown flag which just 3% of all the ftex files have set. The error could be related to not handing that flag correctly.

I had to change the code a little bit to convert that texture to DDS and back to ftex again. But I can't commit it right now as I'd have to test if the change breaks unpacking the remaining 97% of the files. Result: c681a9ba4f51.jpg NSFW

See this patch file for the change I made: fix.zip

Oeroalty3 commented 7 years ago

Any update on this issue? Encountered this same error when modding MGSTPP.

Atvaark commented 6 years ago

The original c681a9ba4f51.ftex file from texture0.dat unpacks without issues. (even with FtexTool version v0.3). The one you uploaded got corrupted. If you can reproduce this issue with an unmodified file please reopen this issue.