annotate msvpvf.c @ 2:ce1e494aeb0e

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