forked from Mirror/GodMode9
Improved hidden bootloader
This commit is contained in:
parent
5cd1c7259f
commit
4244122dda
4
Makefile
4
Makefile
@ -56,6 +56,10 @@ ifeq ($(SAFEMODE),1)
|
|||||||
CFLAGS += -DSAFEMODE
|
CFLAGS += -DSAFEMODE
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(AL3X10MODE),1)
|
||||||
|
CFLAGS += -DAL3X10MODE
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(SWITCH_SCREENS),1)
|
ifeq ($(SWITCH_SCREENS),1)
|
||||||
CFLAGS += -DSWITCH_SCREENS
|
CFLAGS += -DSWITCH_SCREENS
|
||||||
endif
|
endif
|
||||||
|
@ -72,7 +72,7 @@ u32 ValidateFirm(void* firm, u32 firm_size, bool installable) {
|
|||||||
FirmHeader* header = (FirmHeader*) firm;
|
FirmHeader* header = (FirmHeader*) firm;
|
||||||
|
|
||||||
// validate firm header
|
// validate firm header
|
||||||
if (ValidateFirmHeader(header, firm_size) != 0)
|
if ((firm_size < sizeof(FirmHeader)) || (ValidateFirmHeader(header, firm_size) != 0))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
// check for boot9strap magic
|
// check for boot9strap magic
|
||||||
|
@ -50,7 +50,7 @@
|
|||||||
|
|
||||||
#define BOOTLOADER_KEY BUTTON_LEFT
|
#define BOOTLOADER_KEY BUTTON_LEFT
|
||||||
#define BOOTMENU_KEY BUTTON_R1
|
#define BOOTMENU_KEY BUTTON_R1
|
||||||
#define BOOTFIRM_PATH "0:/boot.firm"
|
#define BOOTFIRM_PATHS "0:/boot.firm", "1:/boot.firm", "S:/firm1.bin"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char path[256];
|
char path[256];
|
||||||
@ -693,6 +693,7 @@ u32 BootFirmHandler(const char* bootpath, bool verbose) {
|
|||||||
TruncateString(pathstr, bootpath, 32, 8);
|
TruncateString(pathstr, bootpath, 32, 8);
|
||||||
|
|
||||||
size_t firm_size = FileGetSize(bootpath);
|
size_t firm_size = FileGetSize(bootpath);
|
||||||
|
if (!firm_size) return 1;
|
||||||
if (firm_size > TEMP_BUFFER_SIZE) {
|
if (firm_size > TEMP_BUFFER_SIZE) {
|
||||||
if (verbose) ShowPrompt(false, "%s\nFIRM too big, can't boot", pathstr); // unlikely
|
if (verbose) ShowPrompt(false, "%s\nFIRM too big, can't boot", pathstr); // unlikely
|
||||||
return 1;
|
return 1;
|
||||||
@ -701,7 +702,7 @@ u32 BootFirmHandler(const char* bootpath, bool verbose) {
|
|||||||
if (verbose && !ShowUnlockSequence(3, "%s (%dkB)\nBoot FIRM via chainloader?", pathstr, firm_size / 1024))
|
if (verbose && !ShowUnlockSequence(3, "%s (%dkB)\nBoot FIRM via chainloader?", pathstr, firm_size / 1024))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if ((FileGetData(bootpath, TEMP_BUFFER, firm_size, 0) != firm_size) &&
|
if ((FileGetData(bootpath, TEMP_BUFFER, firm_size, 0) != firm_size) ||
|
||||||
(ValidateFirm(TEMP_BUFFER, firm_size, false) != 0)) {
|
(ValidateFirm(TEMP_BUFFER, firm_size, false) != 0)) {
|
||||||
if (verbose) ShowPrompt(false, "%s\nNot a bootable FIRM", pathstr);
|
if (verbose) ShowPrompt(false, "%s\nNot a bootable FIRM", pathstr);
|
||||||
return 1;
|
return 1;
|
||||||
@ -1518,6 +1519,10 @@ u32 GodMode(bool is_b9s) {
|
|||||||
|
|
||||||
bool bootloader = !is_b9s && IS_SIGHAX && CheckButton(BOOTLOADER_KEY);
|
bool bootloader = !is_b9s && IS_SIGHAX && CheckButton(BOOTLOADER_KEY);
|
||||||
bool bootmenu = !is_b9s && IS_SIGHAX && CheckButton(BOOTMENU_KEY);
|
bool bootmenu = !is_b9s && IS_SIGHAX && CheckButton(BOOTMENU_KEY);
|
||||||
|
#ifdef AL3X10MODE
|
||||||
|
bootloader = !is_b9s && IS_SIGHAX && !bootloader; // default bootloader
|
||||||
|
#endif
|
||||||
|
bool godmode9 = !bootloader && !bootmenu;
|
||||||
|
|
||||||
|
|
||||||
ClearScreenF(true, true, COLOR_STD_BG);
|
ClearScreenF(true, true, COLOR_STD_BG);
|
||||||
@ -1572,31 +1577,38 @@ u32 GodMode(bool is_b9s) {
|
|||||||
|
|
||||||
|
|
||||||
if (bootmenu) {
|
if (bootmenu) {
|
||||||
while (true) {
|
bootloader = false;
|
||||||
const char* optionstr[5] = { "Boot " BOOTFIRM_PATH, "Select payload...", "Select scripts...",
|
while (!bootloader && !godmode9) {
|
||||||
|
const char* optionstr[6] = { "Resume bootloader", "Resume GodMode9", "Select payload...", "Select script...",
|
||||||
"Poweroff system", "Reboot system" };
|
"Poweroff system", "Reboot system" };
|
||||||
int user_select = ShowSelectPrompt(5, optionstr, FLAVOR " bootloader menu.\nSelect action:");
|
int user_select = ShowSelectPrompt(6, optionstr, FLAVOR " bootloader menu.\nSelect action:");
|
||||||
char loadpath[256];
|
char loadpath[256];
|
||||||
if (user_select == 1) {
|
if (user_select == 1) {
|
||||||
BootFirmHandler(BOOTFIRM_PATH, false);
|
bootloader = true;
|
||||||
} else if ((user_select == 2) && (FileSelector(loadpath, "Bootloader payloads menu.\nSelect payload:", PAYLOAD_PATH, "*.firm", true, false))) {
|
} else if (user_select == 2) {
|
||||||
|
godmode9 = true;
|
||||||
|
} else if ((user_select == 3) && (FileSelector(loadpath, "Bootloader payloads menu.\nSelect payload:", PAYLOAD_PATH, "*.firm", true, false))) {
|
||||||
BootFirmHandler(loadpath, false);
|
BootFirmHandler(loadpath, false);
|
||||||
} else if ((user_select == 3) && (FileSelector(loadpath, "Bootloader scripts menu.\nSelect script:", SCRIPT_PATH, "*.gm9", true, false))) {
|
} else if ((user_select == 4) && (FileSelector(loadpath, "Bootloader scripts menu.\nSelect script:", SCRIPT_PATH, "*.gm9", true, false))) {
|
||||||
ExecuteGM9Script(loadpath);
|
ExecuteGM9Script(loadpath);
|
||||||
} else if (user_select == 4) {
|
|
||||||
exit_mode = GODMODE_EXIT_POWEROFF;
|
|
||||||
} else if (user_select == 5) {
|
} else if (user_select == 5) {
|
||||||
|
exit_mode = GODMODE_EXIT_POWEROFF;
|
||||||
|
} else if (user_select == 6) {
|
||||||
exit_mode = GODMODE_EXIT_REBOOT;
|
exit_mode = GODMODE_EXIT_REBOOT;
|
||||||
} else if (user_select) continue;
|
} else if (user_select) continue;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (bootloader) {
|
}
|
||||||
BootFirmHandler(BOOTFIRM_PATH, false);
|
if (bootloader) {
|
||||||
|
const char* bootfirm_paths[] = { BOOTFIRM_PATHS };
|
||||||
|
for (u32 i = 0; i < sizeof(bootfirm_paths) / sizeof(char*); i++) {
|
||||||
|
BootFirmHandler(bootfirm_paths[i], false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ClearScreenF(true, true, COLOR_STD_BG); // clear splash
|
ClearScreenF(true, true, COLOR_STD_BG); // clear splash
|
||||||
while (!bootloader && !bootmenu) { // this is the main loop
|
while (godmode9) { // this is the main loop
|
||||||
int curr_drvtype = DriveType(current_path);
|
int curr_drvtype = DriveType(current_path);
|
||||||
|
|
||||||
// basic sanity checking
|
// basic sanity checking
|
||||||
|
Loading…
x
Reference in New Issue
Block a user