hrydgard / ppsspp

A PSP emulator for Android, Windows, Mac and Linux, written in C++. Want to contribute? Join us on Discord at https://discord.gg/5NJB6dD or just send pull requests / issues. For discussion use the forums at forums.ppsspp.org.
https://www.ppsspp.org
Other
11.03k stars 2.15k forks source link

Gran Turismo - Save that got transferred from PSP to PPSSPP and back to PSP could not be read #15747

Open ghost opened 2 years ago

ghost commented 2 years ago

Game or games this happens in

UCUS-98632

What area of the game / PPSSPP

When moving the save from your PSP to PPSSPP and back to your PSP the save will appear corrupted on the console. Note: I made sure the MAC addresses match between PSP and the PPSSPP so it may be something else with the encryption the game uses.

What should happen

The save should be read on the PSP properly. As an extension - PPSSPP needs to be more accurate when handeling saves.

Logs

No response

Platform

Windows

Mobile phone model or graphics card

AMD Radeon 530

PPSSPP version affected

1.13.1

Last working version

No response

Graphics backend (3D API)

Other

Checklist

ghost commented 2 years ago

If something couldn't be done from PPSSPP side , a warning should be issued that the save could corrupt your PSP save at least.

sum2012 commented 2 years ago

ppsspp save (create) -> real psp Real psp detect other psp save. pic_0000 ppsspp v1.13.1-722-g49d5b6447 create log https://gist.github.com/sum2012/f5394ae9b9f517c82577fd1652ae9a5a1 Use jpcsp emulator same issue I think that that is no way to use other psp save. Can we close this issue ?

ghost commented 2 years ago

ppsspp save (create) -> real psp Real psp detect other psp save. pic_0000 ppsspp v1.13.1-722-g49d5b6447 create log https://gist.github.com/sum2012/f5394ae9b9f517c82577fd1652ae9a5a1 Use jpcsp emulator same issue I think that that is no way to use other psp save. Can we close this issue ?

But that's not the issue... The issue is creating a save first on PSP and then transferring it to the PPSSPP while keeping the same MAC address as the PSP in the settings. Why its detecting another PSP when its the same MAC address and everything matches ..

BTW part of this issue is also warning players from doing what I did because it could corrupt all their progress in the game on their console...

Also weirdly I never got your message when I tried this .. something is not consistent here.. it didn't warn me at all.

unknownbrackets commented 2 years ago

There's another couple IDs called the PSID and OpenPSID. Maybe when the MAC matches but they don't, or something?

If this game wants to make sure data can only be used on the same PSP device, it's probably tricky to make it compatible back and forth.

-[Unknown]

ghost commented 2 years ago

I got that message that sum2012 after just transferring the savedata from PPSSPP to PSP now. If you think its not possible to do something about it you could close the issue. This game is really nasty when it comes to saves huh..

unknownbrackets commented 2 years ago

Well, I just said tricky, not impossible. If it is the PSID/OpenPSID, maybe we need an ini setting for that. I would like it to be doable, but I just think it may be complex.

-[Unknown]

sum2012 commented 2 years ago

(Uploaded save are same with MAC address and nickname) RealPSP-UCAS40265-GAMEDAT.zip ppssspp-UCAS40265-GAMEDAT.zip Real psp save log: https://gist.github.com/sum2012/11aaf6023d53302d98e9329bc7b46ca6 Real psp load ppsspp save bad log: https://gist.github.com/sum2012/a6896d4c6839e74a20f99b7336790043

ppsspp save log: https://gist.github.com/sum2012/e0aeeaf41512e429a7f818eea9f98f83 ppsspp load log (good): https://gist.github.com/sum2012/b48cd63b6b1f80b708be9e198b833631

sum2012 commented 2 years ago

If I overwrite real psp of PARAM.SFO to ppsspp's save In real psp,it said damage save data.cannot load In ppsspp, seem load okay.

sum2012 commented 2 years ago

@unknownbrackets if you have time, write "Read real psp of PSID/OpenPSID " psp's plugin to me.Thanks. I change to PPSSPP 's code of PSID/OpenPSID to test whether real psp load ok with ppsspp 's save.

sum2012 commented 2 years ago

In the ppsspp loading log ,I cannot see PSID/OpenPSID log....

Kethen commented 10 months ago

I distantly remember that I could always load GTpsp saves from psp in ppsspp, but not the reverse, without having to mess with etheraddr/macaddr

On the other hand, GTpsp's sym table from ppsspp suggests that the game does not query PSID nor etheraddr

@sum2012 @ghost have you tried using https://www.gamebrew.org/wiki/Savegame_Deemer_PSP to enable saving/loading plain text saves on a real psp, then https://forums.ppsspp.org/showthread.php?tid=14279&pid=100202#pid100202 on ppsspp, then compare the content of the plain text saves?

It might also worth testing whether savegame deemer on psp could load decrypted saves from ppsspp, could help narrow down whether the detection was part of the process of using sceUtilitySaveData*

Kethen commented 10 months ago

I won't have a psp with me for a while but I was poking around ppsspp today with GTpsp

One thing might be of interest is that during saving, param->sfoParam.unknown on GTpsp is 0x06 0x00 0x00 (looked at US 2.0, EU 2.0 ASIA 1.0 and JP 1.01), while on other games I've looked at, they set 0x00 0x00 0x00

During loading, the "from another system" message can actually be triggered on ppsspp by forcing the first bit of param->bind to 0 it seems. It'll happily load even with bind set to 0x01 0x00 0x00 0x00, but would not load with 0xFE 0xFF 0xFF 0xFF

image

Since ppsspp's implementation always sets param->bind to 1021 during loading, it's probably why it does not trigger in ppsspp with random saves from psp

https://github.com/hrydgard/ppsspp/blob/cc6f9a73ca73907f492d1958697734a4a8f468a6/Core/Dialog/SavedataParam.cpp#L653

So my theory is that the game sets a flag on param->sfoParam.unknown to ask the psp to bind the save to itself by adding something to the SFO (not implemented on ppsspp), then during loading, real implementation would reflect whether the save is from another device in the bind field

For ppsspp to be able to craft ofw loadable saves for games using this feature, someone would have to poke deeper in the psp saving code to see how it actually evaluates the bind field

I have the feeling https://github.com/bucanero/psptools/tree/master/SGDeemer on cfw is also capable of just inserting plaintext saves into the game as long as a valid one is available in it's original location

sum2012 commented 10 months ago

@Kethen ,ghost is Deleted user so that no need @ Deemer_PSP not work for GT in my PSP 3000 pro c2

sum2012 commented 10 months ago

@Kethen using this okay , https://psp.brewology.com/downloads/download.php?id=7709 edit: Not work

Kethen commented 10 months ago

@sum2012 To load non encrypted saves with SGDeemer, you need to:

  1. make a valid save on the psp with your game, then close the game, double check if SGDeemer is working and created ms0:/PSP/SAVEPLAIN/UCAS40265-GAMEDAT/SDDATA.BIN
  2. disable ppsspp save encryption in memstick/PSP/SYSTEM/ppsspp.ini by editing EncryptSave = True to EncryptSave = False, then start ppsspp, load and save your game in ppsspp
  3. on ppsspp, copy memstick/PSP/SAVEDATA/UCAS40265-GAMEDAT/GAME.DAT, find and replace ms0:/PSP/SAVEPLAIN/UCAS40265-GAMEDAT/SDDATA.BIN on the psp
  4. boot up the game on psp and see if you have your progress from ppsspp

Edited for wrong game id*

sum2012 commented 10 months ago

@Kethen ,I have said that Deemer_PSP not work for GT in my PSP 3000 pro c2 I will test another game

Kethen commented 10 months ago

@sum2012 Ah, sorry for not understanding you

Meanwhile the source link I sent last time for SGdeemer was outdated, notably v1.11 has new hooking code for 6.20, source and release can be found at https://github.com/TheHellcat/psp-hb/tree/master/SavegameDeemer_620TN

So how did v1.11 not work for you? It crashes the game or does it not create SAVEPLAIN?

sum2012 commented 10 months ago

The game tell me that cannot create the save

在 2023年11月13日週一 下午12:28,Katharine Chui @.***> 寫道:

Ah, sorry for not understand you

Meanwhile the source link I sent last time for SGdeemer was outdated, notably v1.11 has new hooking code for 6.20, source and release can be found at https://github.com/TheHellcat/psp-hb/tree/master/SavegameDeemer_620TN

So how did v1.11 not work for you? It crashes the game or does not create SAVEPLAIN?

— Reply to this email directly, view it on GitHub https://github.com/hrydgard/ppsspp/issues/15747#issuecomment-1807459325, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQTT7BB7ZTJENYQ7VKKL43YEGOVDAVCNFSM55AXKUAKU5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOBQG42DKOJTGI2Q . You are receiving this because you were mentioned.Message ID: @.***>

Kethen commented 10 months ago

It just dawned on me, that if sony were to internally implement device detection on sceUtilitySaveData*, they already do cmd5 hashing with kirk and put that in PARAM.SFO SAVEDATA_PARAMS + 0x20, so there's a chance that the first bit of param->bind comes from verifying that hash

If that's the case, it wouldn't make too much sense for ppsspp to allow an option for a key, because the user will have to find the kirk per device fuse key on the mainboard

Verifying this would likely require writing a homebrew to try and recreate the psp PARAM.SFO hash without going through sceUtilitySaveData* on a real psp

edit: wait no, why is the mode 6/cmd 4 key 17 hash on ppsspp 0x1 ..., saw the comment about cmd 5 and I assumed that that was a cmd 5 hash... looks like that'd need further investigation first

edit: ah, I see now mode 6 does use cmd 5 at the very end

sum2012 commented 10 months ago

@Kethen same error,please note that my psp system is 6.60

sum2012 commented 10 months ago

@Kethen the method in https://github.com/hrydgard/ppsspp/issues/15747#issuecomment-1807166682 Work in the game PSP-MOD NATION RACERS Chinese version (NPHG00080) PSP can load what ppsspp save (in playing time)

Kethen commented 7 months ago

For PPSSPP to be able to generate PSP load-able Gran Turismo saves, the following will be needed

On PPSSPP:

  1. Allow user input of fuseID used in kirk CMD5 hashing
  2. Implement/pull in upstream kirk CMD5 implementation, see https://github.com/bucanero/apollo-psp/pull/23#issuecomment-1927196758 , it seems that the full algorithm was found recently, and upstream https://github.com/ProximaV/kirk-engine-full/blob/master/libkirk/kirk_engine.c#L488 has an implementation already
  3. Perform param.sfo hashing using the provided CMD 5 fuseID keys extracted from console instead of populating the console dependent hash with stub bytes at

https://github.com/hrydgard/ppsspp/blob/25689c36d9c2f3f1b7aa612d89b86caf1809e376/Core/Dialog/SavedataParam.cpp#L1081-L1086

On PSP:

  1. A homebrew for reading out kirk CMD5 seed fuseID, see https://github.com/bucanero/apollo-psp/commit/99c405be527dfdab3a807452c3b0797d671377e4#diff-c4d722f76e3a4a99cf39b1297c8c15855e823ec8d9b77d808639abb6bf04a2cdR654

@hrydgard any thoughts on this

bucanero commented 7 months ago

Here's a stand-alone PSP homebrew app that dumps the unique FuseID on PSP and Vita (via Adrenaline) hardware: https://github.com/bucanero/psp-fuseid-dumper

The app will display the two fuseID values (fuse90, fuse94) and also write a binary file FUSEID.BIN to disk.

Double-0-seven7 commented 7 months ago

Maybe someone could step up to implement it in PPSSPP. Would be nice if so.

Kethen commented 4 months ago

Until we have a consensus on what to do about this, on PSP/PSV CFW this modified version of sgdeemer can also be used to bypass the console binding check on sceUtilitySaveData*

It'll allow loading GT saves from PPSSPP as well as other consoles