Advertisement
Guest User

decode vvvvvvmusic.vvv

a guest
Jul 26th, 2011
1,074
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.98 KB | None | 0 0
  1. #include "stdio.h"
  2. #include "string.h"
  3. #include "stdlib.h"
  4.  
  5. typedef struct music_t {
  6.     char* name;
  7.     unsigned int length;
  8. } music_t;
  9.  
  10. int main(int argc, char** argv){
  11.     if(argc < 2) return 1;
  12.    
  13.     music_t files[20];
  14.     int x, c, length;
  15.     FILE* f = fopen(argv[1], "rb");
  16.     char namebuff[256], *nameptr = namebuff;
  17.     memset(namebuff, 0, 256);
  18.    
  19.     for(x = 0; x < 15; x++){
  20.         while((c = fgetc(f)) != '\0'){
  21.             *nameptr++ = (char)c;
  22.         }
  23.    
  24.         fseek(f, 51 - (nameptr - namebuff), SEEK_CUR);
  25.         fread(&length, 4, 1, f);
  26.         fseek(f, 4, SEEK_CUR);
  27.        
  28.         files[x].name = strdup(namebuff);
  29.         files[x].length = length;
  30.         nameptr = namebuff;
  31.         memset(namebuff, 0, 256);
  32.     }
  33.     fseek(f, 0x1E00, SEEK_SET);
  34.     for(x = 0; x < 15; x++){
  35.         char* musicdata = malloc(files[x].length);
  36.         fread(musicdata, files[x].length, 1, f);
  37.         FILE* out = fopen(files[x].name+11, "wb");
  38.         fwrite(musicdata, files[x].length, 1, out);
  39.         fflush(out);
  40.         fclose(out);
  41.         free(musicdata);
  42.     }
  43.     fclose(f);
  44.     return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement