Extended write permission system for A9LH regions

This commit is contained in:
d0k3 2016-07-01 01:38:57 +02:00
parent c4d2ffff90
commit 93153f010e
5 changed files with 25 additions and 17 deletions

View File

@ -92,6 +92,12 @@ bool CheckWritePermissions(const char* path) {
} else if (((pdrv >= 1) && (pdrv <= 3)) || (GetVirtualSource(path) == VRT_SYSNAND)) { } else if (((pdrv >= 1) && (pdrv <= 3)) || (GetVirtualSource(path) == VRT_SYSNAND)) {
perm = PERM_SYSNAND; perm = PERM_SYSNAND;
snprintf(area_name, 16, "the 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)) { } else if (((pdrv >= 4) && (pdrv <= 6)) || (GetVirtualSource(path) == VRT_EMUNAND)) {
perm = PERM_EMUNAND; perm = PERM_EMUNAND;
snprintf(area_name, 16, "the 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.")) if (!ShowUnlockSequence(1, "You want to enable RAM drive\nwriting permissions."))
return false; return false;
case PERM_EMUNAND: case PERM_EMUNAND:
if (!ShowUnlockSequence(2, "You want to enable EmuNAND\nwriting permissions.\nKeep backups, just in case."))
return false; return false;
break; break;
case PERM_IMAGE: 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; return false;
break; break;
#ifndef SAFEMODE #ifndef SAFEMODE
case PERM_SYSNAND: 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; return false;
break; break;
case PERM_MEMORY: case PERM_MEMORY:
@ -152,7 +161,7 @@ bool SetWritePermissions(u32 perm, bool add_perm) {
return false; return false;
break; break;
case PERM_ALL: 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; return false;
break; break;
default: default:
@ -418,9 +427,6 @@ bool PathCopyVirtual(const char* destdir, const char* orig) {
ShowPrompt(false, "Origin equals destination:\n%s\n%s", origstr, deststr); ShowPrompt(false, "Origin equals destination:\n%s\n%s", origstr, deststr);
return false; 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 if ((dvfile.keyslot == ovfile.keyslot) && (dvfile.offset == ovfile.offset)) // this improves copy times
dvfile.keyslot = ovfile.keyslot = 0xFF; dvfile.keyslot = ovfile.keyslot = 0xFF;
@ -459,9 +465,6 @@ bool PathCopyVirtual(const char* destdir, const char* orig) {
} }
TruncateString(deststr, dest, 36, 8); 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) { if (dvfile.size != osize) {
char osizestr[32]; char osizestr[32];
char dsizestr[32]; char dsizestr[32];

View File

@ -17,6 +17,7 @@ typedef enum {
#define PERM_SYSNAND (1<<3) #define PERM_SYSNAND (1<<3)
#define PERM_IMAGE (1<<4) #define PERM_IMAGE (1<<4)
#define PERM_MEMORY (1<<5) #define PERM_MEMORY (1<<5)
#define PERM_A9LH ((1<<6) | PERM_SYSNAND)
#define PERM_BASE (PERM_SDCARD | PERM_RAMDRIVE) #define PERM_BASE (PERM_SDCARD | PERM_RAMDRIVE)
#define PERM_ALL (PERM_SDCARD | PERM_RAMDRIVE | PERM_EMUNAND | PERM_SYSNAND | PERM_IMAGE | PERM_MEMORY) #define PERM_ALL (PERM_SDCARD | PERM_RAMDRIVE | PERM_EMUNAND | PERM_SYSNAND | PERM_IMAGE | PERM_MEMORY)

View File

@ -7,14 +7,14 @@
#include "virtual.h" #include "virtual.h"
#include "image.h" #include "image.h"
#define VERSION "0.5.6" #define VERSION "0.5.7"
#define N_PANES 2 #define N_PANES 2
#define IMG_DRV "789I" #define IMG_DRV "789I"
#define WORK_BUFFER ((u8*)0x21100000) #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_SIDE_BAR COLOR_DARKGREY
#define COLOR_MARKED COLOR_TINTEDYELLOW #define COLOR_MARKED COLOR_TINTEDYELLOW
#define COLOR_FILE COLOR_TINTEDGREEN #define COLOR_FILE COLOR_TINTEDGREEN

View File

@ -214,20 +214,23 @@ bool ShowPrompt(bool ask, const char *format, ...)
} }
bool ShowUnlockSequence(u32 seqlvl, 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 int seqcolors[6] = { COLOR_STD_FONT, COLOR_BRIGHTGREEN, COLOR_BRIGHTYELLOW,
const u32 sequences[5][5] = { COLOR_RED, COLOR_BRIGHTBLUE, COLOR_DARKRED };
const u32 sequences[6][5] = {
{ BUTTON_RIGHT, BUTTON_DOWN, BUTTON_RIGHT, BUTTON_DOWN, BUTTON_A }, { BUTTON_RIGHT, BUTTON_DOWN, BUTTON_RIGHT, BUTTON_DOWN, BUTTON_A },
{ BUTTON_LEFT, BUTTON_DOWN, BUTTON_RIGHT, BUTTON_UP, 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_RIGHT, BUTTON_DOWN, BUTTON_UP, BUTTON_A },
{ BUTTON_LEFT, BUTTON_UP, BUTTON_RIGHT, 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' }, { '\x1A', '\x19', '\x1A', '\x19', 'A' },
{ '\x1B', '\x19', '\x1A', '\x18', 'A' }, { '\x1B', '\x19', '\x1A', '\x18', 'A' },
{ '\x1B', '\x1A', '\x19', '\x18', 'A' }, { '\x1B', '\x1A', '\x19', '\x18', 'A' },
{ '\x1B', '\x18', '\x1A', '\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; const u32 len = 5;
u32 lvl = 0; u32 lvl = 0;

View File

@ -24,6 +24,7 @@
#define COLOR_CYAN RGB(0xFF, 0x00, 0xFF) #define COLOR_CYAN RGB(0xFF, 0x00, 0xFF)
#define COLOR_BRIGHTRED RGB(0xFF, 0x30, 0x30) #define COLOR_BRIGHTRED RGB(0xFF, 0x30, 0x30)
#define COLOR_DARKRED RGB(0x80, 0x00, 0x00)
#define COLOR_BRIGHTYELLOW RGB(0xFF, 0xFF, 0x30) #define COLOR_BRIGHTYELLOW RGB(0xFF, 0xFF, 0x30)
#define COLOR_BRIGHTGREEN RGB(0x30, 0xFF, 0x30) #define COLOR_BRIGHTGREEN RGB(0x30, 0xFF, 0x30)
#define COLOR_BRIGHTBLUE RGB(0x30, 0x30, 0xFF) #define COLOR_BRIGHTBLUE RGB(0x30, 0x30, 0xFF)