From 298481f9af631e5165a325e5aeb70080f5138710 Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Tue, 11 May 2021 18:15:14 -0700 Subject: [PATCH] Support redirecting thread-self exe softlink --- Source/Tests/LinuxSyscalls/FileManagement.cpp | 8 ++++++-- Source/Tests/LinuxSyscalls/Syscalls.cpp | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Source/Tests/LinuxSyscalls/FileManagement.cpp b/Source/Tests/LinuxSyscalls/FileManagement.cpp index 791c112a5..3c3e039fd 100644 --- a/Source/Tests/LinuxSyscalls/FileManagement.cpp +++ b/Source/Tests/LinuxSyscalls/FileManagement.cpp @@ -161,7 +161,9 @@ std::optional FileManager::GetSelf(const char *Pathname) { char PidSelfPath[50]; snprintf(PidSelfPath, 50, "/proc/%i/exe", pid); - if (strcmp(Pathname, "/proc/self/exe") == 0 || strcmp(Pathname, PidSelfPath) == 0) { + if (strcmp(Pathname, "/proc/self/exe") == 0 || + strcmp(Pathname, "/proc/thread-self/exe") == 0 || + strcmp(Pathname, PidSelfPath) == 0) { return Filename(); } @@ -262,7 +264,9 @@ uint64_t FileManager::Readlink(const char *pathname, char *buf, size_t bufsiz) { char PidSelfPath[50]; snprintf(PidSelfPath, 50, "/proc/%i/exe", pid); - if (strcmp(pathname, "/proc/self/exe") == 0 || strcmp(pathname, PidSelfPath) == 0) { + if (strcmp(pathname, "/proc/self/exe") == 0 || + strcmp(pathname, "/proc/thread-self/exe") == 0 || + strcmp(pathname, PidSelfPath) == 0) { auto App = Filename(); strncpy(buf, App.c_str(), bufsiz); return std::min(bufsiz, App.size()); diff --git a/Source/Tests/LinuxSyscalls/Syscalls.cpp b/Source/Tests/LinuxSyscalls/Syscalls.cpp index 7945b9ac9..93f0904fc 100644 --- a/Source/Tests/LinuxSyscalls/Syscalls.cpp +++ b/Source/Tests/LinuxSyscalls/Syscalls.cpp @@ -123,7 +123,9 @@ uint64_t ExecveHandler(const char *pathname, std::vector &argv, std char PidSelfPath[50]; snprintf(PidSelfPath, 50, "/proc/%i/exe", pid); - if (strcmp(pathname, "/proc/self/exe") == 0 || strcmp(pathname, PidSelfPath) == 0) { + if (strcmp(pathname, "/proc/self/exe") == 0 || + strcmp(pathname, "/proc/thread-self/exe") == 0 || + strcmp(pathname, PidSelfPath) == 0) { // If pointing to self then redirect to the application // JRE and shapez.io does this Filename = FEX::HLE::_SyscallHandler->Filename();