From d5e74b91c741507f7f34385cc060af505d4770dd Mon Sep 17 00:00:00 2001 From: Aurora Date: Fri, 14 Oct 2016 18:03:17 +0200 Subject: [PATCH] Make loader read from CTRNAND just if SD is not mounted --- injector/source/ifile.c | 2 +- injector/source/patcher.c | 17 +++++++++++++---- source/patches.c | 2 +- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/injector/source/ifile.c b/injector/source/ifile.c index 672213b..1427566 100644 --- a/injector/source/ifile.c +++ b/injector/source/ifile.c @@ -63,4 +63,4 @@ Result IFile_Read(IFile *file, u64 *total, void *buffer, u32 len) *total = cur; return res; -} \ No newline at end of file +} diff --git a/injector/source/patcher.c b/injector/source/patcher.c index 9097d09..342eaf8 100644 --- a/injector/source/patcher.c +++ b/injector/source/patcher.c @@ -26,7 +26,7 @@ static void patchMemory(u8 *start, u32 size, const void *pattern, u32 patSize, i } } -static int fileOpen(IFile *file, FS_ArchiveID archiveId, const char *path, int flags) +static Result fileOpen(IFile *file, FS_ArchiveID archiveId, const char *path, int flags) { FS_Path filePath = {PATH_ASCII, strnlen(path, 255) + 1, path}, archivePath = {PATH_EMPTY, 1, (u8 *)""}; @@ -34,6 +34,15 @@ static int fileOpen(IFile *file, FS_ArchiveID archiveId, const char *path, int f return IFile_Open(file, archiveId, archivePath, filePath, flags); } +static Result openLumaFile(IFile *file, const char *path) +{ + Result res = fileOpen(file, ARCHIVE_SDMC, path, FS_OPEN_READ); + + if((u32)res == 0xC88044AB) res = fileOpen(file, ARCHIVE_NAND_RW, path, FS_OPEN_READ); //Returned if SD is not mounted + + return res; +} + static void loadCFWInfo(void) { static bool infoLoaded = false; @@ -77,7 +86,7 @@ static void loadCustomVerString(u16 *out, u32 *verStringSize, u32 currentNand) IFile file; - if(R_SUCCEEDED(fileOpen(&file, ARCHIVE_SDMC, paths[currentNand], FS_OPEN_READ)) || R_SUCCEEDED(fileOpen(&file, ARCHIVE_NAND_RW, paths[currentNand], FS_OPEN_READ))) + if(R_SUCCEEDED(openLumaFile(&file, paths[currentNand]))) { u64 fileSize; @@ -135,7 +144,7 @@ static void loadTitleCodeSection(u64 progId, u8 *code, u32 size) IFile file; - if(R_SUCCEEDED(fileOpen(&file, ARCHIVE_SDMC, path, FS_OPEN_READ)) || R_SUCCEEDED(fileOpen(&file, ARCHIVE_NAND_RW, path, FS_OPEN_READ))) + if(R_SUCCEEDED(openLumaFile(&file, path))) { u64 fileSize; @@ -161,7 +170,7 @@ static void loadTitleLocaleConfig(u64 progId, u8 *regionId, u8 *languageId) IFile file; - if(R_SUCCEEDED(fileOpen(&file, ARCHIVE_SDMC, path, FS_OPEN_READ)) || R_SUCCEEDED(fileOpen(&file, ARCHIVE_NAND_RW, path, FS_OPEN_READ))) + if(R_SUCCEEDED(openLumaFile(&file, path))) { u64 fileSize; diff --git a/source/patches.c b/source/patches.c index 39299fa..5b2a0ef 100644 --- a/source/patches.c +++ b/source/patches.c @@ -272,7 +272,7 @@ u32 implementSvcGetCFWInfo(u8 *pos, u32 *arm11SvcTable, u32 baseK11VA, u8 **free } else isRelease = rev[4] == 0; - info->flags = isRelease ? 1 : 0; + if(isRelease) info->flags = 1; arm11SvcTable[0x2E] = baseK11VA + *freeK11Space - pos; //Stubbed svc *freeK11Space += svcGetCFWInfo_bin_size;