Make 3ds_injector able to be bigger than the official loader module (max. 25KB on O3DS due to memory limitations). Thanks @mid-kid for the idea.
This commit is contained in:
parent
9e87679ee2
commit
be54052b6d
@ -283,8 +283,8 @@ static inline void patchNativeFirm(u32 nandType, u32 emuHeader, u32 a9lhMode)
|
||||
*(u16 *)sigOffset2 = sigPatch[0];
|
||||
*((u16 *)sigOffset2 + 1) = sigPatch[1];
|
||||
|
||||
//Replace the FIRM loader with the injector
|
||||
injectLoader();
|
||||
//Replace the FIRM loader with the injector while copying section0
|
||||
copySection0AndInjectLoader();
|
||||
}
|
||||
|
||||
static inline void patchEmuNAND(u8 *arm9Section, u8 *proc9Offset, u32 emuHeader)
|
||||
@ -342,21 +342,16 @@ static inline void patchReboots(u8 *arm9Section, u8 *proc9Offset)
|
||||
*pos_fopen = fOpenOffset;
|
||||
}
|
||||
|
||||
static inline void injectLoader(void)
|
||||
static inline void copySection0AndInjectLoader(void)
|
||||
{
|
||||
u32 loaderSize;
|
||||
|
||||
void *loaderOffset = getLoader((u8 *)firm + section[0].offset, section[0].size, &loaderSize);
|
||||
|
||||
//Check that the injector CXI isn't larger than the original
|
||||
if((u32)injector_size <= loaderSize)
|
||||
{
|
||||
memcpy(loaderOffset, injector, injector_size);
|
||||
|
||||
//Patch content size and ExeFS size to match the repaced loader's ones
|
||||
*((u32 *)loaderOffset + 0x41) = loaderSize / 0x200;
|
||||
*((u32 *)loaderOffset + 0x69) = loaderSize / 0x200 - 5;
|
||||
}
|
||||
u8 *arm11Section0 = (u8 *)firm + section[0].offset;
|
||||
u32 injectorOffset = (u8 *)getLoader((u8 *)firm + section[0].offset, section[0].size, &loaderSize) - arm11Section0;
|
||||
u32 remaining = section[0].size - (injectorOffset + loaderSize);
|
||||
|
||||
memcpy(section[0].address, arm11Section0, injectorOffset);
|
||||
memcpy(section[0].address + injectorOffset, injector, injector_size);
|
||||
memcpy(section[0].address + injectorOffset + injector_size, arm11Section0 + section[0].size - remaining, remaining);
|
||||
}
|
||||
|
||||
static inline void patchLegacyFirm(u32 firmType)
|
||||
@ -441,7 +436,7 @@ static void patchFirmWrites(u8 *arm9Section, u32 mode)
|
||||
static inline void launchFirm(u32 bootType)
|
||||
{
|
||||
//Copy FIRM sections to respective memory locations
|
||||
for(u32 i = 0; i < 4 && section[i].size; i++)
|
||||
for(u32 i = 1; i < 4 && section[i].size; i++)
|
||||
memcpy(section[i].address, (u8 *)firm + section[i].offset, section[i].size);
|
||||
|
||||
//Determine the ARM11 entry to use
|
||||
|
@ -40,7 +40,7 @@ static inline void loadFirm(u32 firmType, u32 externalFirm);
|
||||
static inline void patchNativeFirm(u32 nandType, u32 emuHeader, u32 a9lhMode);
|
||||
static inline void patchEmuNAND(u8 *arm9Section, u8 *proc9Offset, u32 emuHeader);
|
||||
static inline void patchReboots(u8 *arm9Section, u8 *proc9Offset);
|
||||
static inline void injectLoader(void);
|
||||
static inline void copySection0AndInjectLoader(void);
|
||||
static inline void patchLegacyFirm(u32 firmType);
|
||||
static inline void patchSafeFirm(void);
|
||||
static void patchFirmWrites(u8 *arm9Section, u32 mode);
|
||||
|
Reference in New Issue
Block a user