Skip to content

Instantly share code, notes, and snippets.

Created November 8, 2012 08:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/4037488 to your computer and use it in GitHub Desktop.
Save anonymous/4037488 to your computer and use it in GitHub Desktop.
Source code to extract the sound files from ponysounds.glz in the MLP Fim game for iOS IPA
/*
This source code is provided "as is" and without warranties as to performance
or merchantability. The author and/or distributors of this source code may have
made statements about this source code. Any such statements do not constitute
warranties and shall not be relied on by the user in deciding whether to use this
source code.
This source code is provided without any express or implied warranties whatsoever.
Because of the diversity of conditions and hardware under which this source code may
be used, no warranty of fitness for a particular purpose is offered. The user is advised
to test the source code thoroughly before relying on it. The user must assume the entire
risk of using the source code.
####################################
Quick Notes About the ponysounds.glz format:
- All sounds are in mpc (Musepack) format (VLC can play these)
- No Compression
- There is a file named sfx_score_counter.vxn in there
which I have not bothered to reverse engineer.
There is no global file header. 1st entry starts right away.
Each entry in the file takes the following format
{
18 bytes : Unknown header for each data block
04 bytes : Length of the data
04 bytes : Length of the data (again)
04 bytes : Length of the file name
xx bytes : The data (length specified previously)
}
There is additional data at the end of the file with what appears
to be a jump table for quickly figuring out where a given sound is
stored. I did not bother deciphering the format.
Code has only been tested under OS X 10.7.5.
Usage: exeName path/to/ponysounds.glz
*/
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <stdlib.h>
#define NUMBER_FILES 471
struct FileHeader {
char unknown[18];
uint32_t length1;
uint32_t length2;
uint32_t nameLen;
};
int main(int argc, const char * argv[])
{
printf("Opening %s\n", argv[1]);
FILE *file = fopen(argv[1], "rb");
// Buffer overflow waiting to happen, idc
char nameBuffer[256];
struct FileHeader header;
for (int f = 0; f<NUMBER_FILES; f++) {
// Read Header
fread(&header.unknown, sizeof(header.unknown), 1, file);
fread(&header.length1, sizeof(header.length1), 1, file);
fread(&header.length2, sizeof(header.length1), 1, file);
fread(&header.nameLen, sizeof(header.nameLen), 1, file);
// Read the Name
fread(nameBuffer, sizeof(char), header.nameLen, file);
nameBuffer[header.nameLen] = '\0';
// Print Some Infos
printf("File %i\n\tName: %s\n\tLength: 0x%x\n", f, nameBuffer, header.length1);
// Read in the data
uint8_t *data = malloc(header.length1);
fread(data, header.length1, 1, file);
FILE *out = fopen(nameBuffer, "wb");
fwrite(data, header.length1, 1, out);
fclose(out);
free(data);
continue;
}
fclose(file);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment