Skip to content

Commit

Permalink
sync to latest commit
Browse files Browse the repository at this point in the history
Signed-off-by: Simo <[email protected]>
  • Loading branch information
Simo3ds authored Mar 9, 2024
1 parent 387d675 commit de1b859
Showing 1 changed file with 30 additions and 11 deletions.
41 changes: 30 additions & 11 deletions sysmodules/loader/source/patcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -651,23 +651,42 @@ static inline bool patchLayeredFs(u64 progId, u8 *code, u32 size, u32 textSize,
if(!findLayeredFsSymbols(code, textSize, &fsMountArchive, &fsRegisterArchive, &fsTryOpenFile, &fsOpenFileDirectly) ||
!findLayeredFsPayloadOffset(code, textSize, roSize, dataSize, roAddress, dataAddress, &payloadOffset, &pathOffset, &pathAddress)) return false;

static const char *updateRomFsMounts[] = { "rom2:",
static const char *updateRomFsMounts[] = { "ro2:",
"rom2:",
"rex:",
"patch:",
"ext:",
"rom:" };
u32 updateRomFsIndex;

//Locate update RomFSes
for(updateRomFsIndex = 0; updateRomFsIndex < sizeof(updateRomFsMounts) / sizeof(char *) - 1; updateRomFsIndex++)
{
u32 patternSize = strlen(updateRomFsMounts[updateRomFsIndex]);
u8 temp[7];
temp[0] = 0;
memcpy(temp + 1, updateRomFsMounts[updateRomFsIndex], patternSize);
if(memsearch(code, temp, size, patternSize + 1) != NULL) break;
bool isMarioKart7 = (u32)progId == 0x00030600 || //JPN MK7
(u32)progId == 0x00030700 || //EUR MK7
(u32)progId == 0x00030800 || //USA MK7
(u32)progId == 0x00030A00 || //KOR MK7
(u32)progId == 0x0008B400; //TWN MK7
// Exclude CHN as it never got updates

const char *updateRomFsMount;

if (isMarioKart7)

updateRomFsMount = "pat1"; // Isolated to prevent false-positives
}

else
{
u32 updateRomFsIndex;

//Locate update RomFS
for(updateRomFsIndex = 0; updateRomFsIndex < sizeof(updateRomFsMounts) / sizeof(char *) - 1; updateRomFsIndex++)
{
u32 patternSize = strlen(updateRomFsMounts[updateRomFsIndex]);
u8 temp[7];
temp[0] = 0;
memcpy(temp + 1, updateRomFsMounts[updateRomFsIndex], patternSize);
if(memsearch(code, temp, size, patternSize + 1) != NULL) break;
}
updateRomFsMount = updateRomFsMounts[updateRomFsIndex];

//Setup the payload
u8 *payload = code + payloadOffset;

Expand All @@ -679,7 +698,7 @@ static inline bool patchLayeredFs(u64 progId, u8 *code, u32 size, u32 textSize,
romfsRedirPatchFsMountArchive = 0x100000 + fsMountArchive;
romfsRedirPatchFsRegisterArchive = 0x100000 + fsRegisterArchive;
romfsRedirPatchArchiveId = archiveId;
memcpy(&romfsRedirPatchUpdateRomFsMount, updateRomFsMounts[updateRomFsIndex], 4);
memcpy(&romfsRedirPatchUpdateRomFsMount, updateRomFsMount, 4);

memcpy(payload, romfsRedirPatch, romfsRedirPatchSize);

Expand Down

0 comments on commit de1b859

Please sign in to comment.