Rewrite the module copying function
This commit is contained in:
parent
06fe06f9f1
commit
7f93733107
@ -351,33 +351,30 @@ static inline void patch2xNativeAndSafeFirm(void)
|
|||||||
|
|
||||||
static inline void copySection0AndInjectSystemModules(void)
|
static inline void copySection0AndInjectSystemModules(void)
|
||||||
{
|
{
|
||||||
u8 *arm11Section0 = (u8 *)firm + section[0].offset;
|
u32 srcModuleSize,
|
||||||
|
dstModuleSize;
|
||||||
|
|
||||||
struct
|
for(u8 *src = (u8 *)firm + section[0].offset, *srcEnd = src + section[0].size, *dst = section[0].address;
|
||||||
|
src < srcEnd; src += srcModuleSize, dst += dstModuleSize)
|
||||||
{
|
{
|
||||||
u32 size;
|
srcModuleSize = *(u32 *)(src + 0x104) * 0x200;
|
||||||
const u8 *addr;
|
char *moduleName = (char *)(src + 0x200);
|
||||||
} modules[5];
|
|
||||||
|
|
||||||
u32 n = 0,
|
void *module;
|
||||||
loaderIndex;
|
|
||||||
u8 *pos = arm11Section0;
|
|
||||||
|
|
||||||
for(u8 *end = pos + section[0].size; pos < end; pos += modules[n++].size)
|
if(memcmp(moduleName, "loader", 6) == 0)
|
||||||
{
|
{
|
||||||
modules[n].addr = pos;
|
module = (void *)injector;
|
||||||
modules[n].size = *(u32 *)(pos + 0x104) * 0x200;
|
dstModuleSize = injector_size;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
module = src;
|
||||||
|
dstModuleSize = srcModuleSize;
|
||||||
|
}
|
||||||
|
|
||||||
if(memcmp(modules[n].addr + 0x200, "loader", 7) == 0) loaderIndex = n;
|
memcpy(dst, module, dstModuleSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
modules[loaderIndex].addr = injector;
|
|
||||||
modules[loaderIndex].size = injector_size;
|
|
||||||
|
|
||||||
pos = section[0].address;
|
|
||||||
|
|
||||||
for(u32 i = 0; i < n; pos += modules[i++].size)
|
|
||||||
memcpy(pos, modules[i].addr, modules[i].size);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void launchFirm(FirmwareType firmType)
|
static inline void launchFirm(FirmwareType firmType)
|
||||||
|
@ -41,7 +41,7 @@ void memset32(void *dest, u32 filler, u32 size)
|
|||||||
{
|
{
|
||||||
u32 *dest32 = (u32 *)dest;
|
u32 *dest32 = (u32 *)dest;
|
||||||
|
|
||||||
for (u32 i = 0; i < size / 4; i++)
|
for(u32 i = 0; i < size / 4; i++)
|
||||||
dest32[i] = filler;
|
dest32[i] = filler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user