Mercurial > msvpvf
comparison msvpvf.c @ 1:528b95e1e24f
Add source and makefile
| author | Paper <mrpapersonic@gmail.com> |
|---|---|
| date | Sun, 09 Jan 2022 00:05:36 -0500 |
| parents | |
| children | 87c7d43b03ff |
comparison
equal
deleted
inserted
replaced
| 0:f6fa92414909 | 1:528b95e1e24f |
|---|---|
| 1 /* Movie Studio / Vegas Pro version spoofer | |
| 2 * by Paper | |
| 3 * | |
| 4 * You should have received a copy of the MIT License along with this program. | |
| 5 * If not, you can access it at https://opensource.org/licenses/MIT. | |
| 6 */ | |
| 7 | |
| 8 #include <stdio.h> | |
| 9 #include <unistd.h> | |
| 10 #include <getopt.h> | |
| 11 #include <inttypes.h> | |
| 12 #include <string.h> | |
| 13 #include <stdlib.h> | |
| 14 #if __STDC_VERSION__ >= 199901L | |
| 15 #include <stdbool.h> | |
| 16 #else | |
| 17 typedef enum { false, true } bool; /* less than C99 */ | |
| 18 #endif | |
| 19 #ifdef _MSC_VER | |
| 20 #define strdup(p) _strdup(p) | |
| 21 #endif | |
| 22 | |
| 23 static struct option options_long[] = { | |
| 24 {"input", required_argument, NULL, 'i'}, | |
| 25 {"output", required_argument, NULL, 'o'}, | |
| 26 {"version", required_argument, NULL, 'v'}, | |
| 27 {"type", required_argument, NULL, 't'}, | |
| 28 {"help", 0, NULL, 'h'} | |
| 29 }; | |
| 30 | |
| 31 void set_data(unsigned char magic[], uint16_t version, FILE* target) { | |
| 32 int i; | |
| 33 fseek(target, 0x46, SEEK_SET); | |
| 34 fputc(version, target); | |
| 35 for (i=0; i<=sizeof(*magic); ++i) { | |
| 36 fseek(target, 0x18+i, SEEK_SET); | |
| 37 fputc(magic[i], target); | |
| 38 } | |
| 39 } | |
| 40 | |
| 41 int copy_file(const char* source_file, const char* target_file) { | |
| 42 FILE *source, *target; | |
| 43 | |
| 44 source = fopen(source_file, "rb"); | |
| 45 if (source == NULL) { | |
| 46 return 1; | |
| 47 } | |
| 48 target = fopen(target_file, "wb"); | |
| 49 if (target == NULL) { | |
| 50 return 1; | |
| 51 } | |
| 52 | |
| 53 size_t n, m; | |
| 54 unsigned char buff[8192]; | |
| 55 do { | |
| 56 n = fread(buff, 1, sizeof(buff), source); | |
| 57 if (n) m = fwrite(buff, 1, n, target); | |
| 58 else m = 0; | |
| 59 } while ((n > 0) && (n == m)); | |
| 60 | |
| 61 fclose(target); | |
| 62 fclose(source); | |
| 63 return 0; | |
| 64 } | |
| 65 | |
| 66 int main(int argc, char *argv[]) { | |
| 67 int c, temp, option_index = 0; | |
| 68 char buf[127]; | |
| 69 struct arguments { | |
| 70 const char* input; | |
| 71 const char* output; | |
| 72 uint16_t version; | |
| 73 const char* type; | |
| 74 } args; | |
| 75 args.input = " "; | |
| 76 args.output = " "; | |
| 77 args.version = -1; | |
| 78 args.type = " "; | |
| 79 | |
| 80 while ((c = getopt_long(argc, argv, "i:o:v:t:h", options_long, &option_index)) != -1) | |
| 81 switch(c) { | |
| 82 case 'i': | |
| 83 args.input = strdup(optarg); | |
| 84 break; | |
| 85 case 'o': | |
| 86 args.output = strdup(optarg); | |
| 87 break; | |
| 88 case 'v': | |
| 89 args.version = abs(atoi(strdup(optarg))); /* abs() for possible negative inputs */ | |
| 90 break; | |
| 91 case 't': | |
| 92 args.type = strdup(optarg); | |
| 93 break; | |
| 94 case 'h': | |
| 95 default: | |
| 96 fprintf(stderr, "msvpvf by Paper\nusage: %s -i infile [-o outfile] -v version -t [vf, veg]", argv[0]); | |
| 97 return 1; | |
| 98 } | |
| 99 copy_file(args.input, args.output); | |
| 100 FILE* outfile = fopen(args.output, "r+b"); | |
| 101 if (strcmp(args.type, "veg") == 0) { | |
| 102 unsigned char T[] = {0xEF, 0x29, 0xC4, 0x46, 0x4A, 0x90, 0xD2, 0x11, 0x87, 0x22, 0x00, 0xC0, 0x4F, 0x8E, 0xDB, 0x8A}; | |
| 103 set_data(T, args.version, outfile); | |
| 104 } else if (strcmp(args.type, "vf") == 0) { | |
| 105 unsigned char T[] = {0xF6, 0x1B, 0x3C, 0x53, 0x35, 0xD6, 0xF3, 0x43, 0x8A, 0x90, 0x64, 0xB8, 0x87, 0x23, 0x1F, 0x7F}; | |
| 106 set_data(T, args.version, outfile); | |
| 107 } else { | |
| 108 fprintf(stderr, "Type %s is invalid!", args.type); | |
| 109 goto exit; | |
| 110 } | |
| 111 exit: | |
| 112 if (&outfile) fclose(outfile); | |
| 113 if (&args) { | |
| 114 free((char*)args.input); | |
| 115 free((char*)args.output); | |
| 116 free((char*)args.type); | |
| 117 } | |
| 118 return 0; | |
| 119 } |
