Remove unneeded stuff from the loader injection

This commit is contained in:
Aurora 2016-04-13 14:23:08 +02:00
parent 89350b1edd
commit 6d4a84a325
4 changed files with 8 additions and 11 deletions

View File

@ -87,8 +87,6 @@ void configureCFW(const char *configPath)
//Boring configuration menu //Boring configuration menu
while(pressed != BUTTON_START) while(pressed != BUTTON_START)
{ {
pressed = 0;
do { do {
//In any case, if the current option is enabled (or a multiple choice option is selected) we must display a red 'x' //In any case, if the current option is enabled (or a multiple choice option is selected) we must display a red 'x'
if(selectedOption < multiOptionsAmount) if(selectedOption < multiOptionsAmount)

View File

@ -339,16 +339,14 @@ static inline void patchReboots(u8 *arm9Section, u8 *proc9Offset)
static inline void injectLoader(void) static inline void injectLoader(void)
{ {
u32 loaderOffset, u32 loaderSize;
loaderSize;
getLoader((u8 *)firm + section[0].offset, section[0].size, &loaderOffset, &loaderSize); void *loaderOffset = getLoader((u8 *)firm + section[0].offset, section[0].size, &loaderSize);
//Check that the injector CXI isn't larger than the original //Check that the injector CXI isn't larger than the original
if(injector_size <= (int)loaderSize) if((u32)injector_size <= loaderSize)
{ {
memset32((void *)loaderOffset, 0, loaderSize); memcpy(loaderOffset, injector, injector_size);
memcpy((void *)loaderOffset, injector, injector_size);
//Patch content size and ExeFS size to match the repaced loader's ones //Patch content size and ExeFS size to match the repaced loader's ones
*((u32 *)loaderOffset + 0x41) = loaderSize / 0x200; *((u32 *)loaderOffset + 0x41) = loaderSize / 0x200;

View File

@ -77,10 +77,11 @@ u8 *getUnitInfoValueSet(u8 *pos, u32 size)
return memsearch(pos, pattern, size, 4) + 3; return memsearch(pos, pattern, size, 4) + 3;
} }
void getLoader(u8 *pos, u32 size, u32 *loaderOffset, u32 *loaderSize) void *getLoader(u8 *pos, u32 size, u32 *loaderSize)
{ {
u8 *const off = memsearch(pos, "loade", size, 5); u8 *const off = memsearch(pos, "loade", size, 5);
*loaderOffset = (u32)off - 0x200;
*loaderSize = *(u32 *)(off - 0xFC) * 0x200; *loaderSize = *(u32 *)(off - 0xFC) * 0x200;
return off - 0x200;
} }

View File

@ -26,4 +26,4 @@ void *getReboot(u8 *pos, u32 size);
u32 getfOpen(u8 *proc9Offset, void *rebootOffset); u32 getfOpen(u8 *proc9Offset, void *rebootOffset);
u16 *getFirmWrite(u8 *pos, u32 size); u16 *getFirmWrite(u8 *pos, u32 size);
u8 *getUnitInfoValueSet(u8 *pos, u32 size); u8 *getUnitInfoValueSet(u8 *pos, u32 size);
void getLoader(u8 *pos, u32 size, u32 *loaderOffset, u32 *loaderSize); void *getLoader(u8 *pos, u32 size, u32 *loaderSize);