diff --git a/NetMFAPatcher/DotNetCTFDumper.csproj b/NetMFAPatcher/DotNetCTFDumper.csproj
index dd98f5a..8bf9531 100644
--- a/NetMFAPatcher/DotNetCTFDumper.csproj
+++ b/NetMFAPatcher/DotNetCTFDumper.csproj
@@ -84,11 +84,36 @@
..\packages\DotNetZip.1.15.0\lib\net40\DotNetZip.dll
True
+
+ ..\packages\Joveler.Compression.ZLib.4.0.0\lib\net451\Joveler.Compression.ZLib.dll
+ True
+
+
+ ..\packages\Joveler.DynLoader.2.0.0\lib\net451\Joveler.DynLoader.dll
+ True
+
+
+
+ ..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll
+ True
+
+
+ ..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll
+ True
+
+
+ ..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll
+ True
+
+
+ ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll
+ True
+
@@ -238,5 +263,14 @@
+
+
+
+ This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105.The missing file is {0}.
+
+
+
+
+
\ No newline at end of file
diff --git a/NetMFAPatcher/Program.cs b/NetMFAPatcher/Program.cs
index 8342c68..06ff8b3 100644
--- a/NetMFAPatcher/Program.cs
+++ b/NetMFAPatcher/Program.cs
@@ -1,10 +1,12 @@
using System;
using System.IO;
+using System.Runtime.InteropServices;
using System.Windows.Forms;
using DotNetCTFDumper.GUI;
using DotNetCTFDumper.MMFParser.Data;
using DotNetCTFDumper.MMFParser.Decompiling;
using DotNetCTFDumper.Utils;
+using Joveler.Compression.ZLib;
namespace DotNetCTFDumper
{
@@ -12,7 +14,7 @@ namespace DotNetCTFDumper
{
//public static string path = @"H:\fnaf-world.exe";//test
//public static string path = @"D:\SteamLibrary\steamapps\common\Five Nights at Freddy's Sister Location\SisterLocation.exe";
- public static string Path = ""; //TODO: Make Selectable
+ //public static string Path = ""; //TODO: Make Selectable
public static MainForm MyForm;
@@ -21,14 +23,13 @@ namespace DotNetCTFDumper
{
var handle = Helper.GetConsoleWindow();
Helper.ShowWindow(handle, Helper.SW_HIDE);
+ InitNativeLibrary();
- //MFAGenerator.BuildMFA();
- //Environment.Exit(0);
var path = "";
var verbose = false;
var dumpImages = false;
var dumpSounds = true;
-
+
if (args.Length == 0)
{
Settings.UseGUI = true;
@@ -73,6 +74,7 @@ namespace DotNetCTFDumper
Settings.DumpImages = dumpImages;
Settings.DumpSounds = dumpSounds;
Settings.Verbose = verbose;
+
var exeReader = new ByteReader(path, FileMode.OpenOrCreate);
var currentExe = new Exe();
Exe.Instance = currentExe;
@@ -113,8 +115,31 @@ namespace DotNetCTFDumper
Directory.CreateDirectory($"{Settings.ChunkPath}");
Directory.CreateDirectory($"{Settings.ExtensionPath}");
+ }
+ public static void InitNativeLibrary()
+ {
+ string arch = null;
+ switch (RuntimeInformation.ProcessArchitecture)
+ {
+ case Architecture.X86:
+ arch = "x86";
+ break;
+ case Architecture.X64:
+ arch = "x64";
+ break;
+ case Architecture.Arm:
+ arch = "armhf";
+ break;
+ case Architecture.Arm64:
+ arch = "arm64";
+ break;
+ }
+ string libPath = Path.Combine(arch, "zlibwapi.dll");
+ if (!File.Exists(libPath))
+ throw new PlatformNotSupportedException($"Unable to find native library [{libPath}].");
+ ZLibInit.GlobalInit(libPath);
}
}
}
\ No newline at end of file
diff --git a/NetMFAPatcher/Utils/Decompressor.cs b/NetMFAPatcher/Utils/Decompressor.cs
index 0c9b5c0..3c5a9a3 100644
--- a/NetMFAPatcher/Utils/Decompressor.cs
+++ b/NetMFAPatcher/Utils/Decompressor.cs
@@ -1,5 +1,7 @@
using System;
using System.Diagnostics;
+using System.IO;
+using Joveler.Compression.ZLib;
namespace DotNetCTFDumper.Utils
{
@@ -17,25 +19,25 @@ namespace DotNetCTFDumper.Utils
{
Int32 decompSize = exeReader.ReadInt32();
Int32 compSize = exeReader.ReadInt32();
- byte[] compressedData = exeReader.ReadBytes(compSize);
- byte[] actualData = Ionic.Zlib.ZlibStream.UncompressBuffer(compressedData);
- Debug.Assert(actualData.Length == decompSize);
decompressed = decompSize;
- return new ByteReader(actualData);
+ return new ByteReader(decompress_block(exeReader,compSize,decompSize));
}
public static byte[] decompress_block(ByteReader reader, int size, int decompSize)
{
- byte[] compressedData = reader.ReadBytes(size);
- byte[] actualData = Ionic.Zlib.ZlibStream.UncompressBuffer(compressedData);
- return actualData;
- }
+ ZLibDecompressOptions decompOpts = new ZLibDecompressOptions();
+ MemoryStream compressedStream = new MemoryStream(reader.ReadBytes(size));
+ MemoryStream decompressedStream = new MemoryStream();
+ using (DeflateStream zs = new DeflateStream(compressedStream, decompOpts))
+ {
+ zs.CopyTo(decompressedStream);
+
+ }
+ return decompressedStream.GetBuffer();
- public static ByteReader decompress_asReader(ByteReader imageData, int v, int decompressedSize)
- {
- return new ByteReader(decompress_block(imageData, v, decompressedSize));
}
+
}
}
\ No newline at end of file
diff --git a/NetMFAPatcher/packages.config b/NetMFAPatcher/packages.config
index 385f809..3601514 100644
--- a/NetMFAPatcher/packages.config
+++ b/NetMFAPatcher/packages.config
@@ -3,5 +3,12 @@
+
+
+
+
+
+
+
\ No newline at end of file