loader: replace NS N3DS CPU patch with exheader override, fix overriding exheader with homebrew

This commit is contained in:
Aurora Wright 2020-05-29 20:57:05 +02:00
parent 0471002d4c
commit 1899bf377b
2 changed files with 15 additions and 28 deletions

View File

@ -172,9 +172,6 @@ static Result GetProgramInfo(ExHeader_Info *exheaderInfo, u64 programHandle)
s64 nbSection0Modules;
svcGetSystemInfo(&nbSection0Modules, 26, 0);
// Force always having sdmc:/ and nand:/rw permission
exheaderInfo->aci.local_caps.storage_info.fs_access_info |= FSACCESS_NANDRW | FSACCESS_SDMC_RW;
// Tweak 3dsx placeholder title exheaderInfo
if (nbSection0Modules == 6 && exheaderInfo->aci.local_caps.title_id == HBLDR_3DSX_TID)
{
@ -182,11 +179,23 @@ static Result GetProgramInfo(ExHeader_Info *exheaderInfo, u64 programHandle)
HBLDR_PatchExHeaderInfo(exheaderInfo);
hbldrExit();
}
else
{
u64 originaltitleId = exheaderInfo->aci.local_caps.title_id;
if(CONFIG(PATCHGAMES) && loadTitleExheaderInfo(exheaderInfo->aci.local_caps.title_id, exheaderInfo))
exheaderInfo->aci.local_caps.title_id = originaltitleId;
if(isN3DS)
{
u32 cpuSetting = MULTICONFIG(NEWCPU);
if(cpuSetting & 0x1)
exheaderInfo->aci.local_caps.core_info.use_cpu_clockrate_804MHz = true;
if(cpuSetting & 0x2)
exheaderInfo->aci.local_caps.core_info.enable_l2c = true;
}
}
return res;
}

View File

@ -698,28 +698,6 @@ void patchCode(u64 progId, u16 progVer, u8 *code, u32 size, u32 textSize, u32 ro
if(ret == 0 || (ret == 1 && progVer > 0xB)) goto error;
}
if(isN3DS)
{
u32 cpuSetting = MULTICONFIG(NEWCPU);
if(cpuSetting != 0)
{
static const u8 pattern[] = {
0x0C, 0x00, 0x94, 0x15
};
u32 *off = (u32 *)memsearch(code, pattern, textSize, sizeof(pattern));
if(off == NULL) goto error;
//Patch N3DS CPU Clock and L2 cache setting
*(off - 4) = *(off - 3);
*(off - 3) = *(off - 1);
memmove(off - 1, off, 16);
*(off + 3) = 0xE3800000 | cpuSetting;
}
}
if(progVer > 0x12)
{
static const u8 pattern[] = {