diff options
author | Sefa Eyeoglu <contact@scrumplex.net> | 2023-08-17 16:09:16 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-17 16:09:16 +0200 |
commit | e88418ab7f1a2979ccb1ef92b4cd7da87f5cd6c5 (patch) | |
tree | 81a36f1f28eefbd0f205780c48b80a531a6364bf /launcher/MangoHud.cpp | |
parent | 85f36ebed7e1295547cd2324d1baf7834be89c31 (diff) | |
parent | 06aba530d7154f0cff76b2d5dc650a428ff1a54e (diff) | |
download | PrismLauncher-e88418ab7f1a2979ccb1ef92b4cd7da87f5cd6c5.tar.gz PrismLauncher-e88418ab7f1a2979ccb1ef92b4cd7da87f5cd6c5.tar.bz2 PrismLauncher-e88418ab7f1a2979ccb1ef92b4cd7da87f5cd6c5.zip |
Merge pull request #1392 from Scrumplex/feat-native-override
Diffstat (limited to 'launcher/MangoHud.cpp')
-rw-r--r-- | launcher/MangoHud.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/launcher/MangoHud.cpp b/launcher/MangoHud.cpp index 5758da3a..ab79f418 100644 --- a/launcher/MangoHud.cpp +++ b/launcher/MangoHud.cpp @@ -16,6 +16,7 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ +#include <QDebug> #include <QDir> #include <QString> #include <QStringList> @@ -26,6 +27,15 @@ #include "Json.h" #include "MangoHud.h" +#ifdef __GLIBC__ +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#define UNDEF_GNU_SOURCE +#endif +#include <dlfcn.h> +#include <linux/limits.h> +#endif + namespace MangoHud { QString getLibraryString() @@ -106,4 +116,37 @@ QString getLibraryString() return QString(); } + +QString findLibrary(QString libName) +{ +#ifdef __GLIBC__ + const char* library = libName.toLocal8Bit().constData(); + + void* handle = dlopen(library, RTLD_NOW); + if (!handle) { + qCritical() << "dlopen() failed:" << dlerror(); + return {}; + } + + char path[PATH_MAX]; + if (dlinfo(handle, RTLD_DI_ORIGIN, path) == -1) { + qCritical() << "dlinfo() failed:" << dlerror(); + dlclose(handle); + return {}; + } + + auto fullPath = FS::PathCombine(QString(path), libName); + + dlclose(handle); + return fullPath; +#else + qWarning() << "MangoHud::findLibrary is not implemented on this platform"; + return {}; +#endif +} } // namespace MangoHud + +#ifdef UNDEF_GNU_SOURCE +#undef _GNU_SOURCE +#undef UNDEF_GNU_SOURCE +#endif |