mirror of
https://github.com/Detanup01/gbe_fork.git
synced 2025-01-08 16:54:14 +08:00
Merge pull request #105 from Edremon/fix/symlink
Fix broken emulator when libsteam_api.so is symlinked
This commit is contained in:
commit
405f6467fa
42
dll/base.cpp
42
dll/base.cpp
@ -167,42 +167,14 @@ bool check_timedout(std::chrono::high_resolution_clock::time_point old, double t
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __LINUX__
|
#ifdef __LINUX__
|
||||||
std::string get_lib_path() {
|
std::string get_lib_path()
|
||||||
std::string dir = "/proc/self/map_files";
|
{
|
||||||
DIR *dp;
|
Dl_info info;
|
||||||
int i = 0;
|
if (dladdr((void*)get_lib_path, &info))
|
||||||
struct dirent *ep;
|
{
|
||||||
dp = opendir (dir.c_str());
|
return std::string(info.dli_fname);
|
||||||
uintptr_t p = (uintptr_t)&get_lib_path;
|
|
||||||
|
|
||||||
if (dp != NULL)
|
|
||||||
{
|
|
||||||
while ((ep = readdir (dp))) {
|
|
||||||
if (memcmp(ep->d_name, ".", 2) != 0 && memcmp(ep->d_name, "..", 3) != 0) {
|
|
||||||
char *upper = NULL;
|
|
||||||
uintptr_t lower_bound = strtoull(ep->d_name, &upper, 16);
|
|
||||||
if (lower_bound) {
|
|
||||||
++upper;
|
|
||||||
uintptr_t upper_bound = strtoull(upper, &upper, 16);
|
|
||||||
if (upper_bound && (lower_bound < p && p < upper_bound)) {
|
|
||||||
std::string path = dir + PATH_SEPARATOR + ep->d_name;
|
|
||||||
char link[PATH_MAX] = {};
|
|
||||||
if (readlink(path.c_str(), link, sizeof(link)) > 0) {
|
|
||||||
std::string lib_path = link;
|
|
||||||
(void) closedir (dp);
|
|
||||||
return link;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return ".";
|
||||||
(void) closedir (dp);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ".";
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user