rcheevos icon indicating copy to clipboard operation
rcheevos copied to clipboard

PSP homebrew hashing

Open hrydgard opened this issue 1 year ago • 2 comments

On the PSP, homebrew games (which often are ports/variations of games for other platforms) are quite popular and it seems people are quite excited to make achievements for them. Hashing them is a real problem though.

Homebrew games are extracted to a directory under /PSP/GAME on the memory stick, like say /PSP/GAME/DOOM. They contain an executable container called EBOOT.PBP which contains the game binary, its PARAM.SFO and icons and stuff, so effectively simply hashing this file might seem to be enough. Unfortunately homebrew games have more files than that which may be easiliy modified, and some are simply an engine running different data files, like the luaengine, so we really have to hash other files as well. But homebrew also often writes their own configuration and save data to the same directory, so simply hashing all files won't work reliably.

It might be necessary to do something like hash the eboot, then look up that hash in an official table to figure out what other files to hash as well to make a solid identification. I realize there's probably no infrastructure for that in retroachievements at this time, and it would be real tricky to maintain.

Of course, it's also a complication that there's often no "canonical" version of a particular homebrew game or engine, so achievement makers will just have to pick one.

Anyway, I'm not sure how practical it is, but I think documenting the problem here is at least a start.

hrydgard avatar Jun 20 '23 07:06 hrydgard

This was briefly discussed in https://github.com/RetroAchievements/RALibretro/issues/373. The big problem is that the hashing code doesn't understand the PBP file format.

Jamiras avatar Jun 21 '23 22:06 Jamiras

Don't really need to understand it, can just hash the whole PBP (unlike in demos/PSX games, they usually are not big). The real issue is the surrounding files that are not part of the PBP. Like here's a very simple homebrew:

image

This is bad because if we hash all those files, we'll end up hashing the game's mutable settings file, Config.dat. While if we don't, we can miss important things, especially if the PBP is an engine that just runs surrounding code files, which there are a bunch of examples of on PSP.

hrydgard avatar Jun 21 '23 22:06 hrydgard

For retail games, the files that are hashed are EBOOT.BIN and PARAMS.SFO. Given that the EBOOT.PBP for homebrew games is these two files plus icons packaged into one, hashing this file for homebrew should be enough to uniquely identify games with as much surety as exists for retail games.

From manually hashing as many released homebrew games as I could get my hands on, including all those available in the PPSSPP standalone emulator, I'm yet two find any duplicate hashes. My belief is that if duplicate hashes do exist, it would mean to games have the same executable, name, version and icons, and therefore is likely not at a development stage that justifies achievements.

So in my views hashing the EBOOT.PBP for homebrew games is the right way to go to unblock achievements for them while maintaining similar standards to retail game hashes.

LucasKell avatar Apr 28 '24 09:04 LucasKell

@LucasKell Thanks for your research, exactly what is need to support a decision.

Let's define the hash as just hashing the EBOOT.PBP then, up to the first 16MB. It'll still be "weak" to people modifying game files but so are retail games, so should be acceptable.

I will enable this hashing method in PPSSPP in the near future.

hrydgard avatar Apr 28 '24 11:04 hrydgard

Since this has been decided, and now implemented in PPSSPP itself, all that remains I guess is to implement this in rhash for use from RetroArch?

hrydgard avatar May 01 '24 10:05 hrydgard