We don't really need two sets of blank spaces
This commit is contained in:
parent
fc994285f9
commit
b58cbd228c
@ -26,11 +26,10 @@ sd_notmounted equ 0xC8804465 ; Error code returned when SD is not mounted
|
||||
cmp r0, r2
|
||||
bne pxi_wait_recv
|
||||
|
||||
adr r1, sd_fname
|
||||
|
||||
open_payload:
|
||||
; Open file
|
||||
add r0, r7, #8
|
||||
adr r1, fname
|
||||
mov r2, #1
|
||||
ldr r6, [fopen]
|
||||
orr r6, 1
|
||||
@ -40,7 +39,10 @@ sd_notmounted equ 0xC8804465 ; Error code returned when SD is not mounted
|
||||
ldr r2, =sd_notmounted
|
||||
cmp r0, r2
|
||||
bne svcBreak
|
||||
adr r1, nand_fname
|
||||
adr r0, fname
|
||||
adr r1, nand_mount
|
||||
mov r2, #8
|
||||
bl memcpy16
|
||||
b open_payload
|
||||
|
||||
read_payload:
|
||||
@ -54,14 +56,10 @@ sd_notmounted equ 0xC8804465 ; Error code returned when SD is not mounted
|
||||
blx r6
|
||||
|
||||
; Copy the low TID (in UTF-16) of the wanted firm to the 5th byte of the payload
|
||||
add r0, r8, 0x1A
|
||||
add r1, r0, #0x10
|
||||
ldr r2, =payload_addr + 4
|
||||
copy_TID_low:
|
||||
ldrh r3, [r0], #2
|
||||
strh r3, [r2], #2
|
||||
cmp r0, r1
|
||||
blo copy_TID_low
|
||||
ldr r0, =payload_addr + 4
|
||||
add r1, r8, 0x1A
|
||||
mov r2, #0x10
|
||||
bl memcpy16
|
||||
|
||||
; Set kernel state
|
||||
mov r0, #0
|
||||
@ -79,6 +77,15 @@ sd_notmounted equ 0xC8804465 ; Error code returned when SD is not mounted
|
||||
die:
|
||||
b die
|
||||
|
||||
memcpy16:
|
||||
add r2, r0, r2
|
||||
copy_loop:
|
||||
ldrh r3, [r1], #2
|
||||
strh r3, [r0], #2
|
||||
cmp r0, r2
|
||||
blo copy_loop
|
||||
bx lr
|
||||
|
||||
svcBreak:
|
||||
swi 0x3C
|
||||
b die
|
||||
@ -86,11 +93,10 @@ sd_notmounted equ 0xC8804465 ; Error code returned when SD is not mounted
|
||||
bytes_read: .word 0
|
||||
fopen: .ascii "OPEN"
|
||||
.pool
|
||||
sd_fname: .dcw "sdmc:/arm9loaderhax.bin"
|
||||
fname: .dcw "sdmc:/arm9loaderhax.bin"
|
||||
.word 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
.pool
|
||||
nand_fname: .dcw "nand:/arm9loaderhax.bin"
|
||||
.word 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
nand_mount: .dcw "nand"
|
||||
|
||||
.align 4
|
||||
kernelcode_start:
|
||||
|
@ -36,7 +36,7 @@
|
||||
|
||||
static Firm *firm = (Firm *)0x24000000;
|
||||
|
||||
u32 loadFirm(FirmwareType *firmType, FirmwareSource nandType, bool loadFromStorage, bool isSdMode)
|
||||
u32 loadFirm(FirmwareType *firmType, FirmwareSource nandType, bool loadFromStorage)
|
||||
{
|
||||
const char *firmwareFiles[] = {
|
||||
"firmware.bin",
|
||||
@ -51,8 +51,6 @@ u32 loadFirm(FirmwareType *firmType, FirmwareSource nandType, bool loadFromStora
|
||||
"cetk_safe"
|
||||
};
|
||||
|
||||
if(isSdMode && !mountFs(false, false)) error("Failed to mount CTRNAND.");
|
||||
|
||||
//Load FIRM from CTRNAND
|
||||
u32 firmVersion = firmRead(firm, (u32)*firmType);
|
||||
|
||||
@ -109,7 +107,7 @@ u32 loadFirm(FirmwareType *firmType, FirmwareSource nandType, bool loadFromStora
|
||||
return firmVersion;
|
||||
}
|
||||
|
||||
u32 patchNativeFirm(u32 firmVersion, FirmwareSource nandType, u32 emuHeader, bool isA9lhInstalled, bool isSdMode, u32 devMode)
|
||||
u32 patchNativeFirm(u32 firmVersion, FirmwareSource nandType, u32 emuHeader, bool isA9lhInstalled, u32 devMode)
|
||||
{
|
||||
u8 *arm9Section = (u8 *)firm + firm->section[2].offset,
|
||||
*arm11Section1 = (u8 *)firm + firm->section[1].offset;
|
||||
@ -148,7 +146,7 @@ u32 patchNativeFirm(u32 firmVersion, FirmwareSource nandType, u32 emuHeader, boo
|
||||
else if(isA9lhInstalled) ret += patchFirmWrites(process9Offset, process9Size);
|
||||
|
||||
//Apply firmlaunch patches
|
||||
ret += patchFirmlaunches(process9Offset, process9Size, process9MemAddr, isSdMode);
|
||||
ret += patchFirmlaunches(process9Offset, process9Size, process9MemAddr);
|
||||
|
||||
//11.0 FIRM patches
|
||||
if(firmVersion >= (ISN3DS ? 0x21 : 0x52))
|
||||
|
@ -24,8 +24,8 @@
|
||||
|
||||
#include "types.h"
|
||||
|
||||
u32 loadFirm(FirmwareType *firmType, FirmwareSource nandType, bool loadFromStorage, bool isSdMode);
|
||||
u32 patchNativeFirm(u32 firmVersion, FirmwareSource nandType, u32 emuHeader, bool isA9lhInstalled, bool isSdMode, u32 devMode);
|
||||
u32 loadFirm(FirmwareType *firmType, FirmwareSource nandType, bool loadFromStorage);
|
||||
u32 patchNativeFirm(u32 firmVersion, FirmwareSource nandType, u32 emuHeader, bool isA9lhInstalled, u32 devMode);
|
||||
u32 patchTwlFirm(u32 firmVersion, u32 devMode);
|
||||
u32 patchAgbFirm(u32 devMode);
|
||||
u32 patch1x2xNativeAndSafeFirm(u32 devMode);
|
||||
|
@ -225,8 +225,10 @@ void main(void)
|
||||
writeConfig(needConfig, configTemp);
|
||||
}
|
||||
|
||||
if(isSdMode && !mountFs(false, false)) error("Failed to mount CTRNAND.");
|
||||
|
||||
bool loadFromStorage = CONFIG(LOADEXTFIRMSANDMODULES);
|
||||
u32 firmVersion = loadFirm(&firmType, firmSource, loadFromStorage, isSdMode);
|
||||
u32 firmVersion = loadFirm(&firmType, firmSource, loadFromStorage);
|
||||
|
||||
u32 devMode = MULTICONFIG(DEVOPTIONS);
|
||||
|
||||
@ -234,7 +236,7 @@ void main(void)
|
||||
switch(firmType)
|
||||
{
|
||||
case NATIVE_FIRM:
|
||||
res = patchNativeFirm(firmVersion, nandType, emuHeader, isA9lhInstalled, isSdMode, devMode);
|
||||
res = patchNativeFirm(firmVersion, nandType, emuHeader, isA9lhInstalled, devMode);
|
||||
break;
|
||||
case SAFE_FIRM:
|
||||
case NATIVE_FIRM1X2X:
|
||||
|
@ -101,7 +101,7 @@ u32 patchSignatureChecks(u8 *pos, u32 size)
|
||||
return ret;
|
||||
}
|
||||
|
||||
u32 patchFirmlaunches(u8 *pos, u32 size, u32 process9MemAddr, bool isSdMode)
|
||||
u32 patchFirmlaunches(u8 *pos, u32 size, u32 process9MemAddr)
|
||||
{
|
||||
//Look for firmlaunch code
|
||||
const u8 pattern[] = {0xE2, 0x20, 0x20, 0x90};
|
||||
@ -145,7 +145,7 @@ u32 patchFirmlaunches(u8 *pos, u32 size, u32 process9MemAddr, bool isSdMode)
|
||||
for(u32 i = 0; i < pathSize; i++)
|
||||
finalPath[i] = (u16)path[i];
|
||||
|
||||
u8 *pos_path = memsearch(off, isSdMode ? u"sd" : u"na", reboot_bin_size, 4) + 0xA;
|
||||
u8 *pos_path = memsearch(off, u"sd", reboot_bin_size, 4) + 0xA;
|
||||
memcpy(pos_path, finalPath, pathSize * 2);
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ u8 *getProcess9Info(u8 *pos, u32 size, u32 *process9Size, u32 *process9MemAddr);
|
||||
u32 *getKernel11Info(u8 *pos, u32 size, u32 *baseK11VA, u8 **freeK11Space, u32 **arm11SvcHandler, u32 **arm11ExceptionsPage);
|
||||
u32 patchSignatureChecks(u8 *pos, u32 size);
|
||||
u32 patchTitleInstallMinVersionChecks(u8 *pos, u32 size, u32 firmVersion);
|
||||
u32 patchFirmlaunches(u8 *pos, u32 size, u32 process9MemAddr, bool isSdMode);
|
||||
u32 patchFirmlaunches(u8 *pos, u32 size, u32 process9MemAddr);
|
||||
u32 patchFirmWrites(u8 *pos, u32 size);
|
||||
u32 patchOldFirmWrites(u8 *pos, u32 size);
|
||||
u32 reimplementSvcBackdoor(u8 *pos, u32 *arm11SvcTable, u32 baseK11VA, u8 **freeK11Space);
|
||||
|
Reference in New Issue
Block a user