Posted December 30, 2017
dtgreene: One possible workaround, if you don't mind writing a little bit of C.
1. Create a shared library. This shared library should contain a function with the same name and signature that strace shows the program is calling, and should return the data you want the program to use.
2. When starting the game, use LD_PRELOAD to force your shared library to load before the game loads it.
Now, when the game calls the function, it will get your version of the function instead of glibc's wrapper of the system call.
I was actually planning to write an LD_PRELOAD hook but I just never had the time and, now that Flatpak is around, I figure I might as well go for the more comprehensive solution that doesn't require me to write any C. 1. Create a shared library. This shared library should contain a function with the same name and signature that strace shows the program is calling, and should return the data you want the program to use.
2. When starting the game, use LD_PRELOAD to force your shared library to load before the game loads it.
Now, when the game calls the function, it will get your version of the function instead of glibc's wrapper of the system call.
(Though I still do plan to write a hook to fix games like Dungeons of Dredmor which only allow you to select valid fullscreen resolutions for windowed mode, which keeps them from playing nicely with a MetaModes line that locks the desktop resolution. That one, I actually started work on years ago, but couldn't figure out how to write a dlsym(RTLD_NEXT, "SDL_ListModes") function pointer signature that the compiler would accept... and then other things kept coming up so I've just not been playing Dredmor.)
I figure that, since the core of my launcher is already being ported from Python to Rust for reusability and stricter type checks, I might as well write the LD_PRELOAD helper using something like redhook ( https://crates.io/crates/redhook ) or hooky ( https://crates.io/crates/hooky ) so I get a language I'm more familiar with and a function pointer syntax that's not so squirrely.
Post edited December 30, 2017 by ssokolow