Skip to content

Commit

Permalink
booter_fc: work around the R4i-SDHC protection scheme (#1961)
Browse files Browse the repository at this point in the history
One of many of Taiju Yamada (nee Xenon++)'s tools included a small patcher
to work around the protection within the R4i-SDHC firmware.

As a result of this patcher, the entry address had to be changed to 0x02000450.
Fortunately, our Acekard 2 booter uses a 0x02000450 entry address, so it is
reused here.
  • Loading branch information
lifehackerhansol authored Jul 8, 2022
1 parent de43f8d commit 4d105f7
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 6 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ jobs:
- name: Install tools
run: |
sudo apt-get update
sudo apt-get install p7zip-full python -y
sudo apt-get install p7zip-full python gcc -y
gcc -o booter_fc/flashcart_specifics/r4isdhc/r4isdhc booter_fc/flashcart_specifics/r4isdhc/r4isdhc.c
chmod +x booter_fc/flashcart_specifics/r4isdhc/r4isdhc
- name: Get manual pages
run: |
cd manual/nitrofiles
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ jobs:
- name: Install tools
run: |
sudo apt-get update
sudo apt-get install jq p7zip-full python -y
sudo apt-get install jq p7zip-full python gcc -y
gcc -o booter_fc/flashcart_specifics/r4isdhc/r4isdhc booter_fc/flashcart_specifics/r4isdhc/r4isdhc.c
chmod +x booter_fc/flashcart_specifics/r4isdhc/r4isdhc
- name: Get manual pages
run: |
cd manual/nitrofiles
Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ ipch/
7zfile/Flashcard users/Autoboot/R4i SDHC Upgrade Revolution (www.r4i-dshc.com), R4i 3DS (v4.3 kernel) & R4i YES
7zfile/Flashcard users/Autoboot/R4i Upgrade Revolution
7zfile/Flashcard users/Autoboot/R4i-REDANT
7zfile/Flashcard users/Autoboot/R4i-SDHC, r4isdhc.com cards 2014+, R4i SDHC Upgrade Revolution, R4DSiXL3D, R4i Advance, R4-IIIi, R4 SDHC Revolution, R4(i) Pocket, R4i Gold (v1.4.1) (3DS) & R4xDS/_BOOT_DS.NDS
7zfile/Flashcard users/Autoboot/R4i-SDHC, r4isdhc.com cards 2014+, R4i SDHC Upgrade Revolution, R4DSiXL3D, R4i Advance, R4-IIIi, R4 SDHC Revolution, R4(i) Pocket, R4i Gold (v1.4.1) (3DS) & R4xDS/TTMenu.dat
7zfile/Flashcard users/Autoboot/R4i-SDHC, r4isdhc.com cards 2014+, R4i SDHC Upgrade Revolution, R4DSiXL3D, R4i Advance, R4-IIIi, R4 SDHC Revolution, R4(i) Pocket, R4i Gold (v1.4.1) (3DS) & R4xDS
7zfile/Flashcard users/Autoboot/R4iDSN
7zfile/Flashcard users/Autoboot/R4IIISDHC (v3.07 kernel), R4i SDHC Silver RTS Lite, R4iTT v1.6
7zfile/Flashcard users/Autoboot/R4iTT 3DS, R4i3D 2012+, r4isdhc.com NEW, r4isdhc.com 2013, r4isdhc.hk cards 2013-2019, r4igold.cc 3DS, r4i-gold.me 2013+
Expand Down
Binary file not shown.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ You can help translate TWiLight Menu++ on the [Crowdin project](https://crowdin.
- [Rocket Robz](https://github.com/RocketRobz): Fixing some DS⁽ⁱ⁾-Enhanced game AP-patches for DS⁽ⁱ⁾ mode compatibility
- fintogive, RadDude McCoolguy, KazoWAR, Vague Rant, [gamemasterplc](https://github.com/gamemasterplc), [Rocket Robz](https://github.com/RocketRobz), [ChampionLeake](https://github.com/ChampionLeake), [DeadSkullzJr](https://github.com/DeadSkullzJr), [spellboundtriangle](https://github.com/spellboundtriangle), [LedyBacer](https://github.com/LedyBacer): Widescreen Cheats
- [chishm](https://github.com/chishm): [tuna-viDS](https://github.com/chishm/tuna-vids) for Xvid video playback
- Taiju Yamada: code used to bypass R4i-SDHC boot file protection
## Translators
- Arabic: [Ken Brown](https://crowdin.com/profile/kenkenkenneth), [SLG3](https://crowdin.com/profile/slg3)
- Bulgarian: [Peter0x44](https://github.com/Peter0x44), [Tescu](https://crowdin.com/profile/tescu48)
Expand Down
11 changes: 9 additions & 2 deletions booter_fc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ autoboot:
mv bootme.nds "../7zfile/Flashcard users/Autoboot/Games N Music/Non-SDHC/bootme.nds"

#### DSTT and its (many) clones
cp booter_fc.nds TTMenu.dat
cp booter_acekard2.nds TTMenu.dat
dlditool flashcart_specifics/DLDI/DSTTDLDIboyakkeyver.dldi TTMenu.dat

mkdir -p "../7zfile/Flashcard users/Autoboot/DSTT, DSTTi, DSTTi Gold, DSTT-Advance, R4Top Revolution, & R4i-SDHC v1.41 + v1.42/"
Expand Down Expand Up @@ -222,7 +222,14 @@ autoboot:
cp TTMenu.dat "../7zfile/Flashcard users/Autoboot/R4i DSi XL & R4V-R4i v2.2 + v2.5/iLL.iL"
cp TTMenu.dat "../7zfile/Flashcard users/Autoboot/R4i DSi XL & R4V-R4i v2.2 + v2.5/TTMenu.dat"

cp TTMenu.dat "../7zfile/Flashcard users/Autoboot/R4i-SDHC, r4isdhc.com cards 2014+, R4i SDHC Upgrade Revolution, R4DSiXL3D, R4i Advance, R4-IIIi, R4 SDHC Revolution, R4(i) Pocket, R4i Gold (v1.4.1) (3DS) & R4xDS/_BOOT_DS.NDS"
# R4i-SDHC has funny protection. Defeat it.
ndstool -x TTMenu.dat -9 arm9.bin -7 arm7.bin -t banner.bin -h header.bin
./flashcart_specifics/r4isdhc/r4isdhc arm9.bin new9.bin
ndstool -c R4.dat -9 new9.bin -7 arm7.bin -t banner.bin -h header.bin -r9 0x02000000
rm -rf new9.bin arm9.bin arm7.bin banner.bin header.bin
mkdir -p "../7zfile/Flashcard users/Autoboot/R4i-SDHC, r4isdhc.com cards 2014+, R4i SDHC Upgrade Revolution, R4DSiXL3D, R4i Advance, R4-IIIi, R4 SDHC Revolution, R4(i) Pocket, R4i Gold (v1.4.1) (3DS) & R4xDS/"
mv R4.dat "../7zfile/Flashcard users/Autoboot/R4i-SDHC, r4isdhc.com cards 2014+, R4i SDHC Upgrade Revolution, R4DSiXL3D, R4i Advance, R4-IIIi, R4 SDHC Revolution, R4(i) Pocket, R4i Gold (v1.4.1) (3DS) & R4xDS/R4.dat"
## For YSMenu softreset, use the original TTMenu.dat
cp TTMenu.dat "../7zfile/Flashcard users/Autoboot/R4i-SDHC, r4isdhc.com cards 2014+, R4i SDHC Upgrade Revolution, R4DSiXL3D, R4i Advance, R4-IIIi, R4 SDHC Revolution, R4(i) Pocket, R4i Gold (v1.4.1) (3DS) & R4xDS/TTMenu.dat"

mkdir -p "../7zfile/Flashcard users/Autoboot/R4 Deluxe v1.20/"
Expand Down
39 changes: 39 additions & 0 deletions booter_fc/flashcart_specifics/r4isdhc/r4isdhc.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// This file is licensed CC0-1.0 by Taiju Yamada.

#include <stdio.h>
#include <string.h>

// arbitrary number. Don't know if this can be changed, because other converters of this type uses this value too... -lifehackerhansol
#define S 433264

#define BUFLEN (1<<19)

int main(int argc, char **argv) {
int size = S - 0x450, u;
if(argc < 3) {
fprintf(stderr, "r4isdhc in out\n");
return 1;
}
FILE* in = fopen(argv[1], "rb");
if(!in) {
fprintf(stderr, "cannot open\n");
return 2;
}
FILE* out = fopen(argv[2], "wb");
if(!out) {
fclose(in);
fprintf(stderr, "cannot open\n");
return 3;
}
unsigned char buf[BUFLEN];
memset(buf, 0, 0x450);
buf[0] = 0x12, buf[1] = 0x01, buf[2] = 0x00, buf[3] = 0xea;
buf[0xec] = 0x49, buf[0xed] = 0x00, buf[0xee] = 0x00, buf[0xef] = 0xeb;
fwrite(buf, 1, 0x450, out);
while(u = fread(buf, 1, BUFLEN, in)) fwrite(buf, 1, u, out), size-=u;
fclose(in);
memset(buf, 0, BUFLEN);
while(size > 0) fwrite(buf, 1, size < BUFLEN ? size : BUFLEN, out), size -= BUFLEN;
fclose(out);
return 0;
}

0 comments on commit 4d105f7

Please sign in to comment.