OSDynLoad_Acquire: make HLE-registered libraries acquirable - #2046
OSDynLoad_Acquire: make HLE-registered libraries acquirable#2046mirzaaamerali wants to merge 1 commit into
Conversation
osLib_registerHLEFunction is DLLEXPORT'd so external code (mods, injected libraries) can register HLE functions, but RPLLoader_GetHandleByModuleName returns RPL_INVALID_HANDLE for any module that is neither a Cafe OS module nor backed by an .rpl file -- which is exactly what a purely HLE-registered library is. OSDynLoad_Acquire on such a library therefore always fails, and does so silently in release builds because the failure log is cemuLog_logDebug. Add osLib_hasLibrary() and accept a module in the handle lookup when it has HLE registrations, so DLLEXPORT-registered libraries are reachable from guest code. Also promote the OSDynLoad_Acquire failure log to a release-visible cemuLog_log.
|
Unless you have a good reason to, you should just add the functions to coreinit(.rpl). And to signal if your Cemu-side hook is loaded you can just set a byte somewhere in PPC memory and read that out. Also for future reference, we do not accept AI generated PRs. See our LLM contribution guidelines |
Problem
osLib_registerHLEFunctionisDLLEXPORTed so that external code can register HLEfunctions under a library name. But guest code can never obtain a handle to such a
library.
RPLLoader_GetHandleByModuleName(src/Cafe/OS/RPL/rpl.cpp) rejects anymodule that is neither a Cafe OS module nor backed by an
.rplfile:A library that exists purely as HLE registrations is exactly that case: it has no
.rplfile and is not a built-in Cafe OS module. SoOSDynLoad_Acquire("my_hle_lib")always fails, and every function registered through the exported API is unreachable
from the guest.
RPLLoader_FindModuleOrHLEExportalready resolves these exports viarpl_mapHLEImport— only the handle lookup was missing.Why this is easy to miss
The failure is invisible in release builds.
coreinit_DynLoad.cppreports it withcemuLog_logDebug, which is compiled out, soOSDynLoad_Acquirereturns"module not found" with no diagnostic anywhere. Behaviour is identical on 1.27.1 and
2.6.
Change
osLib_hasLibrary(const char*)— true if any HLE function is registered underthat library name.
RPLLoader_GetHandleByModuleName.OSDynLoad_Acquirefailure fromcemuLog_logDebugtocemuLog_log.The logging change is separable — happy to drop it if you would rather that stay
debug-only. It is included because the silence is what made this take so long to
identify.
Validation
Tested with an injection-based mod that registers its interceptor library through
osLib_registerHLEFunction:hooks never resolve.
the pointer only on success, so the failure log lines stop at the moment the library
becomes reachable while the caller keeps polling at roughly 480 calls/sec.
(
PPCRecompiler_getJumpTableBase) was observed dispatching into a functionregistered by the injected library.
Built with this repository's own
build.yml(Windows x64).