Skip to content

Commit

Permalink
Only search on first invocation of ResetIopSpecial
Browse files Browse the repository at this point in the history
  • Loading branch information
uyjulian committed Jun 21, 2021
1 parent 6f673c2 commit d537457
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions ee_core/src/iopmgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include "syshook.h"

extern int _iop_reboot_count;
static int imgdrv_offset_ioprpimg = 0;
static int imgdrv_offset_ioprpsiz = 0;

static void ResetIopSpecial(const char *args, unsigned int arglen)
{
Expand Down Expand Up @@ -45,15 +47,20 @@ static void ResetIopSpecial(const char *args, unsigned int arglen)

CopyToIop(IOPRP_img, length_rounded, pIOP_buffer);

for (i = 0; i < size_imgdrv_irx; i += 4) {
if (*(u32 *)((&((unsigned char *)imgdrv_irx)[i])) == 0xDEC1DEC1) {
*(void **)(UNCACHED_SEG(&((unsigned char *)imgdrv_irx)[i])) = pIOP_buffer;
}
if (*(u32 *)((&((unsigned char *)imgdrv_irx)[i])) == 0xDEC2DEC2) {
*(u32 *)(UNCACHED_SEG(&((unsigned char *)imgdrv_irx)[i])) = size_IOPRP_img;
if (imgdrv_offset_ioprpimg == 0 || imgdrv_offset_ioprpsiz == 0) {
for (i = 0; i < size_imgdrv_irx; i += 4) {
if (*(u32 *)((&((unsigned char *)imgdrv_irx)[i])) == 0xDEC1DEC1) {
imgdrv_offset_ioprpimg = i;
}
if (*(u32 *)((&((unsigned char *)imgdrv_irx)[i])) == 0xDEC2DEC2) {
imgdrv_offset_ioprpsiz = i;
}
}
}

*(void **)(UNCACHED_SEG(&((unsigned char *)imgdrv_irx)[imgdrv_offset_ioprpimg])) = pIOP_buffer;
*(u32 *)(UNCACHED_SEG(&((unsigned char *)imgdrv_irx)[imgdrv_offset_ioprpsiz])) = size_IOPRP_img;

LoadMemModule(0, imgdrv_irx, size_imgdrv_irx, 0, NULL);

DIntr();
Expand Down

0 comments on commit d537457

Please sign in to comment.