# HG changeset patch # User thib # Date 1236374742 0 # Node ID 3fe3e5f184b52837a174ba27facce36c61a05198 # Parent d229cce98f5072294ef1b3a841cc8d82c18c891b * Added CLANNAD Full Voice's key diff --git a/system/file.cc b/system/file.cc --- a/system/file.cc +++ b/system/file.cc @@ -599,6 +599,43 @@ int FILESEARCH::InitRoot(char* root) { return 0; } +void FILESEARCH::SetXorKey(char *key) +{ + unsigned short int i; + for (i=0; i < 16; i++) + xor_key[i] = key[i]; +} + +void FILESEARCH::GuessXorKey(char *regname) +{ + char key1[16] = { + 0xa8, 0x28, 0xfd, 0x66, + 0xa0, 0x23, 0x77, 0x69, + 0xf9, 0x45, 0xf8, 0x2c, + 0x7c, 0x00, 0xad, 0xf4 + }; + + char key2[16] = { + 0xAF, 0x2F, 0xFB, 0x6B, + 0xAF, 0x30, 0x77, 0x17, + 0x87, 0x48, 0xFE, 0x2C, + 0x68, 0x1A, 0xB9, 0xF0 + }; + + + if (strcmp(regname, "KEY\\CLANNAD_FV") == 0) { + SetXorKey(key2); + } + else { + SetXorKey(key1); + } +} + +const char * FILESEARCH::GetXorKey(void) +{ + return xor_key; +} + void FILESEARCH::SetFileInformation(FILETYPE tp, ARCTYPE is_arc, char* filename) { int type = tp; if (type < 0 || type >= TYPEMAX) return; @@ -1386,12 +1423,7 @@ char ARCINFO2k::decode_seed[256] ={ ,0x20 ,0x50 ,0x6a ,0x00 ,0xe8 ,0x47 ,0x28 ,0x01 ,0x00 ,0x8b ,0x7d ,0xe8 ,0x89 ,0x45 ,0xf4 ,0x8b ,0xf0 ,0xa1 ,0xe0 ,0x30 ,0x44 ,0x00 ,0x83 ,0xc4 ,0x08 ,0x85 ,0xc0 ,0x75 ,0x56 ,0x8b ,0x1d ,0xd0 ,0xb0 ,0x43 ,0x00 ,0x85 ,0xff ,0x76 ,0x49 ,0x81 ,0xff ,0x00 ,0x00 ,0x04 ,0x00 ,0x6a ,0x00 ,0x76}; -char ARCINFO2k::decode_seed2[16] = { - 0xa8, 0x28, 0xfd, 0x66, - 0xa0, 0x23, 0x77, 0x69, - 0xf9, 0x45, 0xf8, 0x2c, - 0x7c, 0x00, 0xad, 0xf4 -}; + bool ARCINFO2k::ExecExtract(void) { int i; @@ -1424,9 +1456,10 @@ bool ARCINFO2k::ExecExtract(void) { while(lzExtract(Extract_DataType_SCN2k(), char(), s, d, send, dend)) ; } if (read_little_endian_int(data+4) == 0x1adb2) { // Little Busters! + const char *decode_key = file_searcher.GetXorKey(); int header_size = info.private_data; for (i=0x100; i<=0x200 && header_size+i < info.filesize; i++) { - ret_data[header_size+i] ^= decode_seed2[i&0x0f]; + ret_data[header_size+i] ^= decode_key[i&0x0f]; } } delete[] decoded_data; diff --git a/system/file.h b/system/file.h --- a/system/file.h +++ b/system/file.h @@ -136,6 +136,7 @@ private: /* デフォルトの information */ static ARCTYPE default_is_archived[TYPEMAX]; static char* default_dirnames[TYPEMAX]; + char xor_key[16]; public: FILESEARCH(void); ~FILESEARCH(); @@ -153,6 +154,9 @@ public: /* ある種類のファイルをすべてリストアップ ** 末尾は NULL pointer */ + void SetXorKey(char*); + void GuessXorKey(char*); + const char* GetXorKey(void); char** ListAll(FILETYPE type); }; diff --git a/xlovesys.cc b/xlovesys.cc --- a/xlovesys.cc +++ b/xlovesys.cc @@ -114,6 +114,7 @@ int main(int argc, char *argv[]) { if (strcmp(regname, key_lb_orig) == 0) { // "リトルバスターズ! -> LittleBustersに#REGNAMEを変更 config.SetParaStr("#REGNAME", key_lb_new); } + file_searcher.GuessXorKey((char*)regname); SetFont(font); MuSys mu(config);