On Mon, Jul 22, 2013 at 10:45 PM, Alexei Svitkine <alexei.svitk...@gmail.com
> wrote:

> Don't let the gdi32 driver allocate memory in the dplayx region.
>
> Fixes bug: http://bugs.winehq.org/show_bug.cgi?id=34095
>
> The issue is that the dplayx code in wine needs to allocate some
> memory at a static address (0x50000000) and loading the Mac native gdi
> driver ends up using that part of the address space.
>
> This patch fixes that by reserving that part of memory while the
> display driver is initialized and releasing it after.
>
> ---
>  dlls/gdi32/driver.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
>
diff --git a/dlls/gdi32/driver.c b/dlls/gdi32/driver.c
index f625f32..e0b0673 100644
--- a/dlls/gdi32/driver.c
+++ b/dlls/gdi32/driver.c
@@ -105,9 +105,16 @@ static const struct gdi_dc_funcs *get_display_driver( HMODULE *module_ret )
     char buffer[MAX_PATH], libname[32], *name, *next;
     HMODULE module = 0;
     HKEY hkey;
+    LPVOID reserved_region;
 
     if (display_driver) goto done;
 
+    /* Reserve a region of memory that may need to be free later for loading dplayx
+     * (see dplayx_global.c), to prevent the display driver allocating memory there.
+     * Release it after the display driver has been initialized.
+     */
+    reserved_region = VirtualAlloc( (LPVOID)0x50000000, 1024 * 1024, MEM_RESERVE, PAGE_NOACCESS );
+
     strcpy( buffer, default_driver );
     /* @@ Wine registry key: HKCU\Software\Wine\Drivers */
     if (!RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\Drivers", &hkey ))
@@ -142,6 +149,9 @@ static const struct gdi_dc_funcs *get_display_driver( HMODULE *module_ret )
         FreeLibrary( driver->module );
         HeapFree( GetProcessHeap(), 0, driver );
     }
+
+    if (reserved_region) VirtualFree( reserved_region, 0, MEM_RELEASE );
+
 done:
     *module_ret = display_driver->module;
     return display_driver->funcs;


Reply via email to