From db33c315f2fc65938ed4ea53a630355076b64e27 Mon Sep 17 00:00:00 2001 From: Aurora Wright Date: Fri, 28 Apr 2017 00:33:30 +0200 Subject: [PATCH] Instead of filtering mountpoints in the LayeredFS payload by their first letters, change known mountpoints not starting with "r" to start with "r" throughout the code --- injector/patches/romfsredir.s | 2 -- injector/source/patcher.c | 24 +++++++++++++++++++----- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/injector/patches/romfsredir.s b/injector/patches/romfsredir.s index a26773f6..46d346f2 100644 --- a/injector/patches/romfsredir.s +++ b/injector/patches/romfsredir.s @@ -54,8 +54,6 @@ _start: stmfd sp!, {r0-r12, lr} ldrb r12, [r1] cmp r12, #0x72 ; 'r', should include "rom:", "rom2:" and "rex:" - cmpne r12, #0x70 ; 'p', should include "patch:" - cmpne r12, #0x65 ; 'e', should include "ext:" bne endRedir sub sp, sp, #0x400 pathRedir: diff --git a/injector/source/patcher.c b/injector/source/patcher.c index 2d7264b0..14539bf6 100644 --- a/injector/source/patcher.c +++ b/injector/source/patcher.c @@ -13,7 +13,7 @@ static u32 patchMemory(u8 *start, u32 size, const void *pattern, u32 patSize, in { u32 i; - for(i = 0; i < count; i++) + for(i = 0; !count || i < count; i++) { u8 *found = memsearch(start, pattern, size, patSize); @@ -510,7 +510,7 @@ exit: return ret; } -static inline bool patchLayeredFs(u64 progId, u8 *code, u32 size) +static inline bool patchLayeredFs(u64 progId, u8 *code, u32 size, u32 textSize) { /* Here we look for "/luma/titles/[u64 titleID in hex, uppercase]/romfs" If it exists it should be a folder containing ROMFS files */ @@ -530,8 +530,22 @@ static inline bool patchLayeredFs(u64 progId, u8 *code, u32 size) fsOpenFileDirectly = 0xFFFFFFFF, payloadOffset; - if(!findLayeredFsSymbols(code, size, &fsMountArchive, &fsRegisterArchive, &fsTryOpenFile, &fsOpenFileDirectly) || - !findLayeredFsPayloadOffset(code, size, &payloadOffset)) return false; + if(!findLayeredFsSymbols(code, textSize, &fsMountArchive, &fsRegisterArchive, &fsTryOpenFile, &fsOpenFileDirectly) || + !findLayeredFsPayloadOffset(code, textSize, &payloadOffset)) return false; + + static const char *updateRomFsMounts[] = { "patch:", + "ext:" }; + + //Change update RomFS mountpoints to start with "r" + for(u32 i = 0, ret = 0; i < sizeof(updateRomFsMounts) / sizeof(char *) && !ret; i++) + { + ret = patchMemory(code, size, + updateRomFsMounts[i], + strnlen(updateRomFsMounts[i], 255), 0, + "r", + 1, 0 + ); + } //Setup the payload u8 *payload = code + payloadOffset; @@ -840,7 +854,7 @@ void patchCode(u64 progId, u16 progVer, u8 *code, u32 size, u32 textSize, u32 ro if(!loadTitleCodeSection(progId, code, size) || !applyCodeIpsPatch(progId, code, size) || !loadTitleLocaleConfig(progId, ®ionId, &languageId) || - !patchLayeredFs(progId, code, textSize)) goto error; + !patchLayeredFs(progId, code, size, textSize)) goto error; if(regionId != 0xFF) {