From f46773ba64b808eb40a743bd5aeed9b304bbd88e Mon Sep 17 00:00:00 2001 From: Aurora Wright Date: Wed, 20 Sep 2017 01:02:14 +0200 Subject: [PATCH] Stub isTitleAllowed --- sysmodules/loader/source/memory.c | 8 ++++++++ sysmodules/loader/source/memory.h | 1 + sysmodules/loader/source/patcher.c | 19 +++++++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/sysmodules/loader/source/memory.c b/sysmodules/loader/source/memory.c index ec7a392..2836802 100644 --- a/sysmodules/loader/source/memory.c +++ b/sysmodules/loader/source/memory.c @@ -9,6 +9,14 @@ void memcpy(void *dest, const void *src, u32 size) destc[i] = srcc[i]; } +void memset32(void *dest, u32 filler, u32 size) +{ + u32 *dest32 = (u32 *)dest; + + for(u32 i = 0; i < size / 4; i++) + dest32[i] = filler; +} + int memcmp(const void *buf1, const void *buf2, u32 size) { const u8 *buf1c = (const u8 *)buf1, diff --git a/sysmodules/loader/source/memory.h b/sysmodules/loader/source/memory.h index b7cf593..85afe06 100644 --- a/sysmodules/loader/source/memory.h +++ b/sysmodules/loader/source/memory.h @@ -3,5 +3,6 @@ #include <3ds/types.h> void memcpy(void *dest, const void *src, u32 size); +void memset32(void *dest, u32 filler, u32 size); int memcmp(const void *buf1, const void *buf2, u32 size); u8 *memsearch(u8 *startPos, const void *pattern, u32 size, u32 patternSize); \ No newline at end of file diff --git a/sysmodules/loader/source/patcher.c b/sysmodules/loader/source/patcher.c index 5997120..491cb5a 100644 --- a/sysmodules/loader/source/patcher.c +++ b/sysmodules/loader/source/patcher.c @@ -761,6 +761,25 @@ void patchCode(u64 progId, u16 progVer, u8 *code, u32 size, u32 textSize, u32 ro } } + if(progVer > 0x12) + { + static const u8 pattern[] = { + 0x00, 0xB1, 0x15, 0x00 + }; + + u8 *roStart = code + ((textSize + 4095) & 0xFFFFF000), + *start = memsearch(roStart, pattern, roSize, sizeof(pattern)); + + if(start == NULL) goto error; + + start++; + u8 *end; + for(end = start + 8; *(u32 *)end != 0xCC010000; end += 8) + if(end >= roStart + roSize - 12) goto error; + + memset32(start, 0, end - start); + } + s64 nbSection0Modules; svcGetSystemInfo(&nbSection0Modules, 26, 0);