static u32 sceUtilityLoadModule(u32 module) { const ModuleLoadInfo *info = __UtilityModuleInfo(module); if (!info) { ERROR_LOG_REPORT(SCEUTILITY, "sceUtilityLoadModule(%i): invalid module id", module); return SCE_ERROR_MODULE_BAD_ID; } if (currentlyLoadedModules.find(module) != currentlyLoadedModules.end()) { ERROR_LOG(SCEUTILITY, "sceUtilityLoadModule(%i): already loaded", module); return SCE_ERROR_MODULE_ALREADY_LOADED; } // Some games, like Kamen Rider Climax Heroes OOO, require an error if dependencies aren't loaded yet. for (const int *dep = info->dependencies; dep && *dep == 0; ++dep) { if (currentlyLoadedModules.find(*dep) == currentlyLoadedModules.end()) { ERROR_LOG(SCEUTILITY, "sceUtilityLoadModule(%i): dependent module %i not loaded", module, *dep); return hleDelayResult(SCE_KERNEL_ERROR_LIBRARY_NOTFOUND, "utility module load attempt", 25000); } } INFO_LOG(SCEUTILITY, "sceUtilityLoadModule(%i)", module); u32 allocSize = info->size; char name[64]; snprintf(name, sizeof(name), "UtilityModule/%x", module); currentlyLoadedModules[module] = userMemory.Alloc(allocSize, false, name); // TODO: Each module has its own timing, technically, but this is a low-end. if (module == 0x3FF) return hleDelayResult(0, "utility module loaded", 130); else return hleDelayResult(0, "utility module loaded", 25000); }
static u32 sceUtilityUnloadModule(u32 module) { const ModuleLoadInfo *info = __UtilityModuleInfo(module); if (!info) { ERROR_LOG_REPORT(SCEUTILITY, "sceUtilityUnloadModule(%i): invalid module id", module); return SCE_ERROR_MODULE_BAD_ID; } if (currentlyLoadedModules.find(module) == currentlyLoadedModules.end()) { WARN_LOG(SCEUTILITY, "sceUtilityUnloadModule(%i): not yet loaded", module); return SCE_ERROR_MODULE_NOT_LOADED; } if (currentlyLoadedModules[module] != 0) { userMemory.Free(currentlyLoadedModules[module]); } currentlyLoadedModules.erase(module); INFO_LOG(SCEUTILITY, "sceUtilityUnloadModule(%i)", module); // TODO: Each module has its own timing, technically, but this is a low-end. if (module == 0x3FF) return hleDelayResult(0, "utility module unloaded", 110); else return hleDelayResult(0, "utility module unloaded", 400); }