This commit is contained in:
Aurora Wright 2017-04-23 05:40:02 +02:00
parent 9656fe1b6f
commit 2e561f7ea9
2 changed files with 16 additions and 19 deletions

View File

@ -14,8 +14,8 @@
_start: _start:
; Jumps here before the fsOpenFileDirectly call ; Jumps here before the fsOpenFileDirectly call
_mountSd: _mountArchive:
b mountSd b mountArchive
.word 0xdead0000 ; Substituted opcode .word 0xdead0000 ; Substituted opcode
.word 0xdead0001 ; Branch to hooked function .word 0xdead0001 ; Branch to hooked function
@ -25,10 +25,10 @@ _start:
.word 0xdead0002 ; Substituted opcode .word 0xdead0002 ; Substituted opcode
.word 0xdead0003 ; Branch to hooked function .word 0xdead0003 ; Branch to hooked function
; Mounts SDMC and registers the archive as 'sdmc:' ; Mounts the archive and registers it as 'lfs:'
mountSd: mountArchive:
cmp r3, #3 cmp r3, #3
bne _mountSd+4 bne _mountArchive + 4
stmfd sp!, {r0-r4, lr} stmfd sp!, {r0-r4, lr}
sub sp, sp, #4 sub sp, sp, #4
load r1, archiveId load r1, archiveId
@ -43,18 +43,18 @@ _start:
blx r4 blx r4
add sp, sp, #4 add sp, sp, #4
ldmfd sp!, {r0-r4, lr} ldmfd sp!, {r0-r4, lr}
b _mountSd+4 b _mountArchive + 4
; Check the path passed to iFileOpen. ; Check the path passed to iFileOpen.
; If it is trying to access a RomFS file, we try to ; If it is trying to access a RomFS file, we try to
; open it from the title folder on the sdcard. ; open it from the LayeredFS folder.
; If the file cannot be opened from the sdcard, we just open ; If the file cannot be opened, we just open
; it from its original archive like nothing happened ; it from its original archive like nothing happened
fsRedir: fsRedir:
stmfd sp!, {r0-r12, lr} stmfd sp!, {r0-r12, lr}
ldrb r12, [r1] ldrb r12, [r1]
cmp r12, #0x72 ; 'r', should include "rom:" and "rom2:" cmp r12, #0x72 ; 'r', should include "rom:" and "rom2:"
cmpne r12, #0x70 ; 'p', should include "patch:" cmpne r12, #0x70 ; 'p', should include "patch:"
bne endRedir bne endRedir
sub sp, sp, #0x400 sub sp, sp, #0x400
pathRedir: pathRedir:
@ -69,7 +69,7 @@ _start:
sub r0, r0, #2 sub r0, r0, #2
pathRedir_2: pathRedir_2:
ldrh r2, [r1], #2 ldrh r2, [r1], #2
cmp r2, #0x3A ; ':' cmp r2, #0x3A ; ':'
bne pathRedir_2 bne pathRedir_2
pathRedir_3: pathRedir_3:
ldrh r2, [r1], #2 ldrh r2, [r1], #2
@ -78,7 +78,7 @@ _start:
bne pathRedir_3 bne pathRedir_3
ldmfd sp!, {r0-r3} ldmfd sp!, {r0-r3}
mov r1, sp mov r1, sp
bl _fsRedir+4 bl _fsRedir + 4
add sp, sp, #0x400 add sp, sp, #0x400
cmp r0, #0 cmp r0, #0
@ -86,14 +86,14 @@ _start:
ldmfd sp!, {r0-r12, lr} ldmfd sp!, {r0-r12, lr}
moveq r0, #0 moveq r0, #0
bxeq lr bxeq lr
b _fsRedir+4 b _fsRedir + 4
.pool .pool
.align 4 .align 4
archiveName : .word 0xdead0007 archiveName : .dcb "lfs:"
fsMountArchive : .word 0xdead0005 fsMountArchive : .word 0xdead0005
fsRegisterArchive : .word 0xdead0006 fsRegisterArchive : .word 0xdead0006
archiveId : .word 0xdead0008 archiveId : .word 0xdead0007
customPath : .word 0xdead0004 customPath : .word 0xdead0004
.close .close

View File

@ -520,7 +520,7 @@ static inline bool patchLayeredFs(u64 progId, u8* code, u32 size)
if(!archiveId) return true; if(!archiveId) return true;
const char *archiveName = archiveId == ARCHIVE_SDMC ? "sdc:" : "nnd:"; static const char *archiveName = "lfs:";
u32 fsMountArchive = 0xFFFFFFFF, u32 fsMountArchive = 0xFFFFFFFF,
fsRegisterArchive = 0xFFFFFFFF, fsRegisterArchive = 0xFFFFFFFF,
@ -564,9 +564,6 @@ static inline bool patchLayeredFs(u64 progId, u8* code, u32 size)
payload32[i] = 0x100000 + fsRegisterArchive; payload32[i] = 0x100000 + fsRegisterArchive;
break; break;
case 0xdead0007: case 0xdead0007:
memcpy(payload32 + i, archiveName, 4);
break;
case 0xdead0008:
payload32[i] = archiveId; payload32[i] = archiveId;
break; break;
} }