Fix string handling bugs

This commit is contained in:
TuxSH 2017-05-19 22:40:07 +02:00
parent ee880802c8
commit 9f12a47cfc
5 changed files with 16 additions and 9 deletions

View File

@ -32,7 +32,7 @@ void main(int argc __attribute__((unused)), char **argv)
u32 i; u32 i;
for(i = 0; i < 91 && argv[1] != 0; i++) for(i = 0; i < 91 && argv[1] != 0; i++)
absPath[i] = argv[1][i]; absPath[i] = argv[1][i];
for(; i < 91; i++) for(; i < 92; i++)
absPath[i] = 0; absPath[i] = 0;
char *argvPassed[1] = {absPath}; char *argvPassed[1] = {absPath};

View File

@ -105,8 +105,11 @@ arm11_entrypoint_addr equ 0x1FFFFFFC
bytes_read: .word 0 bytes_read: .word 0
fopen: .ascii "OPEN" fopen: .ascii "OPEN"
.pool .pool
fname: .dcw "sdmc:/arm9loaderha.firm"
.word 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 .area 82, 0
fname: .dcw "sdmc:/boot.firm"
.endarea
.pool .pool
nand_mount: .dcw "nand" nand_mount: .dcw "nand"

View File

@ -33,13 +33,14 @@
#include "crypto.h" #include "crypto.h"
#include "fmt.h" #include "fmt.h"
#include "memory.h" #include "memory.h"
#include "i2c.h"
extern CfgData configData; extern CfgData configData;
extern ConfigurationStatus needConfig; extern ConfigurationStatus needConfig;
extern FirmwareSource firmSource; extern FirmwareSource firmSource;
u16 launchedFirmTidLow[8]; u16 launchedFirmTidLow[8];
u16 launchedPath[42]; u16 launchedPath[41];
void main(int argc, char **argv) void main(int argc, char **argv)
{ {
@ -58,7 +59,7 @@ void main(int argc, char **argv)
case 1: //Normal boot case 1: //Normal boot
{ {
u32 i; u32 i;
for(i = 0; i < 41 && launchedPath[i] != 0; i++) //Copy and convert the path to utf16 for(i = 0; i < 40 && launchedPath[i] != 0; i++) //Copy and convert the path to utf16
launchedPath[2 * i] = argv[0][i]; launchedPath[2 * i] = argv[0][i];
for(; i < 41; i++) for(; i < 41; i++)
launchedPath[i] = 0; launchedPath[i] = 0;
@ -70,9 +71,12 @@ void main(int argc, char **argv)
case 2: //Firmlaunch case 2: //Firmlaunch
{ {
i2cWriteRegister(I2C_DEV_MCU, 0x20, 1 << 0);
while(true);
u32 i; u32 i;
u16 *p = (u16 *)argv[0]; u16 *p = (u16 *)argv[0];
for(i = 0; i < 41 && launchedPath[i] != 0; i++) for(i = 0; i < 40 && launchedPath[i] != 0; i++)
launchedPath[i] = p[i]; launchedPath[i] = p[i];
for(; i < 41; i++) for(; i < 41; i++)
launchedPath[i] = 0; launchedPath[i] = 0;

View File

@ -135,8 +135,8 @@ u32 patchFirmlaunches(u8 *pos, u32 size, u32 process9MemAddr)
u32 *pos_fopen = (u32 *)memsearch(off, "OPEN", reboot_bin_size, 4); u32 *pos_fopen = (u32 *)memsearch(off, "OPEN", reboot_bin_size, 4);
*pos_fopen = fOpenOffset; *pos_fopen = fOpenOffset;
//u16 *fname = (u16 *)memsearch(off, u"sd", reboot_bin_size, 4); u16 *fname = (u16 *)memsearch(off, u"sd", reboot_bin_size, 4);
//memcpy(fname, u"sdmc:/test.firm", 32); memcpy(fname, launchedPath, 82);
return 0; return 0;
} }

View File

@ -116,4 +116,4 @@ typedef enum FirmwareType
} FirmwareType; } FirmwareType;
extern u16 launchedFirmTidLow[8]; extern u16 launchedFirmTidLow[8];
extern u16 launchedPath[42]; extern u16 launchedPath[41];