comparison system/file.cc @ 30:3fe3e5f184b5

* Added CLANNAD Full Voice's key
author thib
date Fri, 06 Mar 2009 21:25:42 +0000
parents 3a6aaeab7b4e
children 2c574c3d50a9
comparison
equal deleted inserted replaced
29:d229cce98f50 30:3fe3e5f184b5
597 searcher[ALL] = dat_dir; 597 searcher[ALL] = dat_dir;
598 searcher[ROOT] = root_dir; 598 searcher[ROOT] = root_dir;
599 return 0; 599 return 0;
600 } 600 }
601 601
602 void FILESEARCH::SetXorKey(char *key)
603 {
604 unsigned short int i;
605 for (i=0; i < 16; i++)
606 xor_key[i] = key[i];
607 }
608
609 void FILESEARCH::GuessXorKey(char *regname)
610 {
611 char key1[16] = {
612 0xa8, 0x28, 0xfd, 0x66,
613 0xa0, 0x23, 0x77, 0x69,
614 0xf9, 0x45, 0xf8, 0x2c,
615 0x7c, 0x00, 0xad, 0xf4
616 };
617
618 char key2[16] = {
619 0xAF, 0x2F, 0xFB, 0x6B,
620 0xAF, 0x30, 0x77, 0x17,
621 0x87, 0x48, 0xFE, 0x2C,
622 0x68, 0x1A, 0xB9, 0xF0
623 };
624
625
626 if (strcmp(regname, "KEY\\CLANNAD_FV") == 0) {
627 SetXorKey(key2);
628 }
629 else {
630 SetXorKey(key1);
631 }
632 }
633
634 const char * FILESEARCH::GetXorKey(void)
635 {
636 return xor_key;
637 }
638
602 void FILESEARCH::SetFileInformation(FILETYPE tp, ARCTYPE is_arc, char* filename) { 639 void FILESEARCH::SetFileInformation(FILETYPE tp, ARCTYPE is_arc, char* filename) {
603 int type = tp; 640 int type = tp;
604 if (type < 0 || type >= TYPEMAX) return; 641 if (type < 0 || type >= TYPEMAX) return;
605 ARCFILE* next_arc = 0; 642 ARCFILE* next_arc = 0;
606 /* すでに searcher が存在すれば解放 */ 643 /* すでに searcher が存在すれば解放 */
1384 ,0xc4 ,0x04 ,0x5f ,0x5e ,0x5b ,0x8b ,0xe5 ,0x5d ,0xc3 ,0x8b ,0x55 ,0xf8 ,0x8d ,0x4d ,0xf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, 0x2c,
1393 0x7c, 0x00, 0xad, 0xf4
1394 };
1395 1427
1396 bool ARCINFO2k::ExecExtract(void) { 1428 bool ARCINFO2k::ExecExtract(void) {
1397 int i; 1429 int i;
1398 char* ret_data = new char[info.filesize + 1024]; 1430 char* ret_data = new char[info.filesize + 1024];
1399 char* decoded_data = new char[info.arcsize + 1024]; 1431 char* decoded_data = new char[info.arcsize + 1024];
1422 d = ret_data + info.private_data; 1454 d = ret_data + info.private_data;
1423 dend = ret_data + info.filesize; 1455 dend = ret_data + info.filesize;
1424 while(lzExtract(Extract_DataType_SCN2k(), char(), s, d, send, dend)) ; 1456 while(lzExtract(Extract_DataType_SCN2k(), char(), s, d, send, dend)) ;
1425 } 1457 }
1426 if (read_little_endian_int(data+4) == 0x1adb2) { // Little Busters! 1458 if (read_little_endian_int(data+4) == 0x1adb2) { // Little Busters!
1459 const char *decode_key = file_searcher.GetXorKey();
1427 int header_size = info.private_data; 1460 int header_size = info.private_data;
1428 for (i=0x100; i<=0x200 && header_size+i < info.filesize; i++) { 1461 for (i=0x100; i<=0x200 && header_size+i < info.filesize; i++) {
1429 ret_data[header_size+i] ^= decode_seed2[i&0x0f]; 1462 ret_data[header_size+i] ^= decode_key[i&0x0f];
1430 } 1463 }
1431 } 1464 }
1432 delete[] decoded_data; 1465 delete[] decoded_data;
1433 if (! use_mmap) delete[] data; 1466 if (! use_mmap) delete[] data;
1434 data = ret_data; 1467 data = ret_data;