diff options
Diffstat (limited to 'PE/extract-various.cpp')
-rw-r--r-- | PE/extract-various.cpp | 126 |
1 files changed, 126 insertions, 0 deletions
diff --git a/PE/extract-various.cpp b/PE/extract-various.cpp new file mode 100644 index 0000000..7bc01d7 --- /dev/null +++ b/PE/extract-various.cpp @@ -0,0 +1,126 @@ +#include <stdio.h> +#include "table.h" + +int pos[50]; + +int main(void) { + FILE * f = fopen("dump/0000.out", "r"); + FILE * s = fopen("various/various.txt", "w"); + unsigned int c, b, i, j, size, n, changed; + unsigned short p, t; + char fn[50]; + + for (c = 0; c < 6;) { + b = fgetc(f); + if (b <= MAXCHAR) { + fputc(table[b], s); + } else { + switch(b) { + case 0xfe: + b = fgetc(f); + fprintf(s, "<PT%i>\n", b); + break; + case 0xff: + fprintf(s, "\n<CLOSE>\n"); + c++; + break; + default: + fprintf(s, "<UNK %02X>", b); + } + } + } + + fclose(f); + fclose(s); + + + f = fopen("dump/0001.out", "r"); + + fread(&c, 4, 1, f); + + for (i = 0; i < c; i++) { + fread(&(pos[i]), 4, 1, f); + } + fseek(f, 0, SEEK_END); + pos[c] = ftell(f); + + for (i = 0; i < c; i++) { + fseek(f, pos[i], SEEK_SET); + size = pos[i + 1] - pos[i]; + sprintf(fn, "various/0001/%02i.out", i); + s = fopen(fn, "w"); + for (j = 0; j < size; j++) { + b = fgetc(f); + fputc(b, s); + } + fclose(s); + } + + fclose(f); + + + f = fopen("various/0001/00.out", "r"); + + fread(&c, 4, 1, f); + + for (i = 0; i < c; i++) { + fread(&(pos[i]), 4, 1, f); + } + fseek(f, 0, SEEK_END); + pos[c] = ftell(f); + + for (i = 0; i < c; i++) { + fseek(f, pos[i], SEEK_SET); + size = pos[i + 1] - pos[i]; + sprintf(fn, "various/0001/00/%01i.out", i); + s = fopen(fn, "w"); + for (j = 0; j < size; j++) { + b = fgetc(f); + fputc(b, s); + } + fclose(s); + } + + fclose(f); + + for (i = 0; i < 4; i++) { + sprintf(fn, "various/0001/00/%i.out", i); + f = fopen(fn, "r"); + sprintf(fn, "various/menus%i.txt", i); + s = fopen(fn, "w"); + + fread(&p, 2, 1, f); + fseek(f, p * 2, SEEK_CUR); + + changed = 1; + + for (c = 0; c < p;) { + if (changed) { + fseek(f, c * 2 + 2, SEEK_SET); + fread(&t, 2, 1, f); + fseek(f, t, SEEK_SET); + } + if (!(b = fgetc(f)) && changed) + break; + + changed = 0; + + if (b <= MAXCHAR) { + fputc(table[b], s); + } else { + switch(b) { + case 0xff: + fprintf(s, "\n<CLOSE>\n"); + c++; + changed = 1; + break; + default: + fprintf(s, "<UNK %02X>", b); + } + } + } + + fclose(f); + fclose(s); + } +} |