From 5cc25551e5166b55127b7f5c5bb69c2153a3bf80 Mon Sep 17 00:00:00 2001 From: Maschell Date: Thu, 16 Mar 2023 12:01:20 +0100 Subject: [PATCH] Replace '/' with '|' in OSDynload_Acquire with name starts with '~' --- .../dynload/dynload_function_replacements.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/source/dynload/dynload_function_replacements.cpp b/source/dynload/dynload_function_replacements.cpp index f38bb72..c8f33de 100644 --- a/source/dynload/dynload_function_replacements.cpp +++ b/source/dynload/dynload_function_replacements.cpp @@ -3,6 +3,7 @@ #include "loader_defines.h" #include "logger.h" #include +#include #include #include @@ -27,11 +28,21 @@ DECL_FUNCTION(OSDynLoad_Error, OSDynLoad_Acquire, char const *name, OSDynLoad_Mo } } - OSDynLoad_Error result = real_OSDynLoad_Acquire(name, outModule); - if (result == OS_DYNLOAD_OK) { - return OS_DYNLOAD_OK; + if (name != nullptr && name[0] == '~') { + char cpy[64] = {}; + snprintf(cpy, sizeof(cpy), "%s", name); + char *curPtr = &cpy[1]; + while (*curPtr != '\0') { + if (*curPtr == '/') { + *curPtr = '|'; + } + curPtr++; + } + return real_OSDynLoad_Acquire(cpy, outModule); } + OSDynLoad_Error result = real_OSDynLoad_Acquire(name, outModule); + return result; }