annotate src/main.c @ 7:bd392e82001c

Update README.md
author Paper <37962225+mrpapersonic@users.noreply.github.com>
date Wed, 26 Jan 2022 21:57:01 -0500
parents d1e5b8390cd3
children 9d862edfd3cc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
1 /* Movie Studio / Vegas Pro version spoofer
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
2 * by Paper
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
3 */
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
4
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
5 #include <inttypes.h>
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
6 #include <stdbool.h>
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
7 #include <stdio.h>
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
8 #include <stdlib.h>
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
9 #include <string.h>
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
10 #include "../include/common.h"
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
11 #ifdef _MSC_VER
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
12 #define strdup(p) _strdup(p)
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
13 #endif
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
14
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
15 static struct option options_long[] = {
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
16 {"input", required_argument, NULL, 'i'},
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
17 {"output", required_argument, NULL, 'o'},
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
18 {"version", required_argument, NULL, 'v'},
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
19 {"type", required_argument, NULL, 't'},
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
20 {"help", 0, NULL, 'h'}
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
21 };
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
22
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
23 char* strremove(char* str, const char* sub) {
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
24 size_t len = strlen(sub);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
25 if (len > 0) {
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
26 char *p = str;
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
27 while ((p = strstr(p, sub)) != NULL) {
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
28 memmove(p, p + len, strlen(p + len) + 1);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
29 }
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
30 }
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
31 return str;
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
32 }
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
33
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
34 void set_data(unsigned char magic[], uint16_t version, FILE* target) {
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
35 int i;
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
36 fseek(target, 0x46, SEEK_SET);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
37 fputc(version, target);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
38 for (i=0; i<=sizeof(*magic); ++i) {
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
39 fseek(target, 0x18+i, SEEK_SET);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
40 fputc(magic[i], target);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
41 }
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
42 }
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
43
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
44 int copy_file(char* source_file, char* target_file) {
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
45 FILE *source, *target;
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
46
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
47 source = fopen(source_file, "rb");
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
48
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
49 if (source == NULL) return 1;
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
50
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
51 target = fopen(target_file, "wb");
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
52
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
53 if (target == NULL) {
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
54 fclose(source);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
55 return 1;
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
56 }
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
57
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
58 size_t n, m;
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
59 unsigned char buff[8192];
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
60 do {
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
61 n = fread(buff, 1, sizeof(buff), source);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
62 if (n) m = fwrite(buff, 1, n, target);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
63 else m = 0;
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
64 } while ((n > 0) && (n == m));
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
65
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
66 fclose(target);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
67 fclose(source);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
68 return 0;
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
69 }
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
70
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
71 int main(int argc, char *argv[]) {
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
72 int c, option_index = 0;
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
73 unsigned char magic[16];
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
74 FILE* outfile;
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
75 struct arguments {
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
76 char input[128];
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
77 char output[128];
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
78 int version;
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
79 char type[128];
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
80 } args;
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
81 strcpy(args.input, " ");
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
82 strcpy(args.output, " ");
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
83 args.version = -1;
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
84 strcpy(args.type, " ");
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
85
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
86 while ((c = getopt_long(argc, argv, "i:o:v:t:h", options_long, &option_index)) != -1)
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
87 switch(c) {
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
88 case 'i':
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
89 strncpy(args.input, optarg, sizeof(args.input)-1); /* subtract 1 to make sure it's "null-safe" */
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
90 break;
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
91 case 'o':
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
92 strncpy(args.output, optarg, sizeof(args.input)-1);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
93 break;
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
94 case 'v':
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
95 args.version = abs(atoi(strcpy(optarg))); /* abs() for possible negative inputs */
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
96 break;
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
97 case 't':
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
98 strncpy(args.type, optarg, sizeof(args.input)-1);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
99 break;
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
100 case 'h':
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
101 default:
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
102 printf("msvpvf by Paper\nusage: %s (-i/--input) infile [(-o/--output) outfile] (-v/--version) version (-t/--type) [vf, veg]\n", argv[0]);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
103 return 0;
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
104 }
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
105 if (argc == 1) {
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
106 printf("msvpvf by Paper\nusage: %s (-i/--input) infile [(-o/--output) outfile] (-v/--version) version (-t/--type) [vf, veg]\n", argv[0]);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
107 return 0;
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
108 }
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
109 if (strcmp(args.input, " ") == 0) {
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
110 printf("Input file name?\n");
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
111 fflush(stdout);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
112 fgets(args.input, sizeof(args.input)-1, stdin);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
113 args.input[strcspn(args.input, "\r\n")] = 0;
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
114 }
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
115 if (access(args.input, F_OK) != 0) {
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
116 fprintf(stderr, "Input file \"%s\" doesn't exist! Exiting.", args.input);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
117 return 1;
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
118 }
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
119 FILE* input_file = fopen(args.input, "r");
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
120 if (fgetc() == EOF) {
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
121 fprintf(stderr, "Input file \"%s\" is empty.", args.input);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
122 fclose(input_file);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
123 return 1;
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
124 }
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
125 fseek(input_file, 0x46, SEEK_SET);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
126 printf("Input file version: %d\n", fgetc(input_file));
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
127 fseek(input_file, 0x18, SEEK_SET);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
128 int file_version = fgetc(input_file);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
129 printf("Input file type: ");
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
130 if (file_version == 0xEF) {
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
131 printf("VEGAS Pro\n\n");
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
132 } else if (file_version == 0xF6) {
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
133 printf("Movie Studio\n\n");
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
134 } else {
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
135 printf("Unknown\n\n");
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
136 }
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
137 int* ptr = &args.version;
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
138 if (args.version == -1) {
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
139 printf("What version of VEGAS would you like to spoof to?: ");
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
140 fflush(stdout);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
141 scanf("%d", ptr);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
142 }
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
143 if (strcmp(args.type, " ") == 0) {
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
144 printf("Would you like it to be VEGAS Pro or Movie Studio? [veg/vf]: ");
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
145 fflush(stdout);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
146 scanf("%3s", args.type);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
147 }
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
148 fflush(stdout);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
149 if (strcmp(args.output, " ") == 0) { /* string manipulation hell */
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
150 char temp[128] = {'V'};
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
151 char str_version[16] = {};
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
152 sprintf(str_version, "%d", args.version);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
153 strncat(temp, str_version, 2);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
154 strncat(temp, "_", 1);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
155 strncat(temp, args.input, 120);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
156 strcpy(temp, strremove(temp, strrchr(args.input, ('.')))); /* remove file extension */
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
157 strncat(temp, ".", 1);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
158 strncat(temp, args.type, 3);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
159 strncpy(args.output, temp, 127);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
160 }
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
161 if (strcmp(args.type, "veg") == 0) {
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
162 const unsigned char T[] = {0xEF, 0x29, 0xC4, 0x46, 0x4A, 0x90, 0xD2, 0x11, 0x87, 0x22, 0x00, 0xC0, 0x4F, 0x8E, 0xDB, 0x8A};
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
163 for (option_index = 0; option_index <= 15; option_index++) {
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
164 magic[option_index] = T[option_index];
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
165 }
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
166 } else if (strcmp(args.type, "vf") == 0) {
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
167 const unsigned char T[] = {0xF6, 0x1B, 0x3C, 0x53, 0x35, 0xD6, 0xF3, 0x43, 0x8A, 0x90, 0x64, 0xB8, 0x87, 0x23, 0x1F, 0x7F};
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
168 for (option_index = 0; option_index <= 15; option_index++) {
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
169 magic[option_index] = T[option_index];
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
170 }
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
171 } else {
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
172 fprintf(stderr, "Type %s is invalid!", args.type);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
173 return 1;
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
174 }
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
175 copy_file(args.input, args.output);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
176 #ifdef _WIN32
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
177 if (strcspn(args.input, "<>:\"/\\|?*") == strlen(args.input)+1) {
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
178 #elif defined(__unix__)
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
179 if (strcspn(args.input, "/") == strlen(args.input)+1) {
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
180 #else
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
181 if (NULL) {
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
182 #endif
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
183 fprintf(stderr, "Invalid output filename detected! Exiting...");
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
184 return 1;
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
185 }
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
186 outfile = fopen(args.output, "r+b");
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
187 if (outfile == NULL) {
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
188 fprintf(stderr, "Failed to open file %s! Do you have write permissions?", args.output);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
189 return 1;
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
190 }
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
191 set_data(magic, args.version, outfile);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
192 fclose(outfile);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
193 return 0;
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
194 }