Minor stuff

This commit is contained in:
Aurora 2016-10-23 18:43:04 +02:00
parent 6b80bc08d5
commit 035751980d
3 changed files with 12 additions and 9 deletions

View File

@ -64,9 +64,10 @@ bool mountFs(bool isSd, bool switchToCtrNand)
u32 fileRead(void *dest, const char *path, u32 maxSize) u32 fileRead(void *dest, const char *path, u32 maxSize)
{ {
FIL file; FIL file;
u32 ret = 0; u32 ret;
if(f_open(&file, path, FA_READ) == FR_OK) if(f_open(&file, path, FA_READ) != FR_OK) ret = 0;
else
{ {
u32 size = f_size(&file); u32 size = f_size(&file);
if(dest == NULL) ret = size; if(dest == NULL) ret = size;
@ -191,11 +192,12 @@ u32 firmRead(void *dest, u32 firmType)
concatenateStrings(path, "/content"); concatenateStrings(path, "/content");
DIR dir; DIR dir;
FILINFO info;
u32 firmVersion = 0xFFFFFFFF; u32 firmVersion = 0xFFFFFFFF;
if(f_opendir(&dir, path) == FR_OK) if(f_opendir(&dir, path) == FR_OK)
{ {
FILINFO info;
//Parse the target directory //Parse the target directory
while(f_readdir(&dir, &info) == FR_OK && info.fname[0] != 0) while(f_readdir(&dir, &info) == FR_OK && info.fname[0] != 0)
{ {
@ -228,12 +230,13 @@ u32 firmRead(void *dest, u32 firmType)
void findDumpFile(const char *path, char *fileName) void findDumpFile(const char *path, char *fileName)
{ {
DIR dir; DIR dir;
FILINFO info;
FRESULT result; FRESULT result;
u32 n = 0; u32 n = 0;
while(n <= 99999999) while(n <= 99999999)
{ {
FILINFO info;
result = f_findfirst(&dir, &info, path, fileName); result = f_findfirst(&dir, &info, path, fileName);
if(result != FR_OK || !info.fname[0]) break; if(result != FR_OK || !info.fname[0]) break;

View File

@ -48,13 +48,13 @@ u8 *getProcess9Info(u8 *pos, u32 size, u32 *process9Size, u32 *process9MemAddr)
u32 *getKernel11Info(u8 *pos, u32 size, u32 *baseK11VA, u8 **freeK11Space, u32 **arm11SvcHandler, u32 **arm11ExceptionsPage) u32 *getKernel11Info(u8 *pos, u32 size, u32 *baseK11VA, u8 **freeK11Space, u32 **arm11SvcHandler, u32 **arm11ExceptionsPage)
{ {
const u8 pattern[] = {0x00, 0xB0, 0x9C, 0xE5}; const u8 pattern[] = {0x00, 0xB0, 0x9C, 0xE5};
bool ret = true; bool res = true;
*arm11ExceptionsPage = (u32 *)memsearch(pos, pattern, size, sizeof(pattern)); *arm11ExceptionsPage = (u32 *)memsearch(pos, pattern, size, sizeof(pattern));
u32 *arm11SvcTable; u32 *arm11SvcTable;
if(*arm11ExceptionsPage == NULL) ret = false; if(*arm11ExceptionsPage == NULL) res = false;
else else
{ {
*arm11ExceptionsPage -= 0xB; *arm11ExceptionsPage -= 0xB;
@ -69,10 +69,10 @@ u32 *getKernel11Info(u8 *pos, u32 size, u32 *baseK11VA, u8 **freeK11Space, u32 *
*freeK11Space = memsearch(pos, pattern2, size, sizeof(pattern2)); *freeK11Space = memsearch(pos, pattern2, size, sizeof(pattern2));
if(*freeK11Space == NULL) ret = false; if(*freeK11Space == NULL) res = false;
else (*freeK11Space)++; else (*freeK11Space)++;
if(!ret) error("Failed to get Kernel11 data."); if(!res) error("Failed to get Kernel11 data.");
return arm11SvcTable; return arm11SvcTable;
} }

View File

@ -50,7 +50,7 @@ void newPin(bool allowSkipping, u32 pinMode)
u8 length = 4 + 2 * (pinMode - 1); u8 length = 4 + 2 * (pinMode - 1);
char *title = allowSkipping ? "Press START to skip or enter a new PIN" : "Enter a new PIN to proceed"; const char *title = allowSkipping ? "Press START to skip or enter a new PIN" : "Enter a new PIN to proceed";
drawString(title, true, 10, 10, COLOR_TITLE); drawString(title, true, 10, 10, COLOR_TITLE);
drawString("PIN ( digits): ", true, 10, 10 + 2 * SPACING_Y, COLOR_WHITE); drawString("PIN ( digits): ", true, 10, 10 + 2 * SPACING_Y, COLOR_WHITE);
drawCharacter('0' + length, true, 10 + 5 * SPACING_X, 10 + 2 * SPACING_Y, COLOR_WHITE); drawCharacter('0' + length, true, 10 + 5 * SPACING_X, 10 + 2 * SPACING_Y, COLOR_WHITE);