about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2025-01-29 18:12:29 +0100
committerptitSeb <sebastien.chev@gmail.com>2025-01-29 18:12:29 +0100
commit96bca6eac36f9f1a488e9d6f0414be279624b472 (patch)
treee36544c13bcb16a5b1f107a555f5004983a4eb31 /src
parented7147e598727946912a0e9c11eb9a0330a85f30 (diff)
downloadbox64-96bca6eac36f9f1a488e9d6f0414be279624b472.tar.gz
box64-96bca6eac36f9f1a488e9d6f0414be279624b472.zip
Improved map with fd tracking
Diffstat (limited to 'src')
-rw-r--r--src/wrapped/wrappedlibc.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/wrapped/wrappedlibc.c b/src/wrapped/wrappedlibc.c
index 29ac1f96..71d811f2 100644
--- a/src/wrapped/wrappedlibc.c
+++ b/src/wrapped/wrappedlibc.c
@@ -3006,16 +3006,17 @@ EXPORT void* my_mmap64(x64emu_t* emu, void *addr, size_t length, int prot, int f
                 if((BOX64ENV(log)>=LOG_DEBUG || BOX64ENV(dynarec_log)>=LOG_DEBUG)) {printf_log(LOG_NONE, "Note: Marking the region (%p-%p prot=%x) as NEVERCLEAN because fd have O_RDWR attribute\n", ret, ret+length, prot);}
                 prot |= PROT_NEVERCLEAN;
             }
+            if(emu) {
+                DetectUnityPlayer(fd);
+                // the last_mmap will allow mmap created by wine, even those that have hole, to be fully tracked as one single mmap
+                if((ret>=last_mmap_addr) && ret+length<(last_mmap_addr+last_mmap_len))
+                    RecordEnvMappings((uintptr_t)last_mmap_addr, last_mmap_len, fd);
+                else
+                    RecordEnvMappings((uintptr_t)ret, length, fd);
+            }
         }
-        if(fd>0) {
-            DetectUnityPlayer(fd);
-            // the last_mmap will allow mmap created by wine, even those that have hole, to be fully tracked as one single mmap
-            if((ret>=last_mmap_addr) && ret+length<(last_mmap_addr+last_mmap_len))
-                RecordEnvMappings((uintptr_t)last_mmap_addr, last_mmap_len, fd);
-            else
-                RecordEnvMappings((uintptr_t)ret, length, fd);
-        }
-        if((fd==-1) && (flags==(MAP_PRIVATE|MAP_ANON))) {
+        // hack to capture full size of the mmap done by wine
+        if(emu && (fd==-1) && (flags==(MAP_PRIVATE|MAP_ANON))) {
             last_mmap_addr = ret;
             last_mmap_len = length;
         } else {