From 84bdc675035754d33b56812f1606a20277e41137 Mon Sep 17 00:00:00 2001 From: Atvaark Date: Mon, 15 Jun 2020 20:40:16 +0200 Subject: [PATCH] Fixed Dark Souls Remastered file decompression --- BinderTool.Core/BinderTool.Core.csproj | 10 ++++++---- BinderTool.Core/Dcx/DeflateCompression.cs | 14 ++++++-------- BinderTool.Core/Enfl/EntryFileListFile.cs | 9 +++------ BinderTool.Core/Properties/AssemblyInfo.cs | 2 +- BinderTool.Core/packages.config | 2 +- BinderTool/Program.cs | 2 +- BinderTool/Properties/AssemblyInfo.cs | 2 +- 7 files changed, 19 insertions(+), 22 deletions(-) diff --git a/BinderTool.Core/BinderTool.Core.csproj b/BinderTool.Core/BinderTool.Core.csproj index 3953440..0978a42 100644 --- a/BinderTool.Core/BinderTool.Core.csproj +++ b/BinderTool.Core/BinderTool.Core.csproj @@ -59,9 +59,6 @@ ..\packages\BouncyCastle.1.8.4\lib\BouncyCastle.Crypto.dll - - ..\packages\ICSharpCode.SharpZipLib.dll.0.85.4.369\lib\net20\ICSharpCode.SharpZipLib.dll - @@ -72,6 +69,9 @@ + + ..\packages\Zlib.Portable.1.11.0\lib\portable-net4+sl5+wp8+win8+wpa81+MonoTouch+MonoAndroid\Zlib.Portable.dll + @@ -119,7 +119,9 @@ - + + Designer + diff --git a/BinderTool.Core/Dcx/DeflateCompression.cs b/BinderTool.Core/Dcx/DeflateCompression.cs index ca7ae3e..70686ca 100644 --- a/BinderTool.Core/Dcx/DeflateCompression.cs +++ b/BinderTool.Core/Dcx/DeflateCompression.cs @@ -1,5 +1,5 @@ using System.IO; -using ICSharpCode.SharpZipLib.Zip.Compression.Streams; +using Ionic.Zlib; namespace BinderTool.Core.Dcx { @@ -11,20 +11,18 @@ public class DeflateCompression : DcxCompression //public override MemoryStream CompressData(byte[] uncompressedData) //{ // MemoryStream compressedBufferStream = new MemoryStream(); - // using (DeflaterOutputStream deflaterStream = new DeflaterOutputStream(compressedBufferStream)) + // using (var zlibStream = new ZlibStream(compressedBufferStream, CompressionMode.Compress, (CompressionLevel)Level)) // { - // deflaterStream.Write(uncompressedData, 0, uncompressedData.Length); + // zlibStream.Write(uncompressedData, 0, uncompressedData.Length); // } + // return compressedBufferStream; //} public override MemoryStream DecompressData(byte[] compressedData, int uncompressedSize) { - InflaterInputStream inflaterStream = new InflaterInputStream(new MemoryStream(compressedData)); - MemoryStream outputStream = new MemoryStream(); - inflaterStream.CopyTo(outputStream); - outputStream.Position = 0; - return outputStream; + var decompressedData = ZlibStream.UncompressBuffer(compressedData); + return new MemoryStream(decompressedData); } public static DeflateCompression Read(BinaryReader reader) diff --git a/BinderTool.Core/Enfl/EntryFileListFile.cs b/BinderTool.Core/Enfl/EntryFileListFile.cs index c96847a..c50590e 100644 --- a/BinderTool.Core/Enfl/EntryFileListFile.cs +++ b/BinderTool.Core/Enfl/EntryFileListFile.cs @@ -1,6 +1,6 @@ using System.IO; using System.Text; -using ICSharpCode.SharpZipLib.Zip.Compression.Streams; +using Ionic.Zlib; namespace BinderTool.Core.Enfl { @@ -88,11 +88,8 @@ private MemoryStream Decompress(Stream inputStream) int uncompressedSize = reader.ReadInt32(); byte[] data = reader.ReadBytes(compressedSize); - InflaterInputStream inflaterStream = new InflaterInputStream(new MemoryStream(data)); - MemoryStream decompressedStream = new MemoryStream(); - inflaterStream.CopyTo(decompressedStream); - decompressedStream.Position = 0; - return decompressedStream; + byte[] uncompressData = ZlibStream.UncompressBuffer(data); + return new MemoryStream(uncompressData); } } } diff --git a/BinderTool.Core/Properties/AssemblyInfo.cs b/BinderTool.Core/Properties/AssemblyInfo.cs index 9eae98d..7c515ba 100644 --- a/BinderTool.Core/Properties/AssemblyInfo.cs +++ b/BinderTool.Core/Properties/AssemblyInfo.cs @@ -6,7 +6,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("BinderTool.Core")] -[assembly: AssemblyCopyright("Copyright © 2019 Atvaark")] +[assembly: AssemblyCopyright("Copyright © 2020 Atvaark")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/BinderTool.Core/packages.config b/BinderTool.Core/packages.config index d0353c2..785b58d 100644 --- a/BinderTool.Core/packages.config +++ b/BinderTool.Core/packages.config @@ -1,6 +1,6 @@  - + \ No newline at end of file diff --git a/BinderTool/Program.cs b/BinderTool/Program.cs index a5ab5c3..f6fef81 100644 --- a/BinderTool/Program.cs +++ b/BinderTool/Program.cs @@ -97,7 +97,7 @@ private static void ShowUsageInfo() { Console.WriteLine( "BinderTool by Atvaark\n" + - " A tool for unpacking Dark Souls II/III/Bloodborne/Sekiro Bdt, Bhd, Dcx, Sl2, Tpf, Param and Fmg files\n" + + " A tool for unpacking Dark Souls I/II/III/Bloodborne/Sekiro Bdt, Bhd, Dcx, Sl2, Tpf, Param and Fmg files\n" + "Usage:\n" + " BinderTool file_path [output_path]\n" + "Examples:\n" + diff --git a/BinderTool/Properties/AssemblyInfo.cs b/BinderTool/Properties/AssemblyInfo.cs index ed250db..7817b11 100644 --- a/BinderTool/Properties/AssemblyInfo.cs +++ b/BinderTool/Properties/AssemblyInfo.cs @@ -6,7 +6,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("BinderTool")] -[assembly: AssemblyCopyright("Copyright © 2019 Atvaark")] +[assembly: AssemblyCopyright("Copyright © 2020 Atvaark")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)]