From 93153f010e0b4ec77ea157157d8f2aed9c9e527c Mon Sep 17 00:00:00 2001 From: d0k3 Date: Fri, 1 Jul 2016 01:38:57 +0200 Subject: [PATCH] Extended write permission system for A9LH regions --- source/fs.c | 23 +++++++++++++---------- source/fs.h | 1 + source/godmode.c | 4 ++-- source/ui.c | 13 ++++++++----- source/ui.h | 1 + 5 files changed, 25 insertions(+), 17 deletions(-) diff --git a/source/fs.c b/source/fs.c index c2a7a07..8ad3475 100644 --- a/source/fs.c +++ b/source/fs.c @@ -92,6 +92,12 @@ bool CheckWritePermissions(const char* path) { } else if (((pdrv >= 1) && (pdrv <= 3)) || (GetVirtualSource(path) == VRT_SYSNAND)) { perm = PERM_SYSNAND; snprintf(area_name, 16, "the SysNAND"); + // check virtual file flags (if any) + VirtualFile vfile; + if (FindVirtualFile(&vfile, path, 0) && (vfile.flags & VFLAG_A9LH_AREA)) { + perm = PERM_A9LH; + snprintf(area_name, 16, "A9LH regions"); + } } else if (((pdrv >= 4) && (pdrv <= 6)) || (GetVirtualSource(path) == VRT_EMUNAND)) { perm = PERM_EMUNAND; snprintf(area_name, 16, "the EmuNAND"); @@ -135,16 +141,19 @@ bool SetWritePermissions(u32 perm, bool add_perm) { if (!ShowUnlockSequence(1, "You want to enable RAM drive\nwriting permissions.")) return false; case PERM_EMUNAND: - if (!ShowUnlockSequence(2, "You want to enable EmuNAND\nwriting permissions.\nKeep backups, just in case.")) return false; break; case PERM_IMAGE: - if (!ShowUnlockSequence(2, "You want to enable image\nwriting permissions.\nKeep backups, just in case.")) + if (!ShowUnlockSequence(2, "You want to enable image\nwriting permissions.")) return false; break; #ifndef SAFEMODE case PERM_SYSNAND: - if (!ShowUnlockSequence(3, "!This is your only warning!\n \nYou want to enable SysNAND\nwriting permissions.\nThis enables you to do some\nreally dangerous stuff!\nHaving a SysNAND backup and\nNANDmod is recommended.")) + if (!ShowUnlockSequence(3, "!Better be careful!\n \nYou want to enable SysNAND\nwriting permissions.\nThis enables you to do some\nreally dangerous stuff!")) + return false; + break; + case PERM_A9LH: + if (!ShowUnlockSequence(5, "!THIS IS YOUR ONLY WARNING!\n \nYou want to enable A9LH area\nwriting permissions.\nThis enables you to OVERWRITE\nyour A9LH installation!")) return false; break; case PERM_MEMORY: @@ -152,7 +161,7 @@ bool SetWritePermissions(u32 perm, bool add_perm) { return false; break; case PERM_ALL: - if (!ShowUnlockSequence(3, "!This is your only warning!\n \nYou want to enable ALL\nwriting permissions.\nThis enables you to do some\nreally dangerous stuff!\nHaving a SysNAND backup and\nNANDmod is recommended.")) + if (!ShowUnlockSequence(3, "!Better be careful!\n \nYou want to enable ALL\nwriting permissions.\nThis enables you to do some\nreally dangerous stuff!")) return false; break; default: @@ -418,9 +427,6 @@ bool PathCopyVirtual(const char* destdir, const char* orig) { ShowPrompt(false, "Origin equals destination:\n%s\n%s", origstr, deststr); return false; } - if ((dvfile.flags & VFLAG_A9LH_AREA) && // check A9LH critical area - !ShowPrompt(true, "This is critical for A9LH:\n%s\nProceed writing to it?", deststr)) - return false; if ((dvfile.keyslot == ovfile.keyslot) && (dvfile.offset == ovfile.offset)) // this improves copy times dvfile.keyslot = ovfile.keyslot = 0xFF; @@ -459,9 +465,6 @@ bool PathCopyVirtual(const char* destdir, const char* orig) { } TruncateString(deststr, dest, 36, 8); } - if ((dvfile.flags & VFLAG_A9LH_AREA) && // check A9LH critical area - !ShowPrompt(true, "This is critical for A9LH:\n%s\nProceed writing to it?", deststr)) - return false; if (dvfile.size != osize) { char osizestr[32]; char dsizestr[32]; diff --git a/source/fs.h b/source/fs.h index 3a83935..6975455 100644 --- a/source/fs.h +++ b/source/fs.h @@ -17,6 +17,7 @@ typedef enum { #define PERM_SYSNAND (1<<3) #define PERM_IMAGE (1<<4) #define PERM_MEMORY (1<<5) +#define PERM_A9LH ((1<<6) | PERM_SYSNAND) #define PERM_BASE (PERM_SDCARD | PERM_RAMDRIVE) #define PERM_ALL (PERM_SDCARD | PERM_RAMDRIVE | PERM_EMUNAND | PERM_SYSNAND | PERM_IMAGE | PERM_MEMORY) diff --git a/source/godmode.c b/source/godmode.c index f28b24e..1dca245 100644 --- a/source/godmode.c +++ b/source/godmode.c @@ -7,14 +7,14 @@ #include "virtual.h" #include "image.h" -#define VERSION "0.5.6" +#define VERSION "0.5.7" #define N_PANES 2 #define IMG_DRV "789I" #define WORK_BUFFER ((u8*)0x21100000) -#define COLOR_TOP_BAR ((GetWritePermissions() & PERM_SYSNAND) ? COLOR_RED : (GetWritePermissions() & PERM_MEMORY) ? COLOR_BRIGHTBLUE : (GetWritePermissions() & (PERM_EMUNAND|PERM_IMAGE)) ? COLOR_BRIGHTYELLOW : GetWritePermissions() ? COLOR_BRIGHTGREEN : COLOR_WHITE) +#define COLOR_TOP_BAR ((GetWritePermissions() & (PERM_A9LH&~PERM_SYSNAND)) ? COLOR_DARKRED : (GetWritePermissions() & PERM_SYSNAND) ? COLOR_RED : (GetWritePermissions() & PERM_MEMORY) ? COLOR_BRIGHTBLUE : (GetWritePermissions() & (PERM_EMUNAND|PERM_IMAGE)) ? COLOR_BRIGHTYELLOW : GetWritePermissions() ? COLOR_BRIGHTGREEN : COLOR_WHITE) #define COLOR_SIDE_BAR COLOR_DARKGREY #define COLOR_MARKED COLOR_TINTEDYELLOW #define COLOR_FILE COLOR_TINTEDGREEN diff --git a/source/ui.c b/source/ui.c index 0c16a7c..8c6eedb 100644 --- a/source/ui.c +++ b/source/ui.c @@ -214,20 +214,23 @@ bool ShowPrompt(bool ask, const char *format, ...) } bool ShowUnlockSequence(u32 seqlvl, const char *format, ...) { - const int seqcolors[5] = { COLOR_STD_FONT, COLOR_BRIGHTGREEN, COLOR_BRIGHTYELLOW, COLOR_RED, COLOR_BRIGHTBLUE }; - const u32 sequences[5][5] = { + const int seqcolors[6] = { COLOR_STD_FONT, COLOR_BRIGHTGREEN, COLOR_BRIGHTYELLOW, + COLOR_RED, COLOR_BRIGHTBLUE, COLOR_DARKRED }; + const u32 sequences[6][5] = { { BUTTON_RIGHT, BUTTON_DOWN, BUTTON_RIGHT, BUTTON_DOWN, BUTTON_A }, { BUTTON_LEFT, BUTTON_DOWN, BUTTON_RIGHT, BUTTON_UP, BUTTON_A }, { BUTTON_LEFT, BUTTON_RIGHT, BUTTON_DOWN, BUTTON_UP, BUTTON_A }, { BUTTON_LEFT, BUTTON_UP, BUTTON_RIGHT, BUTTON_UP, BUTTON_A }, - { BUTTON_RIGHT, BUTTON_DOWN, BUTTON_LEFT, BUTTON_DOWN, BUTTON_A } + { BUTTON_RIGHT, BUTTON_DOWN, BUTTON_LEFT, BUTTON_DOWN, BUTTON_A }, + { BUTTON_DOWN, BUTTON_LEFT, BUTTON_UP, BUTTON_LEFT, BUTTON_A } }; - const char seqsymbols[5][5] = { + const char seqsymbols[6][5] = { { '\x1A', '\x19', '\x1A', '\x19', 'A' }, { '\x1B', '\x19', '\x1A', '\x18', 'A' }, { '\x1B', '\x1A', '\x19', '\x18', 'A' }, { '\x1B', '\x18', '\x1A', '\x18', 'A' }, - { '\x1A', '\x19', '\x1B', '\x19', 'A' } + { '\x1A', '\x19', '\x1B', '\x19', 'A' }, + { '\x19', '\x1B', '\x18', '\x1B', 'A' } }; const u32 len = 5; u32 lvl = 0; diff --git a/source/ui.h b/source/ui.h index 311750f..25fa82b 100644 --- a/source/ui.h +++ b/source/ui.h @@ -24,6 +24,7 @@ #define COLOR_CYAN RGB(0xFF, 0x00, 0xFF) #define COLOR_BRIGHTRED RGB(0xFF, 0x30, 0x30) +#define COLOR_DARKRED RGB(0x80, 0x00, 0x00) #define COLOR_BRIGHTYELLOW RGB(0xFF, 0xFF, 0x30) #define COLOR_BRIGHTGREEN RGB(0x30, 0xFF, 0x30) #define COLOR_BRIGHTBLUE RGB(0x30, 0x30, 0xFF)