diff --git a/loader/source/main.c b/loader/source/main.c index cc45b5f..c591cc4 100644 --- a/loader/source/main.c +++ b/loader/source/main.c @@ -27,12 +27,12 @@ void main(int argc __attribute__((unused)), char **argv) { Firm *firm = (Firm *)0x24000000; - char absPath[92]; + char absPath[24 + 255]; u32 i; - for(i = 0; i < 91 && argv[1] != 0; i++) - absPath[i] = argv[1][i]; - for(; i < 92; i++) + for(i = 0; i < 23 + 255 && argv[0][i] != 0; i++) + absPath[i] = argv[0][i]; + for(; i < 24 + 255; i++) absPath[i] = 0; char *argvPassed[1] = {absPath}; diff --git a/source/main.c b/source/main.c index 3191c0b..0960248 100644 --- a/source/main.c +++ b/source/main.c @@ -39,7 +39,7 @@ extern ConfigurationStatus needConfig; extern FirmwareSource firmSource; u16 launchedFirmTidLow[8]; -u16 launchedPath[41]; +u16 launchedPath[7 + 255]; void main(int argc, char **argv) { @@ -60,9 +60,9 @@ void main(int argc, char **argv) case 1: //Normal boot { u32 i; - for(i = 0; i < 40 && argv[0][i] != 0; i++) //Copy and convert the path to utf16 + for(i = 0; i < 6 + 255 && argv[0][i] != 0; i++) //Copy and convert the path to utf16 launchedPath[i] = argv[0][i]; - for(; i < 41; i++) + for(; i < 7 + 255; i++) launchedPath[i] = 0; memset(launchedFirmTidLow, 0, 16); @@ -73,9 +73,9 @@ void main(int argc, char **argv) { u32 i; u16 *p = (u16 *)argv[0]; - for(i = 0; i < 40 && p[i] != 0; i++) + for(i = 0; i < 6 + 255 && p[i] != 0; i++) launchedPath[i] = p[i]; - for(; i < 41; i++) + for(; i < 7 + 255; i++) launchedPath[i] = 0; memcpy(launchedFirmTidLow, (u16 *)argv[1], 16); diff --git a/source/patches.c b/source/patches.c index 120765f..a2c8588 100644 --- a/source/patches.c +++ b/source/patches.c @@ -119,6 +119,12 @@ u32 patchFirmlaunches(u8 *pos, u32 size, u32 process9MemAddr) //Look for firmlaunch code const u8 pattern[] = {0xE2, 0x20, 0x20, 0x90}; + u32 pathLen; + for(pathLen = 0; launchedPath[pathLen] != 0; pathLen++); + + if(pathLen > 82) + return 1; + u8 *off = memsearch(pos, pattern, size, sizeof(pattern)); if(off == NULL) return 1; @@ -136,7 +142,7 @@ u32 patchFirmlaunches(u8 *pos, u32 size, u32 process9MemAddr) *pos_fopen = fOpenOffset; u16 *fname = (u16 *)memsearch(off, u"sdmc", reboot_bin_size, 8); - memcpy(fname, launchedPath, sizeof(launchedPath)); + memcpy(fname, launchedPath, 82); return 0; } diff --git a/source/types.h b/source/types.h index d56d0a5..66ba955 100644 --- a/source/types.h +++ b/source/types.h @@ -115,4 +115,4 @@ typedef enum FirmwareType } FirmwareType; extern u16 launchedFirmTidLow[8]; -extern u16 launchedPath[41]; +extern u16 launchedPath[7 + 255];