Guest User

Untitled

a guest
Nov 24th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.27 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <inttypes.h>
  4.  
  5. struct fileheader
  6. {
  7.     char ident[7];
  8.     uint32_t offset1;
  9.     uint32_t files;
  10.     uint32_t unk;
  11. } __attribute__((packed));
  12.  
  13. int main(int argc, char **argv)
  14. {
  15.     FILE *fil = fopen(argv[1],"rb");
  16.  
  17.     fseek(fil,0,SEEK_END);
  18.  
  19.     uint32_t size = ftell(fil);
  20.  
  21.     fseek(fil,0,SEEK_SET);
  22.  
  23.     fileheader hed;
  24.  
  25.     fread(&hed,sizeof(fileheader),1,fil);
  26.  
  27.     int32_t tab_ptrs = size - hed.offset1;
  28.  
  29.     fseek(fil,tab_ptrs,SEEK_SET);
  30.  
  31.     int32_t ptrs_size;
  32.  
  33.     fread(&ptrs_size,4,1,fil);
  34.  
  35.     int32_t ptrs_count = (ptrs_size/4) - 1;
  36.  
  37.     int32_t *ptrstart = (int32_t *)malloc(ptrs_count * 4);
  38.     int32_t *ptrsize = (int32_t *)malloc(ptrs_count * 4);
  39.  
  40.     fread(ptrsize,ptrs_count*4,1,fil);
  41.  
  42.     int32_t ptr_ = ptrs_size;
  43.  
  44.     for (int j=0;j<ptrs_count;j++)
  45.     {
  46.         ptrstart[j] = ptr_;
  47.         ptr_ = ptrsize[j];
  48.         ptrsize[j] -= ptrstart[j];
  49.     }
  50.  
  51.     void *out=malloc(0x8000);
  52.  
  53.     for (int i=0; i<ptrs_count;i++)
  54.     {
  55.         fseek(fil,ptrstart[i],SEEK_SET);
  56.         void *filbuf = malloc(ptrsize[i]);
  57.         fread(filbuf,ptrsize[i],1,fil);
  58.  
  59.         //decode(filbuf,out); //decode block to 0x8000
  60.  
  61.         free(filbuf);
  62.     }
  63.  
  64.  
  65.     fclose(fil);
  66.     return 0;
  67. }
Add Comment
Please, Sign In to add comment