Fixed config.bin getting recreated on each boot

This commit is contained in:
Aurora 2016-04-13 01:08:13 +02:00
parent 9e58e4ed7a
commit 89350b1edd
8 changed files with 27 additions and 27 deletions

View File

@ -101,8 +101,7 @@ void configureCFW(const char *configPath)
while(!(pressed & MENU_BUTTONS));
//Remember the previously selected option
static u32 oldSelectedOption;
oldSelectedOption = selectedOption;
u32 oldSelectedOption = selectedOption;
if(pressed != BUTTON_A)
{
@ -126,7 +125,7 @@ void configureCFW(const char *configPath)
continue;
}
//The user moved to a different option, print the old option in white and the new one in white. Only print 'x's if necessary
//The user moved to a different option, print the old option in white and the new one in red. Only print 'x's if necessary
if(oldSelectedOption < multiOptionsAmount)
{
drawString(multiOptionsText[oldSelectedOption], 10, multiOptions[oldSelectedOption].posY, COLOR_WHITE);

View File

@ -324,7 +324,7 @@ u32 ctrNandRead(u32 sector, u32 sectorCount, u8 *outbuf)
//Decrypt
aes_use_keyslot(nandSlot);
aes(outbuf, outbuf, (sectorCount * 0x200) / AES_BLOCK_SIZE, tmpCTR, AES_CTR_MODE, AES_INPUT_BE | AES_INPUT_NORMAL);
aes(outbuf, outbuf, sectorCount * 0x200 / AES_BLOCK_SIZE, tmpCTR, AES_CTR_MODE, AES_INPUT_BE | AES_INPUT_NORMAL);
return result;
}
@ -334,11 +334,11 @@ u32 ctrNandWrite(u32 sector, u32 sectorCount, u8 *inbuf)
{
u8 tmpCTR[0x10];
memcpy(tmpCTR, nandCTR, 0x10);
aes_advctr(tmpCTR, ((sector + fatStart) * 0x200) / AES_BLOCK_SIZE, AES_INPUT_BE | AES_INPUT_NORMAL);
aes_advctr(tmpCTR, (sector + fatStart) * 0x200 / AES_BLOCK_SIZE, AES_INPUT_BE | AES_INPUT_NORMAL);
//Encrypt
aes_use_keyslot(nandSlot);
aes(inbuf, inbuf, (sectorCount * 0x200) / AES_BLOCK_SIZE, tmpCTR, AES_CTR_MODE, AES_INPUT_BE | AES_INPUT_NORMAL);
aes(inbuf, inbuf, sectorCount * 0x200 / AES_BLOCK_SIZE, tmpCTR, AES_CTR_MODE, AES_INPUT_BE | AES_INPUT_NORMAL);
//Write
if(!firmSource)
@ -351,7 +351,7 @@ u32 ctrNandWrite(u32 sector, u32 sectorCount, u8 *inbuf)
//Decrypt a FIRM ExeFS
void decryptExeFs(u8 *inbuf)
{
u32 exeFsOffset = (u32)inbuf + *(u32 *)(inbuf + 0x1A0) * 0x200;
u8 *exeFsOffset = inbuf + *(u32 *)(inbuf + 0x1A0) * 0x200;
u32 exeFsSize = *(u32 *)(inbuf + 0x1A4) * 0x200;
u8 ncchCTR[0x10];
@ -363,7 +363,7 @@ void decryptExeFs(u8 *inbuf)
aes_setkey(0x2C, inbuf, AES_KEYY, AES_INPUT_BE | AES_INPUT_NORMAL);
aes_setiv(ncchCTR, AES_INPUT_BE | AES_INPUT_NORMAL);
aes_use_keyslot(0x2C);
aes(inbuf - 0x200, (void *)exeFsOffset, exeFsSize/AES_BLOCK_SIZE, ncchCTR, AES_CTR_MODE, AES_INPUT_BE | AES_INPUT_NORMAL);
aes(inbuf - 0x200, exeFsOffset, exeFsSize / AES_BLOCK_SIZE, ncchCTR, AES_CTR_MODE, AES_INPUT_BE | AES_INPUT_NORMAL);
}
//ARM9Loader replacement
@ -382,7 +382,7 @@ void arm9Loader(u8 *arm9Section, u32 mode)
u32 arm9BinSize = 0;
//http://stackoverflow.com/questions/12791077/atoi-implementation-in-c
for(u8 *tmp = arm9Section + 0x30; *tmp; tmp++)
arm9BinSize = (arm9BinSize << 3) + (arm9BinSize << 1) + (*tmp) - '0';
arm9BinSize = (arm9BinSize << 3) + (arm9BinSize << 1) + *tmp - '0';
if(mode)
{
@ -415,7 +415,7 @@ void arm9Loader(u8 *arm9Section, u32 mode)
{
aes(decKey, keyData, 1, NULL, AES_ECB_DECRYPT_MODE, 0);
aes_setkey(slot, decKey, AES_KEYX, AES_INPUT_BE | AES_INPUT_NORMAL);
*(keyData + 0xF) += 1;
keyData[0xF] += 1;
}
}
}

View File

@ -58,24 +58,20 @@ void drawCharacter(char character, int posX, int posY, u32 color)
char charPos = font[character * 8 + y];
for(int x = 7; x >= 0; x--)
if ((charPos >> x) & 1)
{
int screenPos = (posX * SCREEN_TOP_HEIGHT * 3 + (SCREEN_TOP_HEIGHT - y - posY - 1) * 3) + (7 - x) * 3 * SCREEN_TOP_HEIGHT;
if ((charPos >> x) & 1)
{
select[screenPos] = color >> 16;
select[screenPos + 1] = color >> 8;
select[screenPos + 2] = color;
}
}
}
}
int drawString(const char *string, int posX, int posY, u32 color)
{
int length = strlen(string);
for(int i = 0, line_i = 0; i < length; i++, line_i++)
for(int i = 0, line_i = 0; i < strlen(string); i++, line_i++)
{
if(string[i] == '\n')
{

View File

@ -173,7 +173,7 @@ void main(void)
/* If the boot configuration is different from previously, overwrite it.
Just the no-forcing flag being set is not enough */
if((newConfig & 0x2F) != (config & 0xFF))
if((newConfig & 0x2F) != (config & 0x3F))
{
//Preserve user settings (first 2 bytes)
newConfig |= config & 0xFFFFFFC0;

View File

@ -15,6 +15,7 @@ u32 mountFs(void)
{
if(f_mount(&sdFs, "0:", 1) != FR_OK) return 0;
f_mount(&nandFs, "1:", 0);
return 1;
}
@ -32,6 +33,7 @@ u32 fileRead(void *dest, const char *path, u32 size)
}
f_close(&fp);
return fr ? 0 : 1;
}
@ -45,6 +47,7 @@ u32 fileWrite(const void *buffer, const char *path, u32 size)
if(fr == FR_OK) fr = f_write(&fp, buffer, size, &br);
f_close(&fp);
return fr ? 0 : 1;
}
@ -57,6 +60,7 @@ u32 fileSize(const char *path)
size = f_size(&fp);
f_close(&fp);
return size;
}
@ -68,6 +72,7 @@ u32 fileExists(const char *path)
if(f_open(&fp, path, FA_READ) == FR_OK) exists = 1;
f_close(&fp);
return exists;
}

View File

@ -12,8 +12,8 @@
u32 waitInput(void)
{
u32 pressedKey = 0;
u32 key;
u32 pressedKey = 0,
key;
//Wait for no keys to be pressed
while(HID_PAD);