coreinit: Implement OSDynLoad_IsModuleLoaded

This commit is contained in:
Exzap 2026-05-04 03:09:29 +02:00
parent 0b661488d7
commit a8bd6f84f7

View File

@ -59,7 +59,7 @@ namespace coreinit
PPCCoreCallback(_osDynLoadFuncFree, _mem); PPCCoreCallback(_osDynLoadFuncFree, _mem);
} }
uint32 OSDynLoad_Acquire(const char* libName, uint32be* moduleHandleOut) uint32 OSDynLoad_AcquireInternal(const char* libName, uint32be* moduleHandleOut, bool checkOnly)
{ {
// truncate path // truncate path
sint32 fileNameStartIndex = 0; sint32 fileNameStartIndex = 0;
@ -88,6 +88,11 @@ namespace coreinit
uint32 rplHandle = RPLLoader_GetHandleByModuleName(libName); uint32 rplHandle = RPLLoader_GetHandleByModuleName(libName);
if (rplHandle == RPL_INVALID_HANDLE && !RPLLoader_HasDependency(libName)) if (rplHandle == RPL_INVALID_HANDLE && !RPLLoader_HasDependency(libName))
{ {
if (checkOnly)
{
*moduleHandleOut = 0;
return 0;
}
RPLLoader_AddDependency(libName); RPLLoader_AddDependency(libName);
RPLLoader_UpdateDependencies(); RPLLoader_UpdateDependencies();
RPLLoader_Link(); RPLLoader_Link();
@ -106,6 +111,11 @@ namespace coreinit
return 0; return 0;
} }
uint32 OSDynLoad_Acquire(const char* libName, uint32be* moduleHandleOut)
{
return OSDynLoad_AcquireInternal(libName, moduleHandleOut, false);
}
void OSDynLoad_Release(uint32 moduleHandle) void OSDynLoad_Release(uint32 moduleHandle)
{ {
if (moduleHandle == RPL_INVALID_HANDLE) if (moduleHandle == RPL_INVALID_HANDLE)
@ -114,6 +124,11 @@ namespace coreinit
RPLLoader_UpdateDependencies(); RPLLoader_UpdateDependencies();
} }
uint32 OSDynLoad_IsModuleLoaded(const char* libName, uint32be* moduleHandleOut)
{
return OSDynLoad_AcquireInternal(libName, moduleHandleOut, true);
}
uint32 OSDynLoad_FindExport(uint32 moduleHandle, uint32 isData, const char* exportName, betype<MPTR>* addrOut) uint32 OSDynLoad_FindExport(uint32 moduleHandle, uint32 isData, const char* exportName, betype<MPTR>* addrOut)
{ {
if (moduleHandle == 0xFFFFFFFF) if (moduleHandle == 0xFFFFFFFF)
@ -140,6 +155,7 @@ namespace coreinit
cafeExportRegister("coreinit", OSDynLoad_Acquire, LogType::Placeholder); cafeExportRegister("coreinit", OSDynLoad_Acquire, LogType::Placeholder);
cafeExportRegister("coreinit", OSDynLoad_Release, LogType::Placeholder); cafeExportRegister("coreinit", OSDynLoad_Release, LogType::Placeholder);
cafeExportRegister("coreinit", OSDynLoad_IsModuleLoaded, LogType::Placeholder);
cafeExportRegister("coreinit", OSDynLoad_FindExport, LogType::Placeholder); cafeExportRegister("coreinit", OSDynLoad_FindExport, LogType::Placeholder);
} }
} }