hippie68 / sfo

Fast C program that reads a file to print or modify its SFO parameters. Can be used for automation or to build param.sfo files from scratch. Also available as .exe file for the Windows command line.
21 stars 5 forks source link

Support for PS4 'SCECDF' #1

Closed nitro322 closed 2 years ago

nitro322 commented 3 years ago

Hi. It's great to see some recent developments on basic tools like SFO readers, and especially open source tools that run on Linux. Appreciate your work.

Wanted to ask if it'd be possible to add support for the param.sfo files that are included directly on PS4 ISO. Note that these are different from the param.sfo files that included within app.pkg. These files are located under /bd/param.sfo on the ISO, and begin with SCECDF instead of PSF. The contain similar info, but it's not identical; looking at hexdump output, it appears to be a subset of the main param.sfo data.

For example, here's the main/app.pkg param.sfo for Tetris Effect: https://boxdog.legroom.net/public/te-psf-param.sfo

and here's an example of the bd/ISO param.sfo: https://boxdog.legroom.net/public/te-scecdf-param.sfo

I've been unable to find any other tool capable of reading these, but pretty much all other Linux SFO readers I've found so were last updated in 2015 (or older), so figured you'd be my best shot at this. I'm mainly interested because this file can be extracted instantly from ISOs, while the 'main' param.sfo requires first extracting app.pkg and then extracting from there, which can take quite a while on large ISOs.

hippie68 commented 3 years ago

This could work, assuming all BD param.sfos are structured in this way: In sfo.c, replace line 183,

}

with

} else if (magic == 1128612691) { // BD param.sfo ?                            
  pkg_offset = 0x800;                                                          
  magic = getbytes(0, 4);                                                      
}

Or extract and compile the attached file: sfo.zip

nitro322 commented 3 years ago

Wow, thanks for the extremely fast response!

Just did some testing. Definitely a subset, but getting version, ID, title, and required firmware version covers the basics and is well worth the trade-off of getting the full file in terms of useful information vs. speed. Here's Tetris Effect, for example (I'm sure you already saw this when testing, but for anyone else that may find this):

CATEGORY=bd
DISC_NUMBER=0x00000001
DISC_TOTAL=0x00000001
FORMAT=obs
PUBTOOLVER=0x03390000
SYSTEM_ROOT_VER=0x06008000
SYSTEM_VER=0x06008000
TITLE=Tetris® Effect
TITLE_ID=CUSA13594
VERSION=01.02

Not bad overall. I tested against my entire collection and it worked for all of them. Most were the same as the above, but a few had more details. Here's Final Fantasy VII Remake, just for another example:

APP00_ATTRIBUTE=0x00000000
APP00_CONTENT_ID=UP0082-CUSA07211_00-FFVIIREMAKE00000
APP00_PUBTOOLINFO=
APP00_TITLE_ID=CUSA07211
CATEGORY=bd
DISC0_MDID=CUSA07211
DISC0_ROLE=0x00000000
DISC1_MDID=CUSA16279
DISC1_ROLE=0x00000001
DISC_NUMBER=0x00000002
DISC_TOTAL=0x00000002
FORMAT=obs
PUBTOOLINFO=asa=0500000100000000006421e25f1f24,asa8=e91acf348ba3f84ff0e01ddcd7,asa9=584b8608ec708901fc67f645d8
PUBTOOLVER=0x03700000
SYSTEM_ROOT_VER=0x07020000
SYSTEM_VER=0x07020000
TITLE=FINAL FANTASY VII REMAKE
TITLE_ID=CUSA16279
VERSION=01.01

Overall works great, and couldn't be happier. Thanks a bunch!