Advertisement
Guest User

Untitled

a guest
Nov 7th, 2013
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.70 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <stdint.h>
  4.  
  5. void main(int argc, char** argv)
  6. {
  7.     if (argc != 2)
  8.     {
  9.         printf("No input file specified\n");
  10.         return;
  11.     }
  12.  
  13.     FILE* ccFile = fopen(argv[1], "r+b");
  14.     if (ccFile == NULL)
  15.     {
  16.         printf("Unable to open file\n");
  17.         return;
  18.     }
  19.  
  20.     if (fseek(ccFile, 0x7a, SEEK_SET) != 0)
  21.     {
  22.         fclose(ccFile);
  23.         printf("Unable to seek to position\n");
  24.         return;
  25.     }
  26.  
  27.     uint8_t b1 = fgetc(ccFile);
  28.     uint8_t b2 = fgetc(ccFile);
  29.  
  30.     if (b1 != 0x00 || b2 != 0x27)
  31.     {
  32.         fclose(ccFile);
  33.         printf("Unexpected data\n");
  34.         return;
  35.     }
  36.  
  37.     fseek(ccFile, 0x7a, SEEK_SET);
  38.     fputc(0x80, ccFile);
  39.     fputc(0x13, ccFile);
  40.  
  41.     fclose(ccFile);
  42.  
  43.     printf("Done!\n");
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement