diff --git a/arm9/source/common/unittype.h b/arm9/source/common/unittype.h index 9a53881..34cf6ac 100644 --- a/arm9/source/common/unittype.h +++ b/arm9/source/common/unittype.h @@ -9,17 +9,10 @@ // see: https://www.3dbrew.org/wiki/OTP_Registers#Plaintext_OTP #define IS_DEVKIT ((*(vu8*) (0x01FFB800+0x19)) != 0x0) -// see: https://3dbrew.org/wiki/CONFIG11_Registers -// (also returns true for sighaxed systems, maybe change the name later?) -#define IS_A9LH ((*(vu32*) 0x101401C0) == 0) - // https://www.3dbrew.org/wiki/CONFIG9_Registers -// (actually checks for an unlocked OTP) +// (actually checks for an unlocked OTP, meaning sighax) #define IS_UNLOCKED (!((*(vu8*)0x10000000) & 0x2)) -// A9LH + unlocked == SigHax -#define IS_SIGHAX (IS_A9LH && IS_UNLOCKED) - // System models enum SystemModel { MODEL_OLD_3DS = 0, diff --git a/arm9/source/filesys/fsperm.c b/arm9/source/filesys/fsperm.c index 89a5ded..f331ba7 100644 --- a/arm9/source/filesys/fsperm.c +++ b/arm9/source/filesys/fsperm.c @@ -49,7 +49,7 @@ bool CheckWritePermissions(const char* path) { for (u32 i = 0; (i < sizeof(path_lvl1) / sizeof(char*)) && (lvl < 1); i++) if (strncasecmp(path, path_lvl1[i], 256) == 0) lvl = 1; } - if (!IS_A9LH) { // changed SysNAND permission levels on non-A9LH + if (!IS_UNLOCKED) { // changed SysNAND permission levels on locked systems if ((drvtype & DRV_CTRNAND) || (lvl == 2)) lvl = 3; } perm = perms[lvl]; @@ -179,7 +179,7 @@ bool SetWritePermissions(u32 perm, bool add_perm) { return false; break; case PERM_SYS_LVL3: - if (!ShowUnlockSequence(6, "!THIS IS YOUR ONLY WARNING!\n \nYou want to enable SysNAND\nlvl3 writing permissions.\n \nThis enables you to OVERWRITE\n%s", IS_SIGHAX ? "your B9S installation and/or\nBRICK your console!" : IS_A9LH ? "your A9LH installation and/or\nBRICK your console!" : "essential system files and/or\nBRICK your console!")) + if (!ShowUnlockSequence(6, "!THIS IS YOUR ONLY WARNING!\n \nYou want to enable SysNAND\nlvl3 writing permissions.\n \nThis enables you to OVERWRITE\nyour bootloader installation,\nessential system files and/or\nBRICK your console!")) return false; break; default: diff --git a/arm9/source/godmode.c b/arm9/source/godmode.c index 5ca3dbf..a2d03ed 100644 --- a/arm9/source/godmode.c +++ b/arm9/source/godmode.c @@ -1037,11 +1037,11 @@ u32 FileHandlerMenu(char* current_path, u32* cursor, u32* scroll, PaneData** pan bool renamable = (FTYPE_RENAMABLE(filetype)); bool trimable = (FTYPE_TRIMABLE(filetype)) && !(drvtype & DRV_VIRTUAL) && !(drvtype & DRV_ALIAS) && !(drvtype & DRV_CTRNAND) && !(drvtype & DRV_TWLNAND) && !(drvtype & DRV_IMAGE); - bool transferable = (FTYPE_TRANSFERABLE(filetype) && IS_A9LH && (drvtype & DRV_FAT)); + bool transferable = (FTYPE_TRANSFERABLE(filetype) && IS_UNLOCKED && (drvtype & DRV_FAT)); bool hsinjectable = (FTYPE_HASCODE(filetype)); bool extrcodeable = (FTYPE_HASCODE(filetype)); bool extrdiffable = (FTYPE_ISDISADIFF(filetype)); - bool restorable = (FTYPE_RESTORABLE(filetype) && IS_A9LH && !(drvtype & DRV_SYSNAND)); + bool restorable = (FTYPE_RESTORABLE(filetype) && IS_UNLOCKED && !(drvtype & DRV_SYSNAND)); bool ebackupable = (FTYPE_EBACKUP(filetype)); bool ncsdfixable = (FTYPE_NCSDFIXABLE(filetype)); bool xorpadable = (FTYPE_XORPAD(filetype)); @@ -2011,7 +2011,7 @@ u32 GodMode(int entrypoint) { u32 last_write_perm = GetWritePermissions(); u32 last_clipboard_size = 0; - bool bootloader = IS_SIGHAX && (entrypoint == ENTRY_NANDBOOT); + bool bootloader = IS_UNLOCKED && (entrypoint == ENTRY_NANDBOOT); bool bootmenu = bootloader && (BOOTMENU_KEY != BUTTON_START) && CheckButton(BOOTMENU_KEY); bool godmode9 = !bootloader; @@ -2030,7 +2030,7 @@ u32 GodMode(int entrypoint) { // get mode string for splash screen const char* disp_mode = NULL; if (bootloader) disp_mode = "bootloader mode\nR+LEFT for menu"; - else if (!IS_SIGHAX && (entrypoint == ENTRY_NANDBOOT)) disp_mode = "oldloader mode"; + else if (!IS_UNLOCKED && (entrypoint == ENTRY_NANDBOOT)) disp_mode = "oldloader mode"; else if (entrypoint == ENTRY_NTRBOOT) disp_mode = "ntrboot mode"; else if (entrypoint == ENTRY_UNKNOWN) disp_mode = "unknown mode"; @@ -2075,7 +2075,7 @@ u32 GodMode(int entrypoint) { } // check internal clock - if (IS_SIGHAX) { // we could actually do this on any entrypoint + if (IS_UNLOCKED) { // we could actually do this on any entrypoint DsTime dstime; get_dstime(&dstime); if ((DSTIMEGET(&dstime, bcd_Y) < 18) && @@ -2619,7 +2619,7 @@ u32 ScriptRunner(int entrypoint) { while (timer_msec( timer ) < 500); // show splash for at least 0.5 sec // you didn't really install a scriptrunner to NAND, did you? - if (IS_SIGHAX && (entrypoint == ENTRY_NANDBOOT)) + if (IS_UNLOCKED && (entrypoint == ENTRY_NANDBOOT)) BootFirmHandler("0:/iderped.firm", false, false); if (PathExist("V:/" VRAM0_AUTORUN_GM9)) { diff --git a/arm9/source/nand/nand.c b/arm9/source/nand/nand.c index 8c06dad..3672568 100644 --- a/arm9/source/nand/nand.c +++ b/arm9/source/nand/nand.c @@ -85,14 +85,10 @@ bool GetOtp0x90(void* otp0x90, u32 len) bool InitNandCrypto(bool init_full) { // part #0: KeyX / KeyY for secret sector 0x96 - // on a9lh this MUST be run before accessing the SHA register in any other way if (IS_UNLOCKED) { // if OTP is unlocked // see: https://www.3dbrew.org/wiki/OTP_Registers sha_quick(OtpSha256, (u8*) __OTP_ADDR, 0x90, SHA256_MODE); Crypto0x96 = true; // valid 100% in that case, others need checking - } else if (IS_A9LH) { // for a9lh - // store the current SHA256 from register - memcpy(OtpSha256, (void*) REG_SHAHASH, 32); } if (!CheckSector0x96Crypto()) { // if all else fails... u8 __attribute__((aligned(32))) otp0x90[0x90]; @@ -168,8 +164,8 @@ bool InitNandCrypto(bool init_full) if (GetNandPartitionInfo(NULL, NP_TYPE_FAT, NP_SUBTYPE_CTR, 0, NAND_SYSNAND) != 0) LoadKeyFromFile(slot0x05KeyY, 0x05, 'Y', NULL); - // part #4: AGBSAVE CMAC KEY (set up on A9LH and SigHax) - if (init_full && (IS_A9LH || IS_SIGHAX)) + // part #4: AGBSAVE CMAC KEY (set up on unlocked systems) + if (init_full && IS_UNLOCKED) LoadKeyFromFile(NULL, 0x24, 'Y', NULL); // part #5: FULL INIT diff --git a/arm9/source/utils/nandutil.c b/arm9/source/utils/nandutil.c index f5ea875..3a85160 100644 --- a/arm9/source/utils/nandutil.c +++ b/arm9/source/utils/nandutil.c @@ -387,8 +387,8 @@ u32 SafeRestoreNandDump(const char* path) { if ((ValidateNandDump(path) != 0) && // NAND dump validation !ShowPrompt(true, "Error: NAND dump is corrupt.\nStill continue?")) return 1; - if (!IS_A9LH) { - ShowPrompt(false, "Error: B9S/A9LH not detected."); + if (!IS_UNLOCKED) { + ShowPrompt(false, "Error: System is locked."); return 1; } if (fvx_stat("S:/essential.exefs", NULL) != FR_OK) { diff --git a/arm9/source/utils/scripting.c b/arm9/source/utils/scripting.c index b7dd0d7..4bba175 100644 --- a/arm9/source/utils/scripting.c +++ b/arm9/source/utils/scripting.c @@ -482,7 +482,7 @@ bool init_vars(const char* path_script) { set_var("NULL", ""); // this one is special and should not be changed later set_var("CURRDIR", curr_dir); // script path, never changes set_var("GM9OUT", OUTPUT_PATH); // output path, never changes - set_var("HAX", IS_SIGHAX ? (isntrboot() ? "ntrboot" : "sighax") : IS_A9LH ? "a9lh" : ""); // type of hax running from + set_var("HAX", IS_UNLOCKED ? (isntrboot() ? "ntrboot" : "sighax") : ""); // type of hax running from set_var("ONTYPE", IS_O3DS ? "O3DS" : "N3DS"); // type of the console set_var("RDTYPE", IS_DEVKIT ? "devkit" : "retail"); // devkit / retail char* ptr = set_var("GM9VER", VERSION); // GodMode9 version, truncated below diff --git a/arm9/source/virtual/vmem.c b/arm9/source/virtual/vmem.c index 3f57e7f..5a18180 100644 --- a/arm9/source/virtual/vmem.c +++ b/arm9/source/virtual/vmem.c @@ -94,7 +94,7 @@ bool ReadVMemDir(VirtualFile* vfile, VirtualDir* vdir) { // uses a generic vdir memcpy(vfile, templates + vdir->index, sizeof(VirtualFile)); // process special flags - if (((vfile->flags & VFLAG_N3DS_EXT) && (IS_O3DS || IS_SIGHAX)) || // this is not on O3DS consoles and locked by sighax + if (((vfile->flags & VFLAG_N3DS_EXT) && (IS_O3DS || IS_UNLOCKED)) || // this is not on O3DS consoles and locked by sighax ((vfile->flags & VFLAG_OTP) && !(IS_UNLOCKED)) || // OTP still locked ((vfile->flags & VFLAG_BOOT9) && !(HAS_BOOT9)) || // boot9 not found ((vfile->flags & VFLAG_BOOT11) && !(HAS_BOOT11)) || // boot11 not found