From 52d53d1c0d568751b9a17a41b69fb45a2a9f1774 Mon Sep 17 00:00:00 2001 From: uyjulian Date: Sun, 20 Jun 2021 16:49:48 -0500 Subject: [PATCH 1/2] Replace constants in imgdrv by searching instead of hardcoded offsets --- ee_core/src/iopmgr.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/ee_core/src/iopmgr.c b/ee_core/src/iopmgr.c index 9e06d769d..dbe86924e 100644 --- a/ee_core/src/iopmgr.c +++ b/ee_core/src/iopmgr.c @@ -20,6 +20,7 @@ extern int _iop_reboot_count; 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]; @@ -44,8 +45,14 @@ 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; + 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; + } + } LoadMemModule(0, imgdrv_irx, size_imgdrv_irx, 0, NULL); From 2227569767320152fa76ca6cc813c455dcd10448 Mon Sep 17 00:00:00 2001 From: uyjulian Date: Mon, 21 Jun 2021 10:36:54 -0500 Subject: [PATCH 2/2] Only search on first invocation of ResetIopSpecial --- ee_core/src/iopmgr.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/ee_core/src/iopmgr.c b/ee_core/src/iopmgr.c index dbe86924e..6c40f03b9 100644 --- a/ee_core/src/iopmgr.c +++ b/ee_core/src/iopmgr.c @@ -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) { @@ -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();