Fix loader, other fixes

This commit is contained in:
TuxSH 2017-05-20 01:04:32 +02:00
parent 64ebec3ea4
commit 2d7c1e42d8
4 changed files with 17 additions and 11 deletions

View File

@ -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};

View File

@ -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);

View File

@ -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;
}

View File

@ -115,4 +115,4 @@ typedef enum FirmwareType
} FirmwareType;
extern u16 launchedFirmTidLow[8];
extern u16 launchedPath[41];
extern u16 launchedPath[7 + 255];