diff --git a/src/intercept/main.c b/src/intercept/main.c index b8133bb..e4c3a51 100644 --- a/src/intercept/main.c +++ b/src/intercept/main.c @@ -239,6 +239,42 @@ static const char *vendor_transmute_target[] = { "libSDL2_gfx-1.0.so.0", }; +/** + * Every so often a game comes along that does the following: + * + * open("path") ? dlopen("path"). + * Except: path = "*.dll", dlopen() is transformed to ".dll.so" + * + * This is unrelated to the ".la" errors + */ +static bool lsi_override_dll_fail(const char *orig_name, const char **soname) +{ + size_t len = strlen(orig_name); + static char path_lookup[PATH_MAX]; + + if (len < 7) { + return false; + } + + if (strncmp(orig_name + (len - 7), ".dll.so", 7) != 0) { + return false; + } + + if (!strncpy(path_lookup, orig_name, len - 3)) { + return false; + } + + if (!lsi_file_exists(path_lookup)) { + return false; + } + + *soname = path_lookup; + lsi_log_debug("fixed invalid suffix dlopen() \033[31;1m%s\033[0m -> \033[34;1m%s\033[0m", + orig_name, + path_lookup); + return true; +} + /** * Mono games might try looking for /x86/ plugin directory for a 64-bit process, * as seen with testing with Project Highrise. @@ -316,6 +352,10 @@ static bool lsi_override_dlopen(const char *orig_name, const char **soname) #endif }; + if (lsi_override_dll_fail(orig_name, soname)) { + return true; + } + if (!lsi_file_exists(orig_name)) { return false; }