Fix https://github.com/AuroraWright/Luma3DS/issues/1095 and https://github.com/AuroraWright/Luma3DS/issues/1118
This commit is contained in:
parent
2219b19d5f
commit
53622d777b
@ -71,7 +71,7 @@ Result GetSystemInfoHook(s64 *out, s32 type, s32 param)
|
|||||||
case 0x201: // isN3DS
|
case 0x201: // isN3DS
|
||||||
*out = (cfwInfo.flags >> 4) & 1;
|
*out = (cfwInfo.flags >> 4) & 1;
|
||||||
break;
|
break;
|
||||||
case 0x202: // isSafeMode
|
case 0x202: // needToInitSd
|
||||||
*out = (cfwInfo.flags >> 5) & 1;
|
*out = (cfwInfo.flags >> 5) & 1;
|
||||||
break;
|
break;
|
||||||
case 0x203: // isSdMode
|
case 0x203: // isSdMode
|
||||||
|
@ -344,7 +344,7 @@ static inline void mergeSection0(FirmwareType firmType, u32 firmVersion, bool lo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 patchNativeFirm(u32 firmVersion, FirmwareSource nandType, bool loadFromStorage, bool isFirmProtEnabled, bool isSafeMode, bool doUnitinfoPatch)
|
u32 patchNativeFirm(u32 firmVersion, FirmwareSource nandType, bool loadFromStorage, bool isFirmProtEnabled, bool needToInitSd, bool doUnitinfoPatch)
|
||||||
{
|
{
|
||||||
u8 *arm9Section = (u8 *)firm + firm->section[2].offset,
|
u8 *arm9Section = (u8 *)firm + firm->section[2].offset,
|
||||||
*arm11Section1 = (u8 *)firm + firm->section[1].offset;
|
*arm11Section1 = (u8 *)firm + firm->section[1].offset;
|
||||||
@ -374,7 +374,7 @@ u32 patchNativeFirm(u32 firmVersion, FirmwareSource nandType, bool loadFromStora
|
|||||||
//Skip on FIRMs < 4.0
|
//Skip on FIRMs < 4.0
|
||||||
if(ISN3DS || firmVersion >= 0x1D)
|
if(ISN3DS || firmVersion >= 0x1D)
|
||||||
{
|
{
|
||||||
ret += installK11Extension(arm11Section1, firm->section[1].size, isSafeMode, baseK11VA, arm11ExceptionsPage, &freeK11Space);
|
ret += installK11Extension(arm11Section1, firm->section[1].size, needToInitSd, baseK11VA, arm11ExceptionsPage, &freeK11Space);
|
||||||
ret += patchKernel11(arm11Section1, firm->section[1].size, baseK11VA, arm11SvcTable, arm11ExceptionsPage);
|
ret += patchKernel11(arm11Section1, firm->section[1].size, baseK11VA, arm11SvcTable, arm11ExceptionsPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
u32 loadNintendoFirm(FirmwareType *firmType, FirmwareSource nandType, bool loadFromStorage, bool isSafeMode);
|
u32 loadNintendoFirm(FirmwareType *firmType, FirmwareSource nandType, bool loadFromStorage, bool isSafeMode);
|
||||||
void loadHomebrewFirm(u32 pressed);
|
void loadHomebrewFirm(u32 pressed);
|
||||||
u32 patchNativeFirm(u32 firmVersion, FirmwareSource nandType, bool loadFromStorage, bool isFirmProtEnabled, bool isSafeMode, bool doUnitinfoPatch);
|
u32 patchNativeFirm(u32 firmVersion, FirmwareSource nandType, bool loadFromStorage, bool isFirmProtEnabled, bool needToInitSd, bool doUnitinfoPatch);
|
||||||
u32 patchTwlFirm(u32 firmVersion, bool loadFromStorage, bool doUnitinfoPatch);
|
u32 patchTwlFirm(u32 firmVersion, bool loadFromStorage, bool doUnitinfoPatch);
|
||||||
u32 patchAgbFirm(bool loadFromStorage, bool doUnitinfoPatch);
|
u32 patchAgbFirm(bool loadFromStorage, bool doUnitinfoPatch);
|
||||||
u32 patch1x2xNativeAndSafeFirm(void);
|
u32 patch1x2xNativeAndSafeFirm(void);
|
||||||
|
@ -51,6 +51,7 @@ void main(int argc, char **argv, u32 magicWord)
|
|||||||
{
|
{
|
||||||
bool isFirmProtEnabled,
|
bool isFirmProtEnabled,
|
||||||
isSafeMode = false,
|
isSafeMode = false,
|
||||||
|
needToInitSd = false,
|
||||||
isNoForceFlagSet = false,
|
isNoForceFlagSet = false,
|
||||||
isNtrBoot;
|
isNtrBoot;
|
||||||
FirmwareType firmType;
|
FirmwareType firmType;
|
||||||
@ -192,9 +193,16 @@ void main(int argc, char **argv, u32 magicWord)
|
|||||||
goto boot;
|
goto boot;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Else, force the last used boot options unless a button is pressed
|
//Account for DSiWare soft resets if exiting TWL_FIRM
|
||||||
|
if(CFG_BOOTENV == 3)
|
||||||
|
{
|
||||||
|
static const u8 TLNC[] = {0x54, 0x4C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4E, 0x43};
|
||||||
|
if(memcmp((void *)0x20000C00, TLNC, 10) == 0) needToInitSd = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Force the last used boot options if autobooting a TWL title, or unless a button is pressed
|
||||||
or the no-forcing flag is set */
|
or the no-forcing flag is set */
|
||||||
if(!pressed && !BOOTCFG_NOFORCEFLAG)
|
if(needToInitSd || memcmp((void *)0x20000300, "TLNC", 4) == 0 || (!pressed && !BOOTCFG_NOFORCEFLAG))
|
||||||
{
|
{
|
||||||
nandType = (FirmwareSource)BOOTCFG_NAND;
|
nandType = (FirmwareSource)BOOTCFG_NAND;
|
||||||
firmSource = (FirmwareSource)BOOTCFG_FIRM;
|
firmSource = (FirmwareSource)BOOTCFG_FIRM;
|
||||||
@ -223,6 +231,7 @@ void main(int argc, char **argv, u32 magicWord)
|
|||||||
firmSource = FIRMWARE_SYSNAND;
|
firmSource = FIRMWARE_SYSNAND;
|
||||||
|
|
||||||
isSafeMode = true;
|
isSafeMode = true;
|
||||||
|
needToInitSd = true;
|
||||||
|
|
||||||
//If the PIN has been verified, wait to make it easier to press the SAFE_MODE combo
|
//If the PIN has been verified, wait to make it easier to press the SAFE_MODE combo
|
||||||
if(pinExists && !shouldLoadConfigMenu)
|
if(pinExists && !shouldLoadConfigMenu)
|
||||||
@ -328,7 +337,7 @@ boot:
|
|||||||
switch(firmType)
|
switch(firmType)
|
||||||
{
|
{
|
||||||
case NATIVE_FIRM:
|
case NATIVE_FIRM:
|
||||||
res = patchNativeFirm(firmVersion, nandType, loadFromStorage, isFirmProtEnabled, isSafeMode, doUnitinfoPatch);
|
res = patchNativeFirm(firmVersion, nandType, loadFromStorage, isFirmProtEnabled, needToInitSd, doUnitinfoPatch);
|
||||||
break;
|
break;
|
||||||
case TWL_FIRM:
|
case TWL_FIRM:
|
||||||
res = patchTwlFirm(firmVersion, loadFromStorage, doUnitinfoPatch);
|
res = patchTwlFirm(firmVersion, loadFromStorage, doUnitinfoPatch);
|
||||||
|
@ -100,7 +100,7 @@ static inline u32 *getKernel11HandlerVAPos(u8 *pos, u32 *arm11ExceptionsPage, u3
|
|||||||
return (u32 *)(pos + pointedInstructionVA - baseK11VA + 8);
|
return (u32 *)(pos + pointedInstructionVA - baseK11VA + 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 installK11Extension(u8 *pos, u32 size, bool isSafeMode, u32 baseK11VA, u32 *arm11ExceptionsPage, u8 **freeK11Space)
|
u32 installK11Extension(u8 *pos, u32 size, bool needToInitSd, u32 baseK11VA, u32 *arm11ExceptionsPage, u8 **freeK11Space)
|
||||||
{
|
{
|
||||||
//The parameters to be passed on to the kernel ext
|
//The parameters to be passed on to the kernel ext
|
||||||
//Please keep that in sync with the definition in k11_extension/source/main.c
|
//Please keep that in sync with the definition in k11_extension/source/main.c
|
||||||
@ -201,7 +201,7 @@ u32 installK11Extension(u8 *pos, u32 size, bool isSafeMode, u32 baseK11VA, u32 *
|
|||||||
|
|
||||||
if(ISRELEASE) info->flags = 1;
|
if(ISRELEASE) info->flags = 1;
|
||||||
if(ISN3DS) info->flags |= 1 << 4;
|
if(ISN3DS) info->flags |= 1 << 4;
|
||||||
if(isSafeMode) info->flags |= 1 << 5;
|
if(needToInitSd) info->flags |= 1 << 5;
|
||||||
if(isSdMode) info->flags |= 1 << 6;
|
if(isSdMode) info->flags |= 1 << 6;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
|
|
||||||
u8 *getProcess9Info(u8 *pos, u32 size, u32 *process9Size, u32 *process9MemAddr);
|
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 *getKernel11Info(u8 *pos, u32 size, u32 *baseK11VA, u8 **freeK11Space, u32 **arm11SvcHandler, u32 **arm11ExceptionsPage);
|
||||||
u32 installK11Extension(u8 *pos, u32 size, bool isSafeMode, u32 baseK11VA, u32 *arm11ExceptionsPage, u8 **freeK11Space);
|
u32 installK11Extension(u8 *pos, u32 size, bool needToInitSd, u32 baseK11VA, u32 *arm11ExceptionsPage, u8 **freeK11Space);
|
||||||
u32 patchKernel11(u8 *pos, u32 size, u32 baseK11VA, u32 *arm11SvcTable, u32 *arm11ExceptionsPage);
|
u32 patchKernel11(u8 *pos, u32 size, u32 baseK11VA, u32 *arm11SvcTable, u32 *arm11ExceptionsPage);
|
||||||
u32 patchSignatureChecks(u8 *pos, u32 size);
|
u32 patchSignatureChecks(u8 *pos, u32 size);
|
||||||
u32 patchOldSignatureChecks(u8 *pos, u32 size);
|
u32 patchOldSignatureChecks(u8 *pos, u32 size);
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
#define HBLDR_3DSX_TID (*(vu64 *)0x1FF81100)
|
#define HBLDR_3DSX_TID (*(vu64 *)0x1FF81100)
|
||||||
|
|
||||||
u32 config, multiConfig, bootConfig;
|
u32 config, multiConfig, bootConfig;
|
||||||
bool isN3DS, isSafeMode, isSdMode;
|
bool isN3DS, needToInitSd, isSdMode;
|
||||||
|
|
||||||
const char CODE_PATH[] = {0x01, 0x00, 0x00, 0x00, 0x2E, 0x63, 0x6F, 0x64, 0x65, 0x00, 0x00, 0x00};
|
const char CODE_PATH[] = {0x01, 0x00, 0x00, 0x00, 0x2E, 0x63, 0x6F, 0x64, 0x65, 0x00, 0x00, 0x00};
|
||||||
|
|
||||||
@ -47,12 +47,12 @@ static inline void loadCFWInfo(void)
|
|||||||
if(R_FAILED(svcGetSystemInfo(&out, 0x10000, 0x201))) svcBreak(USERBREAK_ASSERT);
|
if(R_FAILED(svcGetSystemInfo(&out, 0x10000, 0x201))) svcBreak(USERBREAK_ASSERT);
|
||||||
isN3DS = (bool)out;
|
isN3DS = (bool)out;
|
||||||
if(R_FAILED(svcGetSystemInfo(&out, 0x10000, 0x202))) svcBreak(USERBREAK_ASSERT);
|
if(R_FAILED(svcGetSystemInfo(&out, 0x10000, 0x202))) svcBreak(USERBREAK_ASSERT);
|
||||||
isSafeMode = (bool)out;
|
needToInitSd = (bool)out;
|
||||||
if(R_FAILED(svcGetSystemInfo(&out, 0x10000, 0x203))) svcBreak(USERBREAK_ASSERT);
|
if(R_FAILED(svcGetSystemInfo(&out, 0x10000, 0x203))) svcBreak(USERBREAK_ASSERT);
|
||||||
isSdMode = (bool)out;
|
isSdMode = (bool)out;
|
||||||
|
|
||||||
IFile file;
|
IFile file;
|
||||||
if(isSafeMode) fileOpen(&file, ARCHIVE_SDMC, "/", FS_OPEN_READ); //Init SD card if SAFE_MODE is being booted
|
if(needToInitSd) fileOpen(&file, ARCHIVE_SDMC, "/", FS_OPEN_READ); //Init SD card if SAFE_MODE is being booted
|
||||||
}
|
}
|
||||||
|
|
||||||
static int lzss_decompress(u8 *end)
|
static int lzss_decompress(u8 *end)
|
||||||
|
@ -39,7 +39,7 @@ enum singleOptions
|
|||||||
};
|
};
|
||||||
|
|
||||||
extern u32 config, multiConfig, bootConfig;
|
extern u32 config, multiConfig, bootConfig;
|
||||||
extern bool isN3DS, isSafeMode, isSdMode;
|
extern bool isN3DS, needToInitSd, isSdMode;
|
||||||
|
|
||||||
void patchCode(u64 progId, u16 progVer, u8 *code, u32 size, u32 textSize, u32 roSize, u32 dataSize, u32 roAddress, u32 dataAddress);
|
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);
|
Result fileOpen(IFile *file, FS_ArchiveID archiveId, const char *path, int flags);
|
||||||
|
Reference in New Issue
Block a user