Fix chainloading bugs/refactoring
This commit is contained in:
parent
252d32aafe
commit
64ebec3ea4
30
source/fs.c
30
source/fs.c
@ -186,12 +186,11 @@ void loadPayload(u32 pressed, const char *payloadPath)
|
||||
u32 payloadSize = 0,
|
||||
maxPayloadSize = (u32)((u8 *)loaderAddress - (u8 *)firm);
|
||||
|
||||
char path[62] = {0},
|
||||
absPath[92] = {0};
|
||||
char absPath[24 + _MAX_LFN] = {0};
|
||||
char path[10 + _MAX_LFN] = {0};
|
||||
|
||||
u16 mountPoint[5] = {0};
|
||||
for(u32 i = 0; i < 4 && launchedPath[i] != u':'; i++)
|
||||
mountPoint[i] = launchedPath[i];
|
||||
|
||||
if(payloadPath == NULL)
|
||||
{
|
||||
@ -213,6 +212,7 @@ void loadPayload(u32 pressed, const char *payloadPath)
|
||||
FILINFO info;
|
||||
FRESULT result;
|
||||
|
||||
|
||||
result = f_findfirst(&dir, &info, "payloads", pattern);
|
||||
|
||||
if(result != FR_OK) return;
|
||||
@ -221,28 +221,22 @@ void loadPayload(u32 pressed, const char *payloadPath)
|
||||
|
||||
if(!info.fname[0]) return;
|
||||
|
||||
sprintf(path, "payloads/%s", info.altname);
|
||||
if(memcmp(mountPoint, u"nand", 8))
|
||||
sprintf(absPath, "nand:/rw/luma/payloads/%s", info.altname);
|
||||
else
|
||||
sprintf(absPath, "%s:/luma/payloads/%s", mountPoint, info.altname);
|
||||
sprintf(path, "payloads/%s", info.fname);
|
||||
|
||||
}
|
||||
else sprintf(path, "%s", payloadPath);
|
||||
|
||||
payloadSize = fileRead(firm, path, maxPayloadSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(memcmp(mountPoint, u"nand", 8))
|
||||
sprintf(absPath, "nand:/rw/luma/payloads/%s", payloadPath);
|
||||
else
|
||||
sprintf(absPath, "%s:/luma/payloads/%s", mountPoint, payloadPath);
|
||||
|
||||
payloadSize = fileRead(firm, payloadPath, maxPayloadSize);
|
||||
}
|
||||
|
||||
if(!payloadSize || !checkFirmPayload()) return;
|
||||
|
||||
writeConfig(true);
|
||||
|
||||
if(memcmp(mountPoint, u"nand", 8))
|
||||
sprintf(absPath, "nand:/rw/luma/%s", path);
|
||||
else
|
||||
sprintf(absPath, "sdmc:/luma/%s", path);
|
||||
|
||||
char *argv[1] = {absPath};
|
||||
memcpy(loaderAddress, loader_bin, loader_bin_size);
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#define PATTERN(a) a "_*.bin"
|
||||
#define PATTERN(a) a "_*.firm"
|
||||
|
||||
bool mountFs(bool isSd, bool switchToCtrNand);
|
||||
u32 fileRead(void *dest, const char *path, u32 maxSize);
|
||||
|
Reference in New Issue
Block a user