clementgallet / libTAS

GNU/Linux software to (hopefully) give TAS tools to games
GNU General Public License v3.0
496 stars 57 forks source link

Kitty Kart 64 FMOD fails to be hooked #624

Open CasualPokePlayer opened 5 days ago

CasualPokePlayer commented 5 days ago

https://snugboat11.itch.io/kitty-kart-64

Godot game which uses FMOD. FMOD::System::setOutput is called eventually, but it only calls the native function, not calling the hooked function. As such, PulseAudio is used which is not hooked.

CasualPokePlayer commented 5 days ago

Seems the issue comes with dlopen flags.

The game initially dlopen's with libfmod.linux.template_debug.so, which eventually tries to resolve symbols against libfmodL.so.13 and libfmodstudioL.so.13. It uses the RTLD_NOW | RTLD_DEEPBIND flags here. The docs on RTLD_DEEPBIND seem to indicate this is problematic:

RTLD_DEEPBIND (since glibc 2.3.4)
    Place the lookup scope of the symbols in this library ahead of the global scope. This means that a self-contained library will use its own symbols in preference to global symbols with the same name contained in libraries that have already been loaded. This flag is not specified in POSIX.1-2001.

This would effectively prevent the LD_PRELOAD trick from working at all. It's probably also why it appears to be able to dlopen libpulse.so.0 despite that normally being blocked by libTAS (since the dlopen hook is also bypassed). This flag could possibly also cause issues in other games perhaps, since again, it just completely prevents the LD_PRELOAD trick from working at all.

The different naming here might also be an issue here regardless with the hooked function perhaps? (L appears to be a logging variant of fmod, although the game also provides regular unused fmod .so's too so perhaps it'd work fine regardless).