Skip to content

Instantly share code, notes, and snippets.

@noirscape
Last active January 25, 2023 10:18
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save noirscape/291233cb5943f58f99d6715e6ae6d051 to your computer and use it in GitHub Desktop.
Save noirscape/291233cb5943f58f99d6715e6ae6d051 to your computer and use it in GitHub Desktop.
CIA extraction scripts
#!/bin/bash
# Simple banner creation script
# Created by ev1l0rd
# Requirements: bannertool and a folder called 'banner_input', in which the following files exist: banner.png , icon.png , audio.wav
# banner.png must be 256x128
# icon.png must be 48x48
# audio.wav must be shorter than 3 seconds
# Catching additional input
read -rp "Enter the title of your injection: " title
read -rp "Enter the publisher name: " publisher
bannertool makesmdh -s "$title" -l "$title" -p "$publisher" -i "banner_input/icon.png" -o "exefs/icon.icn" -r regionfree -f visible
bannertool makebanner -i "banner_input/banner.png" -a "banner_input/audio.wav" -o "exefs/banner.bnr"
#!/bin/bash
# This script cleans up all the remaining files.
# Created by Ev1l0rd
echo "WARNING!"
echo "This will remove all following files/folders:"
echo "exefs/*"
echo "romfs/*"
echo "exefsheader.bin"
echo "plain.bin"
echo "contents.*"
echo "logo.bcma.lz"
read -p "If you are sure, press the [Enter] key to continue, or [^C] to exit."
rm -f exefsheader.bin plain.bin contents.* logo.bcma.lz
rm -r -f exefs romfs
#!/bin/bash
# Simple extracting script for CIA files.
# Make sure only one CIA file is in the current directory!
# Otherwise the script will do weird things.
# Credit: Ev1l0rd
ctrtool --contents=contents *.cia
ctrtool --exheader=exheader.bin --romfsdir=romfs --logo=logo.bcma.lz --plainrgn=plain.bin --exefs exefs.bin contents.0000.00000000
3dstool -xvtf cxi contents.0000.00000000 --header ncchheader.bin
3dstool -xvtf exefs exefs.bin --exefs-dir exefs --header exefsheader.bin
# exefs is removed, because it is only needed to get the header.
rm exefs.bin
#!/bin/bash
# Simple extracting script for CIA files.
# Make sure only one CIA file is in the current directory!
# Otherwise the script will do weird things.
# This variant skips the nccheader and exheader.
# Credit: Ev1l0rd
ctrtool --contents=contents *.cia
ctrtool --romfsdir=romfs --logo=logo.bcma.lz --plainrgn=plain.bin --exefs exefs.bin contents.0000.00000000
3dstool -xvtf exefs exefs.bin --exefs-dir exefs --header exefsheader.bin
# exefs is removed, because it is only needed to get the header.
rm exefs.bin
#!/bin/bash
# Simple repacking script
# Created by Ev1l0rd
# Output filename prompt
read -rp "Enter the output CIA filename (without the extension): " output
# First we remove any existing exefs/romfs files.
rm exefs.bin romfs.bin
# Now we repack the fs's
3dstool -cvtf exefs exefs.bin --exefs-dir exefs/ --header exefsheader.bin
3dstool -cvtf romfs romfs.bin --romfs-dir romfs/
# Now we create a temporary cxi.
3dstool -cvtf cxi tmp.cxi --header ncchheader.bin --exh exheader.bin --logo logo.bcma.lz --plain plain.bin --exefs exefs.bin --romfs romfs.bin
# And finally, we create the CIA.
makerom -f cia -o $output.cia -content tmp.cxi:0:0
# Removing unneeded files
rm exefs.bin romfs.bin tmp.cxi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment