Created
May 16, 2013 18:42
-
-
Save angelsl/5594021 to your computer and use it in GitHub Desktop.
Converts ".WAV" aka .binka audios extracted from Scribblenauts Unlimited files to PCM WAV files.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can't even compile.