From 6c8a1f805828a9e7835d75d18551fc4590e68169 Mon Sep 17 00:00:00 2001 From: Matias Israelson <57065102+israpps@users.noreply.github.com> Date: Fri, 12 Jul 2024 10:59:53 -0300 Subject: [PATCH 1/4] make ioplib an independent library --- iop/Makefile | 3 +- iop/utilities/Makefile | 12 ++++ iop/utilities/modhook/Makefile | 15 +++++ iop/utilities/modhook/include/ioplib.h | 36 +++++++++++ iop/utilities/modhook/src/ioplib.c | 82 ++++++++++++++++++++++++++ 5 files changed, 147 insertions(+), 1 deletion(-) create mode 100644 iop/utilities/Makefile create mode 100644 iop/utilities/modhook/Makefile create mode 100644 iop/utilities/modhook/include/ioplib.h create mode 100644 iop/utilities/modhook/src/ioplib.c diff --git a/iop/Makefile b/iop/Makefile index 125d5a2623f..443ec9cb705 100644 --- a/iop/Makefile +++ b/iop/Makefile @@ -24,7 +24,8 @@ SUBDIRS = \ startup \ system \ tcpip \ - usb + usb \ + utilities include $(PS2SDKSRC)/Defs.make include $(PS2SDKSRC)/Rules.make diff --git a/iop/utilities/Makefile b/iop/utilities/Makefile new file mode 100644 index 00000000000..5aa4e74dfa5 --- /dev/null +++ b/iop/utilities/Makefile @@ -0,0 +1,12 @@ +# _____ ___ ____ ___ ____ +# ____| | ____| | | |____| +# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. +#----------------------------------------------------------------------- +# Copyright 2001-2004, ps2dev - http://www.ps2dev.org +# Licenced under Academic Free License version 2.0 +# Review ps2sdk README & LICENSE files for further details. + +SUBDIRS = modhook + +include $(PS2SDKSRC)/Defs.make +include $(PS2SDKSRC)/Rules.make diff --git a/iop/utilities/modhook/Makefile b/iop/utilities/modhook/Makefile new file mode 100644 index 00000000000..756fe524c99 --- /dev/null +++ b/iop/utilities/modhook/Makefile @@ -0,0 +1,15 @@ +# _____ ___ ____ ___ ____ +# ____| | ____| | | |____| +# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. +#----------------------------------------------------------------------- +# Copyright 2001-2024, ps2dev - http://www.ps2dev.org +# Licenced under Academic Free License version 2.0 +# Review ps2sdk README & LICENSE files for further details. + +IOP_OBJS = ioplib.o +IOP_LIB = libmodhook.a + +include $(PS2SDKSRC)/Defs.make +include $(PS2SDKSRC)/iop/Rules.lib.make +include $(PS2SDKSRC)/iop/Rules.make +include $(PS2SDKSRC)/iop/Rules.release diff --git a/iop/utilities/modhook/include/ioplib.h b/iop/utilities/modhook/include/ioplib.h new file mode 100644 index 00000000000..2b499619abf --- /dev/null +++ b/iop/utilities/modhook/include/ioplib.h @@ -0,0 +1,36 @@ +#ifndef IOPLIB_H +#define IOPLIB_H + +#include + +/** + * @file ioplib.c + * @brief IOP module manipulation library for hooking exports. + * @note depends on: `CpuSuspendIntr` `CpuResumeIntr` `GetLoadcoreInternalData` + */ + +/** + * @brief returns an iop library pointer for the specified IRX module + * @returns NULL on error, else, a pointer to the struct + */ +iop_library_t *ioplib_getByName(const char *name); + +/** + * @brief returns the size of the export table for the specified module + * @param lib the library to obtain the export table size + * @returns the ammount of exports registered for that module + */ +unsigned int ioplib_getTableSize(iop_library_t *lib); + +/** + * @brief replaces the function called as a module export + * @param lib The iop_library_t struct of the module to modify + * @param entry the export number to be modified + * @param func the function to replace the export with + * @returns a pointer to the original function + */ +void *ioplib_hookExportEntry(iop_library_t *lib, unsigned int entry, void *func); +void ioplib_relinkExports(iop_library_t *lib); + + +#endif \ No newline at end of file diff --git a/iop/utilities/modhook/src/ioplib.c b/iop/utilities/modhook/src/ioplib.c new file mode 100644 index 00000000000..f65519d9fa5 --- /dev/null +++ b/iop/utilities/modhook/src/ioplib.c @@ -0,0 +1,82 @@ +#include "ioplib.h" +#include +#include + +iop_library_t *ioplib_getByName(const char *name) +{ + iop_library_t *libptr; + int i; + + // Get first loaded library + libptr = GetLoadcoreInternalData()->let_next; + // Loop through all loaded libraries + while (libptr != NULL) { + // Compare library name only + for (i = 0; i < 8; i++) { + if (libptr->name[i] != name[i]) + break; + } + + // Return if match + if (i == 8) + return libptr; + + // Next library + libptr = libptr->prev; + } + + return NULL; +} + +unsigned int ioplib_getTableSize(iop_library_t *lib) +{ + void **exp; + unsigned int size; + + exp = NULL; + if (lib != NULL) { + exp = lib->exports; + } + size = 0; + + if (exp != NULL) + while (*exp++ != NULL) + size++; + + return size; +} + +void *ioplib_hookExportEntry(iop_library_t *lib, unsigned int entry, void *func) +{ + if (entry < ioplib_getTableSize(lib)) { + int oldstate; + void **exp, *temp; + + exp = &lib->exports[entry]; + + CpuSuspendIntr(&oldstate); + temp = *exp; + *exp = func; + func = temp; + CpuResumeIntr(oldstate); + + return func; + } + + return NULL; +} + +void ioplib_relinkExports(iop_library_t *lib) +{ + struct irx_import_table *table; + struct irx_import_stub *stub; + + // go through each table that imports the library + for (table = lib->caller; table != NULL; table = table->next) { + // go through each import in the table + for (stub = (struct irx_import_stub *)table->stubs; stub->jump != 0; stub++) { + // patch the stub to jump to the address specified in the library export table for "fno" + stub->jump = 0x08000000 | (((uint32_t)lib->exports[stub->fno] << 4) >> 6); + } + } +} \ No newline at end of file From 8e8650112a9f3b588c43d32ca200fc767b30c554 Mon Sep 17 00:00:00 2001 From: Matias Israelson <57065102+israpps@users.noreply.github.com> Date: Fri, 12 Jul 2024 11:16:04 -0300 Subject: [PATCH 2/4] [mx4sio] remove local copy of ioplib --- iop/sio/mx4sio_bd/src/ioplib.c | 81 ---------------------------------- iop/sio/mx4sio_bd/src/ioplib.h | 14 ------ 2 files changed, 95 deletions(-) delete mode 100644 iop/sio/mx4sio_bd/src/ioplib.c delete mode 100644 iop/sio/mx4sio_bd/src/ioplib.h diff --git a/iop/sio/mx4sio_bd/src/ioplib.c b/iop/sio/mx4sio_bd/src/ioplib.c deleted file mode 100644 index 59028a3de81..00000000000 --- a/iop/sio/mx4sio_bd/src/ioplib.c +++ /dev/null @@ -1,81 +0,0 @@ -#include "ioplib.h" -#include - -iop_library_t *ioplib_getByName(const char *name) -{ - iop_library_t *libptr; - int i; - - // Get first loaded library - libptr = GetLoadcoreInternalData()->let_next; - // Loop through all loaded libraries - while (libptr != NULL) { - // Compare library name only - for (i = 0; i < 8; i++) { - if (libptr->name[i] != name[i]) - break; - } - - // Return if match - if (i == 8) - return libptr; - - // Next library - libptr = libptr->prev; - } - - return NULL; -} - -unsigned int ioplib_getTableSize(iop_library_t *lib) -{ - void **exp; - unsigned int size; - - exp = NULL; - if (lib != NULL) { - exp = lib->exports; - } - size = 0; - - if (exp != NULL) - while (*exp++ != NULL) - size++; - - return size; -} - -void *ioplib_hookExportEntry(iop_library_t *lib, unsigned int entry, void *func) -{ - if (entry < ioplib_getTableSize(lib)) { - int oldstate; - void **exp, *temp; - - exp = &lib->exports[entry]; - - CpuSuspendIntr(&oldstate); - temp = *exp; - *exp = func; - func = temp; - CpuResumeIntr(oldstate); - - return func; - } - - return NULL; -} - -void ioplib_relinkExports(iop_library_t *lib) -{ - struct irx_import_table *table; - struct irx_import_stub *stub; - - // go through each table that imports the library - for (table = lib->caller; table != NULL; table = table->next) { - // go through each import in the table - for (stub = (struct irx_import_stub *)table->stubs; stub->jump != 0; stub++) { - // patch the stub to jump to the address specified in the library export table for "fno" - stub->jump = 0x08000000 | (((u32)lib->exports[stub->fno] << 4) >> 6); - } - } -} diff --git a/iop/sio/mx4sio_bd/src/ioplib.h b/iop/sio/mx4sio_bd/src/ioplib.h deleted file mode 100644 index 7ff39a4940d..00000000000 --- a/iop/sio/mx4sio_bd/src/ioplib.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef IOPLIB_H -#define IOPLIB_H - - -#include - - -iop_library_t *ioplib_getByName(const char *name); -unsigned int ioplib_getTableSize(iop_library_t *lib); -void *ioplib_hookExportEntry(iop_library_t *lib, unsigned int entry, void *func); -void ioplib_relinkExports(iop_library_t *lib); - - -#endif From 9d5cc0419d8f09d490dc693f5c262792356a4445 Mon Sep 17 00:00:00 2001 From: Matias Israelson <57065102+israpps@users.noreply.github.com> Date: Fri, 12 Jul 2024 11:17:40 -0300 Subject: [PATCH 3/4] [mx4sio]: switch to libmodhook --- iop/sio/mx4sio_bd/Makefile | 14 ++++++++++++-- iop/sio/mx4sio_bd/src/mx4sio.c | 3 ++- iop/sio/mx4sio_bd/src/sio2man_hook.c | 2 +- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/iop/sio/mx4sio_bd/Makefile b/iop/sio/mx4sio_bd/Makefile index ddbbd06c4c5..59393359551 100644 --- a/iop/sio/mx4sio_bd/Makefile +++ b/iop/sio/mx4sio_bd/Makefile @@ -6,12 +6,22 @@ # Licenced under Academic Free License version 2.0 # Review ps2sdk README & LICENSE files for further details. -IOP_INCS += -I$(PS2SDKSRC)/iop/fs/bdm/include -I$(PS2SDKSRC)/iop/system/sio2man/include +MODHOOK_PATH = $(PS2SDKSRC)/iop/utilities/modhook/ +IOP_INCS += -I$(PS2SDKSRC)/iop/fs/bdm/include -I$(PS2SDKSRC)/iop/system/sio2man/include -I$(MODHOOK_PATH)include +IOP_LIB_ARCHIVES = $(MODHOOK_PATH)lib/libmodhook.a -IOP_OBJS += spi_sdcard_crc7.o spi_sdcard_driver.o crc16.o ioplib.o sio2man_hook.o mx4sio.o imports.o +IOP_OBJS += spi_sdcard_crc7.o spi_sdcard_driver.o crc16.o sio2man_hook.o mx4sio.o imports.o IOP_LDFLAGS = -lgcc + +$(MODHOOK_PATH)lib/libmodhook.a: + $(MAKEREC) $(MODHOOK_PATH) + +.NOTPARALLEL:: \ + $(IOP_LIB_ARCHIVES) + + include $(PS2SDKSRC)/Defs.make include $(PS2SDKSRC)/iop/Rules.bin.make include $(PS2SDKSRC)/iop/Rules.make diff --git a/iop/sio/mx4sio_bd/src/mx4sio.c b/iop/sio/mx4sio_bd/src/mx4sio.c index ac96710f326..6acc47f39b2 100644 --- a/iop/sio/mx4sio_bd/src/mx4sio.c +++ b/iop/sio/mx4sio_bd/src/mx4sio.c @@ -7,9 +7,10 @@ #include #include +#include + #include "mx4sio.h" #include "crc16.h" -#include "ioplib.h" #include "sio2man_hook.h" #include "sio2regs.h" #include "spi_sdcard_driver.h" diff --git a/iop/sio/mx4sio_bd/src/sio2man_hook.c b/iop/sio/mx4sio_bd/src/sio2man_hook.c index 33e3d1a5a08..212cfc07a29 100644 --- a/iop/sio/mx4sio_bd/src/sio2man_hook.c +++ b/iop/sio/mx4sio_bd/src/sio2man_hook.c @@ -1,8 +1,8 @@ #include #include #include +#include -#include "ioplib.h" #include "sio2man.h" #include "sio2man_hook.h" From 4ef0da9741ccfa06b38f383f5ec0af68d3da4b3b Mon Sep 17 00:00:00 2001 From: Matias Israelson <57065102+israpps@users.noreply.github.com> Date: Fri, 12 Jul 2024 14:59:43 -0300 Subject: [PATCH 4/4] rename all `ioplib` refs to `modhook` --- iop/sio/mx4sio_bd/src/mx4sio.c | 4 +- iop/sio/mx4sio_bd/src/sio2man_hook.c | 68 +++++++++---------- iop/utilities/modhook/Makefile | 2 +- .../modhook/include/{ioplib.h => modhook.h} | 14 ++-- .../modhook/src/{ioplib.c => modhook.c} | 12 ++-- 5 files changed, 50 insertions(+), 50 deletions(-) rename iop/utilities/modhook/include/{ioplib.h => modhook.h} (72%) rename iop/utilities/modhook/src/{ioplib.c => modhook.c} (83%) diff --git a/iop/sio/mx4sio_bd/src/mx4sio.c b/iop/sio/mx4sio_bd/src/mx4sio.c index 6acc47f39b2..01acf5e58bd 100644 --- a/iop/sio/mx4sio_bd/src/mx4sio.c +++ b/iop/sio/mx4sio_bd/src/mx4sio.c @@ -7,7 +7,7 @@ #include #include -#include +#include #include "mx4sio.h" #include "crc16.h" @@ -794,7 +794,7 @@ int module_start(int argc, char *argv[]) goto error4; } - lib_modload = ioplib_getByName("modload"); + lib_modload = modhook_getModule("modload"); if (lib_modload != NULL) { M_DEBUG("modload 0x%x detected\n", lib_modload->version); // Newer modload versions allow modules to be unloaded diff --git a/iop/sio/mx4sio_bd/src/sio2man_hook.c b/iop/sio/mx4sio_bd/src/sio2man_hook.c index 212cfc07a29..09bac6c3d40 100644 --- a/iop/sio/mx4sio_bd/src/sio2man_hook.c +++ b/iop/sio/mx4sio_bd/src/sio2man_hook.c @@ -1,7 +1,7 @@ #include #include #include -#include +#include #include "sio2man.h" #include "sio2man_hook.h" @@ -97,26 +97,26 @@ static void _sio2man_unhook(iop_library_t *lib) return; } - ioplib_hookExportEntry(lib, 23, _23_psio2_pad_transfer_init); - ioplib_hookExportEntry(lib, 24, _24_psio2_mc_transfer_init); - ioplib_hookExportEntry(lib, 25, _25_psio2_transfer); - ioplib_hookExportEntry(lib, 26, _26_psio2_transfer_reset); - ioplib_hookExportEntry(lib, 46, _46_psio2_pad_transfer_init); - ioplib_hookExportEntry(lib, 47, _47_psio2_mc_transfer_init); - ioplib_hookExportEntry(lib, 48, _48_psio2_mtap_transfer_init); + modhookk_hookExportEntry(lib, 23, _23_psio2_pad_transfer_init); + modhook_hookExportEntry(lib, 24, _24_psio2_mc_transfer_init); + modhook_hookExportEntry(lib, 25, _25_psio2_transfer); + modhookk_hookExportEntry(lib, 26, _26_psio2_transfer_reset); + modhook_hookExportEntry(lib, 46, _46_psio2_pad_transfer_init); + modhook_hookExportEntry(lib, 47, _47_psio2_mc_transfer_init); + modhook_hookExportEntry(lib, 48, _48_psio2_mtap_transfer_init); if ((hooked_version >= IRX_VER(1, 2)) && (hooked_version < IRX_VER(2, 0))) { // Only for the newer rom0:XSIO2MAN // Assume all v1.x libraries to use this interface (reset at 50) - ioplib_hookExportEntry(lib, 49, _51_psio2_transfer); - ioplib_hookExportEntry(lib, 50, _52_psio2_transfer_reset); + modhook_hookExportEntry(lib, 49, _51_psio2_transfer); + modhook_hookExportEntry(lib, 50, _52_psio2_transfer_reset); } else /*if (hooked_version >= IRX_VER(2, 3))*/ { // Only for the newer rom1:SIO2MAN // Assume all v2.x libraries to use this interface (reset at 52) - ioplib_hookExportEntry(lib, 49, _49_psio2_rm_transfer_init); - ioplib_hookExportEntry(lib, 50, _50_psio2_unk_transfer_init); - ioplib_hookExportEntry(lib, 51, _51_psio2_transfer); - ioplib_hookExportEntry(lib, 52, _52_psio2_transfer_reset); + modhook_hookExportEntry(lib, 49, _49_psio2_rm_transfer_init); + modhook_hookExportEntry(lib, 50, _50_psio2_unk_transfer_init); + modhook_hookExportEntry(lib, 51, _51_psio2_transfer); + modhook_hookExportEntry(lib, 52, _52_psio2_transfer_reset); } hooked_version = 0; @@ -134,29 +134,29 @@ static void _sio2man_hook(iop_library_t *lib) if (lib->version > IRX_VER(1, 1)) { M_DEBUG("Installing sio2man hooks for version 0x%x\n", lib->version); - _23_psio2_pad_transfer_init = ioplib_hookExportEntry(lib, 23, _23_sio2_pad_transfer_init); + _23_psio2_pad_transfer_init = modhook_hookExportEntry(lib, 23, _23_sio2_pad_transfer_init); // Lock sio2 to prevent race conditions with MC/PAD libraries _23_psio2_pad_transfer_init(); - _24_psio2_mc_transfer_init = ioplib_hookExportEntry(lib, 24, _24_sio2_mc_transfer_init); - _25_psio2_transfer = ioplib_hookExportEntry(lib, 25, _25_sio2_transfer); - _26_psio2_transfer_reset = ioplib_hookExportEntry(lib, 26, _26_sio2_transfer_reset); - _46_psio2_pad_transfer_init = ioplib_hookExportEntry(lib, 46, _46_sio2_pad_transfer_init); - _47_psio2_mc_transfer_init = ioplib_hookExportEntry(lib, 47, _47_sio2_mc_transfer_init); - _48_psio2_mtap_transfer_init = ioplib_hookExportEntry(lib, 48, _48_sio2_mtap_transfer_init); + _24_psio2_mc_transfer_init = modhook_hookExportEntry(lib, 24, _24_sio2_mc_transfer_init); + _25_psio2_transfer = modhook_hookExportEntry(lib, 25, _25_sio2_transfer); + _26_psio2_transfer_reset = modhook_hookExportEntry(lib, 26, _26_sio2_transfer_reset); + _46_psio2_pad_transfer_init = modhook_hookExportEntry(lib, 46, _46_sio2_pad_transfer_init); + _47_psio2_mc_transfer_init = modhook_hookExportEntry(lib, 47, _47_sio2_mc_transfer_init); + _48_psio2_mtap_transfer_init = modhook_hookExportEntry(lib, 48, _48_sio2_mtap_transfer_init); if ((lib->version >= IRX_VER(1, 2)) && (lib->version < IRX_VER(2, 0))) { // Only for the newer rom0:XSIO2MAN // Assume all v1.x libraries to use this interface (reset at 50) - _51_psio2_transfer = ioplib_hookExportEntry(lib, 49, _51_sio2_transfer); - _52_psio2_transfer_reset = ioplib_hookExportEntry(lib, 50, _52_sio2_transfer_reset); + _51_psio2_transfer = modhook_hookExportEntry(lib, 49, _51_sio2_transfer); + _52_psio2_transfer_reset = modhook_hookExportEntry(lib, 50, _52_sio2_transfer_reset); } else /*if (lib->version >= IRX_VER(2, 3))*/ { // Only for the newer rom1:SIO2MAN // Assume all v2.x libraries to use this interface (reset at 52) - _49_psio2_rm_transfer_init = ioplib_hookExportEntry(lib, 49, _49_sio2_rm_transfer_init); - _50_psio2_unk_transfer_init = ioplib_hookExportEntry(lib, 50, _50_sio2_unk_transfer_init); - _51_psio2_transfer = ioplib_hookExportEntry(lib, 51, _51_sio2_transfer); - _52_psio2_transfer_reset = ioplib_hookExportEntry(lib, 52, _52_sio2_transfer_reset); + _49_psio2_rm_transfer_init = modhook_hookExportEntry(lib, 49, _49_sio2_rm_transfer_init); + _50_psio2_unk_transfer_init = modhook_hookExportEntry(lib, 50, _50_sio2_unk_transfer_init); + _51_psio2_transfer = modhook_hookExportEntry(lib, 51, _51_sio2_transfer); + _52_psio2_transfer_reset = modhook_hookExportEntry(lib, 52, _52_sio2_transfer_reset); } // Unlock sio2 @@ -195,19 +195,19 @@ int sio2man_hook_init() lock_sema2 = CreateSema(&sema); // Hook into 'loadcore' so we know when sio2man is loaded in the future - lib = ioplib_getByName("loadcore"); + lib = modhook_getModule("loadcore"); if (lib == NULL) { DeleteSema(lock_sema); DeleteSema(lock_sema2); return -1; } - pRegisterLibraryEntries = ioplib_hookExportEntry(lib, 6, hookRegisterLibraryEntries); + pRegisterLibraryEntries = modhook_hookExportEntry(lib, 6, hookRegisterLibraryEntries); // Hook into 'sio2man' now if it's already loaded - lib = ioplib_getByName("sio2man"); + lib = modhook_getModule("sio2man"); if (lib != NULL) { _sio2man_hook(lib); - ioplib_relinkExports(lib); + modhook_relinkExports(lib); } return 0; @@ -220,14 +220,14 @@ void sio2man_hook_deinit() M_DEBUG("%s\n", __FUNCTION__); // Unhook 'sio2man' - lib = ioplib_getByName("sio2man"); + lib = modhook_getModule("sio2man"); if (lib != NULL) { _sio2man_unhook(lib); - ioplib_relinkExports(lib); + modhook_relinkExports(lib); } // Unhook 'loadcore' - ioplib_hookExportEntry(lib, 6, pRegisterLibraryEntries); + modhook_hookExportEntry(lib, 6, pRegisterLibraryEntries); // Delete locking semaphore DeleteSema(lock_sema); diff --git a/iop/utilities/modhook/Makefile b/iop/utilities/modhook/Makefile index 756fe524c99..eacbc473221 100644 --- a/iop/utilities/modhook/Makefile +++ b/iop/utilities/modhook/Makefile @@ -6,7 +6,7 @@ # Licenced under Academic Free License version 2.0 # Review ps2sdk README & LICENSE files for further details. -IOP_OBJS = ioplib.o +IOP_OBJS = modhook.o IOP_LIB = libmodhook.a include $(PS2SDKSRC)/Defs.make diff --git a/iop/utilities/modhook/include/ioplib.h b/iop/utilities/modhook/include/modhook.h similarity index 72% rename from iop/utilities/modhook/include/ioplib.h rename to iop/utilities/modhook/include/modhook.h index 2b499619abf..913c7ff3660 100644 --- a/iop/utilities/modhook/include/ioplib.h +++ b/iop/utilities/modhook/include/modhook.h @@ -1,10 +1,10 @@ -#ifndef IOPLIB_H -#define IOPLIB_H +#ifndef __MODHOOK_H__ +#define __MODHOOK_H__ #include /** - * @file ioplib.c + * @file modhook.c * @brief IOP module manipulation library for hooking exports. * @note depends on: `CpuSuspendIntr` `CpuResumeIntr` `GetLoadcoreInternalData` */ @@ -13,14 +13,14 @@ * @brief returns an iop library pointer for the specified IRX module * @returns NULL on error, else, a pointer to the struct */ -iop_library_t *ioplib_getByName(const char *name); +iop_library_t *modhook_getModule(const char *name); /** * @brief returns the size of the export table for the specified module * @param lib the library to obtain the export table size * @returns the ammount of exports registered for that module */ -unsigned int ioplib_getTableSize(iop_library_t *lib); +unsigned int modhook_getTableSize(iop_library_t *lib); /** * @brief replaces the function called as a module export @@ -29,8 +29,8 @@ unsigned int ioplib_getTableSize(iop_library_t *lib); * @param func the function to replace the export with * @returns a pointer to the original function */ -void *ioplib_hookExportEntry(iop_library_t *lib, unsigned int entry, void *func); -void ioplib_relinkExports(iop_library_t *lib); +void *modhook_hookExportEntry(iop_library_t *lib, unsigned int entry, void *func); +void modhook_relinkExports(iop_library_t *lib); #endif \ No newline at end of file diff --git a/iop/utilities/modhook/src/ioplib.c b/iop/utilities/modhook/src/modhook.c similarity index 83% rename from iop/utilities/modhook/src/ioplib.c rename to iop/utilities/modhook/src/modhook.c index f65519d9fa5..6f4153c8572 100644 --- a/iop/utilities/modhook/src/ioplib.c +++ b/iop/utilities/modhook/src/modhook.c @@ -1,8 +1,8 @@ -#include "ioplib.h" +#include "modhook.h" #include #include -iop_library_t *ioplib_getByName(const char *name) +iop_library_t *modhook_getModule(const char *name) { iop_library_t *libptr; int i; @@ -28,7 +28,7 @@ iop_library_t *ioplib_getByName(const char *name) return NULL; } -unsigned int ioplib_getTableSize(iop_library_t *lib) +unsigned int modhook_getTableSize(iop_library_t *lib) { void **exp; unsigned int size; @@ -46,9 +46,9 @@ unsigned int ioplib_getTableSize(iop_library_t *lib) return size; } -void *ioplib_hookExportEntry(iop_library_t *lib, unsigned int entry, void *func) +void *modhook_hookExportEntry(iop_library_t *lib, unsigned int entry, void *func) { - if (entry < ioplib_getTableSize(lib)) { + if (entry < modhook_getTableSize(lib)) { int oldstate; void **exp, *temp; @@ -66,7 +66,7 @@ void *ioplib_hookExportEntry(iop_library_t *lib, unsigned int entry, void *func) return NULL; } -void ioplib_relinkExports(iop_library_t *lib) +void modhook_relinkExports(iop_library_t *lib) { struct irx_import_table *table; struct irx_import_stub *stub;