From 3b01919148cdf9591d69393217e04331c6c06296 Mon Sep 17 00:00:00 2001 From: Ikey Doherty Date: Sat, 21 Oct 2017 19:46:25 +0100 Subject: [PATCH] shim: Set LD_PRELOAD for libredirect if enabled Signed-off-by: Ikey Doherty --- src/shim/shim.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/shim/shim.c b/src/shim/shim.c index 030ffc4..50918e0 100644 --- a/src/shim/shim.c +++ b/src/shim/shim.c @@ -32,6 +32,13 @@ */ #define AUDIT_PATH "/usr/\$LIB/liblsi-intercept.so" +/** + * Redirect path is used for the libredirect library to perform internal + * redirections in functions like `open()` where needed to hotfix games + * at runtime. + */ +#define REDIRECT_PATH "/usr/\$LIB/liblsi-redirect.so" + int main(int argc, char **argv) { LsiConfig config = { 0 }; @@ -67,6 +74,14 @@ int main(int argc, char **argv) if (config.use_libintercept) { setenv("LD_AUDIT", AUDIT_PATH, 1); } +#endif +#ifdef HAVE_LIBREDIRECT + /* Only use libredirect in combination with native runtime! + * TODO: Respect existing preload libraries? + */ + if (config.use_libredirect) { + setenv("LD_PRELOAD", REDIRECT_PATH, 1); + } #endif } else { /* Only preload when needed. */