mirror of
https://gist.github.com/3793a40dd0c7930f12b79ca1931a3296.git
synced 2025-10-31 13:51:11 -04:00
This commit is contained in:
parent
3bc02ca6fc
commit
c22e4ccdca
@ -2,7 +2,6 @@
|
|||||||
# Lillian Skinner
|
# Lillian Skinner
|
||||||
# Last modified 2023/08/19
|
# Last modified 2023/08/19
|
||||||
# Extracts firmware CIAs from the RomFS of "SystemUpdater-0_13-0927-UnFixedKey.csu". This can't be done with other tools as 0.13.0 doesn't use the normal RomFS format.
|
# Extracts firmware CIAs from the RomFS of "SystemUpdater-0_13-0927-UnFixedKey.csu". This can't be done with other tools as 0.13.0 doesn't use the normal RomFS format.
|
||||||
# So far this only gets the start/end addresses of the CIAs.
|
|
||||||
|
|
||||||
echo "Finding CIA headers in file..."
|
echo "Finding CIA headers in file..."
|
||||||
od -t x -A d romfs.bin | grep "00002020 00000000 00000a00 00000350" | sed 's/ .*//' | sed 's/^0*//' > romfs-dir.txt
|
od -t x -A d romfs.bin | grep "00002020 00000000 00000a00 00000350" | sed 's/ .*//' | sed 's/^0*//' > romfs-dir.txt
|
||||||
@ -12,11 +11,13 @@ echo "================================================="
|
|||||||
|
|
||||||
declare -i x=0
|
declare -i x=0
|
||||||
declare -i i=1
|
declare -i i=1
|
||||||
|
declare -i z=1
|
||||||
|
|
||||||
echo "Extracting odd CIAs..."
|
echo "Extracting odd CIAs..."
|
||||||
echo "================================================="
|
echo "================================================="
|
||||||
sed 1d romfs-dir.txt | while IFS=, read -r START_HEADER; read NEXT_HEADER
|
sed 1d romfs-dir.txt | while IFS=, read -r START_HEADER; read NEXT_HEADER
|
||||||
do
|
do
|
||||||
|
echo " Check CIA length"
|
||||||
echo "CIA $i header at ${START_HEADER}"
|
echo "CIA $i header at ${START_HEADER}"
|
||||||
echo "Next header at ${NEXT_HEADER}"
|
echo "Next header at ${NEXT_HEADER}"
|
||||||
echo "Finding CIA $i end from CIA $((i + 1)) header... "
|
echo "Finding CIA $i end from CIA $((i + 1)) header... "
|
||||||
@ -34,7 +35,10 @@ do
|
|||||||
echo "End found!"
|
echo "End found!"
|
||||||
echo "Non-zerobyte ($y) at $((NEXT_HEADER - x))"
|
echo "Non-zerobyte ($y) at $((NEXT_HEADER - x))"
|
||||||
echo "Padding from CIA $i to $((i + 1)) is $((x - 1)) bytes."
|
echo "Padding from CIA $i to $((i + 1)) is $((x - 1)) bytes."
|
||||||
echo "CIA $i done!"
|
echo " Extract CIA:"
|
||||||
|
CIA_LENGTH=$(((NEXT_HEADER - START_HEADER) - x + 1))
|
||||||
|
dd skip=${START_HEADER} count=${CIA_LENGTH} if=romfs.bin of="$i.cia" bs=1
|
||||||
|
echo "CIA $i saved as '$i.cia'"
|
||||||
echo "================================================="
|
echo "================================================="
|
||||||
i+=2
|
i+=2
|
||||||
done < romfs-dir.txt
|
done < romfs-dir.txt
|
||||||
@ -43,6 +47,7 @@ echo "Extracting even CIAs..."
|
|||||||
echo "================================================="
|
echo "================================================="
|
||||||
sed 1d romfs-dir.txt | while IFS=, read -r START_HEADER; read NEXT_HEADER
|
sed 1d romfs-dir.txt | while IFS=, read -r START_HEADER; read NEXT_HEADER
|
||||||
do
|
do
|
||||||
|
echo " Check CIA length"
|
||||||
echo "CIA $i header at ${START_HEADER}"
|
echo "CIA $i header at ${START_HEADER}"
|
||||||
echo "Next header at ${NEXT_HEADER}"
|
echo "Next header at ${NEXT_HEADER}"
|
||||||
echo "Finding CIA $i end from CIA $((i + 1)) header... "
|
echo "Finding CIA $i end from CIA $((i + 1)) header... "
|
||||||
@ -60,7 +65,12 @@ do
|
|||||||
echo "End found!"
|
echo "End found!"
|
||||||
echo "Non-zerobyte ($y) at $((NEXT_HEADER - x))"
|
echo "Non-zerobyte ($y) at $((NEXT_HEADER - x))"
|
||||||
echo "Padding from CIA $i to $((i + 1)) is $((x - 1)) bytes."
|
echo "Padding from CIA $i to $((i + 1)) is $((x - 1)) bytes."
|
||||||
echo "CIA $i done!"
|
echo " Extract CIA:"
|
||||||
|
CIA_LENGTH=$(((NEXT_HEADER - START_HEADER) - x + 1))
|
||||||
|
CIA_NUMBER+=1
|
||||||
|
dd skip=${START_HEADER} count=${CIA_LENGTH} if=romfs.bin of="$i.cia" bs=1
|
||||||
|
echo "CIA $i output as '$i.cia', ${CIA_LENGTH} bytes."
|
||||||
|
CIA_LENGTH=""
|
||||||
echo "================================================="
|
echo "================================================="
|
||||||
i+=2
|
i+=2
|
||||||
done
|
done
|
||||||
Loading…
Reference in New Issue
Block a user