Fixed loading the alternate EmuNAND if 9.0 FIRM was set as default, improved comments and further cleanup of the injector
This commit is contained in:
parent
c80ac985fe
commit
f4c48a64ca
@ -146,15 +146,6 @@ u32 patch_code(u64 progid, u8 *code, u32 size){
|
|||||||
static const u8 blockEShopUpdateCheckPatch[] = {
|
static const u8 blockEShopUpdateCheckPatch[] = {
|
||||||
0x00, 0x20, 0x08, 0x60, 0x70, 0x47
|
0x00, 0x20, 0x08, 0x60, 0x70, 0x47
|
||||||
};
|
};
|
||||||
static const u8 countryRespPattern[] = {
|
|
||||||
0x01, 0x20, 0x01, 0x90, 0x22, 0x46, 0x06, 0x9B
|
|
||||||
};
|
|
||||||
static const char countryRespPatchModel[] = {
|
|
||||||
0x06, 0x9A, 0x03, 0x20, 0x90, 0x47, 0x55, 0x21, 0x01, 0x70, 0x53, 0x21, 0x41, 0x70, 0x00, 0x21,
|
|
||||||
0x81, 0x70, 0x60, 0x61, 0x00, 0x20
|
|
||||||
};
|
|
||||||
const char *country;
|
|
||||||
char countryRespPatch[sizeof(countryRespPatchModel)];
|
|
||||||
|
|
||||||
patch_memory(code, size,
|
patch_memory(code, size,
|
||||||
blockAutoUpdatesPattern,
|
blockAutoUpdatesPattern,
|
||||||
@ -168,7 +159,18 @@ u32 patch_code(u64 progid, u8 *code, u32 size){
|
|||||||
blockEShopUpdateCheckPatch,
|
blockEShopUpdateCheckPatch,
|
||||||
sizeof(blockEShopUpdateCheckPatch), 1
|
sizeof(blockEShopUpdateCheckPatch), 1
|
||||||
);
|
);
|
||||||
|
|
||||||
if(R_SUCCEEDED(load_secureinfo())){
|
if(R_SUCCEEDED(load_secureinfo())){
|
||||||
|
static const char countryRespPattern[] = {
|
||||||
|
0x01, 0x20, 0x01, 0x90, 0x22, 0x46, 0x06, 0x9B
|
||||||
|
};
|
||||||
|
static const char countryRespPatchModel[] = {
|
||||||
|
0x06, 0x9A, 0x03, 0x20, 0x90, 0x47, 0x55, 0x21, 0x01, 0x70, 0x53, 0x21, 0x41, 0x70, 0x00, 0x21,
|
||||||
|
0x81, 0x70, 0x60, 0x61, 0x00, 0x20
|
||||||
|
};
|
||||||
|
const char *country;
|
||||||
|
char countryRespPatch[sizeof(countryRespPatchModel)];
|
||||||
|
|
||||||
switch(secureinfo[0x100]){
|
switch(secureinfo[0x100]){
|
||||||
case 1: country = "US"; break;
|
case 1: country = "US"; break;
|
||||||
case 2: country = "GB"; break; // sorry rest-of-Europe, you have to change this
|
case 2: country = "GB"; break; // sorry rest-of-Europe, you have to change this
|
||||||
@ -178,7 +180,6 @@ u32 patch_code(u64 progid, u8 *code, u32 size){
|
|||||||
case 6: country = "TW"; break;
|
case 6: country = "TW"; break;
|
||||||
default: case 0: country = "JP"; break;
|
default: case 0: country = "JP"; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// patch XML response Country
|
// patch XML response Country
|
||||||
memcpy(countryRespPatch,
|
memcpy(countryRespPatch,
|
||||||
countryRespPatchModel,
|
countryRespPatchModel,
|
||||||
@ -203,10 +204,10 @@ u32 patch_code(u64 progid, u8 *code, u32 size){
|
|||||||
case 0x0004001000027000LL: // KOR MSET
|
case 0x0004001000027000LL: // KOR MSET
|
||||||
case 0x0004001000028000LL: // TWN MSET
|
case 0x0004001000028000LL: // TWN MSET
|
||||||
{
|
{
|
||||||
if(R_SUCCEEDED(load_config()) && ((config >> 5) & 0x1)){
|
if(R_SUCCEEDED(load_config()) && ((config >> 5) & 1)){
|
||||||
static const u16 verPattern[] = u"Ver.";
|
static const u16 verPattern[] = u"Ver.";
|
||||||
const u32 currentFirm = ((config >> 12) & 0x1);
|
const u32 currentFirm = ((config >> 12) & 1);
|
||||||
const u32 currentNand = ((config >> 13) & 0x3);
|
const u32 currentNand = ((config >> 13) & 3);
|
||||||
|
|
||||||
patch_memory(code, size,
|
patch_memory(code, size,
|
||||||
verPattern,
|
verPattern,
|
||||||
@ -245,8 +246,6 @@ u32 patch_code(u64 progid, u8 *code, u32 size){
|
|||||||
static const u8 secureinfoSigCheckPatch[] = {
|
static const u8 secureinfoSigCheckPatch[] = {
|
||||||
0x00, 0x26
|
0x00, 0x26
|
||||||
};
|
};
|
||||||
static const u16 secureinfoFilenamePattern[] = u"SecureInfo_";
|
|
||||||
static const u16 secureinfoFilenamePatch[] = u"C";
|
|
||||||
|
|
||||||
// disable SecureInfo signature check
|
// disable SecureInfo signature check
|
||||||
patch_memory(code, size,
|
patch_memory(code, size,
|
||||||
@ -255,7 +254,11 @@ u32 patch_code(u64 progid, u8 *code, u32 size){
|
|||||||
secureinfoSigCheckPatch,
|
secureinfoSigCheckPatch,
|
||||||
sizeof(secureinfoSigCheckPatch), 1
|
sizeof(secureinfoSigCheckPatch), 1
|
||||||
);
|
);
|
||||||
|
|
||||||
if(R_SUCCEEDED(load_secureinfo())){
|
if(R_SUCCEEDED(load_secureinfo())){
|
||||||
|
static const u16 secureinfoFilenamePattern[] = u"SecureInfo_";
|
||||||
|
static const u16 secureinfoFilenamePatch[] = u"C";
|
||||||
|
|
||||||
// use SecureInfo_C
|
// use SecureInfo_C
|
||||||
patch_memory(code, size,
|
patch_memory(code, size,
|
||||||
secureinfoFilenamePattern,
|
secureinfoFilenamePattern,
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
#define HID_PAD (*(vu16 *)0x10146000 ^ 0xFFF)
|
#define HID_PAD (*(vu16 *)0x10146000 ^ 0xFFF)
|
||||||
#define BUTTON_B (1 << 1)
|
|
||||||
#define BUTTON_X (1 << 10)
|
#define BUTTON_X (1 << 10)
|
||||||
#define BUTTON_Y (1 << 11)
|
#define BUTTON_Y (1 << 11)
|
||||||
#define BUTTON_SELECT (1 << 2)
|
#define BUTTON_SELECT (1 << 2)
|
||||||
|
@ -25,8 +25,7 @@ void main(void){
|
|||||||
//Get pressed buttons
|
//Get pressed buttons
|
||||||
u16 pressed = HID_PAD;
|
u16 pressed = HID_PAD;
|
||||||
|
|
||||||
if(((pressed & BUTTON_B) && loadPayload("/aurei/payloads/b.bin")) ||
|
if(((pressed & BUTTON_X) && loadPayload("/aurei/payloads/x.bin")) ||
|
||||||
((pressed & BUTTON_X) && loadPayload("/aurei/payloads/x.bin")) ||
|
|
||||||
((pressed & BUTTON_Y) && loadPayload("/aurei/payloads/y.bin")) ||
|
((pressed & BUTTON_Y) && loadPayload("/aurei/payloads/y.bin")) ||
|
||||||
((pressed & BUTTON_SELECT) && loadPayload("/aurei/payloads/select.bin")) ||
|
((pressed & BUTTON_SELECT) && loadPayload("/aurei/payloads/select.bin")) ||
|
||||||
((pressed & BUTTON_START) && loadPayload("/aurei/payloads/start.bin")) ||
|
((pressed & BUTTON_START) && loadPayload("/aurei/payloads/start.bin")) ||
|
||||||
|
@ -21,6 +21,6 @@
|
|||||||
#define BUTTON_DOWN (1 << 7)
|
#define BUTTON_DOWN (1 << 7)
|
||||||
#define BUTTON_L1R1 ((1 << 8) | (1 << 9))
|
#define BUTTON_L1R1 ((1 << 8) | (1 << 9))
|
||||||
#define SAFE_MODE (BUTTON_L1R1 | BUTTON_A | BUTTON_UP)
|
#define SAFE_MODE (BUTTON_L1R1 | BUTTON_A | BUTTON_UP)
|
||||||
#define OPTION_BUTTONS (BUTTON_L1R1 | BUTTON_A)
|
#define OPTION_BUTTONS (BUTTON_L1R1 | BUTTON_A | BUTTON_SELECT)
|
||||||
#define PAYLOAD_BUTTONS ((BUTTON_L1 | BUTTON_A) ^ 0xFFF)
|
#define PAYLOAD_BUTTONS ((BUTTON_L1 | BUTTON_A | BUTTON_B) ^ 0xFFF)
|
||||||
#define MENU_BUTTONS (BUTTON_LEFT | BUTTON_RIGHT | BUTTON_UP | BUTTON_DOWN | BUTTON_A | BUTTON_START)
|
#define MENU_BUTTONS (BUTTON_LEFT | BUTTON_RIGHT | BUTTON_UP | BUTTON_DOWN | BUTTON_A | BUTTON_START)
|
@ -54,13 +54,13 @@ void setupCFW(void){
|
|||||||
//Determine if A9LH is installed and the user has an updated sysNAND
|
//Determine if A9LH is installed and the user has an updated sysNAND
|
||||||
u32 updatedSys;
|
u32 updatedSys;
|
||||||
|
|
||||||
if(a9lhBoot || (config >> 2) & 0x1){
|
if(a9lhBoot || (config >> 2) & 1){
|
||||||
if(pressed == SAFE_MODE)
|
if(pressed == SAFE_MODE)
|
||||||
error("Using Safe Mode would brick you, or remove A9LH!");
|
error("Using Safe Mode would brick you, or remove A9LH!");
|
||||||
|
|
||||||
a9lhSetup = 1;
|
a9lhSetup = 1;
|
||||||
//Check setting for > 9.2 sysNAND
|
//Check setting for > 9.2 sysNAND
|
||||||
updatedSys = config & 0x1;
|
updatedSys = config & 1;
|
||||||
} else{
|
} else{
|
||||||
a9lhSetup = 0;
|
a9lhSetup = 0;
|
||||||
updatedSys = 0;
|
updatedSys = 0;
|
||||||
@ -71,13 +71,13 @@ void setupCFW(void){
|
|||||||
if(a9lhBoot && previousFirm && needConfig == 1){
|
if(a9lhBoot && previousFirm && needConfig == 1){
|
||||||
//Always force a sysNAND boot when quitting AGB_FIRM
|
//Always force a sysNAND boot when quitting AGB_FIRM
|
||||||
if(previousFirm == 0x7){
|
if(previousFirm == 0x7){
|
||||||
mode = updatedSys ? 1 : (config >> 12) & 0x1;
|
mode = updatedSys ? 1 : (config >> 12) & 1;
|
||||||
emuNAND = 0;
|
emuNAND = 0;
|
||||||
needConfig = 0;
|
needConfig = 0;
|
||||||
//Else, force the last used boot options unless A, L or R are pressed
|
//Else, force the last used boot options unless A, L or R are pressed
|
||||||
} else if(!(pressed & OPTION_BUTTONS)){
|
} else if(!(pressed & OPTION_BUTTONS)){
|
||||||
mode = (config >> 12) & 0x1;
|
mode = (config >> 12) & 1;
|
||||||
emuNAND = (config >> 13) & 0x3;
|
emuNAND = (config >> 13) & 3;
|
||||||
needConfig = 0;
|
needConfig = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -94,10 +94,10 @@ void setupCFW(void){
|
|||||||
configureCFW(configPath, patchedFirms[3]);
|
configureCFW(configPath, patchedFirms[3]);
|
||||||
|
|
||||||
//If screens are inited, load splash screen
|
//If screens are inited, load splash screen
|
||||||
if(PDN_GPU_CNT != 0x1) loadSplash();
|
if(PDN_GPU_CNT != 1) loadSplash();
|
||||||
|
|
||||||
/* If L is pressed, boot 9.0 FIRM */
|
/* If L is pressed, boot 9.0 FIRM */
|
||||||
mode = ((config >> 3) & 0x1) ? ((!(pressed & BUTTON_L1R1)) ? 0 : 1) :
|
mode = ((config >> 3) & 1) ? ((!(pressed & BUTTON_L1R1)) ? 0 : 1) :
|
||||||
((pressed & BUTTON_L1) ? 0 : 1);
|
((pressed & BUTTON_L1) ? 0 : 1);
|
||||||
|
|
||||||
/* If L or R aren't pressed on a 9.0/9.2 sysNAND, or the 9.0 FIRM is selected
|
/* If L or R aren't pressed on a 9.0/9.2 sysNAND, or the 9.0 FIRM is selected
|
||||||
@ -105,18 +105,22 @@ void setupCFW(void){
|
|||||||
if((updatedSys && (!mode || (pressed & BUTTON_R1))) ||
|
if((updatedSys && (!mode || (pressed & BUTTON_R1))) ||
|
||||||
(!updatedSys && mode && !(pressed & BUTTON_R1))){
|
(!updatedSys && mode && !(pressed & BUTTON_R1))){
|
||||||
//If not 9.0 FIRM and B is pressed, attempt booting the second emuNAND
|
//If not 9.0 FIRM and B is pressed, attempt booting the second emuNAND
|
||||||
emuNAND = (mode && ((!(pressed & BUTTON_B)) == ((config >> 4) & 0x1))) ? 2 : 1;
|
emuNAND = (mode && ((!(pressed & BUTTON_B)) == ((config >> 4) & 1))) ? 2 : 1;
|
||||||
} else emuNAND = 0;
|
} else emuNAND = 0;
|
||||||
|
|
||||||
u32 tempConfig = (PATCH_VER << 17) | (a9lhSetup << 16) | (emuNAND << 13) | (mode << 12);
|
u32 tempConfig = (PATCH_VER << 17) | (a9lhSetup << 16);
|
||||||
|
|
||||||
|
/* If the NAND/FIRM information is displayed in System Settings or using A9LH,
|
||||||
|
save boot options */
|
||||||
|
if(a9lhSetup || ((config >> 5) & 1)) tempConfig |= (emuNAND << 13) | (mode << 12);
|
||||||
|
|
||||||
|
//If the boot configuration is different from previously, overwrite it
|
||||||
|
if((tempConfig & 0xFFF000) != (config & 0xFFF000)){
|
||||||
/* If tha FIRM patches version is different or user switched to/from A9LH,
|
/* If tha FIRM patches version is different or user switched to/from A9LH,
|
||||||
delete all patched FIRMs */
|
delete all patched FIRMs */
|
||||||
if((tempConfig & 0xFF0000) != (config & 0xFF0000))
|
if((tempConfig & 0xFF0000) != (config & 0xFF0000))
|
||||||
deleteFirms(patchedFirms, sizeof(patchedFirms) / sizeof(char *));
|
deleteFirms(patchedFirms, sizeof(patchedFirms) / sizeof(char *));
|
||||||
|
|
||||||
//If the boot configuration is different from previously, overwrite it
|
|
||||||
if((tempConfig & 0xFFF000) != (config & 0xFFF000)){
|
|
||||||
//Preserve user settings (first 12 bits)
|
//Preserve user settings (first 12 bits)
|
||||||
tempConfig |= config & 0xFFF;
|
tempConfig |= config & 0xFFF;
|
||||||
fileWrite(&tempConfig, configPath, 3);
|
fileWrite(&tempConfig, configPath, 3);
|
||||||
@ -126,10 +130,10 @@ void setupCFW(void){
|
|||||||
/* Determine which patched FIRM we need to write or attempt to use (if any).
|
/* Determine which patched FIRM we need to write or attempt to use (if any).
|
||||||
Patched 9.0 FIRM is only needed if "Use pre-patched FIRMs" is set */
|
Patched 9.0 FIRM is only needed if "Use pre-patched FIRMs" is set */
|
||||||
selectedFirm = mode ? (emuNAND ? (emuNAND == 1 ? 2 : 3) : 1) :
|
selectedFirm = mode ? (emuNAND ? (emuNAND == 1 ? 2 : 3) : 1) :
|
||||||
(((config >> 1) & 0x1) ? 4 : 0);
|
(((config >> 1) & 1) ? 4 : 0);
|
||||||
|
|
||||||
//If "Use pre-patched FIRMs" is set and the appropriate FIRM exists, use it
|
//If "Use pre-patched FIRMs" is set and the appropriate FIRM exists, use it
|
||||||
usePatchedFirm = (((config >> 1) & 0x1) && fileExists(patchedFirms[selectedFirm - 1])) ? 1 : 0;
|
usePatchedFirm = (((config >> 1) & 1) && fileExists(patchedFirms[selectedFirm - 1])) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Load FIRM into FCRAM
|
//Load FIRM into FCRAM
|
||||||
@ -268,9 +272,11 @@ void patchFirm(void){
|
|||||||
loaderSize;
|
loaderSize;
|
||||||
|
|
||||||
getLoader((u8 *)firm + section[0].offset, section[0].size, &loaderOffset, &loaderSize);
|
getLoader((u8 *)firm + section[0].offset, section[0].size, &loaderOffset, &loaderSize);
|
||||||
|
//Check that the injector CXI isn't larger than the original
|
||||||
if(injector_size <= (int)loaderSize){
|
if(injector_size <= (int)loaderSize){
|
||||||
memset((void *)loaderOffset, 0, loaderSize);
|
memset((void *)loaderOffset, 0, loaderSize);
|
||||||
memcpy((void *)loaderOffset, injector, injector_size);
|
memcpy((void *)loaderOffset, injector, injector_size);
|
||||||
|
//Patch content size and ExeFS size to match the repaced loader's ones
|
||||||
*((u32 *)loaderOffset + 0x41) = loaderSize / 0x200;
|
*((u32 *)loaderOffset + 0x41) = loaderSize / 0x200;
|
||||||
*((u32 *)loaderOffset + 0x69) = loaderSize / 0x200 - 5;
|
*((u32 *)loaderOffset + 0x69) = loaderSize / 0x200 - 5;
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ void deinitScreens(void){
|
|||||||
((void (*)())*arm11)();
|
((void (*)())*arm11)();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(PDN_GPU_CNT != 0x1){
|
if(PDN_GPU_CNT != 1){
|
||||||
*arm11 = (u32)ARM11;
|
*arm11 = (u32)ARM11;
|
||||||
while(*arm11);
|
while(*arm11);
|
||||||
}
|
}
|
||||||
@ -143,7 +143,7 @@ void initScreens(void){
|
|||||||
((void (*)())*arm11)();
|
((void (*)())*arm11)();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(PDN_GPU_CNT == 0x1){
|
if(PDN_GPU_CNT == 1){
|
||||||
*arm11 = (u32)ARM11;
|
*arm11 = (u32)ARM11;
|
||||||
while(*arm11);
|
while(*arm11);
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ void configureCFW(const char *configPath, const char *firm90Path){
|
|||||||
u32 tempConfig = 0;
|
u32 tempConfig = 0;
|
||||||
fileRead(&tempConfig, configPath, 3);
|
fileRead(&tempConfig, configPath, 3);
|
||||||
for(u32 i = 0; i < optionsAmount; i++)
|
for(u32 i = 0; i < optionsAmount; i++)
|
||||||
options[i].enabled = (tempConfig >> i) & 0x1;
|
options[i].enabled = (tempConfig >> i) & 1;
|
||||||
|
|
||||||
//Pre-select the first configuration option
|
//Pre-select the first configuration option
|
||||||
u32 selectedOption = 0;
|
u32 selectedOption = 0;
|
||||||
@ -102,8 +102,7 @@ void configureCFW(const char *configPath, const char *firm90Path){
|
|||||||
}
|
}
|
||||||
|
|
||||||
//If the user has been using A9LH and the "Updated SysNAND" setting changed, delete the patched 9.0 FIRM
|
//If the user has been using A9LH and the "Updated SysNAND" setting changed, delete the patched 9.0 FIRM
|
||||||
if(((tempConfig >> 16) & 0x1) && ((tempConfig & 0x1) != options[0].enabled))
|
if(((tempConfig >> 16) & 1) && ((tempConfig & 1) != options[0].enabled)) fileDelete(firm90Path);
|
||||||
fileDelete(firm90Path);
|
|
||||||
|
|
||||||
//Preserve the last-used boot options (last 12 bits)
|
//Preserve the last-used boot options (last 12 bits)
|
||||||
tempConfig &= 0xFFF000;
|
tempConfig &= 0xFFF000;
|
||||||
|
Reference in New Issue
Block a user