[Wine-patches] [eterhack 1/2] Prevent loading winedevice below 0x80000000 on Fedora 10 (eterbug #4055).

Alexander Morozov amorozov на etersoft.ru
Вт Июл 14 15:51:58 MSD 2009


----------- следующая часть -----------
From 96d76532c5e16cdb7062d6a885c53262a3b3a5c7 Mon Sep 17 00:00:00 2001
From: Alexander Morozov <amorozov на etersoft.ru>
Date: Tue, 14 Jul 2009 14:36:47 +0400
Subject: [eterhack 1/2] Prevent loading winedevice below 0x80000000 on Fedora 10 (eterbug #4055).

---
 dlls/ntdll/virtual.c |   16 ++++++++++++----
 libs/wine/loader.c   |    2 +-
 loader/preloader.c   |   27 +++++++++++++++++++++++++--
 3 files changed, 38 insertions(+), 7 deletions(-)

diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c
index 0167fda..de6affb 100644
--- a/dlls/ntdll/virtual.c
+++ b/dlls/ntdll/virtual.c
@@ -1676,15 +1676,23 @@ static int free_reserved_memory( void *base, size_t size, void *arg )
 void virtual_release_address_space( BOOL free_high_mem )
 {
 #ifdef __i386__
+#ifndef __APPLE__
+    static const char winedevice[] = "\\winedevice.exe";
+    char *path;
+#endif
     struct free_range range;
     sigset_t sigset;
 
     server_enter_uninterrupted_section( &csVirtual, &sigset );
 
 #ifndef __APPLE__  /* dyld doesn't support parts of the WINE_DOS segment being unmapped */
-    range.base  = (char *)0x20000000;
-    range.limit = (char *)0x7f000000;
-    while (wine_mmap_enum_reserved_areas( free_reserved_memory, &range, 0 )) /* nothing */;
+    if (!(path = strrchr( __wine_main_argv[0], '\\' )) ||
+        strcasecmp( path, winedevice ))
+    {
+        range.base  = (char *)0x20000000;
+        range.limit = (char *)0x7f000000;
+        while (wine_mmap_enum_reserved_areas( free_reserved_memory, &range, 0 )) /* nothing */;
+    }
 #endif
 
     /* no large address space on win9x */
@@ -1705,7 +1713,7 @@ void virtual_release_address_space( BOOL free_high_mem )
  */
 void VIRTUAL_UseDriverAddressSpace(void)
 {
-    user_space_limit = working_set_limit = (void *)0x84ff0000;
+    user_space_limit = working_set_limit = (void *)0x8fff0000;
     address_space_start = (void *)0x81000000;
 }
 
diff --git a/libs/wine/loader.c b/libs/wine/loader.c
index ef30edb..d2b0042 100644
--- a/libs/wine/loader.c
+++ b/libs/wine/loader.c
@@ -653,7 +653,7 @@ void wine_init( int argc, char *argv[], char *error, int error_size )
     __wine_main_argv = argv;
     __wine_main_environ = __wine_get_main_environment();
     if ((argc >= 2) && (path = strrchr( argv[1], '\\' )) && !strcasecmp( path, winedevice ))
-        mmap_init( (char *)0x84fe0000 );
+        mmap_init( (char *)0x8ffe0000 );
     else
         mmap_init( (char *)0x7ffe0000 );
 
diff --git a/loader/preloader.c b/loader/preloader.c
index 347d4d6..ad6d12b 100644
--- a/loader/preloader.c
+++ b/loader/preloader.c
@@ -109,7 +109,7 @@
 /* missed in some old systems */
 typedef uint32_t Elf_Symndx;
 
-static struct wine_preload_info preload_info[] =
+static struct wine_preload_info common_preload_info[] =
 {
     { (void *)0x00000000, 0x00010000 },  /* low 64k */
     { (void *)0x00010000, 0x00100000 },  /* DOS area */
@@ -119,6 +119,20 @@ static struct wine_preload_info preload_info[] =
     { 0, 0 }                             /* end of list */
 };
 
+/* special address space layout for winedevice */
+static struct wine_preload_info winedevice_preload_info[] =
+{
+    { (void *)0x00000000, 0x00010000 },
+    { (void *)0x00010000, 0x00100000 },
+    { (void *)0x00110000, 0x7b800000 },
+    { (void *)0x7bf00000, 0x00100000 },
+    { (void *)0x7c010000, 0x05ff0000 },
+    { 0, 0 },
+    { 0, 0 }
+};
+
+static struct wine_preload_info *preload_info = common_preload_info;
+
 /* debugging */
 #undef DUMP_SEGMENTS
 #undef DUMP_AUX_INFO
@@ -1048,7 +1062,7 @@ void* wld_start( void **stack )
 {
     int i, *pargc;
     char **argv, **p;
-    char *interp, *reserve = NULL;
+    char *interp, *reserve = NULL, *ptr, *exec = NULL;
     ElfW(auxv_t) new_av[12], delete_av[3], *av;
     struct wld_link_map main_binary_map, ld_so_map;
     struct wine_preload_info **wine_main_preload_info;
@@ -1081,6 +1095,15 @@ void* wld_start( void **stack )
     dump_auxiliary( av );
 #endif
 
+    /* use special address space layout for winedevice */
+    if (*pargc > 2)
+    {
+        ptr = argv[2];
+        while (*ptr++) if (*ptr == '\\') exec = ptr;
+        if (exec && !wld_strcmp( "\\winedevice.exe", exec ))
+            preload_info = winedevice_preload_info;
+    }
+
     /* reserve memory that Wine needs */
     if (reserve) preload_reserve( reserve );
     for (i = 0; preload_info[i].size; i++)
-- 
1.6.3.3



Подробная информация о списке рассылки Wine-patches