Merge branch 'master' into developer

This commit is contained in:
Aurora 2016-08-16 23:10:25 +02:00
commit de3eb6ccd7
6 changed files with 38 additions and 44 deletions

View File

@ -23,11 +23,13 @@
#include "memory.h"
#include "cache.h"
extern u32 payloadSize; //defined in start.s
void main(void)
{
void *payloadAddress = (void *)0x23F00000;
memcpy(payloadAddress, (void*)0x24F00000, *(u32 *)0x24FFFF04);
memcpy(payloadAddress, (void*)0x24F00000, payloadSize);
flushCaches();

View File

@ -24,4 +24,6 @@
_start:
b main
.global payloadSize
payloadSize:
.word 0

View File

@ -27,7 +27,7 @@
void locateEmuNAND(u32 *off, u32 *head, FirmwareSource *emuNAND)
{
static u8 *const temp = (u8 *)0x24300000;
static u8 temp[0x200];
const u32 nandSize = getMMCDevice(0)->total_size;
u32 nandOffset = *emuNAND == FIRMWARE_EMUNAND ? 0 :

View File

@ -34,7 +34,6 @@
#include "screen.h"
#include "buttons.h"
#include "pin.h"
#include "i2c.h"
#include "../build/injector.h"
extern u16 launchedFirmTIDLow[8]; //defined in start.s
@ -49,8 +48,6 @@ bool isN3DS, isDevUnit;
FirmwareSource firmSource;
PINData pin;
void main(void)
{
bool isFirmlaunch,
@ -137,10 +134,12 @@ void main(void)
//Boot options aren't being forced
if(needConfig != DONT_CONFIGURE)
{
PINData pin;
bool pinExists = CONFIG(7) && readPin(&pin);
//If we get here we should check the PIN (if it exists) in all cases
if(pinExists) verifyPin(&pin, true);
if(pinExists) verifyPin(&pin);
//If no configuration file exists or SELECT is held, load configuration menu
bool shouldLoadConfigurationMenu = needConfig == CREATE_CONFIGURATION || ((pressed & BUTTON_SELECT) && !(pressed & BUTTON_L1));
@ -149,7 +148,7 @@ void main(void)
{
configureCFW(configPath);
if(!pinExists && CONFIG(7)) pin = newPin();
if(!pinExists && CONFIG(7)) newPin();
chrono(2);

View File

@ -31,7 +31,6 @@
#include "memory.h"
#include "buttons.h"
#include "fs.h"
#include "i2c.h"
#include "pin.h"
#include "crypto.h"
@ -44,6 +43,7 @@ bool readPin(PINData *out)
if(memcmp(out->magic, "PINF", 4) != 0) return false;
computePINHash(tmp, zeroes, 1);
return memcmp(out->testHash, tmp, 32) == 0; //test vector verification (SD card has (or hasn't) been used on another console)
}
@ -57,7 +57,7 @@ static inline char PINKeyToLetter(u32 pressed)
return keys[31 - i];
}
PINData newPin(void)
void newPin(void)
{
clearScreens();
@ -69,7 +69,7 @@ PINData newPin(void)
u32 cnt = 0;
int charDrawPos = 20 * SPACING_X;
while(true)
while(cnt < PIN_LENGTH)
{
u32 pressed;
do
@ -87,10 +87,8 @@ PINData newPin(void)
// visualize character on screen.
drawCharacter(key, 10 + charDrawPos, 10, COLOR_WHITE);
charDrawPos += 2 * SPACING_X;
}
// we leave the rest of the array zeroed out.
if(cnt >= PIN_LENGTH)
{
PINData pin = {0};
u8 __attribute__((aligned(4))) tmp[32] = {0};
u8 __attribute__((aligned(4))) zeroes[16] = {0};
@ -106,14 +104,11 @@ PINData newPin(void)
memcpy(pin.hash, tmp, 32);
fileWrite(&pin, "/luma/pin.bin", sizeof(PINData));
return pin;
}
}
while(HID_PAD & PIN_BUTTONS);
}
void verifyPin(PINData *in, bool allowQuit)
void verifyPin(PINData *in)
{
initScreens();
@ -124,10 +119,10 @@ void verifyPin(PINData *in, bool allowQuit)
u8 __attribute__((aligned(4))) enteredPassword[16 * ((PIN_LENGTH + 15) / 16)] = {0};
u32 cnt = 0;
bool unlock;
bool unlock = false;
int charDrawPos = 5 * SPACING_X;
while(true)
while(!unlock)
{
u32 pressed;
do
@ -136,8 +131,8 @@ void verifyPin(PINData *in, bool allowQuit)
}
while(!(pressed & PIN_BUTTONS));
pressed &= PIN_BUTTONS;// & ~BUTTON_START;
if(!allowQuit) pressed &= ~BUTTON_START;
pressed &= PIN_BUTTONS & ~BUTTON_START;
if(!pressed) continue;
if(pressed & BUTTON_START) mcuPowerOff();
@ -167,7 +162,6 @@ void verifyPin(PINData *in, bool allowQuit)
drawString("Pin: ", 10, 10 + 2 * SPACING_Y, COLOR_WHITE);
drawString("Wrong pin! Try again!", 10, 10 + 3 * SPACING_Y, COLOR_RED);
}
else break;
}
}
}

View File

@ -30,9 +30,7 @@
#include "types.h"
#ifndef PIN_LENGTH
#define PIN_LENGTH 4
#endif
#define PIN_LENGTH 4
typedef struct __attribute__((packed))
{
@ -44,6 +42,5 @@ typedef struct __attribute__((packed))
} PINData;
bool readPin(PINData* out);
PINData newPin(void);
void verifyPin(PINData *in, bool allowQuit);
void newPin(void);
void verifyPin(PINData *in);