Check the PIN before loading a payload.

Also fix some bugs.
This commit is contained in:
TuxSH 2016-08-03 16:58:03 +02:00
parent 709aefba5d
commit e01802e299
2 changed files with 73 additions and 63 deletions

View File

@ -71,7 +71,6 @@ void main(void)
//Attempt to read the configuration file //Attempt to read the configuration file
needConfig = fileRead(&config, configPath) ? MODIFY_CONFIGURATION : CREATE_CONFIGURATION; needConfig = fileRead(&config, configPath) ? MODIFY_CONFIGURATION : CREATE_CONFIGURATION;
bool pinExists = CONFIG(7) && readPin(&pin);
//Determine if this is a firmlaunch boot //Determine if this is a firmlaunch boot
if(*(vu8 *)0x23F00005) if(*(vu8 *)0x23F00005)
@ -127,15 +126,21 @@ void main(void)
} }
} }
//If no configuration file exists or SELECT is held, load configuration menu //Boot options aren't being forced
bool loadConfigurationMenu = needConfig == CREATE_CONFIGURATION || ((pressed & BUTTON_SELECT) && !(pressed & BUTTON_L1)); if(needConfig != DONT_CONFIGURE)
bool needToDeinit = false;
if(CFG_BOOTENV == 0 || loadConfigurationMenu)
{ {
if(loadConfigurationMenu || pinExists) needToDeinit = initScreens(); //If no configuration file exists or SELECT is held, load configuration menu
bool shouldLoadConfigurationMenu = needConfig == CREATE_CONFIGURATION || ((pressed & BUTTON_SELECT) && !(pressed & BUTTON_L1));
bool pinExists = CONFIG(7) && readPin(&pin);
if(pinExists || shouldLoadConfigurationMenu)
{
bool needToDeinit = initScreens();
//If we get here we should check the PIN (if it exists) in all cases
if(pinExists) verifyPin(&pin, true); if(pinExists) verifyPin(&pin, true);
}
if(loadConfigurationMenu) if(shouldLoadConfigurationMenu)
{ {
configureCFW(configPath); configureCFW(configPath);
@ -151,6 +156,7 @@ void main(void)
//Update pressed buttons //Update pressed buttons
pressed = HID_PAD; pressed = HID_PAD;
} }
if(needToDeinit) if(needToDeinit)
{ {
//Turn off backlight //Turn off backlight
@ -158,20 +164,20 @@ void main(void)
deinitScreens(); deinitScreens();
PDN_GPU_CNT = 1; PDN_GPU_CNT = 1;
} }
}
if(isA9lh && !CFG_BOOTENV && pressed == SAFE_MODE) if(isA9lh && !CFG_BOOTENV && pressed == SAFE_MODE)
{ {
nandType = FIRMWARE_SYSNAND; nandType = FIRMWARE_SYSNAND;
firmSource = FIRMWARE_SYSNAND; firmSource = FIRMWARE_SYSNAND;
needConfig = DONT_CONFIGURE;
} }
else
//Boot options aren't being forced
if(needConfig != DONT_CONFIGURE)
{ {
/* If L and R/A/Select or one of the single payload buttons are pressed, /* If L and R/A/Select or one of the single payload buttons are pressed,
chainload an external payload */ chainload an external payload (verify the PIN if needed)*/
if((pressed & SINGLE_PAYLOAD_BUTTONS) || ((pressed & BUTTON_L1) && (pressed & L_PAYLOAD_BUTTONS))) bool shouldLoadPayload = (pressed & SINGLE_PAYLOAD_BUTTONS) || ((pressed & BUTTON_L1) && (pressed & L_PAYLOAD_BUTTONS));
if(shouldLoadPayload)
loadPayload(pressed); loadPayload(pressed);
//If screens are inited or the corresponding option is set, load splash screen //If screens are inited or the corresponding option is set, load splash screen
@ -201,6 +207,7 @@ void main(void)
if(nandType != FIRMWARE_SYSNAND && (CONFIG(2) == !(pressed & BUTTON_B))) nandType = FIRMWARE_EMUNAND2; if(nandType != FIRMWARE_SYSNAND && (CONFIG(2) == !(pressed & BUTTON_B))) nandType = FIRMWARE_EMUNAND2;
} }
} }
}
//If we need to boot emuNAND, make sure it exists //If we need to boot emuNAND, make sure it exists
if(nandType != FIRMWARE_SYSNAND) if(nandType != FIRMWARE_SYSNAND)

View File

@ -30,7 +30,10 @@
#include "types.h" #include "types.h"
#ifndef PIN_LENGTH
#define PIN_LENGTH 4 #define PIN_LENGTH 4
#endif
typedef struct __attribute__((packed)) typedef struct __attribute__((packed))
{ {
char magic[4]; char magic[4];