Skip to content

Commit

Permalink
Merge pull request #443 from uyjulian/imgdrvsearch
Browse files Browse the repository at this point in the history
Replace constants in imgdrv by searching instead of hardcoded offsets
  • Loading branch information
AKuHAK committed Jun 22, 2021
2 parents a779691 + d537457 commit eed469e
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions ee_core/src/iopmgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@
#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)
{
int i;
void *pIOP_buffer, *IOPRP_img, *imgdrv_irx;
unsigned int length_rounded, CommandLen, size_IOPRP_img, size_imgdrv_irx;
char command[RESET_ARG_MAX + 1];
Expand All @@ -44,8 +47,19 @@ static void ResetIopSpecial(const char *args, unsigned int arglen)

CopyToIop(IOPRP_img, length_rounded, pIOP_buffer);

*(void **)(UNCACHED_SEG(&((unsigned char *)imgdrv_irx)[0x180])) = pIOP_buffer;
*(u32 *)(UNCACHED_SEG(&((unsigned char *)imgdrv_irx)[0x184])) = 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);

Expand Down

0 comments on commit eed469e

Please sign in to comment.