RetroAchievements / RALibretro

RALibretro is a multi-emulator used to develop RetroAchievements.
https://retroachievements.org
GNU General Public License v3.0
177 stars 35 forks source link

RAHasher - Some PS2 CHDs failing with "Could not locate primary executable" #371

Closed retroNUC closed 1 year ago

retroNUC commented 1 year ago

Thanks for the previous CHD fix, but found a few files that still aren't hashing properly in this format when the ISO versions are fine.

An example of this is with the PS2 title Legend of Spyro, The - Dawn of the Dragon (USA) (En,Fr,De,Es,It,Nl). I'll note that the CHD version is hashed and recognized fine in PCSX2.

This is in latest locally-built version of RAHasher, with the libchdr update.

Verbose output from RAHasher with ISO file:

C:\Emulation\tools\rahasher>rahasher -v 21 "C:\Emulation\tools\rahasher\Legend of Spyro, The - Dawn of the Dragon (USA) (En,Fr,De,Es,It,Nl).iso"
Opened Legend of Spyro, The - Dawn of the Dragon (USA) (En,Fr,De,Es,It,Nl).iso
Found SYSTEM.CNF at sector 868
Looking for boot executable: SLUS_218.20
Found SLUS_218.20 at sector 869
Hashing SLUS_218.20 title (11 bytes) and contents (6903984 bytes)
Generated hash cacd9954aba98b40c41638dfb5c66f8b
cacd9954aba98b40c41638dfb5c66f8b

Verbose output from RAHasher with CHD conversion of same file:

C:\Emulation\tools\rahasher>rahasher -v 21 "C:\Emulation\tools\rahasher\Legend of Spyro, The - Dawn of the Dragon (USA) (En,Fr,De,Es,It,Nl).chd"
Could not locate primary executable
Jamiras commented 1 year ago

When trying to determine the header size of a CD sector, we look for the CD001 marker at 25 bytes in (XA) or 17 bytes in (non-XA). In this case, it's 1 byte in (header removed). Since we're not explicitly looking for it at 1 byte in, the code falls back to determining the sector size from the file size, which is done incorrectly using the CHD's logicalbytes value. In this case, that just happens to be divisible by 2352, so a 16 byte header is assumed, thus preventing the identification from working correctly.

I'm working on a fix.