Advertisement
secXsQuared

MHS Existing Items 999x

Oct 13th, 2016
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.11 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <unistd.h>
  3. #include <stdint.h>
  4. #include <string.h>
  5.  
  6. #define BUFFER_SIZE (1024*1024)
  7. char buffer[BUFFER_SIZE];
  8.  
  9. int main(int argc, char* argv[])
  10. {
  11.     if(argc == 2)
  12.     {
  13.         FILE* file;
  14.         file = fopen(argv[1], "r");
  15.         size_t actual_size = fread(buffer, sizeof(char), BUFFER_SIZE, file);
  16.         printf("Read file size: %u\n", actual_size);
  17.         fclose(file);
  18.         for(int i = 0x10; i < 0x2ee8; i+=8)
  19.         {
  20.             uint16_t* idptr = (uint16_t*)(&buffer[i]);
  21.             if(*idptr != 0)
  22.             {
  23.                 // if there is an item ID
  24.                 // set it to max
  25.         if(*idptr == 1227)
  26.             break;
  27.                 printf("Setting %d from %d to 999.\n", *idptr, *(idptr+1));
  28.                 *(idptr+1) = 999;
  29.             }
  30.  
  31.         }
  32.         file = fopen(strcat(argv[1], "hacked"), "w");
  33.         actual_size = fwrite(buffer, sizeof(char), actual_size, file);
  34.         fclose(file);
  35.         printf("Written file size: %u\n", actual_size);
  36.     }
  37.     else
  38.     {
  39.         fprintf(stderr, "Invalid arguments!\n");
  40.     }
  41.     return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement