IModule *ComponentManager::GetModule( const char *name ) { ModuleInfo *info = getModInfo( name ); if ( info == NULL || info->mModule == NULL ) return NULL; return info->mModule; }
//-------------------------------------------------------------- void hookMODLOAD(void) { // get modload export table modinfo_t info; getModInfo("modload\0", &info); // hook modload's LoadStartModule function LoadStartModule = (void *)info.exports[7]; info.exports[7] = (void *)Hook_LoadStartModule; // hook modload's StartModule function StartModule = (void *)info.exports[8]; info.exports[8] = (void *)Hook_StartModule; // hook modload's LoadModuleBuffer LoadModuleBuffer = (void *)info.exports[10]; info.exports[10] = (void *)Hook_LoadModuleBuffer; // check modload version if (info.version > 0x102) { // hook modload's StopModule StopModule = (void *)info.exports[20]; info.exports[20] = (void *)Hook_StopModule; // hook modload's UnloadModule UnloadModule = (void *)info.exports[21]; info.exports[21] = (void *)Hook_UnloadModule; // hook modload's SearchModuleByName SearchModuleByName = (void *)info.exports[22]; info.exports[22] = (void *)Hook_SearchModuleByName; } // fix imports iop_library_t *lib = (iop_library_t *)((u32)info.exports - 0x14); struct irx_import_table *table; struct irx_import_stub *stub; FlushDcache(); // 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); } } FlushIcache(); }
ErrorCode ComponentManager::RemoveModule( const char *name ) { ModuleInfo *info = getModInfo( name ); if ( info == NULL || info->mModule == NULL ) return kNoClass; info->mModule->unloadComponents(); info->mModule->Release(); info->mModule = NULL; return kNoError; }