FreeCalypso > hg > freecalypso-reveng
changeset 221:9f2e0c34fe33
ftmdump (C1xx factory data reverse eng) tool written
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 17 Nov 2017 19:58:07 +0000 |
parents | 2cc7a17c3859 |
children | 63c5bb42eca5 |
files | .hgignore miscprog/Makefile miscprog/ftmdump.c |
diffstat | 3 files changed, 80 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgignore Thu Nov 16 04:19:58 2017 +0000 +++ b/.hgignore Fri Nov 17 19:58:07 2017 +0000 @@ -29,6 +29,7 @@ ^miscprog/atsc$ ^miscprog/calextract$ ^miscprog/factdiff$ +^miscprog/ftmdump$ ^miscprog/grokdsn$ ^miscprog/imeibrute$ ^miscprog/memwrite-grep$
--- a/miscprog/Makefile Thu Nov 16 04:19:58 2017 +0000 +++ b/miscprog/Makefile Fri Nov 17 19:58:07 2017 +0000 @@ -1,7 +1,7 @@ CC= gcc CFLAGS= -O2 -STD= atsc calextract factdiff grokdsn memwrite-grep mokosrec2bin pircalextr \ - pircksum pircksum2 rfcap-grep +STD= atsc calextract factdiff ftmdump grokdsn memwrite-grep mokosrec2bin \ + pircalextr pircksum pircksum2 rfcap-grep CRYPTO= imeibrute pirimei PROGS= ${STD} ${CRYPTO} @@ -16,6 +16,7 @@ atsc: atsc.c calextract: calextract.c factdiff: factdiff.c +ftmdump: ftmdump.c grokdsn: grokdsn.c imeibrute: imeibrute.c memwrite-grep: memwrite-grep.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/miscprog/ftmdump.c Fri Nov 17 19:58:07 2017 +0000 @@ -0,0 +1,76 @@ +/* + * This program parses the record structure in Compal's FTM sector (or at least + * that's what I *think* it is called) and dumps each record in hex for further + * human analysis. + */ + +#include <sys/types.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <strings.h> + +char *infname; +FILE *inf; +u_char header[8]; +u_char endmarker[8] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; +unsigned hdr_words[4]; + +main(argc, argv) + char **argv; +{ + if (argc < 2 || argc > 3) { + fprintf(stderr, "usage: %s binfile [offset]\n", argv[0]); + exit(1); + } + infname = argv[1]; + inf = fopen(infname, "r"); + if (!inf) { + perror(infname); + exit(1); + } + if (argc == 3) + fseek(inf, strtoul(argv[2], 0, 0), SEEK_SET); + for (;;) { + fread(header, 1, 8, inf); + if (!bcmp(header, endmarker, 8)) + break; + process_record(); + } + exit(0); +} + +process_record() +{ + u_char readbuf[16]; + int pos, chunk, i, c; + + for (i = 0; i < 4; i++) + hdr_words[i] = header[i*2] | (header[i*2+1] << 8); + printf("%04X %04X %04X %04X:\n\n", hdr_words[0], hdr_words[1], + hdr_words[2], hdr_words[3]); + for (pos = 0; pos < hdr_words[3]; pos += chunk) { + chunk = hdr_words[3] - pos; + if (chunk > 16) + chunk = 16; + fread(readbuf, 1, chunk, inf); + printf("%04X:", pos); + for (i = 0; i < 16; i++) { + if (i == 0 || i == 8) + putchar(' '); + if (i < chunk) + printf(" %02X", readbuf[i]); + else + fputs(" ", stdout); + } + fputs(" ", stdout); + for (i = 0; i < chunk; i++) { + c = readbuf[i]; + if (c < ' ' || c > '~') + c = '.'; + putchar(c); + } + putchar('\n'); + } + putchar('\n'); +}