From 9e473693653ae54b0ec719f02e5b4726a622ddb1 Mon Sep 17 00:00:00 2001 From: Aurora Wright Date: Fri, 2 Jun 2017 03:39:26 +0200 Subject: [PATCH] Add DS cart whitelist patch for home menu (both versions of the func should be supported) --- sysmodules/loader/source/patcher.c | 95 +++++++++++++++++++++++------- 1 file changed, 74 insertions(+), 21 deletions(-) diff --git a/sysmodules/loader/source/patcher.c b/sysmodules/loader/source/patcher.c index 160fade..b95c49c 100644 --- a/sysmodules/loader/source/patcher.c +++ b/sysmodules/loader/source/patcher.c @@ -629,29 +629,82 @@ void patchCode(u64 progId, u16 progVer, u8 *code, u32 size, u32 textSize, u32 ro { loadCFWInfo(); - if(((progId == 0x0004003000008F02LL || //USA Home Menu - progId == 0x0004003000008202LL || //JPN Home Menu - progId == 0x0004003000009802LL) //EUR Home Menu - && progVer > 4) || - (progId == 0x000400300000A902LL //KOR Home Menu - && progVer > 0) || - progId == 0x000400300000A102LL || //CHN Home Menu - progId == 0x000400300000B102LL) //TWN Home Menu + if(progId == 0x0004003000008F02LL || //USA Home Menu + progId == 0x0004003000008202LL || //JPN Home Menu + progId == 0x0004003000009802LL || //EUR Home Menu + progId == 0x000400300000A902LL || //KOR Home Menu + progId == 0x000400300000A102LL || //CHN Home Menu + progId == 0x000400300000B102LL) //TWN Home Menu { - static const u8 pattern[] = { - 0x0A, 0x0C, 0x00, 0x10 - }, - patch[] = { - 0x01, 0x00, 0xA0, 0xE3, 0x1E, 0xFF, 0x2F, 0xE1 - }; + bool applyRegionFreePatch = true, + applyNewDsWhitelistPatch = false; - //Patch SMDH region checks - if(!patchMemory(code, textSize, - pattern, - sizeof(pattern), -31, - patch, - sizeof(patch), 1 - )) goto error; + switch(progId) + { + case 0x0004003000008F02LL: //USA Home Menu + case 0x0004003000008202LL: //JPN Home Menu + case 0x0004003000009802LL: //EUR Home Menu + if(progVer <= 4) applyRegionFreePatch = false; + if(progVer >= 0xB) applyNewDsWhitelistPatch = true; + break; + case 0x000400300000A902LL: //KOR Home Menu + if(!progVer) applyRegionFreePatch = false; + if(progVer >= 6) applyNewDsWhitelistPatch = true; + break; + } + + if(applyRegionFreePatch) + { + static const u8 pattern[] = { + 0x0A, 0x0C, 0x00, 0x10 + }, + patch[] = { + 0x01, 0x00, 0xA0, 0xE3, 0x1E, 0xFF, 0x2F, 0xE1 + }; + + //Patch SMDH region checks + if(!patchMemory(code, textSize, + pattern, + sizeof(pattern), -31, + patch, + sizeof(patch), 1 + )) goto error; + } + + if(applyNewDsWhitelistPatch) + { + static const u8 pattern[] = { + 0xE9, 0x12, 0x20, 0xA0 + }, + patch[] = { + 0x00, 0x00, 0xA0, 0xE3, 0x1E, 0xFF, 0x2F, 0xE1 + }; + + //Patch DS title whitelist check + if(!patchMemory(code, textSize, + pattern, + sizeof(pattern), -3, + patch, + sizeof(patch), 1 + )) goto error; + } + else + { + static const u8 pattern[] = { + 0x4D, 0xE2, 0x12, 0x20 + }, + patch[] = { + 0x00, 0x00, 0xA0, 0xE3, 0x1E, 0xFF, 0x2F, 0xE1 + }; + + //Patch DS title whitelist check + if(!patchMemory(code, textSize, + pattern, + sizeof(pattern), -6, + patch, + sizeof(patch), 1 + )) goto error; + } } else if(progId == 0x0004013000003202LL) //FRIENDS