Skip to content

Instantly share code, notes, and snippets.

@angelsl angelsl/BinkA2WAV.cs
Created May 16, 2013

Embed
What would you like to do?
Converts ".WAV" aka .binka audios extracted from Scribblenauts Unlimited files to PCM WAV files.
using System;
using System.IO;
using System.Runtime.InteropServices;
namespace BinkA2WAV
{
internal unsafe class Program
{
private static void Main(string[] args)
{
byte[] inData = File.ReadAllBytes(args[0]);
IntPtr resultPtr;
uint resultSize = 0;
AIL_set_redist_directory(".");
AIL_startup();
if (AIL_decompress_ASI(inData, (uint) inData.Length, ".binka", &resultPtr, &resultSize, 0) == 0)
{
Console.WriteLine("Native call returned 0: failure; it reports \"{0}\"",
Marshal.PtrToStringAnsi(AIL_last_error()));
return;
}
var result = new byte[resultSize];
Marshal.Copy(resultPtr, result, 0, result.Length);
AIL_mem_free_lock(resultPtr);
AIL_shutdown();
File.WriteAllBytes(args[1], result);
}
[DllImport("mss32.dll", EntryPoint = "_AIL_decompress_ASI@24")]
private static extern int AIL_decompress_ASI([MarshalAs(UnmanagedType.LPArray)] byte[] indata, uint insize,
[MarshalAs(UnmanagedType.LPStr)] String ext, IntPtr* result,
uint* resultsize, uint zero);
[DllImport("mss32.dll", EntryPoint = "_AIL_last_error@0")]
private static extern IntPtr AIL_last_error();
[DllImport("mss32.dll", EntryPoint = "_AIL_set_redist_directory@4")]
private static extern IntPtr AIL_set_redist_directory([MarshalAs(UnmanagedType.LPStr)] string redistDir);
[DllImport("mss32.dll", EntryPoint = "_AIL_mem_free_lock@4")]
private static extern void AIL_mem_free_lock(IntPtr ptr);
[DllImport("mss32.dll", EntryPoint = "_AIL_startup@0")]
private static extern int AIL_startup();
[DllImport("mss32.dll", EntryPoint = "_AIL_shutdown@0")]
private static extern int AIL_shutdown();
}
}
@MateoGodlike

This comment has been minimized.

Copy link

commented Dec 31, 2013

Can't even compile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.