Files
threeSD/dist/threeSDumper.gm9
T
Pengfei e2bef4d705 Add support for title.db, and use title.db to augment TMD finding
Also added support for system title CIA building, and fixed various minor issues.
Also moved MakeMagic to Common.
2021-07-01 14:13:20 +08:00

199 lines
5.3 KiB
Plaintext

# Copyright 2019 threeSD Project
# Licensed under GPLv2 or any later version
# Refer to the license.txt file included.
# GM9 Script for dumping necessary files automatically.
set PREVIEW_MODE "threeSD Dumper\nby zhaowenlan1779"
set OUT "0:/threeSD"
if not find $[OUT] NULL
mkdir $[OUT]
end
if not ask "Execute threeSD Dumper?"
goto Exit
end
set PREVIEW_MODE "threeSD Dumper\nby zhaowenlan1779\n \nWorking..."
# === movable.sed
cp -w -n "1:/private/movable.sed" $[OUT]/movable.sed
# === bootrom
if find "M:/boot9.bin" NULL
cp -w -n "M:/boot9.bin" $[OUT]/boot9.bin
elif find "0:/3DS/boot9.bin" NULL
cp -w -n "0:/3DS/boot9.bin" $[OUT]/boot9.bin
else
echo "ERROR: \nboot9.bin not found. \nIf you use fastboot3ds, hold HOME while booting, \nand go to Miscellaneous... > Dump bootroms & OTP. \nWhen finished, simply execute this script again."
goto Exit
end
# === certs.db
if chk $[RDTYPE] "devkit"
echo "WARNING: \nDev kit detected. \nCIA building will not be usable."
else
cp -w -n "1:/dbs/certs.db" $[OUT]/certs.db
end
# === ticket.db
cp -w -n "1:/dbs/ticket.db" $[OUT]/ticket.db
# === title.db
cp -w -n "1:/dbs/title.db" $[OUT]/title.db
# === Safe mode firm
if not find $[OUT]/firm NULL
mkdir $[OUT]/firm
end
if chk $[ONTYPE] "N3DS"
if not find $[OUT]/firm/new NULL
mkdir $[OUT]/firm/new
end
cp -w -n "1:/title/00040138/20000003/content" $[OUT]/firm/new
rm $[OUT]/firm/new/cmd
find $[OUT]/firm/new/*.app APP
decrypt $[APP]
else
if not find $[OUT]/firm/old NULL
mkdir $[OUT]/firm/old
end
cp -w -n "1:/title/00040138/00000003/content" $[OUT]/firm/old
rm $[OUT]/firm/old/cmd
find $[OUT]/firm/old/*.app APP
decrypt $[APP]
end
# === Secret sector (N3DS only)
if chk $[ONTYPE] "N3DS"
cp -w -n "S:/sector0x96.bin" $[OUT]/sector0x96.bin
end
# === System Archives
if not find $[OUT]/sysarchives NULL
mkdir $[OUT]/sysarchives
end
if not find $[OUT]/sysarchives/0004009b NULL
mkdir $[OUT]/sysarchives/0004009b
end
# Mii Data
find 1:/title/0004009b/00010202/content/*.app APP
cp -w -n $[APP] $[OUT]/sysarchives/0004009b/00010202.app
decrypt $[OUT]/sysarchives/0004009b/00010202.app
# Region Manifest
find 1:/title/0004009b/00010402/content/*.app APP
cp -w -n $[APP] $[OUT]/sysarchives/0004009b/00010402.app
decrypt $[OUT]/sysarchives/0004009b/00010402.app
# Shared Font (JPN/EUR/USA)
find 1:/title/0004009b/00014002/content/*.app APP
cp -w -n $[APP] $[OUT]/sysarchives/0004009b/00014002.app
decrypt $[OUT]/sysarchives/0004009b/00014002.app
# Shared Font (CHN)
find 1:/title/0004009b/00014102/content/*.app APP
cp -w -n $[APP] $[OUT]/sysarchives/0004009b/00014102.app
decrypt $[OUT]/sysarchives/0004009b/00014102.app
# Shared Font (KOR)
find 1:/title/0004009b/00014202/content/*.app APP
cp -w -n $[APP] $[OUT]/sysarchives/0004009b/00014202.app
decrypt $[OUT]/sysarchives/0004009b/00014202.app
# Shared Font (TWN)
find 1:/title/0004009b/00014302/content/*.app APP
cp -w -n $[APP] $[OUT]/sysarchives/0004009b/00014302.app
decrypt $[OUT]/sysarchives/0004009b/00014302.app
if not find $[OUT]/sysarchives/000400db NULL
mkdir $[OUT]/sysarchives/000400db
end
# NG Bad word list
find 1:/title/000400db/00010302/content/*.app APP
cp -w -n $[APP] $[OUT]/sysarchives/000400db/00010302.app
decrypt $[OUT]/sysarchives/000400db/00010302.app
# === Config savegame
cp -w -n 1:/data/$[SYSID0]/sysdata/00010017/00000000 $[OUT]/config.sav
# === NAND data
if not find $[OUT]/data NULL
mkdir $[OUT]/data
end
if not find $[OUT]/data/extdata NULL
mkdir $[OUT]/data/extdata
end
cp -w -n "1:/data/$[SYSID0]/extdata" $[OUT]/data/extdata
if not find $[OUT]/data/sysdata NULL
mkdir $[OUT]/data/sysdata
end
cp -w -n "1:/data/$[SYSID0]/sysdata" $[OUT]/data/sysdata
# Already dumped above
rm $[OUT]/data/sysdata/00010017
# === Other system titles
if not find $[OUT]/title NULL
mkdir $[OUT]/title
end
# System Applications
if not find $[OUT]/title/00040010 NULL
mkdir $[OUT]/title/00040010
end
cp -w -n "1:/title/00040010" $[OUT]/title/00040010
# System Data Archives
if not find $[OUT]/title/0004001b NULL
mkdir $[OUT]/title/0004001b
end
cp -w -n "1:/title/0004001b" $[OUT]/title/0004001b
# System Applets
if not find $[OUT]/title/00040030 NULL
mkdir $[OUT]/title/00040030
end
cp -w -n "1:/title/00040030" $[OUT]/title/00040030
# 0004009b Shared Data Archives skipped (included in sysarchives)
# System Data Archives
if not find $[OUT]/title/000400db NULL
mkdir $[OUT]/title/000400db
end
cp -w -n "1:/title/000400db" $[OUT]/title/000400db
# System Modules
if not find $[OUT]/title/00040130 NULL
mkdir $[OUT]/title/00040130
end
cp -w -n "1:/title/00040130" $[OUT]/title/00040130
# 00040138 System Firmware skipped (dumped above)
# Already included in sysarchives
rm $[OUT]/title/000400db/00010302
# === seeddb.bin
sdump -o -s -w seeddb.bin
if not find 0:/gm9/out/seeddb.bin NULL
echo "WARNING: \nseeddb.bin couldn't be built. \nThis may be because your system \ndoes not have any seeds. \nOtherwise, imported games may fail \nto run if they use seed encryption."
else
cp -w -n "0:/gm9/out/seeddb.bin" $[OUT]/seeddb.bin
rm "0:/gm9/out/seeddb.bin"
end
# === Write version
dumptxt $[OUT]/version.txt 4
set PREVIEW_MODE "threeSD Dumper\nby zhaowenlan1779\n \nSuccess!"
echo "Successfully dumped necessary\nfiles for threeSD."
@Exit