@echo off
if exist EBOOT.BIN goto fix
echo EBOOT.BIN not found...
goto end
:fix
set CID=
FOR /F "tokens=1,2 delims= " %%A IN ('scetool.exe -i EBOOT.BIN') DO (
if [%%A]==[ContentID] set CID=%%B
)
scetool.exe --decrypt EBOOT.BIN EBOOT.elf
if not exist EBOOT.elf unself.exe EBOOT.BIN EBOOT.elf
FixELF.exe EBOOT.elf "24 13 BC C5 F6 00 33 00 00 00 36" "24 13 BC C5 F6 00 33 00 00 00 34" /340
ren EBOOT.BIN EBOOT.BIN_ORIGINAL > NUL
if [%CID%]==[] (
scetool.exe -v --sce-type=SELF --compress-data=TRUE --skip-sections=TRUE --key-revision=01 --self-auth-id=1010000001000003 --self-app-version=0001000000000000 --self-vendor-id=01000002 --self-type=APP   --self-fw-version=0003004000000000 --encrypt EBOOT.elf EBOOT.BIN
) else (
echo ContentID=%CID%
scetool.exe -v --sce-type=SELF --compress-data=TRUE --skip-sections=TRUE --key-revision=01 --self-auth-id=1010000001000003 --self-app-version=0001000000000000 --self-add-shdrs=TRUE --self-vendor-id=01000002 --self-type=NPDRM --self-fw-version=0003004000000000 --np-license-type=FREE --np-content-id=%CID% --np-app-type=EXEC --np-real-fname=EBOOT.BIN --encrypt EBOOT.elf EBOOT.BIN
)
del /Q EBOOT.elf > NUL
if not exist EBOOT.BIN ren EBOOT.BIN_ORIGINAL EBOOT.BIN

:end
pause
