Zlib fixes

This commit is contained in:
KillzXGaming 2019-09-18 17:02:25 -04:00
parent 4b83f9f17c
commit 36a09eafdd
5 changed files with 15 additions and 14 deletions

View file

@ -173,11 +173,6 @@ namespace FirstPlugin
public class FileEntry : ArchiveFileInfo
{
public override bool OpenFileFormatOnLoad
{
get { return true; }
}
public NodeEntry nodeEntry;
}

View file

@ -18,6 +18,8 @@ namespace Toolbox.Library
public bool Identify(Stream stream, string fileName)
{
if (stream.Length < 12) return false;
using (var reader = new FileReader(stream, true))
{
uint DecompressedSize = reader.ReadUInt32();

View file

@ -173,9 +173,17 @@ namespace Toolbox.Library.IO
{
var ms = new System.IO.MemoryStream();
if (hasMagic)
{
br.Position = 2;
using (var ds = new DeflateStream(new MemoryStream(br.ReadBytes((int)br.BaseStream.Length - 6)), CompressionMode.Decompress))
ds.CopyTo(ms);
using (var ds = new DeflateStream(new MemoryStream(br.ReadBytes((int)br.BaseStream.Length - 6)), CompressionMode.Decompress))
ds.CopyTo(ms);
}
else
{
using (var ds = new DeflateStream(new MemoryStream(b), CompressionMode.Decompress))
ds.CopyTo(ms);
}
return ms.ToArray();
}
}
@ -248,11 +256,8 @@ namespace Toolbox.Library.IO
//Mario Tennis Aces Custom compression
public class MTA_CUSTOM
{
[DllImport("Lib/LibTennis32.dll", CallingConvention = CallingConvention.Cdecl)]
static extern void DecompressBuffer32(IntPtr output, IntPtr input, uint len);
[DllImport("Lib/LibTennis64.dll", CallingConvention = CallingConvention.Cdecl)]
static extern void DecompressBuffer64(IntPtr output, IntPtr input, uint len);
static extern void DecompressBuffer(IntPtr output, IntPtr input, uint len);
public unsafe byte[] Decompress(byte[] input, uint decompressedLength)
{
@ -261,10 +266,9 @@ namespace Toolbox.Library.IO
fixed (byte* inputPtr = input)
{
if (Environment.Is64BitProcess)
DecompressBuffer64((IntPtr)outputPtr, (IntPtr)inputPtr, decompressedLength);
DecompressBuffer((IntPtr)outputPtr, (IntPtr)inputPtr, decompressedLength);
else
DecompressBuffer32((IntPtr)outputPtr, (IntPtr)inputPtr, decompressedLength);
// Decompress(outputPtr, inputPtr, decompressedLength);
MarioTennisCmp32.DecompressBuffer((IntPtr)outputPtr, (IntPtr)inputPtr, decompressedLength);
}
byte[] decomp = new byte[decompressedLength];

Binary file not shown.

Binary file not shown.