NT driver address space

Alexander Morozov amorozov at etersoft.ru
Tue Nov 18 07:59:06 CST 2008


Hi,

Under Wine NT drivers are running in user address space. Some drivers do not 
work correctly because of this. For example Guardant USB token driver crashes 
when loading but this problem can be fixed with such patch (really I tested 
with our wine fork):

diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c
index 78e38dc..f607f22 100644
--- a/dlls/ntdll/virtual.c
+++ b/dlls/ntdll/virtual.c
@@ -904,6 +904,7 @@ static NTSTATUS map_image( HANDLE hmapping, int fd, char 
*base, SIZE_T total_siz

     server_enter_uninterrupted_section( &csVirtual, &sigset );

+    if (0x10000 == base) base = 0x81000000;
     if (base >= (char *)0x110000)  /* make sure the DOS area remains free */
         status = map_view( &view, base, total_size, mask, FALSE,
                            VPROT_COMMITTED | VPROT_READ | VPROT_EXEC | 
VPROT_WRITECOPY | VPROT_IMAGE );
diff --git a/libs/wine/mmap.c b/libs/wine/mmap.c
index ff117cc..4c18683 100644
--- a/libs/wine/mmap.c
+++ b/libs/wine/mmap.c
@@ -346,7 +346,7 @@ void mmap_init(void)
 #if defined(__i386__) && !defined(__FreeBSD__) 
&& !defined(__FreeBSD_kernel__)  /* commented out until FreeBSD gets fixed */
     char stack;
     char * const stack_ptr = &stack;
-    char *user_space_limit = (char *)0x7ffe0000;
+    char *user_space_limit = (char *)0xaffe0000;

     reserve_malloc_space( 8 * 1024 * 1024 );


I see two ways of fixing this.
1. Modify wine to run winedevice.exe in kernel address space (> 0x80000000) by 
checking name of executable.
2. Modify ExAllocatePool and some other functions to use kernel address space, 
modify functions which is used by drivers (ntoskrnl.exe exports etc.) to use 
only this memory allocation functions, modify winedevice.exe to load driver 
and create stack in kernel address space.
What is better decision?

Thanks,
Alexander Morozov



More information about the wine-devel mailing list