Little fixes
This commit is contained in:
parent
6b8474b7b9
commit
2a563eddd0
@ -10,7 +10,7 @@
|
|||||||
.arm
|
.arm
|
||||||
; fsOpenFileDirectly function will be redirected here.
|
; fsOpenFileDirectly function will be redirected here.
|
||||||
; If the requested archive is not ROMFS, we'll return
|
; If the requested archive is not ROMFS, we'll return
|
||||||
; to the original fucntion.
|
; to the original function.
|
||||||
openFileDirectlyHook:
|
openFileDirectlyHook:
|
||||||
cmp r3, #3
|
cmp r3, #3
|
||||||
beq openRomfs
|
beq openRomfs
|
||||||
|
@ -263,24 +263,24 @@ static u32 findFunctionCommand(u8* code, u32 size, u32 command)
|
|||||||
{
|
{
|
||||||
u32 func = 0;
|
u32 func = 0;
|
||||||
|
|
||||||
for(u32 i = 0; i < size && !func; i += 4)
|
for(u32 i = 0; !func && i <= size - 4; i += 4)
|
||||||
if(*(u32 *)(code + i) == command) func = i;
|
if(*(u32 *)(code + i) == command) func = i;
|
||||||
|
|
||||||
return !func ? 0 : findNearestStmfd(code, func);
|
return findNearestStmfd(code, func);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline u32 findThrowFatalError(u8* code, u32 size)
|
static inline u32 findThrowFatalError(u8* code, u32 size)
|
||||||
{
|
{
|
||||||
u32 connectToPort = 0;
|
u32 connectToPort = 0;
|
||||||
|
|
||||||
for(u32 i = 0; i < size && !connectToPort; i += 4)
|
for(u32 i = 4; !connectToPort && i <= size - 4; i += 4)
|
||||||
if(*(u32 *)(code + i) == 0xEF00002D) connectToPort = i - 4;
|
if(*(u32 *)(code + i) == 0xEF00002D) connectToPort = i - 4;
|
||||||
|
|
||||||
if(!connectToPort) return 0;
|
if(!connectToPort) return 0;
|
||||||
|
|
||||||
u32 func = 0;
|
u32 func = 0;
|
||||||
|
|
||||||
for(u32 i = 0; i < size && !func; i += 4)
|
for(u32 i = 0; !func && i <= size - 4; i += 4)
|
||||||
{
|
{
|
||||||
if(*(u32 *)(code + i) != MAKE_BRANCH_LINK(i, connectToPort)) continue;
|
if(*(u32 *)(code + i) != MAKE_BRANCH_LINK(i, connectToPort)) continue;
|
||||||
|
|
||||||
@ -333,23 +333,15 @@ static inline bool loadTitleLocaleConfig(u64 progId, u8 *regionId, u8 *languageI
|
|||||||
|
|
||||||
if(R_FAILED(openLumaFile(&file, path))) return true;
|
if(R_FAILED(openLumaFile(&file, path))) return true;
|
||||||
|
|
||||||
bool ret;
|
bool ret = false;
|
||||||
u64 fileSize;
|
u64 fileSize;
|
||||||
|
|
||||||
if(R_FAILED(IFile_GetSize(&file, &fileSize)) || fileSize < 6 || fileSize > 8)
|
if(R_FAILED(IFile_GetSize(&file, &fileSize)) || fileSize < 6 || fileSize > 8) goto exit;
|
||||||
{
|
|
||||||
ret = false;
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
char buf[8];
|
char buf[8];
|
||||||
u64 total;
|
u64 total;
|
||||||
|
|
||||||
if(R_FAILED(IFile_Read(&file, &total, buf, fileSize)))
|
if(R_FAILED(IFile_Read(&file, &total, buf, fileSize))) ret = false;
|
||||||
{
|
|
||||||
ret = false;
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
u32 i,
|
u32 i,
|
||||||
j;
|
j;
|
||||||
@ -396,33 +388,21 @@ static bool patchRomfsRedirection(u64 progId, u8* code, u32 size)
|
|||||||
|
|
||||||
if(R_FAILED(openLumaFile(&file, path))) return true;
|
if(R_FAILED(openLumaFile(&file, path))) return true;
|
||||||
|
|
||||||
bool ret;
|
bool ret = false;
|
||||||
u64 romfsSize;
|
u64 romfsSize;
|
||||||
|
|
||||||
if(R_FAILED(IFile_GetSize(&file, &romfsSize)))
|
if(R_FAILED(IFile_GetSize(&file, &romfsSize))) goto exit;
|
||||||
{
|
|
||||||
ret = false;
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
u64 total;
|
u64 total;
|
||||||
u32 header;
|
u32 magic;
|
||||||
|
|
||||||
if(R_FAILED(IFile_Read(&file, &total, &header, 4)) || total != 4 || header != 0x43465649)
|
if(R_FAILED(IFile_Read(&file, &total, &magic, 4)) || total != 4 || magic != 0x43465649) ret = false;
|
||||||
{
|
|
||||||
ret = false;
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
u32 fsOpenFileDirectly = findFunctionCommand(code, size, 0x08030204),
|
u32 fsOpenFileDirectly = findFunctionCommand(code, size, 0x08030204),
|
||||||
fsOpenLinkFile = findFunctionCommand(code, size, 0x80C0000),
|
fsOpenLinkFile = findFunctionCommand(code, size, 0x80C0000),
|
||||||
throwFatalError = findThrowFatalError(code, size);
|
throwFatalError = findThrowFatalError(code, size);
|
||||||
|
|
||||||
if(!fsOpenFileDirectly || !throwFatalError)
|
if(!fsOpenFileDirectly || !throwFatalError) goto exit;
|
||||||
{
|
|
||||||
ret = false;
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Setup the payload
|
//Setup the payload
|
||||||
memcpy(code + throwFatalError, romfsredir_bin, romfsredir_bin_size);
|
memcpy(code + throwFatalError, romfsredir_bin, romfsredir_bin_size);
|
||||||
|
Reference in New Issue
Block a user