Remove some ifdefs
This commit is contained in:
parent
8c79285774
commit
7271850df2
@ -35,10 +35,7 @@
|
||||
#include "buttons.h"
|
||||
#include "pin.h"
|
||||
#include "../build/injector.h"
|
||||
|
||||
#ifdef DEV
|
||||
#include "exceptions.h"
|
||||
#endif
|
||||
|
||||
extern u16 launchedFirmTidLow[8]; //Defined in start.s
|
||||
|
||||
@ -363,19 +360,12 @@ static inline void patchNativeFirm(u32 firmVersion, FirmwareSource nandType, u32
|
||||
process9MemAddr;
|
||||
u8 *process9Offset = getProcess9(arm9Section + 0x15000, section[2].size - 0x15000, &process9Size, &process9MemAddr);
|
||||
|
||||
#ifdef DEV
|
||||
//Find Kernel11 SVC table and handler, exceptions page and free space locations
|
||||
u32 baseK11VA;
|
||||
u8 *freeK11Space;
|
||||
u32 *arm11SvcHandler,
|
||||
*arm11ExceptionsPage,
|
||||
*arm11SvcTable = getKernel11Info(arm11Section1, section[1].size, &baseK11VA, &freeK11Space, &arm11SvcHandler, &arm11ExceptionsPage);
|
||||
#else
|
||||
//Find Kernel11 SVC table and free space locations
|
||||
u32 baseK11VA;
|
||||
u8 *freeK11Space;
|
||||
u32 *arm11SvcTable = getKernel11Info(arm11Section1, section[1].size, &baseK11VA, &freeK11Space);
|
||||
#endif
|
||||
|
||||
//Apply signature patches
|
||||
patchSignatureChecks(process9Offset, process9Size);
|
||||
@ -521,7 +511,7 @@ static inline void copySection0AndInjectSystemModules(FirmwareType firmType)
|
||||
}
|
||||
}
|
||||
#else
|
||||
static inline void copySection0AndInjectSystemModules(void)
|
||||
static inline void copySection0AndInjectSystemModules(FirmwareType firmType)
|
||||
{
|
||||
u32 srcModuleSize,
|
||||
dstModuleSize;
|
||||
@ -534,7 +524,7 @@ static inline void copySection0AndInjectSystemModules(void)
|
||||
|
||||
void *module;
|
||||
|
||||
if(memcmp(moduleName, "loader", 6) == 0)
|
||||
if(firmType == NATIVE_FIRM && memcmp(moduleName, "loader", 6) == 0)
|
||||
{
|
||||
module = (void *)injector;
|
||||
dstModuleSize = injector_size;
|
||||
@ -552,8 +542,7 @@ static inline void copySection0AndInjectSystemModules(void)
|
||||
|
||||
static inline void launchFirm(FirmwareType firmType)
|
||||
{
|
||||
#ifdef DEV
|
||||
//Allow module injection and/or inject 3ds_injector on new NATIVE_FIRMs and LGY FIRMs
|
||||
//Allow module injection and/or inject 3ds_injector on new NATIVE_FIRMs and LGY FIRMs (with DEV set)
|
||||
u32 sectionNum;
|
||||
if(firmType != SAFE_FIRM && firmType != NATIVE_FIRM1X2X)
|
||||
{
|
||||
@ -561,16 +550,6 @@ static inline void launchFirm(FirmwareType firmType)
|
||||
sectionNum = 1;
|
||||
}
|
||||
else sectionNum = 0;
|
||||
#else
|
||||
//If we're booting NATIVE_FIRM, section0 needs to be copied separately to inject 3ds_injector
|
||||
u32 sectionNum;
|
||||
if(firmType == NATIVE_FIRM)
|
||||
{
|
||||
copySection0AndInjectSystemModules();
|
||||
sectionNum = 1;
|
||||
}
|
||||
else sectionNum = 0;
|
||||
#endif
|
||||
|
||||
//Copy FIRM sections to respective memory locations
|
||||
for(; sectionNum < 4 && section[sectionNum].size; sectionNum++)
|
||||
|
@ -52,10 +52,6 @@ static inline void patchNativeFirm(u32 firmVersion, FirmwareSource nandType, u32
|
||||
static inline void patchLegacyFirm(FirmwareType firmType);
|
||||
static inline void patch1x2xNativeAndSafeFirm(void);
|
||||
|
||||
#ifdef DEV
|
||||
static inline void copySection0AndInjectSystemModules(FirmwareType firmType);
|
||||
#else
|
||||
static inline void copySection0AndInjectSystemModules(void);
|
||||
#endif
|
||||
|
||||
static inline void launchFirm(FirmwareType firmType);
|
@ -45,7 +45,6 @@ u8 *getProcess9(u8 *pos, u32 size, u32 *process9Size, u32 *process9MemAddr)
|
||||
return off - 0x204 + (*(u32 *)(off - 0x64) * 0x200) + 0x200;
|
||||
}
|
||||
|
||||
#ifdef DEV
|
||||
u32 *getKernel11Info(u8 *pos, u32 size, u32 *baseK11VA, u8 **freeK11Space, u32 **arm11SvcHandler, u32 **arm11ExceptionsPage)
|
||||
{
|
||||
const u8 pattern[] = {0x00, 0xB0, 0x9C, 0xE5};
|
||||
@ -65,26 +64,6 @@ u32 *getKernel11Info(u8 *pos, u32 size, u32 *baseK11VA, u8 **freeK11Space, u32 *
|
||||
|
||||
return arm11SvcTable;
|
||||
}
|
||||
#else
|
||||
u32 *getKernel11Info(u8 *pos, u32 size, u32 *baseK11VA, u8 **freeK11Space)
|
||||
{
|
||||
const u8 pattern[] = {0x00, 0xB0, 0x9C, 0xE5};
|
||||
|
||||
u32 *arm11ExceptionsPage = (u32 *)memsearch(pos, pattern, size, sizeof(pattern)) - 0xB;
|
||||
|
||||
u32 svcOffset = (-((arm11ExceptionsPage[2] & 0xFFFFFF) << 2) & (0xFFFFFF << 2)) - 8; //Branch offset + 8 for prefetch
|
||||
u32 pointedInstructionVA = 0xFFFF0008 - svcOffset;
|
||||
*baseK11VA = pointedInstructionVA & 0xFFFF0000; //This assumes that the pointed instruction has an offset < 0x10000, iirc that's always the case
|
||||
u32 *arm11SvcTable = (u32 *)(pos + *(u32 *)(pos + pointedInstructionVA - *baseK11VA + 8) - *baseK11VA); //SVC handler address
|
||||
while(*arm11SvcTable) arm11SvcTable++; //Look for SVC0 (NULL)
|
||||
|
||||
const u8 pattern2[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
|
||||
|
||||
*freeK11Space = memsearch(pos, pattern2, size, sizeof(pattern2)) + 1;
|
||||
|
||||
return arm11SvcTable;
|
||||
}
|
||||
#endif
|
||||
|
||||
void patchSignatureChecks(u8 *pos, u32 size)
|
||||
{
|
||||
@ -187,9 +166,9 @@ void implementSvcGetCFWInfo(u8 *pos, u32 *arm11SvcTable, u32 baseK11VA, u8 **fre
|
||||
else isRelease = rev[4] == 0;
|
||||
|
||||
#ifdef DEV
|
||||
info->flags = 1 /* dev branch */ | ((isRelease ? 1 : 0) << 1) /* is release */;
|
||||
info->flags = 1 /* dev build */ | ((isRelease ? 1 : 0) << 1) /* is release */;
|
||||
#else
|
||||
info->flags = 0 /* master branch */ | ((isRelease ? 1 : 0) << 1) /* is release */;
|
||||
info->flags = 0 /* non-dev build */ | ((isRelease ? 1 : 0) << 1) /* is release */;
|
||||
#endif
|
||||
|
||||
arm11SvcTable[0x2E] = baseK11VA + *freeK11Space - pos; //Stubbed svc
|
||||
|
@ -51,19 +51,11 @@ typedef struct __attribute__((packed))
|
||||
u32 config;
|
||||
} CFWInfo;
|
||||
|
||||
extern bool isN3DS;
|
||||
|
||||
#ifdef DEV
|
||||
extern bool isDevUnit;
|
||||
#endif
|
||||
extern bool isN3DS, isDevUnit;
|
||||
|
||||
u8 *getProcess9(u8 *pos, u32 size, u32 *process9Size, u32 *process9MemAddr);
|
||||
|
||||
#ifdef DEV
|
||||
u32 *getKernel11Info(u8 *pos, u32 size, u32 *baseK11VA, u8 **freeK11Space, u32 **arm11SvcHandler, u32 **arm11ExceptionsPage);
|
||||
#else
|
||||
u32 *getKernel11Info(u8 *pos, u32 size, u32 *baseK11VA, u8 **freeK11Space);
|
||||
#endif
|
||||
|
||||
void patchSignatureChecks(u8 *pos, u32 size);
|
||||
void patchTitleInstallMinVersionCheck(u8 *pos, u32 size);
|
||||
|
Reference in New Issue
Block a user