From 7ea87f3bd52142a03660c5df27d5d6d4df604ecd Mon Sep 17 00:00:00 2001 From: Pk11 Date: Sat, 30 Apr 2022 14:54:25 -0500 Subject: [PATCH] Only blacklist system titles from console region --- arm9/src/install.c | 6 +++++- arm9/src/main.c | 5 ++++- arm9/src/main.h | 1 + arm9/src/titlemenu.c | 48 +++++++++++++++++++++++++++++++++----------- 4 files changed, 46 insertions(+), 14 deletions(-) diff --git a/arm9/src/install.c b/arm9/src/install.c index f643b57..7cfdb79 100644 --- a/arm9/src/install.c +++ b/arm9/src/install.c @@ -432,7 +432,11 @@ bool install(char* fpath, bool systemTitle) )) || (h->tid_high == 0x00030015 && ( tidLow == 0x484e4200 || // System Settings tidLow == 0x484e4600 // Nintendo DSi Shop - )))) + ))) && ( + (h->tid_low & 0xFF) == region || //only blacklist console region + (h->tid_low & 0xFF) == 'A' || //and 'A' (all region) + region == 0 //if the region check failed somehow, blacklist everything + )) { iprintf("\x1B[31m"); //red iprintf("Error: "); diff --git a/arm9/src/main.c b/arm9/src/main.c index 663bed3..fcf9219 100644 --- a/arm9/src/main.c +++ b/arm9/src/main.c @@ -12,6 +12,7 @@ bool unlaunchFound = false; bool arm7Exiting = false; bool charging = false; u8 batteryLevel = 0; +u8 region = 0; PrintConsole topScreen; PrintConsole bottomScreen; @@ -142,7 +143,7 @@ int main(int argc, char **argv) return 0; } - //check for unlaunch + //check for unlaunch and region { FILE *file = fopen("nand:/sys/HWINFO_S.dat", "rb"); if (file) @@ -152,6 +153,8 @@ int main(int argc, char **argv) fread(&launcherTid, sizeof(u32), 1, file); fclose(file); + region = launcherTid & 0xFF; + char path[64]; sprintf(path, "nand:/title/00030017/%08lx/content/title.tmd", launcherTid); unsigned long long tmdSize = getFileSizePath(path); diff --git a/arm9/src/main.h b/arm9/src/main.h index 739961f..8f8265a 100644 --- a/arm9/src/main.h +++ b/arm9/src/main.h @@ -10,6 +10,7 @@ extern bool sdnandMode; extern bool unlaunchFound; extern bool charging; extern u8 batteryLevel; +extern u8 region; void installMenu(); void titleMenu(); diff --git a/arm9/src/titlemenu.c b/arm9/src/titlemenu.c index 7b1a0cc..0967d90 100644 --- a/arm9/src/titlemenu.c +++ b/arm9/src/titlemenu.c @@ -95,6 +95,25 @@ static void generateList(Menu* m) "00030015" }; + const char* blacklist[3][6] = { + { // 00030004 + NULL //nothing blacklisted + }, + { // 00030005 + "484e44", // DS Download Play + "484e45", // PictoChat + "484e49", // Nintendo DSi Camera + "484e4a", // Nintendo Zone + "484e4b", // Nintendo DSi Sound + NULL + }, + { // 00030015 + "484e42", // System Settings + "484e46", // Nintendo DSi Shop + NULL + } + }; + //Reset menu clearMenu(m); @@ -121,19 +140,24 @@ static void generateList(Menu* m) continue; //blacklisted titles - if (!sdnandMode && ( - (i == 1 && ( - strncmp(ent->d_name, "484e44", 6) == 0 || // DS Download Play - strncmp(ent->d_name, "484e45", 6) == 0 || // PictoChat - strncmp(ent->d_name, "484e49", 6) == 0 || // Nintendo DSi Camera - strncmp(ent->d_name, "484e4a", 6) == 0 || // Nintendo Zone - strncmp(ent->d_name, "484e4b", 6) == 0 // Nintendo DSi Sound - )) || (i == 2 && ( - strncmp(ent->d_name, "484e42", 6) == 0 || // System Settings - strncmp(ent->d_name, "484e46", 6) == 0 // Nintendo DSi Shop - )))) + if (!sdnandMode) { - continue; + //if the region check somehow failed blacklist all-non DSiWare + if (region == 0 && i > 0) continue; + + bool blacklisted = false; + for (int j = 0; blacklist[i][j] != NULL; j++) + { + char titleId[9]; + sprintf(titleId, "%s%02x", blacklist[i][j], region); + if (strcmp(titleId, ent->d_name) == 0) + blacklisted = true; + + sprintf(titleId, "%s41", blacklist[i][j]); // also blacklist region 'a' + if (strcmp(titleId, ent->d_name) == 0) + blacklisted = true; + } + if (blacklisted) continue; } if (ent->d_type == DT_DIR)