Nice, but I think you need to do some small additional changes.
I think the current code only works for single-disk games from the PSN store and not for multi-disc games or games converted by pop-fe.
See :
https://www.psdevwiki.com/psp/PSISOIMG0000
In the code you take the offset as :
config_offset = header.psar_offset + 0x420;
But this only works for single-disk games from the PSN store because it assumes that the PSAR section starts with a PSISOIMG block.
That is not always the case and sometimes the PSAR section starts with a 0x400 byte large section called PSTITLEIMG before the PSISOIMG section(s).
There are three cases for what PSAR contains:
1, just a single PSISOIMG section. These are single disk games from the PSN store
2, a PSTITLEIMG section followed by a single PSISOIMG section. This is how pop-fe generates single disk eboots
3, a PSTITLEIMG section followed by 2 or more PSISOIMG sections. This is how all multi-disc games are encoded.
So you will need to check the start of the PSAR buffer and check if it starts with a 'PSISOIMG' tag or if it starts with a
'PSTITLEIMG' tag.
In the latter case the offset for the first config will not be 0x420 but instead be 0x820. (because the size of PSTITLEIMG is 0x400 bytes)
In the case of ISOTITLEIMG you should also check the PSTITLEIMG offsets 0x200 for the offsets where the individual ISOs start,
the first ISO always start at offset 0x400 into PSAR, i.e. immediately after the PSTITLEIMG section itself, but there could be additonal disks.
You will need to loop, starting from PSTITLEIMG section offset 0x200 and read all the offsets to where the ISOs start.
A value of 0x00000000 means no more disks.
This will complicate the code slightly because it will no longer be just a single config_offset but it could be up to 5 different config_offsets (max number of disks in a relased game is 5) so you need to keep track of up to 5 different config_offsets.
The good thing though is that you do not need to keep track of up to 5 different CONFIG.BIN. As far as I know all multidisk games that have a config has an identical config for all the disks so you should be able to just read CONFIG.BIN and just inject the same data for each disk in the multidisc eboot.