Alexandre Julliard : ntdll: Avoid calling NtCreateFile() from the Unix side.

Alexandre Julliard julliard at winehq.org
Thu Jul 8 16:43:50 CDT 2021


Module: wine
Branch: master
Commit: 07f8b0c84ad499065ee30a6ac67e6a2d5fcb3e75
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=07f8b0c84ad499065ee30a6ac67e6a2d5fcb3e75

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Thu Jul  8 16:49:41 2021 +0200

ntdll: Avoid calling NtCreateFile() from the Unix side.

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ntdll/unix/file.c     | 18 +++++++++++++-----
 dlls/ntdll/unix/registry.c | 15 ++++++++++++---
 2 files changed, 25 insertions(+), 8 deletions(-)

diff --git a/dlls/ntdll/unix/file.c b/dlls/ntdll/unix/file.c
index a655aa94715..977b0dfbd51 100644
--- a/dlls/ntdll/unix/file.c
+++ b/dlls/ntdll/unix/file.c
@@ -3919,12 +3919,20 @@ NTSTATUS WINAPI NtDeleteFile( OBJECT_ATTRIBUTES *attr )
 {
     HANDLE handle;
     NTSTATUS status;
-    IO_STATUS_BLOCK io;
+    char *unix_name;
+    UNICODE_STRING nt_name;
+    OBJECT_ATTRIBUTES new_attr = *attr;
 
-    status = NtCreateFile( &handle, GENERIC_READ | GENERIC_WRITE | DELETE, attr, &io, NULL, 0,
-                           FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, FILE_OPEN,
-                           FILE_DELETE_ON_CLOSE, NULL, 0 );
-    if (status == STATUS_SUCCESS) NtClose( handle );
+    get_redirect( &new_attr, &nt_name );
+    if (!(status = nt_to_unix_file_name( &new_attr, &unix_name, FILE_OPEN )))
+    {
+        if (!(status = open_unix_file( &handle, unix_name, GENERIC_READ | GENERIC_WRITE | DELETE, &new_attr,
+                                       0, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, FILE_OPEN,
+                                       FILE_DELETE_ON_CLOSE, NULL, 0 )))
+            NtClose( handle );
+        free( unix_name );
+    }
+    free( nt_name.Buffer );
     return status;
 }
 
diff --git a/dlls/ntdll/unix/registry.c b/dlls/ntdll/unix/registry.c
index 9a572d7f44e..915b99d2c7f 100644
--- a/dlls/ntdll/unix/registry.c
+++ b/dlls/ntdll/unix/registry.c
@@ -661,14 +661,23 @@ NTSTATUS WINAPI NtLoadKey( const OBJECT_ATTRIBUTES *attr, OBJECT_ATTRIBUTES *fil
 {
     NTSTATUS ret;
     HANDLE key;
-    IO_STATUS_BLOCK io;
     data_size_t len;
     struct object_attributes *objattr;
+    char *unix_name;
+    UNICODE_STRING nt_name;
+    OBJECT_ATTRIBUTES new_attr = *file;
 
     TRACE("(%p,%p)\n", attr, file);
 
-    ret = NtCreateFile( &key, GENERIC_READ | SYNCHRONIZE, file, &io, NULL, FILE_ATTRIBUTE_NORMAL, 0,
-                        FILE_OPEN, 0, NULL, 0);
+    get_redirect( &new_attr, &nt_name );
+    if (!(ret = nt_to_unix_file_name( &new_attr, &unix_name, FILE_OPEN )))
+    {
+        ret = open_unix_file( &key, unix_name, GENERIC_READ | SYNCHRONIZE,
+                              &new_attr, 0, 0, FILE_OPEN, 0, NULL, 0 );
+        free( unix_name );
+    }
+    free( nt_name.Buffer );
+
     if (ret) return ret;
 
     if ((ret = alloc_object_attributes( attr, &objattr, &len ))) return ret;




More information about the wine-cvs mailing list