[PATCH] dplayx: Map global memory anywhere if the standard address is unavailable.

Tim Clem tclem at codeweavers.com
Wed Sep 29 15:13:04 CDT 2021


Signed-off-by: Tim Clem <tclem at codeweavers.com>
---
There's an existing code path and ERR log that seems to assume MapViewOfFileEx
will already do this, but it doesn't. As the comments note, if this memory
winds up somewhere else, it will cause problems if more than one process is
trying to use dplay. However, the current code breaks in all circumstances
if the fixed address is unavailable.

 dlls/dplayx/dplayx_global.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/dlls/dplayx/dplayx_global.c b/dlls/dplayx/dplayx_global.c
index a544cd2196e9..957f7cf46f57 100644
--- a/dlls/dplayx/dplayx_global.c
+++ b/dlls/dplayx/dplayx_global.c
@@ -418,6 +418,15 @@ BOOL DPLAYX_ConstructData(void)
                                         FILE_MAP_WRITE,
                                         0, 0, 0, lpDesiredMemoryMapStart );
 
+  if( lpSharedStaticData == NULL && GetLastError() == ERROR_INVALID_ADDRESS )
+  {
+    /* We couldn't map the data where we wanted. Try again, allowing any
+     * location. */
+    lpSharedStaticData = MapViewOfFile( hDplayxSharedMem,
+                                        FILE_MAP_WRITE,
+                                        0, 0, 0 );
+  }
+
   if( lpSharedStaticData == NULL )
   {
     ERR( ": unable to map static data into process memory space (%d)\n",
-- 
2.33.0




More information about the wine-devel mailing list