Add Gunhound EX PSP key; try to get key from external file

Needed for files which incorrectly guess its XOR key (like Gunhound).
The format for ADX keyfiles is 6 bytes with start/mult/add (ex.
0x111122223333).
This commit is contained in:
bnnm 2016-11-27 19:41:36 +01:00
parent 5a1a122698
commit 088fb4a480

View File

@ -470,9 +470,15 @@ static struct {
/* Phantasy Star Online 2
* guessed with degod */
{0x07d2,0x1ec5,0x0c7f},
/* Dragon Ball Z: Dokkan Battle
* guessed with degod */
{0x0003,0x0d19,0x043b},
/* Kisou Ryouhei Gunhound EX (2013-01-31)(Dracue)[PSP]
* guessed with degod */
{0x0005,0x0bcd,0x1add},
};
static const int keys_8_count = sizeof(keys_8)/sizeof(keys_8[0]);
@ -487,6 +493,23 @@ static int find_key(STREAMFILE *file, uint8_t type, uint16_t *xor_start, uint16_
int startoff, endoff;
int rc = 0;
/* try to find key in external file first */
{
char filename[PATH_LIMIT];
uint8_t keybuf[6];
file->get_name(file,filename,sizeof(filename));
if ( read_key_file(keybuf, 6, filename) ) {
*xor_start = get_16bitBE(keybuf+0);
*xor_mult = get_16bitBE(keybuf+2);
*xor_add = get_16bitBE(keybuf+4);
return 1;
}
}
/* guess key from the tables above */
startoff=read_16bitBE(2, file)+4;
endoff=(read_32bitBE(12, file)+31)/32*18*read_8bit(7, file)+startoff;