I have nothing to gatekeep, i have nothing special...

This commit is contained in:
yarik0chka
2024-04-28 19:52:44 +05:00
parent d135a93412
commit 054df3b752
12 changed files with 203 additions and 27 deletions

View File

@@ -0,0 +1,25 @@
using System;
using System.IO;
using System.Runtime.InteropServices;
namespace AssetStudio;
public static class OodleHelper
{
[DllImport(@"oo2core_9_win64.dll")]
static extern int OodleLZ_Decompress(ref byte compressedBuffer, int compressedBufferSize, ref byte decompressedBuffer, int decompressedBufferSize, int fuzzSafe, int checkCRC, int verbosity, IntPtr rawBuffer, int rawBufferSize, IntPtr fpCallback, IntPtr callbackUserData, IntPtr decoderMemory, IntPtr decoderMemorySize, int threadPhase);
public static int Decompress(Span<byte> compressed, Span<byte> decompressed)
{
int numWrite = -1;
try
{
numWrite = OodleLZ_Decompress(ref compressed[0], compressed.Length, ref decompressed[0], decompressed.Length, 1, 0, 0, 0, 0, 0, 0, 0, 0, 3);
}
catch (Exception)
{
throw new IOException($"Oodle decompression error, write {numWrite} bytes but expected {decompressed.Length} bytes");
}
return numWrite;
}
}