about summary refs log tree commit diff stats
path: root/src/tools
diff options
context:
space:
mode:
authorYang Liu <liuyang22@iscas.ac.cn>2025-01-23 18:43:24 +0800
committerGitHub <noreply@github.com>2025-01-23 11:43:24 +0100
commitf0d8712275d2ca1b27d7022acf48cde647bdacd5 (patch)
tree760e60c42e378ade560cb1d0a824ba0cfd9ebe8d /src/tools
parentfe3b66b018adb3d7a89289fc1c74f80309938716 (diff)
downloadbox64-f0d8712275d2ca1b27d7022acf48cde647bdacd5.tar.gz
box64-f0d8712275d2ca1b27d7022acf48cde647bdacd5.zip
Clean up UnityPlayer.dll detection from my_mmap64 (#2286)
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/wine_tools.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/tools/wine_tools.c b/src/tools/wine_tools.c
index 96978bed..ffbebdf2 100644
--- a/src/tools/wine_tools.c
+++ b/src/tools/wine_tools.c
@@ -149,3 +149,25 @@ void dynarec_wine_prereserve()
     #endif
 }
 #endif
+
+void detect_unityplayer(int fd)
+{
+    static int unityplayer_detected = 0;
+    if (fd > 0 && BOX64ENV(unityplayer) && !unityplayer_detected) {
+        char filename[4096];
+        char buf[128];
+        sprintf(buf, "/proc/self/fd/%d", fd);
+        ssize_t r = readlink(buf, filename, sizeof(filename) - 1);
+        if (r != -1) filename[r] = 0;
+        if (r > 0 && strlen(filename) > strlen("UnityPlayer.dll") && !strcasecmp(filename + strlen(filename) - strlen("UnityPlayer.dll"), "UnityPlayer.dll")) {
+            printf_log(LOG_NONE, "Detected UnityPlayer.dll\n");
+#ifdef DYNAREC
+            if (!BOX64ENV(dynarec_strongmem)) {
+                SET_BOX64ENV(dynarec_strongmem, 1);
+                PrintEnvVariables();
+            }
+#endif
+            unityplayer_detected = 1;
+        }
+    }
+}
\ No newline at end of file