loader: use fsMakePath

This commit is contained in:
TuxSH 2021-04-30 19:01:13 +01:00
parent 4ae4d16dba
commit 50c81f8165
3 changed files with 8 additions and 14 deletions

View File

@ -15,7 +15,7 @@ namespace util
{
inline FS_Path MakePath(const char *path)
{
return {PATH_ASCII, strnlen(path, 255) + 1, path};
return fsMakePath(PATH_ASCII, path);
}
// A small wrapper to make forgetting to close a file and

View File

@ -28,12 +28,9 @@ static u32 patchMemory(u8 *start, u32 size, const void *pattern, u32 patSize, s3
return i;
}
Result fileOpen(IFile *file, FS_ArchiveID archiveId, const char *path, int flags)
static Result fileOpen(IFile *file, FS_ArchiveID archiveId, const char *path, u32 flags)
{
FS_Path filePath = {PATH_ASCII, strnlen(path, 255) + 1, path},
archivePath = {PATH_EMPTY, 1, (u8 *)""};
return IFile_Open(file, archiveId, archivePath, filePath, flags);
return IFile_Open(file, archiveId, fsMakePath(PATH_ASCII, path), fsMakePath(PATH_EMPTY, ""), flags);
}
static bool dirCheck(FS_ArchiveID archiveId, const char *path)
@ -41,13 +38,11 @@ static bool dirCheck(FS_ArchiveID archiveId, const char *path)
bool ret;
Handle handle;
FS_Archive archive;
FS_Path dirPath = {PATH_ASCII, strnlen(path, 255) + 1, path},
archivePath = {PATH_EMPTY, 1, (u8 *)""};
if(R_FAILED(FSUSER_OpenArchive(&archive, archiveId, archivePath))) ret = false;
if(R_FAILED(FSUSER_OpenArchive(&archive, archiveId, fsMakePath(PATH_EMPTY, "")))) ret = false;
else
{
ret = R_SUCCEEDED(FSUSER_OpenDirectory(&handle, archive, dirPath));
ret = R_SUCCEEDED(FSUSER_OpenDirectory(&handle, archive, fsMakePath(PATH_ASCII, path)));
if(ret) FSDIR_Close(handle);
FSUSER_CloseArchive(archive);
}
@ -519,7 +514,7 @@ static inline bool patchLayeredFs(u64 progId, u8 *code, u32 size, u32 textSize,
//Locate update RomFSes
for(updateRomFsIndex = 0; updateRomFsIndex < sizeof(updateRomFsMounts) / sizeof(char *) - 1; updateRomFsIndex++)
{
u32 patternSize = strnlen(updateRomFsMounts[updateRomFsIndex], 255);
u32 patternSize = strlen(updateRomFsMounts[updateRomFsIndex]);
u8 temp[7];
temp[0] = 0;
memcpy(temp + 1, updateRomFsMounts[updateRomFsIndex], patternSize);
@ -834,10 +829,10 @@ void patchCode(u64 progId, u16 progVer, u8 *code, u32 size, u32 textSize, u32 ro
patch,
sizeof(patch), 1
)) goto error;
// Patch DLP client region check
u8 *found = memsearch(code, pattern2, textSize, sizeof(pattern2));
if (!patchMemory(found, textSize,
pattern3,
sizeof(pattern3), 1,

View File

@ -43,6 +43,5 @@ extern u32 config, multiConfig, bootConfig;
extern bool isN3DS, isSdMode;
void patchCode(u64 progId, u16 progVer, u8 *code, u32 size, u32 textSize, u32 roSize, u32 dataSize, u32 roAddress, u32 dataAddress);
Result fileOpen(IFile *file, FS_ArchiveID archiveId, const char *path, int flags);
bool loadTitleCodeSection(u64 progId, u8 *code, u32 size);
bool loadTitleExheaderInfo(u64 progId, ExHeader_Info *exheaderInfo);