Rebase against 948a6a47b8dbd0ddd86cad04de03f0e4ba81b65d.

This commit is contained in:
Zebediah Figura
2020-06-12 18:15:13 -05:00
parent eb4f9db59c
commit b6595d9e28
23 changed files with 509 additions and 744 deletions

View File

@@ -1,22 +1,76 @@
From 934a7712600b45fa584386b4ada2a73af88ee072 Mon Sep 17 00:00:00 2001
From c8bd4fe87f7a49a3da2c53ead6df94a9172e7bbb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Fri, 26 May 2017 05:17:17 +0200
Subject: ntdll: Implement opening files through nt device paths.
Subject: [PATCH] ntdll: Implement opening files through nt device paths.
---
dlls/ntdll/directory.c | 132 +++++++++++++++++++++++++++++++++++++---
dlls/ntdll/tests/file.c | 25 +++++++-
dlls/ntdll/unix/file.c | 132 +++++++++++++++++++++++++++++++++++++---
2 files changed, 147 insertions(+), 10 deletions(-)
diff --git a/dlls/ntdll/directory.c b/dlls/ntdll/directory.c
index c6249dd8658..242dbd27b2f 100644
--- a/dlls/ntdll/directory.c
+++ b/dlls/ntdll/directory.c
@@ -2732,16 +2732,10 @@ NTSTATUS nt_to_unix_file_name_attr( const OBJECT_ATTRIBUTES *attr, ANSI_STRING *
diff --git a/dlls/ntdll/tests/file.c b/dlls/ntdll/tests/file.c
index 184b7cdad59..87b5945a4e2 100644
--- a/dlls/ntdll/tests/file.c
+++ b/dlls/ntdll/tests/file.c
@@ -135,18 +135,22 @@ static void WINAPI apc( void *arg, IO_STATUS_BLOCK *iosb, ULONG reserved )
static void create_file_test(void)
{
+ static const WCHAR notepadW[] = {'n','o','t','e','p','a','d','.','e','x','e',0};
static const WCHAR systemrootW[] = {'\\','S','y','s','t','e','m','R','o','o','t',
'\\','f','a','i','l','i','n','g',0};
+ static const WCHAR systemrootExplorerW[] = {'\\','S','y','s','t','e','m','R','o','o','t',
+ '\\','e','x','p','l','o','r','e','r','.','e','x','e',0};
static const WCHAR questionmarkInvalidNameW[] = {'a','f','i','l','e','?',0};
static const WCHAR pipeInvalidNameW[] = {'a','|','b',0};
static const WCHAR pathInvalidNtW[] = {'\\','\\','?','\\',0};
static const WCHAR pathInvalidNt2W[] = {'\\','?','?','\\',0};
static const WCHAR pathInvalidDosW[] = {'\\','D','o','s','D','e','v','i','c','e','s','\\',0};
static const char testdata[] = "Hello World";
+ static const WCHAR sepW[] = {'\\',0};
FILE_NETWORK_OPEN_INFORMATION info;
NTSTATUS status;
HANDLE dir, file;
- WCHAR path[MAX_PATH];
+ WCHAR path[MAX_PATH], temp[MAX_PATH];
OBJECT_ATTRIBUTES attr;
IO_STATUS_BLOCK io;
UNICODE_STRING nameW;
@@ -327,6 +331,25 @@ static void create_file_test(void)
status = pNtQueryFullAttributesFile( &attr, &info );
ok( status == STATUS_OBJECT_NAME_INVALID,
"query %s failed %x\n", wine_dbgstr_w(nameW.Buffer), status );
+
+ GetWindowsDirectoryW( path, MAX_PATH );
+ path[2] = 0;
+ ok( QueryDosDeviceW( path, temp, MAX_PATH ),
+ "QueryDosDeviceW failed with error %u\n", GetLastError() );
+ lstrcatW( temp, sepW );
+ lstrcatW( temp, path+3 );
+ lstrcatW( temp, sepW );
+ lstrcatW( temp, notepadW );
+
+ pRtlInitUnicodeString( &nameW, temp );
+ status = pNtQueryFullAttributesFile( &attr, &info );
+ ok( status == STATUS_SUCCESS,
+ "query %s failed %x\n", wine_dbgstr_w(nameW.Buffer), status );
+
+ pRtlInitUnicodeString( &nameW, systemrootExplorerW );
+ status = pNtQueryFullAttributesFile( &attr, &info );
+ ok( status == STATUS_SUCCESS,
+ "query %s failed %x\n", wine_dbgstr_w(nameW.Buffer), status );
}
static void open_file_test(void)
diff --git a/dlls/ntdll/unix/file.c b/dlls/ntdll/unix/file.c
index 31a6c761c7c..83e4810f00b 100644
--- a/dlls/ntdll/unix/file.c
+++ b/dlls/ntdll/unix/file.c
@@ -2818,16 +2818,10 @@ NTSTATUS CDECL nt_to_unix_file_name_attr( const OBJECT_ATTRIBUTES *attr, ANSI_ST
/******************************************************************************
- * wine_nt_to_unix_file_name (NTDLL.@) Not a Windows API
- * nt_to_unix_file_name
- *
- * Convert a file name from NT namespace to Unix namespace.
- *
@@ -25,14 +79,14 @@ index c6249dd8658..242dbd27b2f 100644
- * returned, but the unix name is still filled in properly.
+ * nt_to_unix_file_name_internal
*/
-NTSTATUS CDECL wine_nt_to_unix_file_name( const UNICODE_STRING *nameW, ANSI_STRING *unix_name_ret,
- UINT disposition, BOOLEAN check_case )
-NTSTATUS CDECL nt_to_unix_file_name( const UNICODE_STRING *nameW, ANSI_STRING *unix_name_ret,
- UINT disposition, BOOLEAN check_case )
+static NTSTATUS nt_to_unix_file_name_internal( const UNICODE_STRING *nameW, ANSI_STRING *unix_name_ret,
+ UINT disposition, BOOLEAN check_case )
{
static const WCHAR unixW[] = {'u','n','i','x'};
static const WCHAR pipeW[] = {'p','i','p','e'};
@@ -2857,6 +2851,126 @@ NTSTATUS CDECL wine_nt_to_unix_file_name( const UNICODE_STRING *nameW, ANSI_STRI
@@ -2940,6 +2934,126 @@ NTSTATUS CDECL nt_to_unix_file_name( const UNICODE_STRING *nameW, ANSI_STRING *u
return status;
}
@@ -103,7 +157,7 @@ index c6249dd8658..242dbd27b2f 100644
+}
+
+/******************************************************************************
+ * wine_nt_to_unix_file_name (NTDLL.@) Not a Windows API
+ * nt_to_unix_file_name (NTDLL.@) Not a Windows API
+ *
+ * Convert a file name from NT namespace to Unix namespace.
+ *
@@ -111,7 +165,7 @@ index c6249dd8658..242dbd27b2f 100644
+ * element doesn't have to exist; in that case STATUS_NO_SUCH_FILE is
+ * returned, but the unix name is still filled in properly.
+ */
+NTSTATUS CDECL wine_nt_to_unix_file_name( const UNICODE_STRING *nameW, ANSI_STRING *unix_name_ret,
+NTSTATUS CDECL nt_to_unix_file_name( const UNICODE_STRING *nameW, ANSI_STRING *unix_name_ret,
+ UINT disposition, BOOLEAN check_case )
+{
+ static const WCHAR systemrootW[] = {'\\','S','y','s','t','e','m','R','o','o','t','\\',0};
@@ -157,62 +211,8 @@ index c6249dd8658..242dbd27b2f 100644
+ return status;
+}
/******************************************************************
* RtlWow64EnableFsRedirection (NTDLL.@)
diff --git a/dlls/ntdll/tests/file.c b/dlls/ntdll/tests/file.c
index 546795456a8..709698209d8 100644
--- a/dlls/ntdll/tests/file.c
+++ b/dlls/ntdll/tests/file.c
@@ -135,18 +135,22 @@ static void WINAPI apc( void *arg, IO_STATUS_BLOCK *iosb, ULONG reserved )
static void create_file_test(void)
{
+ static const WCHAR notepadW[] = {'n','o','t','e','p','a','d','.','e','x','e',0};
static const WCHAR systemrootW[] = {'\\','S','y','s','t','e','m','R','o','o','t',
'\\','f','a','i','l','i','n','g',0};
+ static const WCHAR systemrootExplorerW[] = {'\\','S','y','s','t','e','m','R','o','o','t',
+ '\\','e','x','p','l','o','r','e','r','.','e','x','e',0};
static const WCHAR questionmarkInvalidNameW[] = {'a','f','i','l','e','?',0};
static const WCHAR pipeInvalidNameW[] = {'a','|','b',0};
static const WCHAR pathInvalidNtW[] = {'\\','\\','?','\\',0};
static const WCHAR pathInvalidNt2W[] = {'\\','?','?','\\',0};
static const WCHAR pathInvalidDosW[] = {'\\','D','o','s','D','e','v','i','c','e','s','\\',0};
static const char testdata[] = "Hello World";
+ static const WCHAR sepW[] = {'\\',0};
FILE_NETWORK_OPEN_INFORMATION info;
NTSTATUS status;
HANDLE dir, file;
- WCHAR path[MAX_PATH];
+ WCHAR path[MAX_PATH], temp[MAX_PATH];
OBJECT_ATTRIBUTES attr;
IO_STATUS_BLOCK io;
UNICODE_STRING nameW;
@@ -327,6 +331,25 @@ static void create_file_test(void)
status = pNtQueryFullAttributesFile( &attr, &info );
ok( status == STATUS_OBJECT_NAME_INVALID,
"query %s failed %x\n", wine_dbgstr_w(nameW.Buffer), status );
+
+ GetWindowsDirectoryW( path, MAX_PATH );
+ path[2] = 0;
+ ok( QueryDosDeviceW( path, temp, MAX_PATH ),
+ "QueryDosDeviceW failed with error %u\n", GetLastError() );
+ lstrcatW( temp, sepW );
+ lstrcatW( temp, path+3 );
+ lstrcatW( temp, sepW );
+ lstrcatW( temp, notepadW );
+
+ pRtlInitUnicodeString( &nameW, temp );
+ status = pNtQueryFullAttributesFile( &attr, &info );
+ ok( status == STATUS_SUCCESS,
+ "query %s failed %x\n", wine_dbgstr_w(nameW.Buffer), status );
+
+ pRtlInitUnicodeString( &nameW, systemrootExplorerW );
+ status = pNtQueryFullAttributesFile( &attr, &info );
+ ok( status == STATUS_SUCCESS,
+ "query %s failed %x\n", wine_dbgstr_w(nameW.Buffer), status );
}
static void open_file_test(void)
/***********************************************************************
* unmount_device
--
2.26.0
2.27.0