Postpone creation disposition check in CreateFile until it's really used

Dmitry Timoshkov dmitry at baikal.ru
Mon Dec 20 02:06:08 CST 2004


Hello,

it's a common practice to open a VxD with a call like the following one:

vxd_handle = CreateFile(vxd_name, 0, 0, NULL, 0, 0, NULL);

i.e. pass 0 as a creation disposition. It works in Windows but fails
in Wine.

Changelog:
    Dmitry Timoshkov <dmitry at codeweavers.com>
    Postpone creation disposition check in CreateFile until it's really used.

diff -up cvs/hq/wine/dlls/kernel/file.c wine/dlls/kernel/file.c
--- cvs/hq/wine/dlls/kernel/file.c	2004-11-29 08:58:38.000000000 +0800
+++ wine/dlls/kernel/file.c	2004-12-20 15:39:27.000000000 +0800
@@ -1182,10 +1182,6 @@ HANDLE WINAPI CreateFileW( LPCWSTR filen
     static const WCHAR bkslashes_with_dotW[] = {'\\','\\','.','\\',0};
     static const WCHAR coninW[] = {'C','O','N','I','N','$',0};
     static const WCHAR conoutW[] = {'C','O','N','O','U','T','$',0};
-
-    static const char * const creation_name[5] =
-        { "CREATE_NEW", "CREATE_ALWAYS", "OPEN_EXISTING", "OPEN_ALWAYS", "TRUNCATE_EXISTING" };
-
     static const UINT nt_disposition[5] =
     {
         FILE_CREATE,        /* CREATE_NEW */
@@ -1195,7 +1191,6 @@ HANDLE WINAPI CreateFileW( LPCWSTR filen
         FILE_OVERWRITE      /* TRUNCATE_EXISTING */
     };
 
-
     /* sanity checks */
 
     if (!filename || !filename[0])
@@ -1204,28 +1199,14 @@ HANDLE WINAPI CreateFileW( LPCWSTR filen
         return INVALID_HANDLE_VALUE;
     }
 
-    if (creation < CREATE_NEW || creation > TRUNCATE_EXISTING)
-    {
-        SetLastError( ERROR_INVALID_PARAMETER );
-        return INVALID_HANDLE_VALUE;
-    }
-
-    TRACE("%s %s%s%s%s%s%s%s attributes 0x%lx\n", debugstr_w(filename),
+    TRACE("%s %s%s%s%s%s%s creation %ld attributes 0x%lx\n", debugstr_w(filename),
           (access & GENERIC_READ)?"GENERIC_READ ":"",
           (access & GENERIC_WRITE)?"GENERIC_WRITE ":"",
           (!access)?"QUERY_ACCESS ":"",
           (sharing & FILE_SHARE_READ)?"FILE_SHARE_READ ":"",
           (sharing & FILE_SHARE_WRITE)?"FILE_SHARE_WRITE ":"",
           (sharing & FILE_SHARE_DELETE)?"FILE_SHARE_DELETE ":"",
-          creation_name[creation - CREATE_NEW], attributes);
-
-    /* Open a console for CONIN$ or CONOUT$ */
-
-    if (!strcmpiW(filename, coninW) || !strcmpiW(filename, conoutW))
-    {
-        ret = OpenConsoleW(filename, access, (sa && sa->bInheritHandle), creation);
-        goto done;
-    }
+          creation, attributes);
 
     if (!strncmpW(filename, bkslashes_with_dotW, 4))
     {
@@ -1251,7 +1232,22 @@ HANDLE WINAPI CreateFileW( LPCWSTR filen
             return INVALID_HANDLE_VALUE;
         }
     }
-    else dosdev = RtlIsDosDeviceName_U( filename );
+
+    if (creation < CREATE_NEW || creation > TRUNCATE_EXISTING)
+    {
+        SetLastError( ERROR_INVALID_PARAMETER );
+        return INVALID_HANDLE_VALUE;
+    }
+
+    /* Open a console for CONIN$ or CONOUT$ */
+
+    if (!strcmpiW(filename, coninW) || !strcmpiW(filename, conoutW))
+    {
+        ret = OpenConsoleW(filename, access, (sa && sa->bInheritHandle), creation);
+        goto done;
+    }
+
+    dosdev = RtlIsDosDeviceName_U( filename );
 
     if (dosdev)
     {
diff -up cvs/hq/wine/dlls/kernel/vxd.c wine/dlls/kernel/vxd.c
--- cvs/hq/wine/dlls/kernel/vxd.c	2004-08-19 17:59:08.000000000 +0900
+++ wine/dlls/kernel/vxd.c	2004-12-20 15:36:43.000000000 +0800
@@ -195,10 +195,9 @@ HANDLE VXD_Open( LPCWSTR filenameW, DWOR
         return 0;
     }
     strcpyW( name, filenameW );
-    strlwrW( name );
     p = strchrW( name, '.' );
     if (!p) strcatW( name, dotVxDW );
-    else if (strcmpW( p, dotVxDW ))  /* existing extension has to be .vxd */
+    else if (strcmpiW( p, dotVxDW ))  /* existing extension has to be .vxd */
     {
         SetLastError( ERROR_FILE_NOT_FOUND );
         return 0;






More information about the wine-patches mailing list