KERNEL: use FILE_SHARE_DELETE when loading modules

Mike McCormack mike at codeweavers.com
Wed Sep 15 03:02:19 CDT 2004


Macromedia's Dreamweaver MX uninstaller does this:

CreateFile("uninstall.exe", 0, FILE_SHARE_READ, NULL,
             OPEN_EXISTING, FILE_FLAG_DELETE_ON_CLOSE, NULL);
CreateProcess( NULL, "uninstall.exe", NULL, NULL,
                TRUE, 0, NULL, NULL, &si, &pi );

The code that deals with loading PE modules presently does not add 
FILE_SHARE_DELETE, so CreateProcess fails with a sharing violation.

Mike


ChangeLog:
* use FILE_SHARE_DELETE when loading modules, as
   running an exe that's going to be deleted should work

-------------- next part --------------
Index: dlls/ntdll/loader.c
===================================================================
RCS file: /home/wine/wine/dlls/ntdll/loader.c,v
retrieving revision 1.76
diff -u -r1.76 loader.c
--- dlls/ntdll/loader.c	2 Aug 2004 22:25:01 -0000	1.76
+++ dlls/ntdll/loader.c	15 Sep 2004 06:19:30 -0000
@@ -1398,7 +1398,7 @@
             attr.ObjectName = &nt_name;
             attr.SecurityDescriptor = NULL;
             attr.SecurityQualityOfService = NULL;
-            if (NtOpenFile( handle, GENERIC_READ, &attr, &io, FILE_SHARE_READ, 0 )) *handle = 0;
+            if (NtOpenFile( handle, GENERIC_READ, &attr, &io, FILE_SHARE_READ|FILE_SHARE_DELETE, 0 )) *handle = 0;
             RtlFreeUnicodeString( &nt_name );
             return STATUS_SUCCESS;
         }
@@ -1445,7 +1445,7 @@
         attr.ObjectName = &nt_name;
         attr.SecurityDescriptor = NULL;
         attr.SecurityQualityOfService = NULL;
-        if (NtOpenFile( handle, GENERIC_READ, &attr, &io, FILE_SHARE_READ, 0 )) *handle = 0;
+        if (NtOpenFile( handle, GENERIC_READ, &attr, &io, FILE_SHARE_READ|FILE_SHARE_DELETE, 0 )) *handle = 0;
     }
     RtlFreeUnicodeString( &nt_name );
     return STATUS_SUCCESS;
Index: dlls/kernel/process.c
===================================================================
RCS file: /home/wine/wine/dlls/kernel/process.c,v
retrieving revision 1.75
diff -u -r1.75 process.c
--- dlls/kernel/process.c	10 Sep 2004 21:16:02 -0000	1.75
+++ dlls/kernel/process.c	15 Sep 2004 06:19:30 -0000
@@ -195,7 +195,7 @@
 
     TRACE("looking for %s\n", debugstr_w(name) );
 
-    if ((handle = CreateFileW( name, GENERIC_READ, FILE_SHARE_READ,
+    if ((handle = CreateFileW( name, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_DELETE,
                                NULL, OPEN_EXISTING, 0, 0 )) == INVALID_HANDLE_VALUE)
     {
         /* file doesn't exist, check for builtin */
@@ -260,7 +260,7 @@
         if (SearchPathW( NULL, name, NULL, buflen, buffer, NULL ))
         {
             TRACE( "Trying native/Unix binary %s\n", debugstr_w(buffer) );
-            if ((*handle = CreateFileW( buffer, GENERIC_READ, FILE_SHARE_READ,
+            if ((*handle = CreateFileW( buffer, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_DELETE,
                                         NULL, OPEN_EXISTING, 0, 0 )) != INVALID_HANDLE_VALUE)
                 return TRUE;
         }
@@ -276,7 +276,7 @@
         {
         case LOADORDER_DLL:
             TRACE( "Trying native exe %s\n", debugstr_w(buffer) );
-            if ((*handle = CreateFileW( buffer, GENERIC_READ, FILE_SHARE_READ,
+            if ((*handle = CreateFileW( buffer, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_DELETE,
                                         NULL, OPEN_EXISTING, 0, 0 )) != INVALID_HANDLE_VALUE)
                 return TRUE;
             if (GetLastError() != ERROR_FILE_NOT_FOUND) return TRUE;


More information about the wine-patches mailing list