User:Remark/dec-flipbook.c: Difference between revisions

Remark (talk | contribs)
New page: <source lang="c"> // dec_flipbook // written by remark // thanks to steven & ludo #include <stdio.h> #include <stdlib.h> // misses last 5 bytes atm char key [0x40] = { 0xF7, 0x4C, 0x6A, ...
 
No edit summary
 
(3 intermediate revisions by 2 users not shown)
Line 7: Line 7:
#include <stdlib.h>
#include <stdlib.h>


// misses last 5 bytes atm
char key [0x40] = {
char key [0x40] = {
0xF7, 0x4C, 0x6A, 0x3A, 0xFB, 0x82, 0xA6, 0x37, 0x6E, 0x11, 0x38, 0xCF, 0xA0, 0xDD, 0x85, 0xC0,
0xF7, 0x4C, 0x6A, 0x3A, 0xFB, 0x82, 0xA6, 0x37, 0x6E, 0x11, 0x38, 0xCF, 0xA0, 0xDD, 0x85, 0xC0,
0xC7, 0x9B, 0xC4, 0xD8, 0xDD, 0x28, 0x8A, 0x87, 0x53, 0x20, 0xEE, 0xE0, 0x0B, 0xEB, 0x43, 0xA0,
0xC7, 0x9B, 0xC4, 0xD8, 0xDD, 0x28, 0x8A, 0x87, 0x53, 0x20, 0xEE, 0xE0, 0x0B, 0xEB, 0x43, 0xA0,
0xDB, 0x55, 0x0F, 0x75, 0x36, 0x37, 0xEB, 0x35, 0x6A, 0x34, 0x7F, 0xB5, 0x0F, 0x99, 0xF7, 0xEF,
0xDB, 0x55, 0x0F, 0x75, 0x36, 0x37, 0xEB, 0x35, 0x6A, 0x34, 0x7F, 0xB5, 0x0F, 0x99, 0xF7, 0xEF,
0x43, 0x25, 0xCE, 0xA0, 0x29, 0x46, 0xD9, 0xD4, 0x4D, 0xBB, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00
0x43, 0x25, 0xCE, 0xA0, 0x29, 0x46, 0xD9, 0xD4, 0x4D, 0xBB, 0x04, 0x66, 0x68, 0x08, 0xF1, 0xF8
};
};


Line 37: Line 36:
    
    
   FILE* f = fopen(argv[1], "rb");
   FILE* f = fopen(argv[1], "rb");
   if(f == NULL)
   if(!f)
   PERR("fopen");
   PERR("fopen");
  
  
   int len = fsize(f);
   int len = fsize(f);
   char* buf = malloc(len);
   //char* buf = malloc(len);
   if(buf == NULL)
  char* buf = (char*) malloc(len);
   if(!buf)
  {
  fclose(f);
   PERR("malloc");
   PERR("malloc");
  }
    
    
   if(fread(buf,len,1,f) != 1)
   if(fread(buf,len,1,f) != 1)
  {
  fclose(f);
  free(buf);
   PERR("fread");
   PERR("fread");
  }
    
    
   int i;
   int i;
Line 55: Line 62:
    
    
   FILE* fout = fopen(argv[2], "wb+");
   FILE* fout = fopen(argv[2], "wb+");
   if(fout == NULL)  
   if(!fout)  
  {
  fclose(f);
  free(buf);
   PERR("fopen");
   PERR("fopen");
  }
  
  
   if(fwrite(buf, len, 1, fout) != 1)
   if(fwrite(buf, len, 1, fout) != 1)
  {
  fclose(f);
  free(buf);
  fclose(fout);
   PERR("fwrite");
   PERR("fwrite");
    
   }
    
    
   free(buf);
   free(buf);