Advertisement
Reisyukaku

importDesc.c

Sep 1st, 2016
438
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.76 KB | None | 0 0
  1. /*
  2. *   importDesc.c
  3. *       by Reisyukaku
  4. */
  5.  
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8.  
  9. int main(int argc, char** argv){
  10.     if(argc != 4){
  11.         printf("usage: %s [txt file] [descriptor file] [num]\n", argv[0]);
  12.         return -1;
  13.     }
  14.     FILE* txt = fopen(argv[1], "r");
  15.     FILE* desc = fopen(argv[2], "rb+");
  16.     if(!txt || !desc){
  17.         printf("Error opening file.\n");
  18.         return -1;
  19.     }
  20.     fseek(txt, 0, SEEK_END);
  21.     int size = ftell(txt);
  22.     unsigned char* text = calloc(size + 1, sizeof(unsigned char));
  23.     fseek(txt, 0, SEEK_SET);
  24.     fread(text, 1, size, txt);
  25.     fseek(desc, 0x8 + (strtol(argv[3], NULL, 10) * 0xC8), SEEK_SET);
  26.     fwrite(text, 1, size, desc);
  27.    
  28.     fclose(txt);
  29.     fclose(desc);
  30.    
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement