-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathdump_projector.c
49 lines (46 loc) · 1.49 KB
/
dump_projector.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
int szFile;
char dataEnd[8];
uint32_t lpNumberOfBytesRW;
void *hfInput,
*hfOutput,
*hMemHeap;
if (argc != 3) {
printf("Usage: dump_projector infile outfile\r\n\
Example: `dump_projector application.exe application.swf`\r\n");
return 1;
}
hfInput = fopen(argv[1], "rb");
if (hfInput == NULL) {
printf("Cannot open input file for reading!\r\n");
} else {
fseek(hfInput, -8L, SEEK_END);
szFile = ftell(hfInput);
fread(dataEnd, 8, 1, hfInput);
if (*(uint32_t*)&dataEnd == 0xFA123456) { // Check the signature
hMemHeap = calloc(1, *(uint32_t*)&dataEnd[4]);
if (hMemHeap != NULL) {
fseek(hfInput, szFile-*(uint32_t*)&dataEnd[4], SEEK_SET);
lpNumberOfBytesRW = fread(hMemHeap, 1, *(uint32_t*)&dataEnd[4], hfInput);
hfOutput = fopen(argv[2], "wb");
if (hfOutput == NULL) {
printf("Cannot create output file for writing!\r\n");
} else {
fwrite(hMemHeap, 1, *(uint32_t*)&dataEnd[4], hfOutput);
fclose(hfOutput);
printf("Done, check your shiny new %s! =)\r\n", argv[2]);
}
free(hMemHeap);
} else {
printf("Can't fetch the process heap!\r\n");
}
} else {
printf("This doesn't seems to be a projector bundle.\r\n");
}
fclose(hfInput);
}
return 0;
}