Fix loader, other fixes
This commit is contained in:
parent
64ebec3ea4
commit
2d7c1e42d8
@ -27,12 +27,12 @@
|
|||||||
void main(int argc __attribute__((unused)), char **argv)
|
void main(int argc __attribute__((unused)), char **argv)
|
||||||
{
|
{
|
||||||
Firm *firm = (Firm *)0x24000000;
|
Firm *firm = (Firm *)0x24000000;
|
||||||
char absPath[92];
|
char absPath[24 + 255];
|
||||||
|
|
||||||
u32 i;
|
u32 i;
|
||||||
for(i = 0; i < 91 && argv[1] != 0; i++)
|
for(i = 0; i < 23 + 255 && argv[0][i] != 0; i++)
|
||||||
absPath[i] = argv[1][i];
|
absPath[i] = argv[0][i];
|
||||||
for(; i < 92; i++)
|
for(; i < 24 + 255; i++)
|
||||||
absPath[i] = 0;
|
absPath[i] = 0;
|
||||||
|
|
||||||
char *argvPassed[1] = {absPath};
|
char *argvPassed[1] = {absPath};
|
||||||
|
@ -39,7 +39,7 @@ extern ConfigurationStatus needConfig;
|
|||||||
extern FirmwareSource firmSource;
|
extern FirmwareSource firmSource;
|
||||||
|
|
||||||
u16 launchedFirmTidLow[8];
|
u16 launchedFirmTidLow[8];
|
||||||
u16 launchedPath[41];
|
u16 launchedPath[7 + 255];
|
||||||
|
|
||||||
void main(int argc, char **argv)
|
void main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
@ -60,9 +60,9 @@ void main(int argc, char **argv)
|
|||||||
case 1: //Normal boot
|
case 1: //Normal boot
|
||||||
{
|
{
|
||||||
u32 i;
|
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];
|
launchedPath[i] = argv[0][i];
|
||||||
for(; i < 41; i++)
|
for(; i < 7 + 255; i++)
|
||||||
launchedPath[i] = 0;
|
launchedPath[i] = 0;
|
||||||
|
|
||||||
memset(launchedFirmTidLow, 0, 16);
|
memset(launchedFirmTidLow, 0, 16);
|
||||||
@ -73,9 +73,9 @@ void main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
u32 i;
|
u32 i;
|
||||||
u16 *p = (u16 *)argv[0];
|
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];
|
launchedPath[i] = p[i];
|
||||||
for(; i < 41; i++)
|
for(; i < 7 + 255; i++)
|
||||||
launchedPath[i] = 0;
|
launchedPath[i] = 0;
|
||||||
|
|
||||||
memcpy(launchedFirmTidLow, (u16 *)argv[1], 16);
|
memcpy(launchedFirmTidLow, (u16 *)argv[1], 16);
|
||||||
|
@ -119,6 +119,12 @@ u32 patchFirmlaunches(u8 *pos, u32 size, u32 process9MemAddr)
|
|||||||
//Look for firmlaunch code
|
//Look for firmlaunch code
|
||||||
const u8 pattern[] = {0xE2, 0x20, 0x20, 0x90};
|
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));
|
u8 *off = memsearch(pos, pattern, size, sizeof(pattern));
|
||||||
|
|
||||||
if(off == NULL) return 1;
|
if(off == NULL) return 1;
|
||||||
@ -136,7 +142,7 @@ u32 patchFirmlaunches(u8 *pos, u32 size, u32 process9MemAddr)
|
|||||||
*pos_fopen = fOpenOffset;
|
*pos_fopen = fOpenOffset;
|
||||||
|
|
||||||
u16 *fname = (u16 *)memsearch(off, u"sdmc", reboot_bin_size, 8);
|
u16 *fname = (u16 *)memsearch(off, u"sdmc", reboot_bin_size, 8);
|
||||||
memcpy(fname, launchedPath, sizeof(launchedPath));
|
memcpy(fname, launchedPath, 82);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -115,4 +115,4 @@ typedef enum FirmwareType
|
|||||||
} FirmwareType;
|
} FirmwareType;
|
||||||
|
|
||||||
extern u16 launchedFirmTidLow[8];
|
extern u16 launchedFirmTidLow[8];
|
||||||
extern u16 launchedPath[41];
|
extern u16 launchedPath[7 + 255];
|
||||||
|
Reference in New Issue
Block a user