Rebuilding a game or application in .cia format using RSF files - ihaveamac/3DS-rom-tools GitHub Wiki
This guide explains how you can rebuild a CTR Importable Archive (CIA) from the extracted contents of another CIA or CCI (.3ds/.cci).
This guide is focused on rebuilding contents that were already extracted from a CIA or CCI.
This page is still a work in progress, and not everything on it has been fully tested.
The RSF methods are currently not good methods for newer games (9.0+?), update data or system titles. If possible use the "extracted NCCH header" method.
- Work in progress
- Python 2.7
-
ctrtool and makerom
If you are not using a 64-bit operating system, you must build the source yourself for now. - 3dstool
- A 3DS system with signature patches to install "un-legit" CIA files
- An extracted game's contents
- At the very least, you need the code, banner, icon, ExHeader, and RomFS to easily rebuild.
- Having the original game/application means you can get the CompanyCode, ProductCode, and UniqueId from it. These can be filled in manually if needed.
- If rebuilding a game based on an extracted NCCH Header, extracting the logo and plain region is recommended.
-
dummy.rsf
- This file must have DOS line endings. If your resulting RSF looks strange, this might be the reason.
- One of the Python scripts for RSF generation:
-
rsfgen.py
- used with an existing .3ds/.cci and decrypted/extracted ExHeader -
rsfgen_cia.py
- used with an existing decrypted .cia -
rsfgen_exh.py
- used with an ExHeader (does not get CompanyCode, ProductCode, or UniqueId automatically)
-
- Basic knowledge of the Terminal/Command Line
-
NCCH partitions of a CCI (.3ds/.cci)
Partition Use Type 0 Game Executable [[CXI 1 Manual [[CFA 2 Download Play Child container [[CFA 6 New3DS Update Data [[CFA 7 Old3DS Update Data [[CFA 3, 4, and 5 do exist, but don't usually contain anything.
-
Content Indexes for a CIA (i.e.
XXXX
incontents.XXXX.00000000
)
Downloadable Content (including Themes) do not follow this format. Some system titles also only use a CFA as the first index.Index Use Type 0 Game Executable [[CXI 1 Manual [[CFA 2 Download Play Child container [[CFA -
Small note: If you are rebuilding a title to be installed to NAND, you must encrypt NCCH first with Decrypt9, after rebuilding the CIA. Place your CIA in
/files9
, then go to "Game Decryptor Options", "CIA File Options..." and "CIA Encryptor (NCCH)".
Warning: This is currently not fully tested.
- Use
rsfgen_cia.py
on the CIA and a copy of the dummy RSF:
python rsfgen_cia.py -c original_game.cia -o game.rsf
Explanation of possible arguments for this situation:
-
-c
or--cia
- CIA file to use -
-o
or--rsf
- Template RSF to use and write to -
-f icon
or--regionfree icon
- Apply region-free to the specified icon (usuallyicon.bin
) -
-s
or--spoof
- Spoof the minimum required kernel version to 2.33 (4.0 NATIVE_FIRM)
You should make sure the RSF doesn't display garbage data. If it does, your CIA might not be fully decrypted.
If you get "CIA is probably encrypted (NCCH magic not found)
", your CIA might be encrypted.
If you are sure it's fully decrypted, the NCCH magic offset might be at an unknown location. Please create a new issue if this is the case.
-
Modify the RSF file as needed (for instance, changing the UniqueId, Category, etc.).
-
Make sure you have extracted:
- the CIA's contents,
- the ExHeader, ExeFS and RomFS have been extracted from the first content (Game Executable),
- the decompressed code/icon/banner have been extracted from the ExeFS of the first content.
See Extract .cia for details on extracting.
- If the RomFS needs to be rebuilt, use 3dstool to rebuild:
3dstool -cvtf romfs romfs.bin --romfs-dir romfs/
- Use makerom to rebuild the Game Executable from the extracted contents and RSF. For example:
makerom -f cxi -o game.cxi -rsf game.rsf -code exefs/code.bin -icon exefs/icon.bin -banner exefs/banner.bin -exheader exheader.bin -romfs romfs.bin
Explanation of possible arguments for this situation:
-
-f
- Format to save as -
-o
- File to save to -
-rsf
- RSF to use -
-code
- Code to use -
-icon
- Icon/SMDH to use- An SMDH generated with smdhtool will probably not work out of the box. You should use bannertool's "makesmdh".
-
-banner
- Banner to use -
-exheader
- Extended Header to use -
-romfs
- RomFS to use -
-exefslogo
Include Logo in ExeFS, required if the CIA will be used on <5.0.0-11 -
-logo
- Logo file to use (overrides "BasicInfo/Logo" in RSF), generally not needed -
-plainrgn
- Plain region file to use, generally not needed
- Use makerom to rebuild the CIA with the contents. Include any others you might want, with the appropriate index.
For example, to include just the Game Executable:
makerom -f cia -o game.cia -content game.cxi:0
...or to include the Manual and Download Play child container as well:
makerom -f cia -o game.cia -content game.cxi:0 -content manual.cfa:1 -content dlpchild.cfa:2
The original content names might be:
-
contents.0000.xxxxxxxx
- Game Executable -
contents.0001.xxxxxxxx
- Manual -
contents.0002.xxxxxxxx
- Download Play child container
Explanation of possible arguments for this situation:
-
-f
- Format to save as -
-o
- File to save to -
-content file:index:id
- Content to include, "id
" not required -
-ver
- Title Version, accepts decimal and hex -
-major
- Major version -
-minor
- Minor version -
-micro
- Micro version
Warning: This is currently not fully tested.
-
Extract the ExHeader from the CCI. See Extract .3ds/.cci for details.
-
Use
rsfgen.py
on the CCI and a copy of the dummy RSF:
python rsfgen.py -r original_game.3ds -e exheader.bin -o game.rsf
Explanation of possible arguments for this situation:
-
-r
or--rom
- CCI to use -
-e
or--exheader
- Decrypted ExHeader to use -
-o
or--rsf
- Template RSF to use and write to -
-f icon
or--regionfree icon
- Apply region-free to the specified icon (usuallyicon.bin
) -
-s
or--spoof
- Spoof the minimum required kernel version to 2.33 (4.0 NATIVE_FIRM)
You should make sure the RSF doesn't display garbage data. If it does, your ExHeader might not be decrypted. If the CCI is encrypted, you need to decrypt it, or generate XORpads and use the ExHeader XORpad to decrypt & extract it.
-
Modify the RSF file as needed (for instance, changing the UniqueId, Category, etc.).
-
Make sure you have extracted:
- the CCI's contents,
- the ExHeader, ExeFS, and RomFS have been extracted from the first content (Game Executable),
- the decompressed code/icon/banner have been extracted from the ExeFS of the first content.
See Extract .3ds/.cci for details on extracting.
- If the RomFS needs to be rebuilt, use 3dstool to rebuild:
3dstool -cvtf romfs romfs.bin --romfs-dir romfs/
- Use makerom to rebuild the Game Executable from the extracted contents and RSF. For example:
makerom -f cxi -o game.cxi -rsf game.rsf -code exefs/code.bin -icon exefs/icon.bin -banner exefs/banner.bin -exheader exheader.bin -romfs romfs.bin
Explanation of possible arguments for this situation:
-
-f
- Format to save as -
-o
- File to save to -
-rsf
- RSF to use -
-code
- Code to use -
-icon
- Icon/SMDH to use- An SMDH generated with smdhtool will probably not work out of the box. You should use bannertool's "makesmdh".
-
-banner
- Banner to use -
-exheader
- Extended Header to use -
-romfs
- RomFS to use -
-exefslogo
Include Logo in ExeFS, required if the CIA will be used on pre-5.0.0-11 -
-logo
- Logo file to use (overrides "BasicInfo/Logo" in RSF), generally not needed -
-plainrgn
- Plain region file to use, generally not needed
- Use makerom to rebuild the CIA with the contents. Include any others you might want, with the appropriate index.
For example, to include just the Game Executable:
makerom -f cia -o game.cia -content game.cxi:0:0
...or to include the Manual and Download Play child container as well:
makerom -f cia -o game.cia -content game.cxi:0:0 -content manual.cfa:1:1 -content dlpchild.cfa:2:2
Explanation of possible arguments for this situation:
-
-f
- Format to save as -
-o
- File to save to -
-content file:index:id
- Content to include, "id
" not required -
-ver
- Title Version, accepts decimal and hex -
-major
- Major version -
-minor
- Minor version -
-micro
- Micro version