diff options
Diffstat (limited to 'VP/main_dump.cpp')
-rw-r--r-- | VP/main_dump.cpp | 53 |
1 files changed, 32 insertions, 21 deletions
diff --git a/VP/main_dump.cpp b/VP/main_dump.cpp index cf6197d..47c90ac 100644 --- a/VP/main_dump.cpp +++ b/VP/main_dump.cpp @@ -35,7 +35,7 @@ unsigned int tourne = 0; struct t_index_tab { unsigned long address; - long size; + unsigned char flags; long type; long index; }; @@ -64,7 +64,7 @@ int main(int argc, char **argv) { FILE * f_def, * f_iso; - verbosity = 3; + verbosity = M_STATUS; fprintf(stderr, "Valkyrie Profile File Extractor by Nicolas \"Pixel\" Noble\n" @@ -184,52 +184,63 @@ long check_iso(FILE * f_iso) void read_files(FILE * f_iso) { t_index_tab index_tab[10000]; - unsigned char t[8]; unsigned long i; unsigned long j; unsigned int seq = 0; unsigned long indexer; - struct t_index_tab *p = (struct t_index_tab *) t; - unsigned char fat[32768]; + unsigned char fat[20480]; + unsigned char key[256]; -#define INDEXPOS 24 +#define INDEXPOS 150 sector_seek(f_iso, INDEXPOS); - for (i = INDEXPOS; i < (INDEXPOS + 16); i++) { + for (i = INDEXPOS; i < (INDEXPOS + 10); i++) { printm(M_INFO, "Reading fat sector %lu\n", i); read_sector(f_iso, &fat[2048 * (i - INDEXPOS)], MODE_2_FORM_1); } + memcpy(key, fat + 0x4f00, 256); + + printm(M_INFO, "Decrypting.\n"); + for (i = 0; i < 20480; i++) { + fat[i] ^= key[i % 256]; + } + indexer = 0; - for (j = 0; j < 32768; j = j + 7) { - t[0] = 0; - bcopy((char *) &fat[j], (char *) t + 1, 7); - p->address >>= 8; - index_tab[indexer] = *p; - if (p->size > 0 && p->address != 0) { - index_tab[indexer].index = j / 7; - printm(M_INFO, "Found a quite valid index: number %4lu, address %6lu, size %3li\n", - indexer, index_tab[indexer].address, index_tab[indexer].size); + for (j = 4; j < 20480; j += 4) { + unsigned char m, s, f; + m = fat[j]; + s = fat[j + 1]; + f = fat[j + 2]; + index_tab[indexer].address = from_MSF(m, s, f); + if (m || s || f) { + index_tab[indexer].index = j / 4; + index_tab[indexer].flags = fat[j + 3]; + printm(M_INFO, "Found a quite valid index: number %4lu, address %6lu - flags = %02x\n", + indexer, index_tab[indexer].address, fat[j + 3]); indexer++; if (indexer == nb_records) break; } else { - printm(M_WARNING, "Ignored invalid index chunk number %4lu (size = %lu) (%02x %02x %02x %02x %02x %02x %02x)\n", - j / 7, -index_tab[indexer].size, t[0], t[1], t[2], t[4], t[5], t[6], t[7]); + printm(M_WARNING, "Ignored invalid index chunk number %4lu\n", j / 4); } } printm(M_STATUS, "Index file generation complete.\n\n"); + index_tab[indexer].address = filesize(f_iso) / 2352; for (i = 0; i < nb_records; i++) { if (sequences[seq].sum == i) seq++; index_tab[i].type = sequences[seq].type; if (sequences[seq].type == 0) { - printm(M_INFO, "%6lu (%10lu): ignored\n", index_tab[i].address, index_tab[i].size); + printm(M_INFO, "%6lu - %02x: ignored\n", index_tab[i].address, index_tab[i].flags); } else { - printm(M_INFO, "%6lu (%10lu): ", index_tab[i].address, index_tab[i].size); - file_dump(f_iso, index_tab[i].address, index_tab[i].size, i, seq); + int size; + printm(M_INFO, "%6lu - %02x: ", index_tab[i].address, index_tab[i].flags); + size = index_tab[i + 1].address - index_tab[i].address; + size *= sec_sizes[index_tab[i].type]; + file_dump(f_iso, index_tab[i].address, size, i, seq); if (verbosity >= M_INFO) { fprintf(stderr, "\n"); } |